C++ mpi module for stochmagnet_main Package
SM_AnisotropyOperator.hpp
1 #ifndef SM_AnisotropyOperator_HPP
2 #define SM_AnisotropyOperator_HPP
3 
4 template<class I>
6  const SM_Network& network,
7  const SM_Material& material,
8  const tIndex& startIndex,
9  const tIndex& endIndex,
10  const tReal *S,
11  const tBoolean& alpha,
12  const tIndex& nH,
13  tReal *H) const {
14 
15 
16 
17  //number of particles of the slice
18  tIndex s=endIndex-startIndex;
19 
20  //iterator on H at start index
21  tReal *iH=H;
22  if (nH>s) iH+=startIndex*SM_Constants::DIM;
23 
24 
25  if (alpha==0) {
26  //H=0
27  memset(iH,0,sizeof(tReal)*s*SM_Constants::DIM);
28  }
29 
30 
31 
32 
33  //anisotropy variables
34  tReal K=material.getAdimensionizedAnisotropyEnergyFactor();
35  //dividide by \mu_s depending on adimenonizized variable or not
36  //mu_s=\tilde mu_s . mu_B for dimensionized variable
37  //mu_s=\tilde mu_s for adimenisonized variable
38  K/=material.getAtomicSpinMoment();
40 
41  //begin anisotropy direction
42  const tReal*U=&material.getAnisotropyDirections()[0];
43 
44  //end anisotropy direction
45  const tReal *eU=U;
46  eU+=material.getAnisotropyDirections().size();
47 
48 
49 
50  //phi value
51  tReal phi;
52 
53  //gradPhi value
54  std::array<tReal,SM_Constants::DIM> gradPhi;
55  const tReal *iGradPhi=gradPhi.data();
56  const tReal *eGradPhi=iGradPhi;eGradPhi+=SM_Constants::DIM;
57 
58 
59 
60  //begin iterator on S
61  const tReal *iS=S;iS+=startIndex*SM_Constants::DIM;
62 
63  //end iterator on S
64  const tReal *eS=S;eS+=endIndex*SM_Constants::DIM;
65 
66  //end iterator on coodinate of k
67  const tReal *eSk=iS;eSk+=SM_Constants::DIM;
68 
69  //work values
70  tReal W,W3;
71  while (iS!=eS) {
72 
73  //compute phi & GradPhi
74  computePhiDerivatives(U,eU,iS,eSk,phi,gradPhi,W,W3);
75 
76  //H+=K.GradPhi
77  iGradPhi=gradPhi.data();
78  while (iGradPhi!=eGradPhi) {
79  (*iH)-=K*(*iGradPhi);
80  iGradPhi++;
81  iH++;
82  }
83 
84  //iterator at next particle
85  iS=eSk;
86  eSk+=SM_Constants::DIM;
87 
88  }//end loop on particles
89 
90 }
91 
92 template<class I>
93 tReal SM_AnisotropyOperator<I>::computeEnergySlice(const tIndex& timeIndex,
94  const SM_Network& network,
95  const SM_Material& material,
96  const tIndex& startIndex,
97  const tIndex& endIndex,
98  const tReal *S) const {
99 
100 
101  //energy of the operator
102  tReal E=0;
103 
104  //anisotropy constant
105  const tReal &K=material.getAdimensionizedAnisotropyEnergyFactor();
106 
107  //begin anisotropy direction
108  const tReal *U=&material.getAnisotropyDirections()[0];
109 
110  //end anisotropy direction
111  const tReal *eU=U;
112  eU+=material.getAnisotropyDirections().size();
113 
114 
115 
116  //begin iterator on S
117  const tReal *iS=S;iS+=startIndex*SM_Constants::DIM;
118 
119  //end iterator on S
120  const tReal *eS=S;eS+=endIndex*SM_Constants::DIM;
121 
122  //end iterator on coodinate of k
123  const tReal *eSk=iS;eSk+=SM_Constants::DIM;
124 
125 
126  tReal W,Ei;
127 
128 
129 
130  while (iS!=eS) {
131 
132  //compute the spin energy
133  computePhi(U,eU,iS,eSk,Ei,W);
134 
135  //add to total energy
136  E+=Ei;
137 
138 
139  //iterator at next particles
140  iS=eSk;
141  eSk+=SM_Constants::DIM;
142 
143  }//end particles loop
144 
145  // E= \sum_{i=0}^{i=P-1} K. \Phi
146  E*=K;
147 
148  return E;
149 }//end method
150 
151 
152 #endif
virtual void computeMagneticFieldSlice(const tIndex &stepIndex, const SM_Network &network, const SM_Material &material, const tIndex &startIndex, const tIndex &endIndex, const tReal *S, const tBoolean &alpha, const tIndex &nH, tReal *H) const
compute the anisotropy magnetic field by virtual method
Definition: SM_AnisotropyOperator.hpp:5
virtual tReal computeEnergySlice(const tIndex &timeIndex, const SM_Network &network, const SM_Material &material, const tIndex &startIndex, const tIndex &endIndex, const tReal *S) const
compute the energy at time t by virtual method for all particles in [startIndex,endIndex[
Definition: SM_AnisotropyOperator.hpp:93
static constexpr tDimension DIM
space dimension
Definition: SM_Constants.h:80
This class describes a materials defined by state attributes:
Definition: SM_Material.h:61
const std::valarray< tReal > & getAnisotropyDirections() const
get the anisotropy directions
Definition: SM_Material.h:303
const tReal & getAtomicSpinMoment() const
get the atomic spin moment in unit of Bohr magneton
Definition: SM_Material.h:242
const tReal & getAdimensionizedDerivativeEnergyFactor() const
get the characteristic dipolar energy factor
Definition: SM_Material.h:401
const tReal & getAdimensionizedAnisotropyEnergyFactor() const
get the characteristic anisotropy energy factor
Definition: SM_Material.h:389
This class is describes a network composed by.
Definition: SM_Network.h:66