1 #ifndef SM_LandauLifschitzFunction_H
2 #define SM_LandauLifschitzFunction_H
8 #include "SM_Constants.h"
40 using LambdaF = std::function<void(
const tReal&,
const tReal& ,tReal&)>;
55 tBoolean mIsSNormalized;
70 mAlphaF=([](
const tReal& gamma,
const tReal& lambda,tReal& alpha) {
81 mAlphaF(mGamma,mLambda,mAlpha);
127 mAlphaF(mGamma,mLambda,mAlpha);
155 mAlphaF(mGamma,mLambda,mAlpha);
162 mAlphaF(mGamma,mLambda,mAlpha);
209 return mIsSNormalized;
228 tIndex nB=B.getElementsNumber();
247 const tIndex& nBParticles,
const tReal *B,
266 const tIndex& nBParticles,
const tReal *B,tReal *F)
const=0;
281 const tIndex& nBParticles,
const tReal *B,tReal *F)
const=0;
300 const tIndex& nSParticles,
const tReal *S,
301 const tIndex& nBParticles,
const tReal *B,tReal *F)
const {
311 const tReal *iS=S;iS+=start;
313 const tReal *eS=S;eS+=end;
317 if (nBParticles==nSParticles) iB+=start;
321 if (nBParticles==nSParticles) iF+=start;
323 tReal S0,S1,S2,B0,B1,B2;
336 sSB=S0*B0+S1*B1+S2*B2;
337 sSS=S0*S0+S1*S1+S2*S2;
338 (*iF)= mAlpha*((S1 * B2 - S2 * B1) + mLambda * (S0 * sSB - B0 * sSS));iF++;
339 (*iF)= mAlpha*((S2 * B0 - S0 * B2) + mLambda * (S1 * sSB - B1 * sSS));iF++;
340 (*iF)= mAlpha*((S0 * B1 - S1 * B0) + mLambda * (S2 * sSB - B2 * sSS));iF++;
343 if (std::isnan(iF[-1]) || std::isnan(iF[-2]) || std::isnan(iF[-3])) {
345 "SM_LandauLifschitzFunction::computeSliceLLFunction("+std::to_string(start)+
","+std::to_string(end)+
",..)",
346 "nan detected : S=("+std::to_string(S0)+
","+std::to_string(S1)+
","+std::to_string(S2)+
") B=("+std::to_string(B0)+
","+std::to_string(B1)+
","+std::to_string(B2)+
") F=("+std::to_string(iF[-3])+
","+std::to_string(iF[-2])+
","+std::to_string(iF[-3])+
")");
367 const tIndex& nSParticles,
const tReal *S,
368 const tIndex& nBParticles,
const tReal *B,tReal *F)
const {
379 const tReal *iS=S;iS+=start;
381 const tReal *eS=S;eS+=end;
384 if (nBParticles==nSParticles) iB+=start;
388 if (nBParticles==nSParticles) iF+=start;
390 tReal S0,S1,S2,B0,B1,B2;
403 sSB=S0*B0+S1*B1+S2*B2;
406 (*iF)= mAlpha*((S1 * B2 - S2 * B1) + mLambda * (S0 * sSB - B0 ));iF++;
407 (*iF)= mAlpha*((S2 * B0 - S0 * B2) + mLambda * (S1 * sSB - B1 ));iF++;
408 (*iF)= mAlpha*((S0 * B1 - S1 * B0) + mLambda * (S2 * sSB - B2 ));iF++;
411 if (std::isnan(iF[-1]) || std::isnan(iF[-2]) || std::isnan(iF[-3])) {
413 "SM_LandauLifschitzFunction::computeSliceNLLFunction("+std::to_string(start)+
","+std::to_string(end)+
",..)",
414 "nan detected : S=("+std::to_string(S0)+
","+std::to_string(S1)+
","+std::to_string(S2)+
") B=("+std::to_string(B0)+
","+std::to_string(B1)+
","+std::to_string(B2)+
") F=("+std::to_string(iF[-3])+
","+std::to_string(iF[-2])+
","+std::to_string(iF[-3])+
")");
429 std::stringstream ret;
430 ret<<
"LL gamma:"<<mGamma<<
"\n";
431 ret<<
"LL alpha:"<<mAlpha<<
"\n";
432 ret<<
"LL lambda:"<<mLambda<<
"\n";
433 ret<<((mIsSNormalized)?
434 "LL(S,H)=alpha.( S ^ H + lambda.(<S,H>S - H )\n":
435 "LL(S,H)=alpha.( S ^ H + lambda.(<S,H>S - |S|^2 H )\n");
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
void setElementsNumber(const tInteger &n)
set the number of element of the container
Definition: CORE_Field.h:121
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 constexpr tReal GAMMA
gyroscopic precession :
Definition: SM_Constants.h:36
This class describes a landau lifschitz function of the form :
Definition: SM_LandauLifschitzFunction.h:30
void setAlpha(const tReal &v)
set the alpha parameter directly without setting setGamma()
Definition: SM_LandauLifschitzFunction.h:168
virtual ~SM_LandauLifschitzFunction(void)
destroy
Definition: SM_LandauLifschitzFunction.h:91
void computeSliceLLFunction(tIndex start, tIndex end, const tIndex &nSParticles, const tReal *S, const tIndex &nBParticles, const tReal *B, tReal *F) const
compute the magnetic function for particle indices in [start,end[
Definition: SM_LandauLifschitzFunction.h:299
virtual void computeLLFunction(const tIndex &nSParticles, const tReal *S, const tIndex &nBParticles, const tReal *B, tReal *F) const =0
compute the magnetic function
virtual tString toString() const override
turn the class into a string
Definition: SM_LandauLifschitzFunction.h:428
void copy(const SM_LandauLifschitzFunction &LL)
copy the LL function
Definition: SM_LandauLifschitzFunction.h:124
tBoolean isSNormalized() const
return true if M is supposed to be normalized
Definition: SM_LandauLifschitzFunction.h:208
void setAlphaFunction(const LambdaF &L)
set the alpha function
Definition: SM_LandauLifschitzFunction.h:147
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_LandauLifschitzFunction.h:113
void computeFunction(const tIndex &nParticles, const SM_RealField &S, const SM_RealField &B, SM_RealField &F) const
computes the magnetic function
Definition: SM_LandauLifschitzFunction.h:226
void computeSliceNLLFunction(tIndex start, tIndex end, const tIndex &nSParticles, const tReal *S, const tIndex &nBParticles, const tReal *B, tReal *F) const
compute the normalized magnetic function for particle indices in [start,end[
Definition: SM_LandauLifschitzFunction.h:366
void setLambda(const tReal &v)
set the lambda parameter
Definition: SM_LandauLifschitzFunction.h:160
void computeFunction(const tIndex &nSParticles, const tReal *S, const tIndex &nBParticles, const tReal *B, tReal *F) const
compute the magnetic function
Definition: SM_LandauLifschitzFunction.h:246
SM_LandauLifschitzFunction(void)
create
Definition: SM_LandauLifschitzFunction.h:64
void setGamma(const tReal &gamma)
set the alpha parameter
Definition: SM_LandauLifschitzFunction.h:153
const tReal & getLambda() const
get the lambda parameter
Definition: SM_LandauLifschitzFunction.h:201
const tReal & getGamma() const
get the gamma parameter
Definition: SM_LandauLifschitzFunction.h:187
const tReal & getAlpha() const
get the alpha parameter
Definition: SM_LandauLifschitzFunction.h:194
void setIsSNormalized(const tBoolean &v)
set true if M is supposed to be normalized
Definition: SM_LandauLifschitzFunction.h:177
virtual void computeNLLFunction(const tIndex &nSParticles, const tReal *S, const tIndex &nBParticles, const tReal *B, tReal *F) const =0
compute the normalized magnetic function
This class is a base class for Stoch Microm package.
Definition: SM_Object.h:36