19#include <boost/algorithm/string/predicate.hpp>
32 int nlevels = ham.len1();
33 for (
size_t iH = 0; iH < nData; iH++) {
47 for (
auto iE = 1; iE <= nlevels; iE++) {
48 double expfact = exp(-beta * en(iE));
50 M += moment(iE) * expfact;
52 out[iH] = convfact * M /
Z;
57void calculate_powder(
double *out,
const double *xValues,
const size_t nData,
const ComplexFortranMatrix &ham,
58 const int nre,
const double T,
const double convfact,
const bool cgs) {
59 for (
size_t j = 0; j < nData; j++) {
64 std::vector<double>
tmp(nData, 0.);
65 for (
int i = 1; i <= 3; i++) {
68 calculate(&
tmp[0], xValues, nData, ham, nre, Hmag, T, convfact, cgs);
69 for (
size_t j = 0; j < nData; j++) {
73 for (
size_t j = 0; j < nData; j++) {
90 if (Hdir.size() != 3) {
91 throw std::invalid_argument(
"Hdir must be a three-element vector.");
95 double Hnorm = sqrt(Hdir[0] * Hdir[0] + Hdir[1] * Hdir[1] + Hdir[2] * Hdir[2]);
97 if (
fabs(Hnorm) > 1.e-6) {
98 for (
auto i = 0; i < 3; i++) {
99 H(i + 1) = Hdir[i] / Hnorm;
103 const double NAMUB = 5.5849397;
108 double convfact = boost::iequals(unit,
"SI") ? NAMUB : (boost::iequals(unit,
"cgs") ? NAMUB * 1000. : 1.);
109 const bool iscgs = boost::iequals(unit,
"cgs");
112 calculate_powder(out, xValues, nData,
m_ham,
m_nre, T, convfact, iscgs);
114 calculate(out, xValues, nData,
m_ham,
m_nre, H, T, convfact, iscgs);
118 for (
size_t i = 0; i < nData; i++) {
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
This is a specialization of IFunction for functions of one real argument.
Attribute is a non-fitting parameter.
std::vector< double > asVector() const
Returns vector<double> if attribute is vector<double>, throws exception otherwise.
std::string asString() const
Returns string value if attribute is a string, throws exception otherwise.
double asDouble() const
Returns double value if attribute is a double, throws exception otherwise.
bool asBool() const
Returns bool value if attribute is a bool, throws exception otherwise.
virtual Attribute getAttribute(const std::string &name) const
Return a value of attribute attName.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
Implements the part of IFunction interface dealing with parameters.
CrystalFieldMagnetisation is a function that calculates the induced magnetic moment (in bohr magneton...
ComplexFortranMatrix m_ham
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
CrystalFieldMagnetisationBase()
void setHamiltonian(const ComplexFortranMatrix &ham, const int nre)
CrystalFieldMagnetisationCalculation()
void setHamiltonian(const ComplexFortranMatrix &ham, const int nre)
void function1D(double *out, const double *xValues, const size_t nData) const override
Function you want to fit to.
CrystalFieldPeaks is a function that calculates crystal field peak positions and intensities.
void calculateEigenSystem(DoubleFortranVector &en, ComplexFortranMatrix &wf, ComplexFortranMatrix &ham, ComplexFortranMatrix &hz, int &nre) const
Calculate the crystal field eigensystem.
void MANTID_CURVEFITTING_DLL calculateMagneticMoment(const ComplexFortranMatrix &ev, const DoubleFortranVector &Hmag, const int nre, DoubleFortranVector &moment)
Calculate the diagonal matrix elements of the magnetic moment operator in a particular eigenvector ba...
void MANTID_CURVEFITTING_DLL calculateZeemanEigensystem(DoubleFortranVector &eigenvalues, ComplexFortranMatrix &eigenvectors, const ComplexFortranMatrix &hamiltonian, int nre, const DoubleFortranVector &bext)
Calculates the eigenvalues/vectors of a crystal field Hamiltonian in a specified external magnetic fi...
FortranMatrix< ComplexMatrix > ComplexFortranMatrix
FortranVector< EigenVector > DoubleFortranVector
MANTID_GEOMETRY_DLL Raster calculate(const Kernel::V3D &beamDirection, const IObject &shape, const double cubeSizeInMetre)
static constexpr double BoltzmannConstant
Boltzmann Constant in meV/K Taken from http://physics.nist.gov/cuu/Constants on 10/07/2012.