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 +
8//#include "MantidKernel/ArrayLengthValidator.h"
11
13
14#include <sstream>
15
16namespace Mantid::CurveFitting {
17
23
24// Register the algorithm into the AlgorithmFactory
25DECLARE_ALGORITHM(CrystalFieldEnergies)
26
27//----------------------------------------------------------------------------------------------
28
29
30const std::string CrystalFieldEnergies::name() const { return "CrystalFieldEnergies"; }
31
33int CrystalFieldEnergies::version() const { return 1; }
34
36const std::string CrystalFieldEnergies::category() const { return "Inelastic"; }
37
39const std::string CrystalFieldEnergies::summary() const {
40 return "Calculates crystal field energies and wave functions for rare earth "
41 "ions given the field parameters.";
42}
43
44//----------------------------------------------------------------------------------------------
48
49 // Input
50 auto bounds = std::make_shared<Kernel::BoundedValidator<int>>(-99, 13);
51 declareProperty("Nre", 1, bounds,
52 "A rare earth ion. Possible values are: "
53 "1=Ce 2=Pr 3=Nd 4=Pm 5=Sm 6=Eu 7=Gd 8=Tb "
54 "9=Dy 10=Ho 11=Er 12=Tm 13=Yb, or "
55 "negative values for arbitrary J with "
56 "J=-nre/2 up to nre=-99 (J=99/2)");
57
58 declareProperty("BmolX", 0.0, "The x-component of the molecular field.");
59 declareProperty("BmolY", 0.0, "The y-component of the molecular field.");
60 declareProperty("BmolZ", 0.0, "The z-component of the molecular field.");
61
62 declareProperty("BextX", 0.0, "The x-component of the external field.");
63 declareProperty("BextY", 0.0, "The y-component of the external field.");
64 declareProperty("BextZ", 0.0, "The z-component of the external field.");
65
66 declareProperty("B20", 0.0, "Real part of the B20 field parameter.");
67 declareProperty("B21", 0.0, "Real part of the B21 field parameter.");
68 declareProperty("B22", 0.0, "Real part of the B22 field parameter.");
69 declareProperty("B40", 0.0, "Real part of the B40 field parameter.");
70 declareProperty("B41", 0.0, "Real part of the B41 field parameter.");
71 declareProperty("B42", 0.0, "Real part of the B42 field parameter.");
72 declareProperty("B43", 0.0, "Real part of the B43 field parameter.");
73 declareProperty("B44", 0.0, "Real part of the B44 field parameter.");
74 declareProperty("B60", 0.0, "Real part of the B60 field parameter.");
75 declareProperty("B61", 0.0, "Real part of the B61 field parameter.");
76 declareProperty("B62", 0.0, "Real part of the B62 field parameter.");
77 declareProperty("B63", 0.0, "Real part of the B63 field parameter.");
78 declareProperty("B64", 0.0, "Real part of the B64 field parameter.");
79 declareProperty("B65", 0.0, "Real part of the B65 field parameter.");
80 declareProperty("B66", 0.0, "Real part of the B66 field parameter.");
81
82 declareProperty("IB20", 0.0, "Imaginary part of the B20 field parameter.");
83 declareProperty("IB21", 0.0, "Imaginary part of the B21 field parameter.");
84 declareProperty("IB22", 0.0, "Imaginary part of the B22 field parameter.");
85 declareProperty("IB40", 0.0, "Imaginary part of the B40 field parameter.");
86 declareProperty("IB41", 0.0, "Imaginary part of the B41 field parameter.");
87 declareProperty("IB42", 0.0, "Imaginary part of the B42 field parameter.");
88 declareProperty("IB43", 0.0, "Imaginary part of the B43 field parameter.");
89 declareProperty("IB44", 0.0, "Imaginary part of the B44 field parameter.");
90 declareProperty("IB60", 0.0, "Imaginary part of the B60 field parameter.");
91 declareProperty("IB61", 0.0, "Imaginary part of the B61 field parameter.");
92 declareProperty("IB62", 0.0, "Imaginary part of the B62 field parameter.");
93 declareProperty("IB63", 0.0, "Imaginary part of the B63 field parameter.");
94 declareProperty("IB64", 0.0, "Imaginary part of the B64 field parameter.");
95 declareProperty("IB65", 0.0, "Imaginary part of the B65 field parameter.");
96 declareProperty("IB66", 0.0, "Imaginary part of the B66 field parameter.");
97
98 // Output
100 "The energies starting at 0 in ascending order.");
102 "The eigenvectors.");
104 "The Hamiltonian.");
105}
106
107//----------------------------------------------------------------------------------------------
111 int nre = getProperty("Nre");
112
113 double BmolX = getProperty("BmolX");
114 double BmolY = getProperty("BmolY");
115 double BmolZ = getProperty("BmolZ");
116 DoubleFortranVector bmol(1, 3);
117 bmol(1) = BmolX;
118 bmol(2) = BmolY;
119 bmol(3) = BmolZ;
120
121 double BextX = getProperty("BextX");
122 double BextY = getProperty("BextY");
123 double BextZ = getProperty("BextZ");
124 DoubleFortranVector bext(1, 3);
125 bext(1) = BextX;
126 bext(2) = BextY;
127 bext(3) = BextZ;
128
129 double B20 = getProperty("B20");
130 double B21 = getProperty("B21");
131 double B22 = getProperty("B22");
132 double B40 = getProperty("B40");
133 double B41 = getProperty("B41");
134 double B42 = getProperty("B42");
135 double B43 = getProperty("B43");
136 double B44 = getProperty("B44");
137 double B60 = getProperty("B60");
138 double B61 = getProperty("B61");
139 double B62 = getProperty("B62");
140 double B63 = getProperty("B63");
141 double B64 = getProperty("B64");
142 double B65 = getProperty("B65");
143 double B66 = getProperty("B66");
144
145 double IB20 = getProperty("IB20");
146 double IB21 = getProperty("IB21");
147 double IB22 = getProperty("IB22");
148 double IB40 = getProperty("IB40");
149 double IB41 = getProperty("IB41");
150 double IB42 = getProperty("IB42");
151 double IB43 = getProperty("IB43");
152 double IB44 = getProperty("IB44");
153 double IB60 = getProperty("IB60");
154 double IB61 = getProperty("IB61");
155 double IB62 = getProperty("IB62");
156 double IB63 = getProperty("IB63");
157 double IB64 = getProperty("IB64");
158 double IB65 = getProperty("IB65");
159 double IB66 = getProperty("IB66");
160
161 ComplexFortranMatrix bkq(0, 6, 0, 6);
162 bkq(2, 0) = ComplexType(B20, IB20);
163 bkq(2, 1) = ComplexType(B21, IB21);
164 bkq(2, 2) = ComplexType(B22, IB22);
165 bkq(4, 0) = ComplexType(B40, IB40);
166 bkq(4, 1) = ComplexType(B41, IB41);
167 bkq(4, 2) = ComplexType(B42, IB42);
168 bkq(4, 3) = ComplexType(B43, IB43);
169 bkq(4, 4) = ComplexType(B44, IB44);
170 bkq(6, 0) = ComplexType(B60, IB60);
171 bkq(6, 1) = ComplexType(B61, IB61);
172 bkq(6, 2) = ComplexType(B62, IB62);
173 bkq(6, 3) = ComplexType(B63, IB63);
174 bkq(6, 4) = ComplexType(B64, IB64);
175 bkq(6, 5) = ComplexType(B65, IB65);
176 bkq(6, 6) = ComplexType(B66, IB66);
177
181 calculateEigensystem(en, wf, ham, nre, bmol, bext, bkq);
182
183 setProperty("Energies", en.toStdVector());
184 setProperty("Eigenvectors", wf.packToStdVector());
185 setProperty("Hamiltonian", ham.packToStdVector());
186}
187
188} // namespace Mantid::CurveFitting
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
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.
std::vector< double > toStdVector() const
Copy the values to an std vector of doubles.
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
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