C++ main module for stochmagnet Package  1.0
SM_TemplatedSystem.h
Go to the documentation of this file.
1 #ifndef SM_TemplatedSystem_H
2 #define SM_TemplatedSystem_H
3 
4 #include "SM_System.h"
5 
6 
7 #include "SM_ZeemanOperator.h"
10 
11 
18 template<class SystemImpl>
19 class SM_TemplatedSystem : public SM_System {
20 
21  //attributes
22 private :
23 
24 
25  //associations
26 
27 
31 
32 
33 
34 
35 
36 protected:
37  // CONSTRUCTORS
41 
42 
43  }
44 
45  // DESTRUCTORS
48  virtual ~SM_TemplatedSystem(void) {
49  }
50 
51 
52 public :
53  // CREATE class
54 
55 
56  //MEMORY
57 
71  virtual tMemSize getMemorySize() const {
72  return sizeof(*this)+getContentsMemorySize();
73  }
74 
75 
76  //SET & GET methods
77 
78 
82  virtual void getOperatorNames(std::vector<tString>& names) const override {
83  names.clear();
84  if (mZeemanOperator!=null) names.push_back(mZeemanOperator->getName());
85  if (mDemagnetizedOperator!=null) names.push_back(mDemagnetizedOperator->getName());
86  if (mHeissenbergOperator!=null) names.push_back(mHeissenbergOperator->getName());
87 
88  }
89 
90 
91 public:
92 
97  virtual void discretize() {
98 
100 
101  //discretize the operators on the network
102 
103  //registed the operatosr for the templated method computeTemplatedMagneticField call
104 
105  mZeemanOperator=dynamic_cast<const SM_ZeemanOperator*>(getOperator("Zeeman"));
106  mDemagnetizedOperator=dynamic_cast<const SM_DemagnetizedOperator*>(getOperator("Demagnetized"));
107  mHeissenbergOperator=dynamic_cast<const SM_HeissenbergOperator*>(getOperator("Heissenberg"));
108 
109 
110  }
111 
112 
113 
114 public:
115 
123  template<class StochImpl>
125  tReal *mu,tReal *Es) {
126  std::cerr<<"SM_templatedSystem:::makeTemplatedRelaxation(randomFunction,mu,Es) is not yet implemented ! \n";
127  return false;
128  }
129 
130 
131 public:
140  template<class StochImpl,class NoiseImpl>
142  const SM_TemplatedNoiseRateFunction<NoiseImpl>& noiseRateFunction,
143  tReal *mu,
144  tReal *Es);
145 
146 protected:
153  inline void computeTemplatedMagneticField(const tIndex& t,
154  const SM_Network& network,
155  const tReal *mu,
156  tReal *B) const {
157 
158  // B=0
159  memset(B,0,sizeof(tReal)*network.getParticlesNumber()*network.getDimension());
160 
161  //B+=Bop
162  if (mZeemanOperator!=null)
164  if (mDemagnetizedOperator!=null)
166  if (mHeissenbergOperator!=null)
168  }
169 
178  const SM_Network& network,
179  const tReal *mu,
180  tReal *B,tReal* Es) const {
181 
182  // B=0
183  memset(B,0,sizeof(tReal)*network.getParticlesNumber()*network.getDimension());
184 
185  //total energy
186  tReal &Et=(*Es);Es++;//total energy
187  tReal *Es_p=Es;//energy of the operator op
188  //B+=Bop
189  if (mZeemanOperator!=null) {
191  Et+=(*Es_p);//operator's energy contribution
192  Es_p++;//energy of next operator
193  }
194  if (mDemagnetizedOperator!=null) {
196  Et+=(*Es_p);//operator's energy contribution
197  Es_p++;//energy of next operator
198  }
199  if (mHeissenbergOperator!=null) {
201  Et+=(*Es_p);//operator's energy contribution
202  Es_p++;//energy of next operator
203  }
204  }
217  virtual tBoolean computeMuAtNextTimeStep(const tReal& dt,const tReal& epsilon_t,
218  const tIndex& nParticles,const tDimension& dim,
219  const tReal* mu_t,
220  tReal *mu_tpdt) const {
221  return computeTemplatedMuAtNextTimeStep(dt,epsilon_t,nParticles,dim,mu_t,mu_tpdt);
222  }
233  inline tBoolean computeTemplatedMuAtNextTimeStep(const tReal& dt,const tReal& epsilon_t,
234  const tIndex& nParticles,const tDimension& dim,
235  const tReal* mu_t,
236  tReal *mu_tpdt) const {
237 
238  return static_cast<const SystemImpl*>(this)->computeTemplatedMuAtNextTimeStep(dt,epsilon_t,nParticles,dim,mu_t,mu_tpdt);
239  }
240 
241 };
242 
243 #include "SM_TemplatedSystem.hpp"
244 #endif
tUCInt tDimension
Definition: CORE_StdPtrField.h:567
This class is describes a demagnetized operator.
Definition: SM_DemagnetizedOperator.h:32
void computeTemplatedMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const
compute the magnetic field
Definition: SM_DemagnetizedOperator.h:172
void computeTemplatedMagneticFieldAndEnergy(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B, tReal &E) const
compute the magnetic field and energy
Definition: SM_DemagnetizedOperator.h:188
This class is describes the exchange operator.
Definition: SM_HeissenbergOperator.h:27
void computeTemplatedMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const
compute the magnetic field
Definition: SM_HeissenbergOperator.h:125
void computeTemplatedMagneticFieldAndEnergy(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *H, tReal &E) const
compute the magnetic field and energy
Definition: SM_HeissenbergOperator.h:141
This class is describes a a network.
Definition: SM_Network.h:18
tDimension getDimension() const
return the dimension
Definition: SM_Network.h:133
tInteger getParticlesNumber() const
return the particles number
Definition: SM_Network.h:146
const tString & getName() const
return the operator name
Definition: SM_Operator.h:102
This class is a simulation of one trajectory class for Stoch Microm package.
Definition: SM_System.h:51
virtual void discretize()
discretize the system
Definition: SM_System.h:354
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_System.h:140
const SM_Operator * getOperator(const tString &name) const
get the operator with name
Definition: SM_System.h:287
This class describes a templated noise rate function as static polymorphism.
Definition: SM_TemplatedNoiseRateFunction.h:14
This class describes a templated stochastic function to generate random numbers.
Definition: SM_TemplatedStochasticFunction.h:15
Definition: SM_TemplatedSystem.h:19
tBoolean makeTemplatedRelaxation(const SM_TemplatedStochasticFunction< StochImpl > &randomFunction, tReal *mu, tReal *Es)
compute the relaxation process by calling only templated methods
Definition: SM_TemplatedSystem.h:124
virtual void getOperatorNames(std::vector< tString > &names) const override
get the operator names
Definition: SM_TemplatedSystem.h:82
void computeTemplatedMagneticFieldAndEnergies(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B, tReal *Es) const
compute the magnetic field at time t by calling the templated method SM_TemplatedOperator::computeTem...
Definition: SM_TemplatedSystem.h:177
tBoolean computeTemplatedMuAtNextTimeStep(const tReal &dt, const tReal &epsilon_t, const tIndex &nParticles, const tDimension &dim, const tReal *mu_t, tReal *mu_tpdt) const
compute mu at time step
Definition: SM_TemplatedSystem.h:233
virtual void discretize()
discretize the system
Definition: SM_TemplatedSystem.h:97
virtual ~SM_TemplatedSystem(void)
destroy the class
Definition: SM_TemplatedSystem.h:48
const SM_DemagnetizedOperator * mDemagnetizedOperator
Definition: SM_TemplatedSystem.h:29
const SM_HeissenbergOperator * mHeissenbergOperator
Definition: SM_TemplatedSystem.h:30
void computeTemplatedMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const
compute the magnetic field at time step index t by calling the templated method SM_TemplatedOperator:...
Definition: SM_TemplatedSystem.h:153
const SM_ZeemanOperator * mZeemanOperator
Definition: SM_TemplatedSystem.h:28
SM_TemplatedSystem(void)
create a class
Definition: SM_TemplatedSystem.h:40
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_TemplatedSystem.h:71
virtual tBoolean computeMuAtNextTimeStep(const tReal &dt, const tReal &epsilon_t, const tIndex &nParticles, const tDimension &dim, const tReal *mu_t, tReal *mu_tpdt) const
compute mu at time step
Definition: SM_TemplatedSystem.h:217
This class is describes a Zeeman operator interface.
Definition: SM_ZeemanOperator.h:27
void computeTemplatedMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const
compute the magnetic field
Definition: SM_ZeemanOperator.h:259
void computeTemplatedMagneticFieldAndEnergy(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B, tReal &E) const
compute the magnetic field
Definition: SM_ZeemanOperator.h:275
#define tIndex
Definition: types.h:157
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151
#define tReal
Definition: types.h:137