C++ mpi module for stochmagnet_main Package
SM_CrystalStructure.h
1 #ifndef SM_CrystalStructure_H
2 #define SM_CrystalStructure_H
3 
4 //super class header
5 #include "SM_Object.h"
6 
7 //constant header
8 #include "SM_Constants.h"
9 
10 //array utilities functions
11 #include "functions_array.h"
12 
13 
31 
32  //attributes
33 private :
34 
35  //name of the structure
36  tString mName;
37  //max number of neighboring particles per particles
38  tUCInt mCoordinationNumber;
39  //number of atoms per unit cell
40  tUCInt mAtomsNumber;
41 
42  //atom volume weight : the normalized volume with respect of the unit cell volume
43  tReal mAtomVolumeWeight;
44 
45  //volume of unit cell in Angstrom
46  tReal mUnitVolume;
47 
48  //size of unit cell in angstrom
49  std::array<tReal,SM_Constants::DIM> mUnitCellSize;
50 
51 
52 protected:
53  // CONSTRUCTORS
57  mCoordinationNumber=0;
58  mAtomsNumber=1;
59  mAtomVolumeWeight=1;
60 
61  mUnitVolume=1;
62  for(auto& Sk:mUnitCellSize) Sk=1;
63 
64  mName="";
65 
66  }
67 
68  // DESTRUCTORS
71  virtual ~SM_CrystalStructure(void) {
72  }
73 
74 public :
75 
76  //Instance building
77  //=================
78 
79 
80 
81 
82  //MEMORY
83 
97  virtual tMemSize getMemorySize() const {
98  return sizeof(*this)+getContentsMemorySize();
99  }
100 
109  virtual tMemSize getContentsMemorySize() const {
110  tMemSize mem=SM_Object::getContentsMemorySize();
111  mem+= mUnitCellSize.size()*sizeof(tReal);
112 
113  return mem;
114  }
115 
116 
117  //constructors
118  //============
119 
123  virtual CORE_UniquePointer<SM_CrystalStructure> newInstance() const=0;
124 
125 
126  //SET & GET methods
127  //==================
128 
132  virtual void copy(const SM_CrystalStructure& s) {
133  mAtomsNumber=s.getAtomsNumber();
134  mCoordinationNumber=s.getCoordinationNumber();
136 
137  }
140  inline const tString& getName() const {
141  return mName;
142  }
143 protected:
146  inline void setName(const tString& name) {
147  mName=name;
148  }
149 
150 protected:
151 
155  inline void setCoordinationNumber(const tUCInt& n) {
156  mCoordinationNumber=n;
157  }
161  inline void setAtomsNumber(const tUCInt& n) {
162  mAtomsNumber=n;
163  }
164 
165 public:
169  inline const tUCInt& getCoordinationNumber() const {
170  return mCoordinationNumber;
171  }
175  inline const tUCInt& getAtomsNumber() const {
176  return mAtomsNumber;
177  }
178 
179 
180 
181  //unit cell size
182  //==============
183 
187  inline void setUnitCellSize(const tReal& a) {
188  mUnitVolume=1;
189  for(auto& Sk:mUnitCellSize) {
190  Sk=a;
191  mUnitVolume*=Sk;
192  }
193  }
197  inline void setUnitCellSize(const std::array<tReal,SM_Constants::DIM>& as) {
198  mUnitCellSize=as;
199 
200  mUnitVolume=1;
201  for(const auto& Sk:mUnitCellSize) mUnitVolume*=Sk;
202  }
206  inline void setUnitCellSize(const std::vector<tReal>& as) {
207  //d=min(DIM,as.size)
208  tUCInt d=SM_Constants::DIM;
209  d=(d>as.size())?as.size():d;
210  //last value of as
211  tReal a=1;
212  for(tUCInt i=0;i<d;i++) {
213  a=as[i];
214  mUnitCellSize[i]=a;
215  }
216  for(tUCInt i=d;i<SM_Constants::DIM;i++) {
217  mUnitCellSize[i]=a;
218  }
219  setUnitCellSize(mUnitCellSize);
220 
221  }
225  inline void setUnitCellSize(std::initializer_list<tReal>&& as) {
226  //d=min(DIM,as.size)
227  tUCInt d=SM_Constants::DIM;
228  d=(d>as.size())?as.size():d;
229 
230  //last value of as
231  tReal *iHs=mUnitCellSize.data();
232  tReal a=1;
233  for(const auto& v:as) {
234  a=v;
235  (*iHs)=v;
236  iHs++;
237  }
238 
239  for(tUCInt i=d;i<SM_Constants::DIM;i++) {
240  (*iHs)=a;
241  iHs++;
242  }
243  setUnitCellSize(mUnitCellSize);
244 
245  }
249  inline const std::array<tReal,SM_Constants::DIM>& getUnitCellSize() const {
250  return mUnitCellSize;
251  }
252 
256  inline const tReal& getUnitVolume() const {
257  return mUnitVolume;
258  }
259 
260 
261 
262 
263 
266  inline tReal getAtomVolume() const {
267  return mAtomVolumeWeight*mUnitVolume;
268  }
271  inline const tReal& getAtomVolumeWeight() const {
272  return mAtomVolumeWeight;
273  }
278  inline void setAtomVolumeWeight(const tReal& weight) {
279  mAtomVolumeWeight=weight;
280  }
281 
282 
283 public:
284 
285 
286 
287 
288  //IO methods
289  //===========
290 
294  virtual tString toString() const override {
295  std::stringstream ret;
296  ret<<SM_Object::toString()<<"\n";
297  ret<<"Name : "<<getName()<<"\n";
298  ret<<"Unit Cell Size (A):"<<functions_array::toString(mUnitCellSize)<<"\n";
299  ret<<"Unit Cell Volume (A^3):"<<mUnitVolume<<"\n";
300  ret<<"Coordination number:"<<((int)mCoordinationNumber)<<"\n";
301  ret<<"Atoms number:"<<((int)mAtomsNumber)<<"\n";
302  ret<<"Atom volume weight:"<<mAtomVolumeWeight<<"\n";
303  ret<<"Atom volume (A^3):"<<getAtomVolume()<<"\n";
304  return ret.str();
305  }
306 };
307 
308 #endif
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:333
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
This class decribe a crystal structure.
Definition: SM_CrystalStructure.h:30
const std::array< tReal, SM_Constants::DIM > & getUnitCellSize() const
get unit cell size
Definition: SM_CrystalStructure.h:249
void setUnitCellSize(const std::array< tReal, SM_Constants::DIM > &as)
set unit cell size
Definition: SM_CrystalStructure.h:197
void setUnitCellSize(std::initializer_list< tReal > &&as)
set unit cell size
Definition: SM_CrystalStructure.h:225
tReal getAtomVolume() const
get atom volume in angstrom^3
Definition: SM_CrystalStructure.h:266
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_CrystalStructure.h:97
void setAtomsNumber(const tUCInt &n)
set the atoms number per unit cell
Definition: SM_CrystalStructure.h:161
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_CrystalStructure.h:109
virtual tString toString() const override
turn the class into a string representation
Definition: SM_CrystalStructure.h:294
const tReal & getAtomVolumeWeight() const
get atom volume weight with no unit
Definition: SM_CrystalStructure.h:271
void setName(const tString &name)
set the name of the structure (in constructor)
Definition: SM_CrystalStructure.h:146
void setUnitCellSize(const std::vector< tReal > &as)
set unit cell size
Definition: SM_CrystalStructure.h:206
const tUCInt & getAtomsNumber() const
get the atoms number
Definition: SM_CrystalStructure.h:175
const tReal & getUnitVolume() const
get unit volume
Definition: SM_CrystalStructure.h:256
virtual void copy(const SM_CrystalStructure &s)
copy the structure
Definition: SM_CrystalStructure.h:132
const tString & getName() const
get the name of the structure (in constructor)
Definition: SM_CrystalStructure.h:140
void setUnitCellSize(const tReal &a)
set unit cell size
Definition: SM_CrystalStructure.h:187
virtual ~SM_CrystalStructure(void)
destroy
Definition: SM_CrystalStructure.h:71
void setAtomVolumeWeight(const tReal &weight)
set atom volume weight in angstrom
Definition: SM_CrystalStructure.h:278
virtual CORE_UniquePointer< SM_CrystalStructure > newInstance() const =0
create new instance of the network
const tUCInt & getCoordinationNumber() const
get the coodination number
Definition: SM_CrystalStructure.h:169
void setCoordinationNumber(const tUCInt &n)
set the coordination number
Definition: SM_CrystalStructure.h:155
SM_CrystalStructure(void)
create a network class
Definition: SM_CrystalStructure.h:56
This class is a base class for Stoch Microm package.
Definition: SM_Object.h:36