1 #ifndef SM_DemagnetizedOperator_H
2 #define SM_DemagnetizedOperator_H
126 for (k=0;k<dim;k++) {
127 n2Muj+=(*Mu_jk)*(*Mu_jk);
147 tReal *B)
const override {
148 return computeTemplatedMagneticField(t,network,mu,B);
161 tReal& E)
const override{
162 return computeTemplatedMagneticFieldAndEnergy(t,network,mu,B,E);
177 computeTemplatedMagneticFieldAndEnergy(t,network,mu,B,E);
206 const tReal *Mu_jk,*Mu_j=
null;
207 tReal lambda3=lambda*lambda*lambda;
216 tReal d3PiPjL3,d2PiPj,dd;
219 const tReal *Pik,*Pi;
220 const tReal *Mu_ik,*Mu_i=mu;
223 const tReal *Pjk,*Pj=
null;
242 for (i=0;i<nParticles;i++) {
246 memset(Bi,0,dim*
sizeof(
tReal));
255 auto isMj=mAreMagnetizedCells.cbegin();
256 for (j=0;j<nParticles;j++) {
269 for (k=0;k<dim;k++) {
274 sRijMuj+=dd*(*Mu_jk);
283 d3PiPjL3=(d2PiPj*sqrt(d2PiPj)*lambda3);
290 for (k=0;k<dim;k++) {
293 Bdem_ik=-2*((*Mu_jk)-3.*(sRijMuj/d2PiPj)*((*Pik)-(*Pjk)) )/d3PiPjL3;
297 E-=0.5*Bdem_ik*(*Mu_ik);
339 const tReal *mu)
const override{
340 return computeTemplatedEnergy(t,network,mu);
352 const tReal *mu)
const {
362 tReal iLambda3=1./(lambda*lambda*lambda);
375 const tReal *Mui=mu,*Mui_d;
378 const tReal *Muj,*Muj_d;
381 const tReal *Pi_d,*Pi=particles;
384 const tReal *Pj_d,*Pj=
null;
402 for (i=0;i<nParticles;i++) {
406 for (j=0;j<nParticles;j++) {
419 for (d=0;d<dim;d++) {
420 (*rij)=(*Pj_d)-(*Pi_d);
422 sMu+= (*Mui_d)*(*Muj_d);
423 rMui+=(*Mui_d)*(*rij);
424 rMuj+=(*Muj_d)*(*rij);
432 dij3=dij2*sqrt(dij2);
434 E+=iLambda3*(sMu-(3*rMui*rMuj/dij2))/dij3;
tUCInt tDimension
Definition: CORE_StdPtrField.h:567
K getDimension() const
get the dimension of the field
Definition: CORE_Field.h:143
const T * getValues() const
get the values of the array for reading
Definition: CORE_Field.h:298
tIndex getElementsNumber() const
return the number values of the container
Definition: CORE_Field.h:118
constexpr auto cbegin() const
return begin iterator for reading
Definition: CORE_Field.h:199
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
auto begin()
return begin iterator for writing
Definition: CORE_PtrArray.h:309
auto end()
return end iterator for writing
Definition: CORE_PtrArray.h:315
void setSize(const tIndex &n)
set the number of values
Definition: CORE_PtrArray.h:142
tIndex getSize() const
return the size of the array for writing
Definition: CORE_PtrArray.h:151
this class describes a standart arithmetic array type implemented with a memory allocation with type ...
Definition: CORE_StdPtrArray.h:10
This class is describes a demagnetized operator.
Definition: SM_DemagnetizedOperator.h:32
virtual void computeMagneticFieldAndEnergy(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B, tReal &E) const override
compute the magnetic field at time step t by virtual method
Definition: SM_DemagnetizedOperator.h:157
void updateMagnetizedCells(const SM_RealField &Mu)
update the boolean array to indicates if mu at particule is magnetized
Definition: SM_DemagnetizedOperator.h:117
static CORE_UniquePointer< SM_DemagnetizedOperator > New()
build a new instance of the operator
Definition: SM_DemagnetizedOperator.h:64
CORE_BooleanArray mAreMagnetizedCells
Definition: SM_DemagnetizedOperator.h:39
void computeTemplatedMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const
compute the magnetic field
Definition: SM_DemagnetizedOperator.h:172
virtual tReal computeEnergy(const tIndex &t, const SM_Network &network, const tReal *mu) const override
compute the energy at time step index t
Definition: SM_DemagnetizedOperator.h:337
SM_DemagnetizedOperator(void)
create a network class
Definition: SM_DemagnetizedOperator.h:45
virtual void computeMagneticField(const tIndex &t, const SM_Network &network, const tReal *mu, tReal *B) const override
compute the magnetic field at time step t by virtual method
Definition: SM_DemagnetizedOperator.h:144
tReal computeTemplatedEnergy(const tIndex &t, const SM_Network &network, const tReal *mu) const
compute the energy at time step index t
Definition: SM_DemagnetizedOperator.h:350
virtual CORE_UniquePointer< SM_Operator > NewInstance() const override
create a New instance of this @retrun an unique pointer to the instance
Definition: SM_DemagnetizedOperator.h:72
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_DemagnetizedOperator.h:90
virtual void discretize(const SM_System &system)
discretize the operator : do nothing by default
Definition: SM_DemagnetizedOperator.cpp:5
virtual ~SM_DemagnetizedOperator(void)
destroy
Definition: SM_DemagnetizedOperator.h:52
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
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_DemagnetizedOperator.h:102
This class is describes a a network.
Definition: SM_Network.h:18
tDimension getDimension() const
return the dimension
Definition: SM_Network.h:133
const tReal & getLambda() const
get the lambda value
Definition: SM_Network.h:201
tInteger getParticlesNumber() const
return the particles number
Definition: SM_Network.h:146
const SM_RealField & getParticlesCoordinates() const
void get particles coordinates
Definition: SM_Network.h:181
void setName(const tString &name)
set the name
Definition: SM_Operator.h:95
virtual tMemSize getContentsMemorySize() const
return nthe memory size of the included associations
Definition: SM_Operator.h:80
This class is a simulation of one trajectory class for Stoch Microm package.
Definition: SM_System.h:51
This class is describes an implmentation of operator with the class I.
Definition: SM_TemplatedOperator.h:18
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
#define tIndex
Definition: types.h:157
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151
#define tReal
Definition: types.h:137