ARTS 2.5.11 (git: 6827797f)
zeemandata.h
Go to the documentation of this file.
1
12#ifndef zeemandata_h
13#define zeemandata_h
14
15#include "arts_conversions.h"
16#include "file.h"
17#include "mystring.h"
18#include "propagationmatrix.h"
19#include "quantum_numbers.h"
20
21#include <limits>
22
24namespace Zeeman {
25
27enum class Polarization : char { SigmaMinus, Pi, SigmaPlus, None };
28
35constexpr Index dM(Polarization type) noexcept {
36 switch (type) {
38 return -1;
40 return 0;
42 return 1;
44 return 0;
45 }
46 return std::numeric_limits<Index>::max();
47}
48
63constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept {
64 switch (type) {
66 if (Ju < Jl)
67 return -Ju;
68 else if (Ju == Jl)
69 return -Ju + 1;
70 else
71 return -Ju + 2;
73 return -min(Ju, Jl);
75 return -Ju;
77 return 0;
78 }
79 return std::numeric_limits<Index>::max();
80}
81
96constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept {
97 switch (type) {
99 return Ju + 1;
100 case Polarization::Pi:
101 return min(Ju, Jl);
103 if (Ju < Jl)
104 return Ju + 1;
105 else if (Ju == Jl)
106 return Ju;
107 else
108 return Jl;
110 return 0;
111 }
112 return std::numeric_limits<Index>::max();
113}
114
125constexpr Index nelem(Rational Ju, Rational Jl, Polarization type) noexcept {
126 return (end(Ju, Jl, type) - start(Ju, Jl, type)).toIndex() + 1;
127}
128
142constexpr Rational Mu(Rational Ju,
143 Rational Jl,
144 Polarization type,
145 Index n) noexcept {
146 return start(Ju, Jl, type) + n;
147}
148
149
163constexpr Rational Ml(Rational Ju,
164 Rational Jl,
165 Polarization type,
166 Index n) noexcept {
167 return Mu(Ju, Jl, type, n) + dM(type);
168}
169
181constexpr Numeric PolarizationFactor(Polarization type) noexcept {
182 switch (type) {
184 return .75;
185 case Polarization::Pi:
186 return 1.5;
188 return .75;
190 return 1.0;
191 }
192 return std::numeric_limits<Numeric>::max();
193}
194
209constexpr Numeric SimpleGCaseB(Rational N,
210 Rational J,
211 Rational Lambda,
212 Rational S,
213 Numeric GS,
214 Numeric GL) noexcept {
215 auto JJ = J * (J + 1);
216 auto NN = N * (N + 1);
217 auto SS = S * (S + 1);
218 auto LL = Lambda * Lambda;
219
220 if (JJ == 0)
221 return 0.0;
222 if (NN not_eq 0) {
223 auto T1 = ((JJ + SS - NN) / JJ / 2).toNumeric();
224 auto T2 = ((JJ - SS + NN) * LL / NN / JJ / 2).toNumeric();
225 return GS * T1 + GL * T2;
226 }
227 auto T1 = ((JJ + SS - NN) / JJ / 2).toNumeric();
228 return GS * T1;
229}
230
245constexpr Numeric SimpleGCaseA(Rational Omega,
246 Rational J,
247 Rational Lambda,
248 Rational Sigma,
249 Numeric GS,
250 Numeric GL) noexcept {
251 auto JJ = J * (J + 1);
252
253 if (JJ == Rational(0))
254 return 0.0;
255 auto DIV = Omega / JJ;
256 auto T1 = (Sigma * DIV).toNumeric();
257 auto T2 = (Lambda * DIV).toNumeric();
258 return GS * T1 + GL * T2;
259
260}
261
269 Numeric gu, gl;
270};
271
279class Model {
280 private:
282
283 public:
285 constexpr Model(SplittingData gs = {NAN, NAN}) noexcept : mdata(gs) {}
286
288 constexpr Model(Numeric gu, Numeric gl) noexcept : Model(SplittingData{gu, gl}) {}
289
300 explicit Model(const QuantumIdentifier& qid) noexcept;
301
303 [[nodiscard]] /* constexpr */ bool empty() const noexcept {
304 return std::isnan(mdata.gu) and std::isnan(mdata.gl);
305 }
306
308 constexpr Numeric& gu() noexcept { return mdata.gu; }
309
311 constexpr Numeric& gl() noexcept { return mdata.gl; }
312
314 constexpr void gu(Numeric x) noexcept { mdata.gu = x; }
315
317 constexpr void gl(Numeric x) noexcept { mdata.gl = x; }
318
320 [[nodiscard]] constexpr Numeric gu() const noexcept { return mdata.gu; }
321
323 [[nodiscard]] constexpr Numeric gl() const noexcept { return mdata.gl; }
324
338 [[nodiscard]] Numeric Strength(Rational Ju, Rational Jl, Polarization type, Index n) const ARTS_NOEXCEPT;
339
353 [[nodiscard]] constexpr Numeric Splitting(Rational Ju, Rational Jl, Polarization type, Index n) const
354 noexcept {
356 using Constant::h;
357 constexpr Numeric C = bohr_magneton / h;
358
359 return C * (Ml(Ju, Jl, type, n) * gl() - Mu(Ju, Jl, type, n) * gu());
360 }
361
363 friend std::ostream& operator<<(std::ostream& os, const Model& m);
364
366 friend std::istream& operator>>(std::istream& is, Model& m);
367
369 friend std::ostream& operator<<(bofstream& bof, const Model& m);
370
372 friend std::istream& operator>>(bifstream& bif, Model& m);
373}; // Model;
374
385
398
406 std::array<Numeric, 4> att{0, 0, 0, 0}; // attenuation vector
407 std::array<Numeric, 3> dis{0, 0, 0}; // dispersion vector
408
411 Numeric b = 0,
412 Numeric c = 0,
413 Numeric d = 0,
414 Numeric u = 0,
415 Numeric v = 0,
416 Numeric w = 0) noexcept
417 : att({a, b, c, d}), dis({u, v, w}) {};
418};
419
427};
428
437 Numeric eta) noexcept;
438
447 Numeric theta, const Numeric eta) noexcept;
448
457 Numeric eta) noexcept;
458
465 const AllPolarizationVectors& data, Polarization type) noexcept;
466
473void sum(PropagationMatrix& pm, const ComplexVectorView& abs, const PolarizationVector& polvec, const bool do_phase=true) ARTS_NOEXCEPT;
474
487void dsum(PropagationMatrix& dpm,
488 const ComplexVectorView& abs,
489 const ComplexVectorView& dabs,
490 const PolarizationVector& polvec,
491 const PolarizationVector& dpolvec_dtheta,
492 const PolarizationVector& dpolvec_deta,
493 const Numeric dH,
494 const Numeric dtheta,
495 const Numeric deta, const bool do_phase=true) ARTS_NOEXCEPT;
496
505struct Derived {
506 Numeric H, theta, eta, dH_du, dH_dv, dH_dw, dtheta_du, dtheta_dv, dtheta_dw,
507 deta_du, deta_dv, deta_dw;
508};
509
541Derived FromGrids(Numeric u, Numeric v, Numeric w, Numeric z, Numeric a) noexcept;
542
551constexpr Derived FromPreDerived(Numeric H,
552 Numeric theta,
553 Numeric eta) noexcept {
554 return {H, theta, eta, 0, 0, 0, 0, 0, 0, 0, 0, 0};
555}
556}; // namespace Zeeman
557
558// Typedef to make it easier to use
560
561#endif /* zeemandata_h */
base min(const Array< base > &x)
Min function.
Definition: array.h:144
Common ARTS conversions.
Main Zeeman Model.
Definition: zeemandata.h:279
constexpr Numeric & gl() noexcept
Returns the lower state g.
Definition: zeemandata.h:311
SplittingData mdata
Definition: zeemandata.h:281
constexpr Model(Numeric gu, Numeric gl) noexcept
Default copy/init of Model from its only private variable.
Definition: zeemandata.h:288
constexpr Numeric & gu() noexcept
Returns the upper state g.
Definition: zeemandata.h:308
Numeric Strength(Rational Ju, Rational Jl, Polarization type, Index n) const ARTS_NOEXCEPT
Gives the strength of one subline of a given polarization.
Definition: zeemandata.cc:318
friend std::istream & operator>>(std::istream &is, Model &m)
Input operator for Zeeman::Model.
Definition: zeemandata.cc:337
friend std::ostream & operator<<(std::ostream &os, const Model &m)
Output operator for Zeeman::Model.
Definition: zeemandata.cc:332
constexpr Numeric Splitting(Rational Ju, Rational Jl, Polarization type, Index n) const noexcept
Gives the splitting of one subline of a given polarization.
Definition: zeemandata.h:353
constexpr Numeric gl() const noexcept
Returns the lower state g.
Definition: zeemandata.h:323
bool empty() const noexcept
Returns true if the Model represents no Zeeman effect.
Definition: zeemandata.h:303
constexpr void gl(Numeric x) noexcept
Sets the lower state g.
Definition: zeemandata.h:317
constexpr Model(SplittingData gs={NAN, NAN}) noexcept
Default copy/init of Model from its only private variable.
Definition: zeemandata.h:285
constexpr void gu(Numeric x) noexcept
Sets the upper state g.
Definition: zeemandata.h:314
constexpr Numeric gu() const noexcept
Returns the upper state g.
Definition: zeemandata.h:320
Binary output file stream class.
Definition: bifstream.h:26
Binary output file stream class.
Definition: bofstream.h:25
#define ARTS_NOEXCEPT
Definition: debug.h:81
This file contains basic functions to handle ASCII files.
This file contains the definition of String, the ARTS string class.
constexpr Numeric bohr_magneton
Bohr magneton [J/T].
constexpr Numeric h
Planck constant convenience name [J s].
Implements Zeeman modeling.
Definition: zeemandata.cc:317
constexpr Index dM(Polarization type) noexcept
Gives the change of M given a polarization type.
Definition: zeemandata.h:35
constexpr Numeric SimpleGCaseB(Rational N, Rational J, Rational Lambda, Rational S, Numeric GS, Numeric GL) noexcept
Computes the Zeeman splitting coefficient.
Definition: zeemandata.h:209
const PolarizationVector & SelectPolarization(const AllPolarizationVectors &data, Polarization type) noexcept
Selects the polarization vector depending on polarization type.
Definition: zeemandata.cc:402
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:63
constexpr Index nelem(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the number of elements of the polarization type of this transition.
Definition: zeemandata.h:125
constexpr Derived FromPreDerived(Numeric H, Numeric theta, Numeric eta) noexcept
Sets Derived from predefined Derived parameters.
Definition: zeemandata.h:551
constexpr Numeric SimpleGCaseA(Rational Omega, Rational J, Rational Lambda, Rational Sigma, Numeric GS, Numeric GL) noexcept
Computes the Zeeman splitting coefficient.
Definition: zeemandata.h:245
constexpr Numeric PolarizationFactor(Polarization type) noexcept
The renormalization factor of a polarization type.
Definition: zeemandata.h:181
Derived FromGrids(Numeric u, Numeric v, Numeric w, Numeric z, Numeric a) noexcept
Computes the derived plane from ARTS grids.
Definition: zeemandata.cc:261
AllPolarizationVectors AllPolarization_deta(Numeric theta, Numeric eta) noexcept
The derivative of AllPolarization wrt eta.
Definition: zeemandata.cc:384
AllPolarizationVectors AllPolarization_dtheta(Numeric theta, const Numeric eta) noexcept
The derivative of AllPolarization wrt theta.
Definition: zeemandata.cc:367
Polarization
Zeeman polarization selection.
Definition: zeemandata.h:27
Model GetAdvancedModel(const QuantumIdentifier &qid) ARTS_NOEXCEPT
Returns an advanced Zeeman model.
Definition: zeemandata.cc:115
void dsum(PropagationMatrix &pm, const ComplexVectorView &abs, const ComplexVectorView &dabs, const PolarizationVector &polvec, const PolarizationVector &dpolvec_dtheta, const PolarizationVector &dpolvec_deta, const Numeric dH, const Numeric dt, const Numeric de, const bool do_phase) ARTS_NOEXCEPT
Sums the Zeeman components derivatives into a propagation matrix.
Definition: zeemandata.cc:437
void sum(PropagationMatrix &pm, const ComplexVectorView &abs, const PolarizationVector &polvec, const bool do_phase) ARTS_NOEXCEPT
Sums the Zeeman components into a propagation matrix.
Definition: zeemandata.cc:417
Model GetSimpleModel(const QuantumIdentifier &qid) ARTS_NOEXCEPT
Returns a simple Zeeman model.
Definition: zeemandata.cc:55
constexpr Rational Ml(Rational Ju, Rational Jl, Polarization type, Index n) noexcept
Gives the lower state M value at an index.
Definition: zeemandata.h:163
AllPolarizationVectors AllPolarization(Numeric theta, Numeric eta) noexcept
Computes the polarization of each polarization type.
Definition: zeemandata.cc:352
constexpr Rational Mu(Rational Ju, Rational Jl, Polarization type, Index n) noexcept
Gives the upper state M value at an index.
Definition: zeemandata.h:142
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:96
A logical struct for global quantum numbers with species identifiers.
PolarizationVector for each Polarization.
Definition: zeemandata.h:425
Contains derived values useful for Zeeman calculations.
Definition: zeemandata.h:505
Numeric deta_du
Definition: zeemandata.h:507
Polarization vector for Zeeman Propagation Matrix.
Definition: zeemandata.h:405
std::array< Numeric, 4 > att
Definition: zeemandata.h:406
std::array< Numeric, 3 > dis
Definition: zeemandata.h:407
PolarizationVector(Numeric a=1, Numeric b=0, Numeric c=0, Numeric d=0, Numeric u=0, Numeric v=0, Numeric w=0) noexcept
Default init of class.
Definition: zeemandata.h:410
Main storage for Zeeman splitting coefficients.
Definition: zeemandata.h:268
#define u
#define d
#define v
#define w
#define a
#define c
#define b