Mantid
Loading...
Searching...
No Matches
CrystalFieldEnergies.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
11
12#include <sstream>
13
14namespace Mantid::CurveFitting {
15
21
22// Register the algorithm into the AlgorithmFactory
23DECLARE_ALGORITHM(CrystalFieldEnergies)
24
25//----------------------------------------------------------------------------------------------
26
27
28const std::string CrystalFieldEnergies::name() const { return "CrystalFieldEnergies"; }
29
31int CrystalFieldEnergies::version() const { return 1; }
32
34const std::string CrystalFieldEnergies::category() const { return "Inelastic"; }
35
37const std::string CrystalFieldEnergies::summary() const {
38 return "Calculates crystal field energies and wave functions for rare earth "
39 "ions given the field parameters.";
40}
41
42//----------------------------------------------------------------------------------------------
46
47 // Input
48 auto bounds = std::make_shared<Kernel::BoundedValidator<int>>(-99, 13);
49 declareProperty("Nre", 1, bounds,
50 "A rare earth ion. Possible values are: "
51 "1=Ce 2=Pr 3=Nd 4=Pm 5=Sm 6=Eu 7=Gd 8=Tb "
52 "9=Dy 10=Ho 11=Er 12=Tm 13=Yb, or "
53 "negative values for arbitrary J with "
54 "J=-nre/2 up to nre=-99 (J=99/2)");
55
56 declareProperty("BmolX", 0.0, "The x-component of the molecular field.");
57 declareProperty("BmolY", 0.0, "The y-component of the molecular field.");
58 declareProperty("BmolZ", 0.0, "The z-component of the molecular field.");
59
60 declareProperty("BextX", 0.0, "The x-component of the external field.");
61 declareProperty("BextY", 0.0, "The y-component of the external field.");
62 declareProperty("BextZ", 0.0, "The z-component of the external field.");
63
64 declareProperty("B20", 0.0, "Real part of the B20 field parameter.");
65 declareProperty("B21", 0.0, "Real part of the B21 field parameter.");
66 declareProperty("B22", 0.0, "Real part of the B22 field parameter.");
67 declareProperty("B40", 0.0, "Real part of the B40 field parameter.");
68 declareProperty("B41", 0.0, "Real part of the B41 field parameter.");
69 declareProperty("B42", 0.0, "Real part of the B42 field parameter.");
70 declareProperty("B43", 0.0, "Real part of the B43 field parameter.");
71 declareProperty("B44", 0.0, "Real part of the B44 field parameter.");
72 declareProperty("B60", 0.0, "Real part of the B60 field parameter.");
73 declareProperty("B61", 0.0, "Real part of the B61 field parameter.");
74 declareProperty("B62", 0.0, "Real part of the B62 field parameter.");
75 declareProperty("B63", 0.0, "Real part of the B63 field parameter.");
76 declareProperty("B64", 0.0, "Real part of the B64 field parameter.");
77 declareProperty("B65", 0.0, "Real part of the B65 field parameter.");
78 declareProperty("B66", 0.0, "Real part of the B66 field parameter.");
79
80 declareProperty("IB20", 0.0, "Imaginary part of the B20 field parameter.");
81 declareProperty("IB21", 0.0, "Imaginary part of the B21 field parameter.");
82 declareProperty("IB22", 0.0, "Imaginary part of the B22 field parameter.");
83 declareProperty("IB40", 0.0, "Imaginary part of the B40 field parameter.");
84 declareProperty("IB41", 0.0, "Imaginary part of the B41 field parameter.");
85 declareProperty("IB42", 0.0, "Imaginary part of the B42 field parameter.");
86 declareProperty("IB43", 0.0, "Imaginary part of the B43 field parameter.");
87 declareProperty("IB44", 0.0, "Imaginary part of the B44 field parameter.");
88 declareProperty("IB60", 0.0, "Imaginary part of the B60 field parameter.");
89 declareProperty("IB61", 0.0, "Imaginary part of the B61 field parameter.");
90 declareProperty("IB62", 0.0, "Imaginary part of the B62 field parameter.");
91 declareProperty("IB63", 0.0, "Imaginary part of the B63 field parameter.");
92 declareProperty("IB64", 0.0, "Imaginary part of the B64 field parameter.");
93 declareProperty("IB65", 0.0, "Imaginary part of the B65 field parameter.");
94 declareProperty("IB66", 0.0, "Imaginary part of the B66 field parameter.");
95
96 // Output
98 "The energies starting at 0 in ascending order.");
100 "The eigenvectors.");
102 "The Hamiltonian.");
103}
104
105//----------------------------------------------------------------------------------------------
109 int nre = getProperty("Nre");
110
111 double BmolX = getProperty("BmolX");
112 double BmolY = getProperty("BmolY");
113 double BmolZ = getProperty("BmolZ");
114 DoubleFortranVector bmol(1, 3);
115 bmol(1) = BmolX;
116 bmol(2) = BmolY;
117 bmol(3) = BmolZ;
118
119 double BextX = getProperty("BextX");
120 double BextY = getProperty("BextY");
121 double BextZ = getProperty("BextZ");
122 DoubleFortranVector bext(1, 3);
123 bext(1) = BextX;
124 bext(2) = BextY;
125 bext(3) = BextZ;
126
127 double B20 = getProperty("B20");
128 double B21 = getProperty("B21");
129 double B22 = getProperty("B22");
130 double B40 = getProperty("B40");
131 double B41 = getProperty("B41");
132 double B42 = getProperty("B42");
133 double B43 = getProperty("B43");
134 double B44 = getProperty("B44");
135 double B60 = getProperty("B60");
136 double B61 = getProperty("B61");
137 double B62 = getProperty("B62");
138 double B63 = getProperty("B63");
139 double B64 = getProperty("B64");
140 double B65 = getProperty("B65");
141 double B66 = getProperty("B66");
142
143 double IB20 = getProperty("IB20");
144 double IB21 = getProperty("IB21");
145 double IB22 = getProperty("IB22");
146 double IB40 = getProperty("IB40");
147 double IB41 = getProperty("IB41");
148 double IB42 = getProperty("IB42");
149 double IB43 = getProperty("IB43");
150 double IB44 = getProperty("IB44");
151 double IB60 = getProperty("IB60");
152 double IB61 = getProperty("IB61");
153 double IB62 = getProperty("IB62");
154 double IB63 = getProperty("IB63");
155 double IB64 = getProperty("IB64");
156 double IB65 = getProperty("IB65");
157 double IB66 = getProperty("IB66");
158
159 ComplexFortranMatrix bkq(0, 6, 0, 6);
160 bkq(2, 0) = ComplexType(B20, IB20);
161 bkq(2, 1) = ComplexType(B21, IB21);
162 bkq(2, 2) = ComplexType(B22, IB22);
163 bkq(4, 0) = ComplexType(B40, IB40);
164 bkq(4, 1) = ComplexType(B41, IB41);
165 bkq(4, 2) = ComplexType(B42, IB42);
166 bkq(4, 3) = ComplexType(B43, IB43);
167 bkq(4, 4) = ComplexType(B44, IB44);
168 bkq(6, 0) = ComplexType(B60, IB60);
169 bkq(6, 1) = ComplexType(B61, IB61);
170 bkq(6, 2) = ComplexType(B62, IB62);
171 bkq(6, 3) = ComplexType(B63, IB63);
172 bkq(6, 4) = ComplexType(B64, IB64);
173 bkq(6, 5) = ComplexType(B65, IB65);
174 bkq(6, 6) = ComplexType(B66, IB66);
175
179 calculateEigensystem(en, wf, ham, nre, bmol, bext, bkq);
180
181 setProperty("Energies", en.toStdVector());
182 setProperty("Eigenvectors", wf.packToStdVector());
183 setProperty("Hamiltonian", ham.packToStdVector());
184}
185
186} // namespace Mantid::CurveFitting
std::string name
Definition Run.cpp:60
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
std::vector< double > packToStdVector() const
Pack the matrix into a single std vector of doubles (for passing in and out of algorithms)
CrystalFieldEnergies : Calculates crystal field energies and wave functions for rare earth ions given...
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
const std::string category() const override
Algorithm's category for identification.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
const std::vector< double > & toStdVector() const
Copy the values to an std vector of doubles.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void MANTID_CURVEFITTING_DLL calculateEigensystem(DoubleFortranVector &eigenvalues, ComplexFortranMatrix &eigenvectors, ComplexFortranMatrix &hamiltonian, ComplexFortranMatrix &hzeeman, int nre, const DoubleFortranVector &bmol, const DoubleFortranVector &bext, const ComplexFortranMatrix &bkq, double alpha_euler=0.0, double beta_euler=0.0, double gamma_euler=0.0)
Calculate eigenvalues and eigenvectors of the crystal field hamiltonian.
std::complex< double > ComplexType
STL namespace.
Describes the direction (within an algorithm) of a Property.
Definition Property.h:50
@ Output
An output workspace.
Definition Property.h:54