CrystalFp
 All Classes Namespaces Files Functions Enumerations Enumerator Pages
CrystalFp.h
Go to the documentation of this file.
1 
2 
3 
4 
5 #ifndef CRYSTALFP_H
6 #define CRYSTALFP_H
7 
8 #ifdef _MSC_VER
9 #pragma warning(disable:4786)
10 #endif
11 #include <vector>
12 #include <set>
13 #include <string>
14 #include <climits>
15 #include "CrystalFpExceptions.h"
16 
20 namespace cfp
21 {
29 class CrystalFp
30 {
31 public:
32  //###################################################################################
34 
35 
43  CrystalFp(unsigned int aVerboseLevel);
44 
47  ~CrystalFp();
48 
51  void resetAll(void);
52 
54 
55 
56  //###################################################################################
59 
60 
64  const std::vector<std::string> getFingerprintMethodsNames(void) const;
65 
69  const std::vector<std::string> getDistanceMethodsNames(void) const;
70 
74  const std::vector<std::string> getGroupingMethodsNames(void) const;
75 
77 
78 
79  //###################################################################################
82 
83 
95  void addStructure(int aStep, unsigned int aNumAtoms, const float *aCoords, const unsigned int *aZ, const float *aUnitCell, bool aHasEnergy=false, float aEnergy=0.0F, bool aEnergyIsPerAtom=true);
96 
109  void addStructureBatch(int aStep, unsigned int aNumAtoms, const float *aCoords, const unsigned int *aZ, const float *aUnitCell, bool aHasEnergy=false, float aEnergy=0.0F, bool aEnergyIsPerAtom=true);
110 
113  void addStructureBatchFinish(void);
114 
119  size_t getNumActiveStructures(void) const;
120 
125  size_t getNumTotalStructures(void) const;
126 
128 
129 
130  //###################################################################################
133 
134 
139  void energyThreshold(float aEnergyThreshold);
140 
143  void noEnergyThreshold(void);
144 
146 
147 
148  //###################################################################################
151 
152 
157  bool hasEnergies(void) const;
158 
163  float getMinEnergy(void) const;
164 
169  bool hasUnitCell(void) const;
170 
172 
173 
174  //###################################################################################
177 
178 
184  int idxToStep(size_t aIdx) const;
185 
191  float getTotalEnergy(size_t aIdx) const;
192 
198  float getPerAtomEnergy(size_t aIdx) const;
199 
205  unsigned int getNatoms(size_t aIdx) const;
206 
212  const float* getUnitCell(size_t aIdx) const;
213 
218  const unsigned int* getAtomZ(size_t aIdx) const;
219 
225  const float* getCoords(size_t aIdx) const;
226 
228 
229 
230  //###################################################################################
233 
234 
240  float computeCutoffDistance(float aMargin=0.02F) const;
241 
248  void setFingerprintMethod(unsigned int aFingerprintType);
249 
254  bool isDiffractionLike(void) const;
255 
260  const std::string getFingerprintMethod(void) const;
261 
266  void setCutoffDistance(float aCutoff);
267 
271  void setNanoclusterStructureType(void);
272 
276  void setDiffrBinSize(float aBinSize);
277 
282  void setDiffrPeakSize(float aPeakSize);
283 
288  void forceFpLength(unsigned int aDim);
289 
295  void setCheckpointDir(const char* aDir);
296 
299  void loadCheckpoint(void);
300 
303  void computeFingerprints(void);
304 
308  unsigned int getFingerprintNumSections(void) const;
309 
314  unsigned int getFingerprintSectionLen(void) const;
315 
320  bool hasFingerprints(void) const;
321 
326  float getCutoffDistance(void) const;
327 
333  const float* getFingerprint(size_t aStructureIdx) const;
334 
339  float getDiffrPeakSize(void) const;
340 
345  float getDiffrBinSize(void) const;
346 
352  const std::vector< std::vector<float> >& getInteratomicDistances(unsigned int aIdx) const;
353 
359  const float* getWeights(size_t aIdx) const;
360 
362 
363 
364  //###################################################################################
367 
368 
375  void setDistanceMethod(unsigned int aMeasureType);
376 
381  const std::string getDistanceMethod(void) const;
382 
387  void computeDistanceMatrix(void);
388 
393  bool hasDistanceMatrix(void) const;
394 
403  float getDistance(size_t aIdx1, size_t aIdx2) const;
404 
409  float getMaxDistance(void) const;
410 
412 
413 
414  //###################################################################################
417 
418 
425  void setGroupingMethod(unsigned int aGroupingMethod);
426 
431  const std::string getGroupingMethod(void) const;
432 
437  void groupResults(void);
438 
443  void setMaxGroupingDistance(float aMaxDistance);
444 
449  float getMaxGroupingDistance(void) const;
450 
456  void setK(unsigned int aK);
457 
462  unsigned int getNgroups(void) const;
463 
468  const std::vector< std::set<unsigned int> >& getGroups(void) const;
469 
474  unsigned int getNsingle(void) const;
475 
480  bool groupingNeedsK(void) const;
481 
487  unsigned int reduceDuplicatesToRepresentative(std::vector<unsigned int>& aNewIndexList);
488 
490 
491 
492  //###################################################################################
495 
496 
503  void serialize(std::ofstream& aStream) const;
504 
513  void unserialize(std::ifstream& aStream, bool aAppend=false, int aStepOffset=10000);
514 
516 
517  //###################################################################################
520 
521 
524  void dump(void) const;
526 
527 private:
528  CrystalFp(const CrystalFp&);
529  CrystalFp& operator=(const CrystalFp&);
530 
531 private:
532  static void unitCellInverse(const float *aUnitCell, float aUnitCellInverse[3][3]);
533  void computeExpansion(const float* aUnitCell, unsigned int* aExpansion) const;
534 
535 private:
536  struct CrystalFpImpl;
537  struct CrystalFpImpl* mPimpl;
538 };
539 
540 }
541 
542 #endif
543