-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAnalysisMethod.h
280 lines (250 loc) · 15.6 KB
/
AnalysisMethod.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#ifndef ANALYSISMETHOD_H
#define ANALYSISMETHOD_H
#include <vector>
#include <string>
#include <cstring>
#include <list>
#include <climits>
#include "MethodsList.h"
#include "CrystalFp.h"
namespace cfp_internal
{
class AnalysisMethod
{
public:
AnalysisMethod(const char* aName, const char* aNameHist=0) : mName(aName), mNameHist(), mPartSelected(UINT_MAX), mStructureIdx(0)
{
//mName = aName;
if(aNameHist) mNameHist = aNameHist;
//mPartSelected = UINT_MAX; // All fingerprint parts selected
//mStructureIdx = 0;
}
virtual ~AnalysisMethod() {}
std::string getName(void) const { return mName; }
std::string getNameHist(void) const { return mNameHist; }
virtual bool isValid(const cfp::CrystalFp* aCfp) const =0;
virtual size_t numElements(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures(); }
virtual size_t numElements(const cfp::CrystalFp* aCfp, unsigned int /*aIdx*/) const { return aCfp->getNumActiveStructures(); }
virtual size_t numArrays(void) const {return 1;}
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> names; return names; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { std::vector<std::string> names; return names; }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const =0;
void setFingerprintPart(unsigned int aPartSelected) {mPartSelected = aPartSelected;}
void setStructureIdx(unsigned int aStructureIdx) {mStructureIdx = aStructureIdx;}
protected:
std::string mName;
std::string mNameHist;
unsigned int mPartSelected;
unsigned int mStructureIdx;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetIdx : public AnalysisMethod
{
public:
MethodGetIdx() : AnalysisMethod("Index") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0; }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Index"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetStep : public AnalysisMethod
{
public:
MethodGetStep() : AnalysisMethod("Step") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0; }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Step"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetEnergy : public AnalysisMethod
{
public:
MethodGetEnergy() : AnalysisMethod("Energy per atom", "Per atom energy histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0 && aCfp->hasEnergies(); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Energy per atom"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetCellVolume : public AnalysisMethod
{
public:
MethodGetCellVolume() : AnalysisMethod("Cell volume per atom", "Per atom cell volume histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0 && aCfp->hasUnitCell(); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Cell volume per atom"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetDeltaEnergy : public AnalysisMethod
{
public:
MethodGetDeltaEnergy() : AnalysisMethod("Per atom energy difference", "Per atom energy difference histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 1 && aCfp->hasEnergies(); }
virtual size_t numElements(const cfp::CrystalFp* aCfp) const { size_t n = aCfp->getNumActiveStructures(); return (n*(n-1))/2;}
virtual size_t numElements(const cfp::CrystalFp* aCfp, unsigned int /*aIdx*/) const { return numElements(aCfp); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Per atom energy difference"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetDistances : public AnalysisMethod
{
public:
MethodGetDistances() : AnalysisMethod("Distances", "Distances histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 1 && aCfp->hasDistanceMatrix(); }
virtual size_t numElements(const cfp::CrystalFp* aCfp) const { size_t n = aCfp->getNumActiveStructures(); return (n*(n-1))/2;}
virtual size_t numElements(const cfp::CrystalFp* aCfp, unsigned int /*aIdx*/) const { return numElements(aCfp); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Distance"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetEnergyFromMin : public AnalysisMethod
{
public:
MethodGetEnergyFromMin() : AnalysisMethod("Energy per atom from min.", "Energy per atom from min. histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0 && aCfp->hasEnergies(); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Energy per atom from min."); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetDistFromMin : public AnalysisMethod
{
public:
MethodGetDistFromMin() : AnalysisMethod("Distances from min.", "Distances from min. histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0 && aCfp->hasDistanceMatrix(); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Distance from min."); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetPointDepth : public AnalysisMethod
{
public:
MethodGetPointDepth() : AnalysisMethod("Point depth", "Point depth histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 1 && aCfp->hasFingerprints(); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Depth"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetOrderF2 : public AnalysisMethod
{
public:
MethodGetOrderF2() : AnalysisMethod("Order (F2)", "Order (F2) histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const {
return aCfp->getNumActiveStructures() > 1 && aCfp->hasFingerprints() && aCfp->isDiffractionLike() && aCfp->hasUnitCell();}
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Degree of order (F2)"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetOrderF2R2 : public AnalysisMethod
{
public:
MethodGetOrderF2R2() : AnalysisMethod("Order (F2R2)", "Order (F2R2) histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const {
return aCfp->getNumActiveStructures() > 1 && aCfp->hasFingerprints() && aCfp->isDiffractionLike() && aCfp->hasUnitCell();}
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Degree of order (F2R2)"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetQuasiEntropy : public AnalysisMethod
{
public:
MethodGetQuasiEntropy() : AnalysisMethod("Quasi-entropy", "Quasi-entropy histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const {
return aCfp->getNumActiveStructures() > 1 && aCfp->hasFingerprints() && aCfp->isDiffractionLike() && aCfp->hasUnitCell();}
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Quasi-entropy"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
private:
float computeQuasiEntropy(const cfp::CrystalFp* aCfp, unsigned int aIdx) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetMinDimension : public AnalysisMethod
{
public:
MethodGetMinDimension() : AnalysisMethod("Min. dimension", "Min. dimension histogram") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0 && aCfp->hasFingerprints() && aCfp->isDiffractionLike(); }
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> lbl; lbl.push_back("Min. dimension"); return lbl; }
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* /*aCfp*/) const { return getLabels(); }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class AnalysisMethodsSimpleList : public MethodsList<AnalysisMethod>
{
public:
AnalysisMethodsSimpleList()
{
mMethodsList.push_back(new MethodGetIdx);
mMethodsList.push_back(new MethodGetStep);
mMethodsList.push_back(new MethodGetEnergy);
mMethodsList.push_back(new MethodGetCellVolume);
mMethodsList.push_back(new MethodGetDeltaEnergy);
mMethodsList.push_back(new MethodGetDistances);
mMethodsList.push_back(new MethodGetEnergyFromMin);
mMethodsList.push_back(new MethodGetDistFromMin);
mMethodsList.push_back(new MethodGetPointDepth);
mMethodsList.push_back(new MethodGetOrderF2);
mMethodsList.push_back(new MethodGetOrderF2R2);
mMethodsList.push_back(new MethodGetQuasiEntropy);
mMethodsList.push_back(new MethodGetMinDimension);
}
~AnalysisMethodsSimpleList() {clear();}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class AnalysisMethodsHistList : public MethodsList<AnalysisMethod>
{
public:
AnalysisMethodsHistList()
{
mMethodsList.push_back(new MethodGetEnergy);
mMethodsList.push_back(new MethodGetCellVolume);
mMethodsList.push_back(new MethodGetDeltaEnergy);
mMethodsList.push_back(new MethodGetDistances);
mMethodsList.push_back(new MethodGetEnergyFromMin);
mMethodsList.push_back(new MethodGetDistFromMin);
mMethodsList.push_back(new MethodGetPointDepth);
mMethodsList.push_back(new MethodGetOrderF2);
mMethodsList.push_back(new MethodGetOrderF2R2);
mMethodsList.push_back(new MethodGetQuasiEntropy);
mMethodsList.push_back(new MethodGetMinDimension);
}
~AnalysisMethodsHistList() {clear();}
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class MethodGetFingerprint : public AnalysisMethod
{
public:
MethodGetFingerprint() : AnalysisMethod("One fingerprint") {}
virtual bool isValid(const cfp::CrystalFp* aCfp) const { return aCfp->getNumActiveStructures() > 0 && aCfp->hasFingerprints(); }
virtual size_t numElements(const cfp::CrystalFp* aCfp, unsigned int /*aIdx*/) const
{
return static_cast<size_t>(aCfp->getFingerprintSectionLen()*((mPartSelected >= aCfp->getFingerprintNumSections()) ? aCfp->getFingerprintNumSections() : 1));
}
virtual size_t numElements(const cfp::CrystalFp* aCfp) const { return numElements(aCfp, 0); }
virtual size_t numArrays(void) const {return 2;}
virtual const std::vector<std::string> getLabels(const cfp::CrystalFp* aCfp) const;
virtual const std::vector<std::string> getLabels(void) const { std::vector<std::string> names; return names; }
virtual void getValues(const cfp::CrystalFp* aCfp, float* aValue, unsigned int aIdx=0) const;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class AnalysisMethodsSpecialList : public MethodsList<AnalysisMethod>
{
public:
AnalysisMethodsSpecialList()
{
mMethodsList.push_back(new MethodGetFingerprint);
}
~AnalysisMethodsSpecialList() {clear();}
};
}
#endif