C++ mpi module for stochmagnet_main Package
SM_BeamHysteresis.h
1 #ifndef SM_BeamHysteresis_H
2 #define SM_BeamHysteresis_H
3 
4 //inherits header
5 #include "SM_BeamCycle.h"
6 
7 //zeeman operator header
8 #include "SM_ZeemanOperator.h"
9 
10 //OpenMP header
11 #include "openMP.h"
12 
13 //ll system header
14 #include "SM_LandauLifschitzSystem.h"
15 
16 //associated stochastic output
17 #include "SM_StochasticHysteresis.h"
18 
19 //chrono
20 #include "CORE_Chrono.h"
21 
28 class SM_BeamHysteresis : public SM_BeamCycle<SM_BeamHysteresis> {
29 
30  //attributes
31 private :
32 
33  //class type
36 
37  std::array<tReal,7> mHextRange;
38 
39  //number of steps for a complete cycle of hysteresis
40  tInteger mCycleStepsNumber;
41 
42  std::array<tReal,SM_Constants::DIM> mHextMax;
43  std::array<tReal,SM_Constants::DIM> mHextMin;
44  std::array<tReal,SM_Constants::DIM> mHext;
45  tInteger mHextNumber;
46 
47  std::array<tReal,SM_Constants::DIM> mDHext;//direction of Hext
48 
49  tReal mAHext;//amplitude of Hext
50  tReal mDH;//variation of hext
51  tReal mH;//value of projection of Hext on D
52  tReal mHysValue;//hysteresis value
53 
54  tCInt mHysteresisDirection;//direction of hysteresis
55  tRelativeInteger mHysteresisIndex;//index of the hysteresis in direction
56 
57  //backup
58  tInteger mBackupIndex;//index of backup
59  tInteger mBackupStep;//cycle steps number from last backup
60  tInteger mBackupsNumber;//number of backup files
61  tInteger mBackupStepsNumber;//number of cycle steps between 2 backups
62 
63  //critical point
64  tBoolean mAreCriticalPointsSaved;
65  tInteger mCriticalPointIndex;
66  tBoolean mIsCriticalPoint;
67 
68  //restoring
69  tBoolean mIsRestoring;
70 
71  //hysteresis file
72  tString mHysFileName;
73 
74 
75 
76  CORE_Chrono mTimer;
77 
78  SM_ZeemanOperator* mZeemanOperator;//zeeman operator
79 
80 
81 public:
82  // CONSTRUCTORS
86  mAHext=0;
87  mDH=0;
88  mH=0;
89  mHextNumber=10;
90  mHysteresisDirection=0;
91  mHysteresisIndex=0;
92  mHysFileName="";
93  mZeemanOperator=null;
94  mBackupIndex=0;
95  mBackupsNumber=2;
96  mBackupStep=0;
97  mBackupStepsNumber=1;
98  memset(mHextMin.data(),0,sizeof(tReal)*SM_Constants::DIM);
99  memset(mHextMax.data(),0,sizeof(tReal)*SM_Constants::DIM);
100  memset(mHext.data(),0,sizeof(tReal)*SM_Constants::DIM);
101  memset(mDHext.data(),0,sizeof(tReal)*SM_Constants::DIM);
102  mZeemanOperator=null;
103  mAreCriticalPointsSaved=true;
104  mCriticalPointIndex=0;
105  mIsCriticalPoint=false;
106  mCycleStepsNumber=0;
107  }
108 
109  // DESTRUCTORS
112  virtual ~SM_BeamHysteresis(void) {
113  }
114 
115 
116 
117 public :
118  // CREATE class
119 
120 
121  //SET & GET methods
122 
123 
124 
125 
126  //MEMORY
127 
141  virtual tMemSize getMemorySize() const {
142  return sizeof(*this)+getContentsMemorySize();
143  }
152  virtual tMemSize getContentsMemorySize() const {
153  tMemSize mem=SuperClass::getContentsMemorySize();
154  mem+=4*SM_Constants::DIM*sizeof(tReal);//mHextMax+mHextMin+mHext+mDHext
155  mem+=mHysFileName.length()*sizeof(tChar);
156  mem+=mHextRange.size()*sizeof(tReal);
157  return mem;
158  }
159 
160 
164  static CORE_UniquePointer<SelfClass> New() {
165  return CORE_UniquePointer<SelfClass>(new SelfClass(),
166  SelfClass::Delete());
167 
168  }
169 public:
170 
171 public:
172 
176  inline void setAreCriticalPointsSaved(const tBoolean& flag) {
177  mAreCriticalPointsSaved=flag;
178  }
179 
183  inline void setBackupsNumber(const tInteger& nBackups) {
184  mBackupsNumber=nBackups;
185  }
186 
187 
191  inline void setBackupStepsNumber(const tInteger& s) {
192  mBackupStepsNumber=s;
193  }
194 
195 
199  inline void setHextRange(const std::array<tReal,7>& range) {
200  mHextRange=range;
201 
202  }
203 
204 
208  inline void setHysteresisFileName(const tString& hysteresisFile) {
209  mHysFileName=hysteresisFile;
210  tIndex iExt=mHysFileName.rfind(".hys");
211  if (iExt==tString::npos) {
212  mHysFileName+=".hys";
213  }
214  }
215 
216 
217 public:
218 
225  inline tBoolean open(SM_Beam& beam,SM_StochasticOutputComponent& stochasticOutput,
226  const tInteger& outputId,
227  tIndex& iCycleStep) {
228 
229  //std::cout<<"begin SM_BeamHysteresis::open("<<outputId<<")\n";
230 
231  mCycleStepsNumber=0;
232 
233  //system
234  SM_System& system=beam.getSystem();
235 
236  //compute Hext Min & Hext Max
237  const tReal *iRange=mHextRange.data();
238  for(auto& Hk:mHextMin) {
239  Hk=(*iRange);
240  iRange++;
241  }
242  for(auto& Hk:mHextMax) {
243  Hk=(*iRange);
244  iRange++;
245  }
246  //number of Hext
247  mHextNumber=mHextRange[6];
248 
249  //characteristic field
250  const tReal& cField=system.getMaterial().getCharacteristicField();
251 
252  //adimensionize Hext values
253  for(auto& Hk:mHextMax) {
254  Hk/=cField;
255  }
256  for(auto& Hk:mHextMin) {
257  Hk/=cField;
258  }
259 
260  //D=(Hmax-Hmin)
261  //hmax=|Hmax-Hmin|
262  //D=Hmax
263  memcpy(mDHext.data(),mHextMax.data(),SM_Constants::DIM*sizeof(tReal));//dest,source,size
264  mAHext=0;//amplitude of Hext
265  //D=Hmax-Hmin
266  //hmax=|Hmax-Hmin|
267  const tReal *iHext=mHextMin.data();
268  for(auto& Dk:mDHext) {
269  Dk-=(*iHext);
270  mAHext+=Dk*Dk;
271  iHext++;
272  }
273  mAHext=sqrt(mAHext);
274 
275  //h variation
276  mDH=mAHext/mHextNumber;
277 
278  //normalize D
279  for(auto& Dk:mDHext) Dk/=mAHext;
280 
281  //get zeeman operator
282  mZeemanOperator=dynamic_cast<SM_ZeemanOperator*>(system.getOperator("Zeeman"));
283  if (mZeemanOperator==null) {
284  std::cout<<"fatal error : use-zeeman must be true in options\n";
285  return false;
286 
287  }
288  //set the adimensionized Hext
289  memcpy(mHext.data(),mHextMax.data(),sizeof(tReal)*mHextMax.size());//dest,source,size
290  mZeemanOperator->setHext(mHext);
291 
292  //number of cycles steps
293  mCycleStepsNumber=2*mHextNumber+1;
294 
295 
296  //set S0 to Hext
297  tIndex nParticles=system.getInitialMagneticMomentDirections().getElementsNumber();
298  system.setInitialMagneticMomentDirections(nParticles,mDHext);
299 
300  //set the stochastic data
301  SM_StochasticHysteresis* hysOutput=dynamic_cast<SM_StochasticHysteresis*>(&stochasticOutput);
302  if (hysOutput==null) {
303  throw CORE_Exception("stochMagnet/main/cycle",
304  "SM_BeamHysteresis::open(...)",
305  "Fatal Error: bad stochastic output for this cycle. Aborted");
306  }
307  hysOutput->setHysteresisDirection(mDHext);
308 
309  mBackupStep=0;
310  mBackupIndex=0;
311 
312  if (isRestoring() && CORE_IO::Exists(mHysFileName)) {
313  //restore from last hysteresis step
314  if (!restoreFromLastBackup(system,iCycleStep,outputId)) {
315  throw CORE_Exception("stochMagnet/main/cycle",
316  "SM_BeamHysteresis::open(...)",
317  "Fatal Error: impossible to restore hysterisis cycle. Aborted");
318  }
319 
320  } else {
321  iCycleStep=0;
322  //not restoring hysteresis: begin at hysteresis first step
323  if (outputId==0) {
324  std::ofstream file(mHysFileName.c_str(),std::ios::out);
325  //std::cout<<"create Hysteresis file:"<<mHysFileName<<"\n";
326  if (!file) {
327  std::cout<<"impossible to open Hysteresis file : "<<mHysFileName<<"\n";
328  return false;
329  }
330 
331  //print header in hyteressis file
332  printHeader(file,beam);
333 
334  //close the file
335  file.close();
336  }
337 
338  //decreasing hext cycle
339  mHysteresisDirection=-1;
340  mHysteresisIndex=0;
341  mCriticalPointIndex=0;
342  mIsCriticalPoint=false;
343  mHysValue=1;
344  }
345 
346 
347  //start the timer
348  mTimer.start();
349 
350  //std::cout<<"end SM_BeamHysteresis::open("<<outputId<<")\n";
351  return true;
352  }
353 
360  inline void nextCycleStep(const tIndex& iCycleStep,SM_Beam& beam,const tInteger& outputId,const SM_StochasticOutputComponent& output) {
361  //std::cout<<"begin SM_BeamHysteresis::nextCycleStep("<<outputId<<")\n";
362  //system
363  SM_System& system=beam.getSystem();
364  SM_LandauLifschitzSystem* llSystem=dynamic_cast<SM_LandauLifschitzSystem*>(&system);
365 
366  //S
367  const SM_RealField& S=system.getMagneticMomentDirections();
368 
369  //compute the hysteresis value
370  tReal oldHysValue=mHysValue;
371  mHysValue=output.getOutputValues()[0];
372 
373  //critical point when hys value changes of sign
374  if (!mIsCriticalPoint) mIsCriticalPoint=(mHysValue*oldHysValue<=0);
375 
376  //mH=<mHext,mDHext>
377  mH=0;
378  const tReal *iHext=mHext.data();
379  for(const auto& Dk:mDHext) {
380  mH+=(*iHext)*Dk;
381  iHext++;
382  }
383 
384  tReal netTorque=llSystem->computeNetTorque();
385 
386  //add the value into file
387  if (outputId==0) {
388 
389  std::ofstream file(mHysFileName.c_str(),std::ios::app);
390  file<<((int)mHysteresisDirection)<<"\t"<<mHysteresisIndex<<"\t"<<std::setprecision(12)<<mH<<"\t"<<system.getStepIndex();
391  file<<"\t"<<std::setprecision(12)<<mHysValue;
392  if (llSystem!=null) {
393  file<<"\t"<<std::setprecision(12)<<llSystem->getTime();
394  file<<"\t"<<std::setprecision(12)<<netTorque;
395  }
396  file<<"\t"<<(mTimer.stop()/1000);//chorno is stop and restart
397  file<<"\n";
398  file.close();
399  mBackupStep++;
400  if (mIsCriticalPoint && mAreCriticalPointsSaved) {
401  tString SFileName=getSFile()+std::to_string(mCriticalPointIndex)+".cpt";
402  std::stringstream SHeader;
403  SHeader<<"dir="<<((int)mHysteresisDirection)<<"\n";
404  SHeader<<"i="<<((int)mHysteresisIndex)<<"\n";
405  SHeader<<"h="<<std::setprecision(12)<<mH<<"\n";
406  SHeader<<"criticalPointIndex="<<mCriticalPointIndex<<"\n";
407  S.saveToFile(SHeader.str(),SFileName,12);
408  mCriticalPointIndex++;
409  mIsCriticalPoint=false;
410  }
411 
412  //save S for future restore
413  if ((mBackupStep==mBackupStepsNumber)) {
414  tString SFileName=getSFile()+std::to_string(mBackupIndex)+".back";
415  std::stringstream SHeader;
416  SHeader<<"dir="<<((int)mHysteresisDirection)<<"\n";
417  SHeader<<"i="<<((int)mHysteresisIndex)<<"\n";
418  SHeader<<"h="<<std::setprecision(12)<<mH<<"\n";
419  SHeader<<"criticalPointIndex="<<mCriticalPointIndex<<"\n";
420  if(S.saveToFile(SHeader.str(),SFileName,12)) {
421  mBackupIndex++;
422  mBackupIndex%=mBackupsNumber;
423  }
424  mBackupStep=0;
425  }
426 
427 
428  }
429 
430 
431  //next cycle
432  moveToNextCycle(iCycleStep,S,system,outputId);
433 
434  //std::cout<<"end SM_BeamHysteresis::nextCycleStep("<<outputId<<")\n";
435  }
436 
437 private:
443  inline void moveToNextCycle(const tIndex& iCycleStep,const SM_RealField& S0,SM_System& system,const tInteger& outputId) {
444 
445  if (iCycleStep==mHextNumber) {
446  //mHext=mHextMin
447  //next cycle is in the other dierction
448  mHysteresisDirection*=-1;
449  }
450  mHysteresisIndex-=mHysteresisDirection;
451 
452 
453 
454  //next H
455  tReal Hold=mH;
456  mH+=mDH*mHysteresisDirection;
457 
458  //critical point when H changes of sign
459  if (!mIsCriticalPoint) mIsCriticalPoint=(mH*Hold<=0);
460 
461  //next Hext=mH.DHext
462  const tReal *iD=mDHext.data();
463  for(auto& Hk:mHext) {
464  Hk=(*iD)*mH;
465  iD++;
466  }
467 
468  //set the adimensionized Hext
469  mZeemanOperator->setHext(mHext);
470 
471  //set the next initial direction to last magnetic moment direction computed
472  //std::cout<<"S set to "<<S0<<" for id:"<<outputId<<" for cycle step "<<iCycleStep<<"\n";
474 
475  }
476 
479  inline tBoolean restoreFromLastBackup(SM_System& system,tIndex& iCycleIndex,const tInteger& outputId) {
480  //std::cout<<"begin SM_BeamHysteresis::restoreFromLastBacku(system,"<<iCycleIndex<<")\n";
481  std::valarray<tReal> hValues;
482  std::valarray<tReal> hysValues;
483  tInteger nHysValues;
484  if (!LoadFromFile(mHysFileName,mDHext,mAHext,mDH,mCycleStepsNumber,
485  mHysteresisDirection,mHysteresisIndex,mH,
486  nHysValues,hValues,hysValues)) return false;
487  mHysValue=hysValues[nHysValues-1];
488 
489  //set the number of hysteresis values
490  mHextNumber=(mCycleStepsNumber-1)/2;
491 
492 
493  //load S at last computed hysteresis values
494  SM_RealField S;
495  tString SFile;
496  tRelativeInteger d=0;//direction of hysteresis
497  tRelativeInteger i=-1;//index of the hysteresis in direction
498  tString line;
499  int nMaxReadData=2;
500  int nReadData=0;
501  for (mBackupIndex=0;mBackupIndex<mBackupsNumber;mBackupIndex++) {
502  SFile=getSFile()+std::to_string(mBackupIndex)+".back";
503  std::ifstream file(SFile.c_str(),std::ios::in);
504  nReadData=0;
505  while ( (!file.eof()) && (std::getline(file,line)) && (nReadData<nMaxReadData)) {
506  nReadData+=ReadKeyValue(line,"#dir",d);
507  nReadData+=ReadKeyValue(line,"#i",i);
508  }
509  if ( (((tCInt)d)==mHysteresisDirection) && (i==mHysteresisIndex)) {
510  //read critical point
511  nMaxReadData++;
512  while ( (!file.eof()) && (std::getline(file,line)) && (nReadData<nMaxReadData)) {
513  nReadData+=ReadKeyValue(line,"#criticalPointIndex",mCriticalPointIndex);
514  }
515  break;
516  }
517  }
518  if (mBackupIndex==mBackupsNumber) {
519  std::cout<<"can not find the S backup file from backup files of type "<<SFile<<" and index in [0,"<<mBackupsNumber<<"[ with hysteresis direction \n";
520  std::cout<<std::to_string((int)mHysteresisDirection)+" and index ";
521  std::cout<<std::to_string((int)mHysteresisIndex)+" ";
522  return false;
523  }
524 
525 
526  //load S
527  S.loadFromFile(SFile);
528 
529  //next hysteresis step
530  iCycleIndex=mHysteresisIndex;
531  if (mHysteresisDirection==1) {
532  iCycleIndex=mHextNumber;
533  iCycleIndex+=mHextNumber;
534  iCycleIndex-=mHysteresisIndex;
535  }
536  moveToNextCycle(iCycleIndex,S,system,outputId);
537  iCycleIndex++;
538 
539  //std::cout<<"end SM_BeamHysteresis::restoreFromLastBacku(system,"<<iCycleIndex<<")\n";
540  return true;
541  }
542 
543 
548  inline tString getSFile() const {
549  tString SFileName=mHysFileName;
550  tIndex iExt=SFileName.rfind(".hys");
551  SFileName=CORE_IO::GetAbsolutePath(SFileName.substr(0,iExt))+"-S";
552  return SFileName;
553  }
554 
555 public :
571  inline static tBoolean LoadFromFile(const tString& fileName,
572  std::array<tReal,SM_Constants::DIM>& direction,
573  tReal& amplitude,
574  tReal &dh,
575  tInteger& nCycleSteps,
576  tCInt& hysDirection,
577  tRelativeInteger& hysStep,
578  tReal& h,
579  tInteger& nHysValues,std::valarray<tReal>& hs,std::valarray<tReal>& hys) {
580  //restoring hysteresis
581  tString line;
582  std::ifstream file(fileName.c_str(),std::ios::in);
583  if (!file) {
584  std::cout<<"file "<<fileName<<" does not exist\n";
585  return false;
586  }
587 
588  //load the hysteresis data
589  int nReadData=0;
590 
591  std::vector<tString> keys={
592  "Direction of Hext",
593  "Amplitude of Hext",
594  "Variation of Hext",
595  "number of steps",
596  };
597  int nMaxReadData=keys.size();
598 
599  std::vector<tString>::const_iterator iKey;
600  while ( (!file.eof()) && (std::getline(file,line)) && (nReadData<nMaxReadData)) {
601  iKey=keys.begin();
602  nReadData+=ReadKeyValue(line,*iKey,direction);iKey++;
603  nReadData+=ReadKeyValue(line,*iKey,amplitude);iKey++;
604  nReadData+=ReadKeyValue(line,*iKey,dh);iKey++;
605  nReadData+=ReadKeyValue(line,*iKey,nCycleSteps);iKey++;
606  }
607  if (nReadData!=nMaxReadData) {
608  std::cout<<"error in reading the data from hysteresis file "<<fileName<<" nReadData:"<<nReadData<<" != "<<nMaxReadData<<"\n";
609  for(const auto& key:keys) {
610  std::cout<<"\t "<<key<<"\n";
611  }
612  return false;
613  }
614  hs.resize(nCycleSteps);
615  hys.resize(nCycleSteps);
616  tReal *ihs=&hs[0];
617  tReal* ihys=&hys[0];
618  tIndex step;
619  //ignore the comments
620  while ( (!file.eof()) && (std::getline(file,line)) && (line[0]=='#'));
621  //read the hyteresis file
622  nHysValues=0;
623  do {
624  std::stringstream sstream;
625  sstream<<line;
626  sstream>>step;hysDirection=step;
627  sstream>>hysStep;
628  sstream>>h;(*ihs)=h;ihs++;
629  sstream>>step;
630  sstream>>(*ihys);ihys++;
631  nHysValues++;
632 
633  } while ( (!file.eof()) && (std::getline(file,line)) && (line.length()>0));
634 
635  file.close();
636  return true;
637  }
638 
639 
640 public:
645  inline tBoolean isCycleFinished(const tIndex& iCycle,const SM_Beam& beam) {
646  return (iCycle==mCycleStepsNumber);
647  }
648 
651  virtual tString toString() const override {
652  std::stringstream ret;
653  ret<<SuperClass::toString()<<"\n";
654  ret<<"\t Direction of Hext="<<functions_array::toString(mDHext)<<"\n";
655  ret<<std::setprecision(12)<<"\t Amplitude of Hext="<<mAHext<<"\n";
656  ret<<std::setprecision(12)<<"\t Variation of Hext="<<mDH<<"\n";
657  ret<<std::setprecision(12)<<"\t Adimensionized Max of Hext="<<functions_array::toString(mHextMax)<<"\n";
658  ret<<"\t number of steps:"<<mCycleStepsNumber<<"\n";
659  return ret.str();
660  }
661 
667  inline tBoolean close(const tIndex& iCycle,const SM_Beam& beam) {
668  return true;
669  }
670 private:
673  inline void printHeader(std::ofstream& file,const SM_Beam& beam) const {
674 
675  file<<"# Hysteresis cycle Beam generated by soft:"<<CORE_Run::GetSoftName()<<" Version:"<<CORE_Run::GetVersion()<<"\n";
676  tString str="Hysteresis Cycle:"+this->toString();
677  functions_string::replaceAll("\n","\n#",str);
678  file<<"#"<<str<<"\n";
679 
680  str="beam:"+beam.toString();
681  functions_string::replaceAll("\n","\n#",str);
682  file<<"#"<<str<<"\n";
683 
684  file<<"# [...] : for Landau Lifschitz system only \n";
685  file<<"#<hysteresis direction> <hysteresis index> <H> <Step Index> <HysValue> [<time> <netTorque>] <duration in s>\n";
686  }
687 
688 
689 
692  template<typename T,size_t D>
693  static tBoolean ReadKeyValue(tString& line,const tString& key,std::array<T,D>& values) {
694  auto *iValues=values.data();
695  size_t s=0;
696  T v;
697  tIndex iKey=line.find(key);
698  if (iKey!=tString::npos) {//key
699  line=line.substr(iKey+key.length());
700  iKey=line.find("=");
701  if (iKey==tString::npos) iKey=line.find(":");
702  if (iKey!=tString::npos) {//key =
703  line=line.substr(iKey+1);
704  iKey=line.find("{");
705  if (iKey==tString::npos) iKey=line.find("[");
706  if (iKey!=tString::npos) {//key = {
707  line=line.substr(iKey+1);
708  iKey=line.rfind("}");
709  if (iKey==tString::npos) iKey=line.find("]");
710  if (iKey!=tString::npos) {//key = { }
711 
712  //read the vector
713  line=line.substr(0,iKey);
714  iKey=line.rfind(",");
715  while (iKey!=tString::npos) {
716  std::stringstream vss;
717  vss<<std::setprecision(12)<<line.substr(0,iKey);
718  vss>>v;
719  if (s<D) {
720  (*iValues)=v;
721  iValues++;
722  s++;
723  }
724  line=line.substr(iKey+1);
725  iKey=line.rfind(",");
726  }
727  std::stringstream vss;
728  vss<<std::setprecision(12)<<line;
729  if (s<D) {
730  (*iValues)=v;
731  iValues++;
732  s++;
733  }
734  return true;
735  }//end reading key value
736  }//end reading {
737  }//end reading =
738  }//end reading key
739  return false;
740  }//end method
741 
744  template<typename T>
745  static tBoolean ReadKeyValue(tString& line,const tString& key,T& value) {
746  tIndex iKey=line.find(key);
747  if (iKey!=tString::npos) {//key
748  line=line.substr(iKey+key.length());
749  iKey=line.find("=");
750  if (iKey==tString::npos) iKey=line.find(":");
751  if (iKey!=tString::npos) {//key =
752  line=line.substr(iKey+1);
753  std::stringstream vss;
754  vss<<std::setprecision(12)<<line;
755  vss>> value;
756  return true;
757  }//end =
758  }//end key
759  return false;
760  }//end method
761 
762 
763 };
764 
765 
766 #endif
this class describes the chono class by default write on standart output
Definition: CORE_Chrono.h:14
tULLInt stop()
stop the chrono and return the duration time in micro seconds as an int
Definition: CORE_Chrono.h:95
void start()
start the chrono
Definition: CORE_Chrono.h:89
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:17
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:135
tBoolean loadFromFile(const tString &filename, tString &comment, tInt &retCode)
load the field from a txt file with the format :
Definition: CORE_Field.h:1003
static tString GetAbsolutePath(const tString &path)
get the absolute path of the path
Definition: CORE_IO.h:365
static tBoolean Exists(const tString &f)
return true if the file or the path exists
Definition: CORE_IO.h:91
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:113
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
static const tString & GetSoftName()
get soft name
Definition: CORE_Run.h:115
static const tString & GetVersion()
get the version
Definition: CORE_Run.h:129
This class is an interface of Beam Cycle class for Stoch Microm package.
Definition: SM_BeamCycle.h:20
virtual tString toString() const override
return the string representation of the class
Definition: SM_BeamCycle.h:193
const tBoolean & isRestoring() const
return true if the cycle starts at last computed cycle index
Definition: SM_BeamCycle.h:137
This class is an hysteresis cycle manager for running a cycle of a beam class for Stoch Microm packag...
Definition: SM_BeamHysteresis.h:28
static tBoolean LoadFromFile(const tString &fileName, std::array< tReal, SM_Constants::DIM > &direction, tReal &amplitude, tReal &dh, tInteger &nCycleSteps, tCInt &hysDirection, tRelativeInteger &hysStep, tReal &h, tInteger &nHysValues, std::valarray< tReal > &hs, std::valarray< tReal > &hys)
read an hysteresis file
Definition: SM_BeamHysteresis.h:571
static CORE_UniquePointer< SelfClass > New()
create an unique pointer to a new instance of this
Definition: SM_BeamHysteresis.h:164
virtual ~SM_BeamHysteresis(void)
destroy
Definition: SM_BeamHysteresis.h:112
SM_BeamHysteresis(void)
create
Definition: SM_BeamHysteresis.h:85
tBoolean close(const tIndex &iCycle, const SM_Beam &beam)
return true if the cycle is close without error
Definition: SM_BeamHysteresis.h:667
void setBackupsNumber(const tInteger &nBackups)
set the number of backups
Definition: SM_BeamHysteresis.h:183
tBoolean isCycleFinished(const tIndex &iCycle, const SM_Beam &beam)
return true if the cycle is finished
Definition: SM_BeamHysteresis.h:645
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_BeamHysteresis.h:141
void setAreCriticalPointsSaved(const tBoolean &flag)
true to save magnetic moment dierctions at critical points
Definition: SM_BeamHysteresis.h:176
virtual tString toString() const override
return the string representation of the class
Definition: SM_BeamHysteresis.h:651
void nextCycleStep(const tIndex &iCycleStep, SM_Beam &beam, const tInteger &outputId, const SM_StochasticOutputComponent &output)
next the cycle of beam run
Definition: SM_BeamHysteresis.h:360
void setHysteresisFileName(const tString &hysteresisFile)
set the hystersis file
Definition: SM_BeamHysteresis.h:208
void setHextRange(const std::array< tReal, 7 > &range)
set the hext range
Definition: SM_BeamHysteresis.h:199
void setBackupStepsNumber(const tInteger &s)
set the number of steps between 2 backups
Definition: SM_BeamHysteresis.h:191
tBoolean open(SM_Beam &beam, SM_StochasticOutputComponent &stochasticOutput, const tInteger &outputId, tIndex &iCycleStep)
init the cycle of beam run
Definition: SM_BeamHysteresis.h:225
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_BeamHysteresis.h:152
This class defines a general stochastic beam of trajectories of system.
Definition: SM_Beam.h:61
const SM_System & getSystem() const
get the system
Definition: SM_Beam.h:264
virtual tString toString() const override
turn the class into a string representation
Definition: SM_Beam.h:315
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
This class is a simulation of one trajectory class for Stoch Magnet package.
Definition: SM_LandauLifschitzSystem.h:59
const tReal & getTime() const
get the time
Definition: SM_LandauLifschitzSystem.h:214
tReal computeNetTorque() const
compute Net Torque
Definition: SM_LandauLifschitzSystem.h:347
const tReal & getCharacteristicField() const
get the characteristic field in T
Definition: SM_Material.h:367
This class stores stochastic hysteresis values.
Definition: SM_StochasticHysteresis.h:30
void setHysteresisDirection(const std::array< tReal, SM_Constants::DIM > &D)
set the direction of hysteresis
Definition: SM_StochasticHysteresis.h:155
This class stores stochastic outpus computed for each trajectory of a simulation of trajectories of a...
Definition: SM_StochasticOutputComponent.h:36
const std::valarray< tReal > & getOutputValues() const
get the output values of the stochastic output for reading
Definition: SM_StochasticOutputComponent.h:330
This class is a one simulation of a beam for Stoch Magnet package.
Definition: SM_System.h:53
const SM_RealField & getMagneticMomentDirections() const
get the unit direction of spins at time
Definition: SM_System.h:267
void setInitialMagneticMomentDirections(const std::valarray< tReal > &S0)
set the initial unit direction of spins
Definition: SM_System.h:214
const SM_SliceOperator * getOperator(const tString &name) const
get the operator with name
Definition: SM_System.h:305
const SM_RealField & getInitialMagneticMomentDirections() const
get the initial unit direction of spins
Definition: SM_System.h:253
const SM_Material & getMaterial() const
get the material of the network
Definition: SM_System.h:193
const tIndex & getStepIndex() const
get the step index
Definition: SM_System.h:415
virtual tBoolean updateInitialMagneticMomentDirections(const SM_RealField &S0)
update the initial unit direction of spins
Definition: SM_System.h:241
This class is describes a Zeeman operator interface.
Definition: SM_ZeemanOperator.h:26
void setHext(std::initializer_list< tReal > &&values)
set the Hext value
Definition: SM_ZeemanOperator.h:200