C++ mpi module for stochmagnet_main Package
SM_DipolarOperator.h
1 #ifndef SM_DipolarOperator_H
2 #define SM_DipolarOperator_H
3 
4 //base classes
5 #include "SM_SliceOperator.h"
6 #include "SM_LinearSliceOperator.h"
7 
8 //network class
9 #include "SM_Network.h"
10 
11 
12 //dipolar field class
13 #include "SM_DipolarField.h"
14 
45 
46 
47 private :
48 
49  //type class
51 
54 
55  //attributes
56 
57  //constant for computing H
58  tReal mLambdaH;
59 
60 protected:
61  // CONSTRUCTORS
65 
66  setName("Dipolar");
67  mLambdaH=0;
68  }
69 
70  // DESTRUCTORS
73  virtual ~SM_DipolarOperator(void) {
74  }
75 
76 
77 public :
78 
79  //Instance building
80  //=================
81 
95  virtual tMemSize getMemorySize() const {
96  return sizeof(*this)+this->getContentsMemorySize();
97  }
98 
107  virtual tMemSize getContentsMemorySize() const {
108  tMemSize mem=SuperClass::getContentsMemorySize();
110  return mem;
111  }
112 public:
113 
114 
115  //discretize the operator
116  //=======================
123  virtual void discretize(const SM_Network& network,
124  const SM_Material& material) override {
125 
126  SuperClass::discretize(network,material);
127 
128 
129 
130  //x coefficient for H
131  //lambdaH=\frac{1}{4.PI}
132  mLambdaH=4;
133  mLambdaH*=M_PI;
134  mLambdaH=1./mLambdaH;
135  //mLambdaH*=(mu_0.mu_B)/(A^3) for dimensionzed field
136  // *=1 for adimensionized field
137  mLambdaH*=material.getAdimensionizedDerivativeEnergyFactor();//mCde
138  mLambdaH*=material.getAdimensionizedDipolarEnergyFactor();//cEdip
139 
140  }
141 
142 
143 protected:
147  inline const tReal& getLambdaH() const {
148  return mLambdaH;
149  }
150 
151  //Fields computation
152  //==================
153 public:
154 
155 
156 
157 
158 
176  void computeDipolarFieldAtPoints(const SM_Material& material,
177  const tInteger& nP,//number of particles of the network (P,S)
178  const tReal *P,//X at particles of the network for each S
179  const tReal *S,//S at particles of the network
180  const tInteger& nX,//number of elements of X (number of elements of H)
181  const tReal* X,//coordinate of points in which H is computed
182  const tBoolean& alpha,
183  tReal *H) const;
184 
203  const tInteger& nP,//number of particles of the network (P,S)
204  const tReal *P,//X at particles of the network for each S
205  const tReal *S,//S at particles of the network
206  const tInteger& nX,//number of elements of X (number of elements of H)
207  const tReal* X,//coordinate of points in which H is computed
208  const tBoolean& alpha,
209  tReal *H) const;
210 
211 
212  //Spin energy computation
213  //=======================
214 
226  inline static void ComputeSpinDipolarEnergy(const tReal& mu_s,
227  const tReal &Edip,
228  const tInteger& nParticles, const tReal* X,const tReal* S,
229  const tReal *Xi,const tReal *Si,
230  tReal& E) {
231 
232 
233  E=0;
234 
235  //iterators on first particle j
236  const tReal *iXj=X;// coordinates
237  const tReal *iSj=S;// spin direction
238 
239  //iterators on last particle j
240  const tReal *eXj=X;eXj+=nParticles*SM_Constants::DIM;
241 
242 
243  //dipolar interaction betaween particle i and particules j in [start,end[
244  SM_DipolarField::ComputeUnscaledSpinEnergy(Xi,Si,//coordinate & direction of spin of particle i
245  iXj,eXj,//begin & end iterator on coordinates of particles j
246  iSj,//begin iterator on direction of magnetic moment of particles j
247  E);//Energy between particle i and particles j
248 
249 
250  E*=Edip;
251  E*=mu_s;
252  E*=mu_s;
253  E/=M_PI;
254  E*=0.25;
255 
256  }
268  inline static void ComputeSeparatedSpinDipolarEnergy(const tReal& mu_s,
269  const tReal &Edip,
270  const tInteger& nParticles, const tReal* X,const tReal* S,
271  const tReal *Xi,const tReal *Si,
272  tReal& E) {
273 
274 
275  E=0;
276 
277  //iterators on first particle j
278  const tReal *iXj=X;// coordinates
279  const tReal *iSj=S;// spin direction
280 
281  //iterators on last particle j
282  const tReal *eXj=X;eXj+=nParticles*SM_Constants::DIM;
283 
284 
285  //dipolar interaction betaween particle i and particules j in [start,end[
286  SM_DipolarField::ComputeSeparatedUnscaledSpinEnergy(Xi,Si,//coordinate & direction of spin of particle i
287  iXj,eXj,//begin & end iterator on coordinates of particles j
288  iSj,//begin iterator on direction of magnetic moment of particles j
289  E);//Energy between particle i and particles j
290 
291 
292  E*=Edip;
293  E*=mu_s;
294  E*=mu_s;
295  E/=M_PI;
296  E*=0.25;
297 
298  }
299 
300 
301 
302 };
303 
304 
305 #endif
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: CORE_Object.h:278
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
static void ComputeSeparatedUnscaledSpinEnergy(const tReal *Xi, const tReal *Si, const tReal *iXj, const tReal *eXj, const tReal *iSj, tReal &Ei)
compute the dipolar field unscaled energy in sperated domain
Definition: SM_DipolarField.h:583
static void ComputeUnscaledSpinEnergy(const tReal *Xi, const tReal *Si, const tReal *iXj, const tReal *eXj, const tReal *iSj, tReal &Ei)
compute the dipolar field energy
Definition: SM_DipolarField.h:459
This class is describes a demagnetized operator.
Definition: SM_DipolarOperator.h:44
void computeDipolarFieldAtPoints(const SM_Material &material, const tInteger &nP, const tReal *P, const tReal *S, const tInteger &nX, const tReal *X, const tBoolean &alpha, tReal *H) const
compute the magnetic field by virtual method
Definition: SM_DipolarOperator.cpp:4
static void ComputeSpinDipolarEnergy(const tReal &mu_s, const tReal &Edip, const tInteger &nParticles, const tReal *X, const tReal *S, const tReal *Xi, const tReal *Si, tReal &E)
compute the dipolar spin energy
Definition: SM_DipolarOperator.h:226
virtual void discretize(const SM_Network &network, const SM_Material &material) override
discretize the operator on the netowek
Definition: SM_DipolarOperator.h:123
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_DipolarOperator.h:95
void computeDipolarFieldAtSeparatedPoints(const SM_Material &material, const tInteger &nP, const tReal *P, const tReal *S, const tInteger &nX, const tReal *X, const tBoolean &alpha, tReal *H) const
compute the dipolar field at separated X points
Definition: SM_DipolarOperator.cpp:96
virtual ~SM_DipolarOperator(void)
destroy
Definition: SM_DipolarOperator.h:73
SM_DipolarOperator(void)
create a network class
Definition: SM_DipolarOperator.h:64
const tReal & getLambdaH() const
get lambda H
Definition: SM_DipolarOperator.h:147
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_DipolarOperator.h:107
static void ComputeSeparatedSpinDipolarEnergy(const tReal &mu_s, const tReal &Edip, const tInteger &nParticles, const tReal *X, const tReal *S, const tReal *Xi, const tReal *Si, tReal &E)
compute the dipolar spin energy for a separated domain
Definition: SM_DipolarOperator.h:268
This class is describes a linear operator interface in a slice of particles of a network.
Definition: SM_LinearSliceOperator.h:17
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
const tReal & getAdimensionizedDerivativeEnergyFactor() const
get the characteristic dipolar energy factor
Definition: SM_Material.h:401
const tReal & getAdimensionizedDipolarEnergyFactor() const
get the characteristic dipolar energy factor
Definition: SM_Material.h:395
This class is describes a network composed by.
Definition: SM_Network.h:66
This class is describes an operator operating on slice of particles of a network SM_Network.
Definition: SM_SliceOperator.h:32
void setName(const tString &name)
set the name
Definition: SM_SliceOperator.h:112
virtual void discretize(const SM_Network &network, const SM_Material &material)
discretize the operator on the network
Definition: SM_SliceOperator.h:142
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: SM_SliceOperator.h:97