ARTS 2.5.4 (git: 31ce4f0e)
zeemandata.h
Go to the documentation of this file.
1/* Copyright (C) 2018 Richard Larsson
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
29#ifndef zeemandata_h
30#define zeemandata_h
31
32#include "arts_conversions.h"
33#include "file.h"
34#include "mystring.h"
35#include "propagationmatrix.h"
36#include "quantum_numbers.h"
37
38#include <limits>
39
41namespace Zeeman {
42
44enum class Polarization : char { SigmaMinus, Pi, SigmaPlus, None };
45
52constexpr Index dM(Polarization type) noexcept {
53 switch (type) {
55 return -1;
57 return 0;
59 return 1;
61 return 0;
62 }
64}
65
80constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept {
81 switch (type) {
83 if (Ju < Jl)
84 return -Ju;
85 else if (Ju == Jl)
86 return -Ju + 1;
87 else
88 return -Ju + 2;
90 return -min(Ju, Jl);
92 return -Ju;
94 return 0;
95 }
97}
98
113constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept {
114 switch (type) {
116 return Ju + 1;
117 case Polarization::Pi:
118 return min(Ju, Jl);
120 if (Ju < Jl)
121 return Ju + 1;
122 else if (Ju == Jl)
123 return Ju;
124 else
125 return Jl;
127 return 0;
128 }
130}
131
142constexpr Index nelem(Rational Ju, Rational Jl, Polarization type) noexcept {
143 return (end(Ju, Jl, type) - start(Ju, Jl, type)).toIndex() + 1;
144}
145
159constexpr Rational Mu(Rational Ju,
160 Rational Jl,
161 Polarization type,
162 Index n) noexcept {
163 return start(Ju, Jl, type) + n;
164}
165
166
180constexpr Rational Ml(Rational Ju,
181 Rational Jl,
182 Polarization type,
183 Index n) noexcept {
184 return Mu(Ju, Jl, type, n) + dM(type);
185}
186
198constexpr Numeric PolarizationFactor(Polarization type) noexcept {
199 switch (type) {
201 return .75;
202 case Polarization::Pi:
203 return 1.5;
205 return .75;
207 return 1.0;
208 }
210}
211
227 Rational J,
228 Rational Lambda,
229 Rational S,
230 Numeric GS,
231 Numeric GL) noexcept {
232 auto JJ = J * (J + 1);
233 auto NN = N * (N + 1);
234 auto SS = S * (S + 1);
235 auto LL = Lambda * Lambda;
236
237 if (JJ == 0)
238 return 0.0;
239 if (NN not_eq 0) {
240 auto T1 = ((JJ + SS - NN) / JJ / 2).toNumeric();
241 auto T2 = ((JJ - SS + NN) * LL / NN / JJ / 2).toNumeric();
242 return GS * T1 + GL * T2;
243 }
244 auto T1 = ((JJ + SS - NN) / JJ / 2).toNumeric();
245 return GS * T1;
246}
247
263 Rational J,
264 Rational Lambda,
265 Rational Sigma,
266 Numeric GS,
267 Numeric GL) noexcept {
268 auto JJ = J * (J + 1);
269
270 if (JJ == Rational(0))
271 return 0.0;
272 auto DIV = Omega / JJ;
273 auto T1 = (Sigma * DIV).toNumeric();
274 auto T2 = (Lambda * DIV).toNumeric();
275 return GS * T1 + GL * T2;
276
277}
278
287};
288
296class Model {
297 private:
299
300 public:
302 constexpr Model(SplittingData gs = {NAN, NAN}) noexcept : mdata(gs) {}
303
305 constexpr Model(Numeric gu, Numeric gl) noexcept : Model(SplittingData{gu, gl}) {}
306
317 explicit Model(const QuantumIdentifier& qid) noexcept;
318
320 [[nodiscard]] /* constexpr */ bool empty() const noexcept {
321 return std::isnan(mdata.gu) and std::isnan(mdata.gl);
322 }
323
325 constexpr Numeric& gu() noexcept { return mdata.gu; }
326
328 constexpr Numeric& gl() noexcept { return mdata.gl; }
329
331 constexpr void gu(Numeric x) noexcept { mdata.gu = x; }
332
334 constexpr void gl(Numeric x) noexcept { mdata.gl = x; }
335
337 [[nodiscard]] constexpr Numeric gu() const noexcept { return mdata.gu; }
338
340 [[nodiscard]] constexpr Numeric gl() const noexcept { return mdata.gl; }
341
355 [[nodiscard]] Numeric Strength(Rational Ju, Rational Jl, Polarization type, Index n) const ARTS_NOEXCEPT;
356
370 [[nodiscard]] constexpr Numeric Splitting(Rational Ju, Rational Jl, Polarization type, Index n) const
371 noexcept {
373 using Constant::h;
374 constexpr Numeric C = bohr_magneton / h;
375
376 return C * (Ml(Ju, Jl, type, n) * gl() - Mu(Ju, Jl, type, n) * gu());
377 }
378
380 friend std::ostream& operator<<(std::ostream& os, const Model& m);
381
383 friend std::istream& operator>>(std::istream& is, Model& m);
384
386 friend std::ostream& operator<<(bofstream& bof, const Model& m);
387
389 friend std::istream& operator>>(bifstream& bif, Model& m);
390}; // Model;
391
402
415
423 std::array<Numeric, 4> att{0, 0, 0, 0}; // attenuation vector
424 std::array<Numeric, 3> dis{0, 0, 0}; // dispersion vector
425
428 Numeric b = 0,
429 Numeric c = 0,
430 Numeric d = 0,
431 Numeric u = 0,
432 Numeric v = 0,
433 Numeric w = 0) noexcept
434 : att({a, b, c, d}), dis({u, v, w}) {};
435};
436
444};
445
454 Numeric eta) noexcept;
455
464 Numeric theta, const Numeric eta) noexcept;
465
474 Numeric eta) noexcept;
475
482 const AllPolarizationVectors& data, Polarization type) noexcept;
483
490void sum(PropagationMatrix& pm, const ComplexVectorView& abs, const PolarizationVector& polvec, const bool do_phase=true) ARTS_NOEXCEPT;
491
504void dsum(PropagationMatrix& dpm,
505 const ComplexVectorView& abs,
506 const ComplexVectorView& dabs,
507 const PolarizationVector& polvec,
508 const PolarizationVector& dpolvec_dtheta,
509 const PolarizationVector& dpolvec_deta,
510 const Numeric dH,
511 const Numeric dtheta,
512 const Numeric deta, const bool do_phase=true) ARTS_NOEXCEPT;
513
522struct Derived {
523 Numeric H, theta, eta, dH_du, dH_dv, dH_dw, dtheta_du, dtheta_dv, dtheta_dw,
524 deta_du, deta_dv, deta_dw;
525};
526
559
569 Numeric theta,
570 Numeric eta) noexcept {
571 return {H, theta, eta, 0, 0, 0, 0, 0, 0, 0, 0, 0};
572}
573}; // namespace Zeeman
574
575// Typedef to make it easier to use
577
578#endif /* zeemandata_h */
Common ARTS conversions.
The ComplexVectorView class.
Main Zeeman Model.
Definition: zeemandata.h:296
constexpr Numeric & gl() noexcept
Returns the lower state g.
Definition: zeemandata.h:328
SplittingData mdata
Definition: zeemandata.h:298
constexpr Model(Numeric gu, Numeric gl) noexcept
Default copy/init of Model from its only private variable.
Definition: zeemandata.h:305
constexpr Numeric & gu() noexcept
Returns the upper state g.
Definition: zeemandata.h:325
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:334
friend std::istream & operator>>(std::istream &is, Model &m)
Input operator for Zeeman::Model.
Definition: zeemandata.cc:353
friend std::ostream & operator<<(std::ostream &os, const Model &m)
Output operator for Zeeman::Model.
Definition: zeemandata.cc:348
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:370
constexpr Numeric gl() const noexcept
Returns the lower state g.
Definition: zeemandata.h:340
bool empty() const noexcept
Returns true if the Model represents no Zeeman effect.
Definition: zeemandata.h:320
constexpr void gl(Numeric x) noexcept
Sets the lower state g.
Definition: zeemandata.h:334
constexpr Model(SplittingData gs={NAN, NAN}) noexcept
Default copy/init of Model from its only private variable.
Definition: zeemandata.h:302
constexpr void gu(Numeric x) noexcept
Sets the upper state g.
Definition: zeemandata.h:331
constexpr Numeric gu() const noexcept
Returns the upper state g.
Definition: zeemandata.h:337
Binary output file stream class.
Definition: bifstream.h:43
Binary output file stream class.
Definition: bofstream.h:42
#define ARTS_NOEXCEPT
Definition: debug.h:80
This file contains basic functions to handle ASCII files.
#define abs(x)
#define min(a, b)
#define dabs(x)
#define max(a, b)
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
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:333
constexpr Index dM(Polarization type) noexcept
Gives the change of M given a polarization type.
Definition: zeemandata.h:52
constexpr Numeric SimpleGCaseB(Rational N, Rational J, Rational Lambda, Rational S, Numeric GS, Numeric GL) noexcept
Computes the Zeeman splitting coefficient.
Definition: zeemandata.h:226
const PolarizationVector & SelectPolarization(const AllPolarizationVectors &data, Polarization type) noexcept
Selects the polarization vector depending on polarization type.
Definition: zeemandata.cc:418
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:80
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:142
constexpr Derived FromPreDerived(Numeric H, Numeric theta, Numeric eta) noexcept
Sets Derived from predefined Derived parameters.
Definition: zeemandata.h:568
constexpr Numeric SimpleGCaseA(Rational Omega, Rational J, Rational Lambda, Rational Sigma, Numeric GS, Numeric GL) noexcept
Computes the Zeeman splitting coefficient.
Definition: zeemandata.h:262
constexpr Numeric PolarizationFactor(Polarization type) noexcept
The renormalization factor of a polarization type.
Definition: zeemandata.h:198
Derived FromGrids(Numeric u, Numeric v, Numeric w, Numeric z, Numeric a) noexcept
Computes the derived plane from ARTS grids.
Definition: zeemandata.cc:277
AllPolarizationVectors AllPolarization_deta(Numeric theta, Numeric eta) noexcept
The derivative of AllPolarization wrt eta.
Definition: zeemandata.cc:400
AllPolarizationVectors AllPolarization_dtheta(Numeric theta, const Numeric eta) noexcept
The derivative of AllPolarization wrt theta.
Definition: zeemandata.cc:383
Polarization
Zeeman polarization selection.
Definition: zeemandata.h:44
Model GetAdvancedModel(const QuantumIdentifier &qid) ARTS_NOEXCEPT
Returns an advanced Zeeman model.
Definition: zeemandata.cc:131
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:453
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:433
Model GetSimpleModel(const QuantumIdentifier &qid) ARTS_NOEXCEPT
Returns a simple Zeeman model.
Definition: zeemandata.cc:71
constexpr Rational Ml(Rational Ju, Rational Jl, Polarization type, Index n) noexcept
Gives the lower state M value at an index.
Definition: zeemandata.h:180
AllPolarizationVectors AllPolarization(Numeric theta, Numeric eta) noexcept
Computes the polarization of each polarization type.
Definition: zeemandata.cc:368
constexpr Rational Mu(Rational Ju, Rational Jl, Polarization type, Index n) noexcept
Gives the upper state M value at an index.
Definition: zeemandata.h:159
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:113
constexpr bool isnan(double d) noexcept
Definition: nonstd.h:53
Stuff related to the propagation matrix.
#define N
Definition: rng.cc:164
A logical struct for global quantum numbers with species identifiers.
Implements rational numbers to work with other ARTS types.
Definition: rational.h:43
PolarizationVector for each Polarization.
Definition: zeemandata.h:442
Contains derived values useful for Zeeman calculations.
Definition: zeemandata.h:522
Numeric deta_du
Definition: zeemandata.h:524
Polarization vector for Zeeman Propagation Matrix.
Definition: zeemandata.h:422
std::array< Numeric, 4 > att
Definition: zeemandata.h:423
std::array< Numeric, 3 > dis
Definition: zeemandata.h:424
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:427
Main storage for Zeeman splitting coefficients.
Definition: zeemandata.h:285
#define u
#define d
#define v
#define w
#define a
#define c
#define b