ARTS 2.5.0 (git: 9ee3ac6c)
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 "constants.h"
33#include "file.h"
34#include "mystring.h"
35#include "propagationmatrix.h"
36#include "quantum.h"
37#include "wigner_functions.h"
38#include <limits>
39
41namespace Zeeman {
42
45
52constexpr Index dM(Polarization type) noexcept {
53 switch (type) {
55 return -1;
57 return 0;
59 return 1;
60 }
62}
63
78constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept {
79 switch (type) {
81 if (Ju < Jl)
82 return -Ju;
83 else if (Ju == Jl)
84 return -Ju + 1;
85 else
86 return -Ju + 2;
88 return -min(Ju, Jl);
90 return -Ju;
91 }
93}
94
109constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept {
110 switch (type) {
112 return Ju + 1;
113 case Polarization::Pi:
114 return min(Ju, Jl);
116 if (Ju < Jl)
117 return Ju + 1;
118 else if (Ju == Jl)
119 return Ju;
120 else
121 return Jl;
122 }
124}
125
136constexpr Index nelem(Rational Ju, Rational Jl, Polarization type) noexcept {
137 return (end(Ju, Jl, type) - start(Ju, Jl, type)).toIndex() + 1;
138}
139
153constexpr Rational Mu(Rational Ju,
154 Rational Jl,
156 Index n) noexcept {
157 return start(Ju, Jl, type) + n;
158}
159
160
174constexpr Rational Ml(Rational Ju,
175 Rational Jl,
177 Index n) noexcept {
178 return Mu(Ju, Jl, type, n) + dM(type);
179}
180
193 switch (type) {
195 return .75;
196 case Polarization::Pi:
197 return 1.5;
199 return .75;
200 }
202}
203
213constexpr bool GoodHundData(const QuantumNumbers& qns) noexcept {
214 if (qns[QuantumNumberType::Hund].isUndefined()) return false;
215 switch (Hund(qns[QuantumNumberType::Hund].toIndex())) {
216 case Hund::CaseA:
217 if (qns[QuantumNumberType::Omega].isUndefined() or
218 qns[QuantumNumberType::J].isUndefined() or
219 qns[QuantumNumberType::Lambda].isUndefined() or
220 qns[QuantumNumberType::S].isUndefined())
221 return false;
222 break;
223 case Hund::CaseB:
224 if (qns[QuantumNumberType::N].isUndefined() or
225 qns[QuantumNumberType::J].isUndefined() or
226 qns[QuantumNumberType::Lambda].isUndefined() or
227 qns[QuantumNumberType::S].isUndefined())
228 return false;
229 break;
230 default:
231 return false;
232 }
233 return true;
234}
235
251 Rational J,
252 Rational Lambda,
253 Rational S,
254 Numeric GS,
255 Numeric GL) noexcept {
256 auto JJ = J * (J + 1);
257 auto NN = N * (N + 1);
258 auto SS = S * (S + 1);
259 auto LL = Lambda * Lambda;
260
261 if (JJ == 0)
262 return 0.0;
263 if (NN not_eq 0) {
264 auto T1 = ((JJ + SS - NN) / JJ / 2).toNumeric();
265 auto T2 = ((JJ - SS + NN) * LL / NN / JJ / 2).toNumeric();
266 return GS * T1 + GL * T2;
267 }
268 auto T1 = ((JJ + SS - NN) / JJ / 2).toNumeric();
269 return GS * T1;
270}
271
287 Rational J,
288 Rational Lambda,
289 Rational Sigma,
290 Numeric GS,
291 Numeric GL) noexcept {
292 auto JJ = J * (J + 1);
293
294 if (JJ == Rational(0))
295 return 0.0;
296 auto DIV = Omega / JJ;
297 auto T1 = (Sigma * DIV).toNumeric();
298 auto T2 = (Lambda * DIV).toNumeric();
299 return GS * T1 + GL * T2;
300
301}
302
314constexpr Numeric SimpleG(const QuantumNumbers& qns,
315 const Numeric& GS,
316 const Numeric& GL) noexcept{
317 if (not GoodHundData(qns))
318 return NAN;
319
320 switch (Hund(qns[QuantumNumberType::Hund].toIndex())) {
321 case Hund::CaseA:
322 return SimpleGCaseA(qns[QuantumNumberType::Omega],
323 qns[QuantumNumberType::J],
324 qns[QuantumNumberType::Lambda],
325 qns[QuantumNumberType::S],
326 GS,
327 GL);
328 case Hund::CaseB:
330 qns[QuantumNumberType::J],
331 qns[QuantumNumberType::Lambda],
332 qns[QuantumNumberType::S],
333 GS,
334 GL);
335 }
336
337 return NAN;
338}
339
348};
349
357class Model {
358 private:
360
361 public:
363 constexpr Model(SplittingData gs = {NAN, NAN}) noexcept : mdata(gs) {}
364
366 constexpr Model(Numeric gu, Numeric gl) noexcept : Model(SplittingData{gu, gl}) {}
367
378 explicit Model(const QuantumIdentifier& qid) noexcept;
379
381 [[nodiscard]] /* constexpr */ bool empty() const noexcept {
382 return std::isnan(mdata.gu) and std::isnan(mdata.gl);
383 }
384
386 constexpr Numeric& gu() noexcept { return mdata.gu; }
387
389 constexpr Numeric& gl() noexcept { return mdata.gl; }
390
392 constexpr void gu(Numeric x) noexcept { mdata.gu = x; }
393
395 constexpr void gl(Numeric x) noexcept { mdata.gl = x; }
396
398 [[nodiscard]] constexpr Numeric gu() const noexcept { return mdata.gu; }
399
401 [[nodiscard]] constexpr Numeric gl() const noexcept { return mdata.gl; }
402
416 [[nodiscard]] Numeric Strength(Rational Ju, Rational Jl, Polarization type, Index n) const;
417
431 [[nodiscard]] constexpr Numeric Splitting(Rational Ju, Rational Jl, Polarization type, Index n) const
432 noexcept {
433 using Constant::bohr_magneton;
434 using Constant::h;
435 constexpr Numeric C = bohr_magneton / h;
436
437 return C * (Ml(Ju, Jl, type, n).toNumeric() * gl() -
438 Mu(Ju, Jl, type, n).toNumeric() * gu());
439 }
440
442 friend std::ostream& operator<<(std::ostream& os, const Model& m);
443
445 friend std::istream& operator>>(std::istream& is, Model& m);
446
448 friend std::ostream& operator<<(bofstream& bof, const Model& m);
449
451 friend std::istream& operator>>(bifstream& bif, Model& m);
452}; // Model;
453
464
477
478std::ostream& operator<<(std::ostream& os, const Model& m);
479
480std::istream& operator>>(std::istream& is, Model& m);
481
482std::ostream& operator<<(bofstream& bof, const Model& m);
483
484std::istream& operator>>(bifstream& bif, Model& m);
485
493 private:
494 Eigen::RowVector4d att; // attenuation vector
495 Eigen::RowVector3d dis; // dispersion vector
496
497 public:
500 Numeric b = 0,
501 Numeric c = 0,
502 Numeric d = 0,
503 Numeric u = 0,
504 Numeric v = 0,
505 Numeric w = 0) noexcept
506 : att(a, b, c, d), dis(u, v, w){};
507
509 [[nodiscard]] const Eigen::RowVector4d& attenuation() const noexcept { return att; }
510
512 [[nodiscard]] const Eigen::RowVector3d& dispersion() const noexcept { return dis; }
513
515 Eigen::RowVector4d& attenuation() noexcept { return att; }
516
518 Eigen::RowVector3d& dispersion() noexcept { return dis; }
519
524 [[nodiscard]] Eigen::Matrix4d matrix() const noexcept {
525 return (Eigen::Matrix4d() << att[0],
526 att[1],
527 att[2],
528 att[3],
529 att[1],
530 att[0],
531 dis[0],
532 dis[1],
533 att[2],
534 -dis[0],
535 att[0],
536 dis[2],
537 att[3],
538 -dis[1],
539 -dis[2],
540 att[0])
541 .finished();
542 }
543};
544
552};
553
562 Numeric eta) noexcept;
563
572 Numeric theta, const Numeric eta) noexcept;
573
582 Numeric eta) noexcept;
583
591
598void sum(PropagationMatrix& pm, const ComplexVectorView& abs, const PolarizationVector& polvec, const bool do_phase=true) ARTS_NOEXCEPT;
599
612void dsum(PropagationMatrix& dpm,
613 const ComplexVectorView& abs,
614 const ComplexVectorView& dabs,
615 const PolarizationVector& polvec,
616 const PolarizationVector& dpolvec_dtheta,
617 const PolarizationVector& dpolvec_deta,
618 const Numeric dH,
619 const Numeric dtheta,
620 const Numeric deta, const bool do_phase=true) ARTS_NOEXCEPT;
621
630struct Derived {
631 Numeric H, theta, eta, dH_du, dH_dv, dH_dw, dtheta_du, dtheta_dv, dtheta_dw,
632 deta_du, deta_dv, deta_dw;
633};
634
667
677 Numeric theta,
678 Numeric eta) noexcept {
679 return {H, theta, eta, 0, 0, 0, 0, 0, 0, 0, 0, 0};
680}
681}; // namespace Zeeman
682
683// Typedef to make it easier to use
685
686#endif /* zeemandata_h */
void * data
The ComplexVectorView class.
Container class for Quantum Numbers.
Definition: quantum.h:112
Implements rational numbers to work with other ARTS types.
Definition: rational.h:52
constexpr Numeric toNumeric() const noexcept
Converts this to a Numeric.
Definition: rational.h:142
Main Zeeman Model.
Definition: zeemandata.h:357
constexpr Numeric & gl() noexcept
Returns the lower state g.
Definition: zeemandata.h:389
SplittingData mdata
Definition: zeemandata.h:359
constexpr Model(Numeric gu, Numeric gl) noexcept
Default copy/init of Model from its only private variable.
Definition: zeemandata.h:366
constexpr Numeric & gu() noexcept
Returns the upper state g.
Definition: zeemandata.h:386
Numeric Strength(Rational Ju, Rational Jl, Polarization type, Index n) const
Gives the strength of one subline of a given polarization.
Definition: zeemandata.cc:282
friend std::istream & operator>>(std::istream &is, Model &m)
Input operator for Zeeman::Model.
Definition: zeemandata.cc:296
friend std::ostream & operator<<(std::ostream &os, const Model &m)
Output operator for Zeeman::Model.
Definition: zeemandata.cc:291
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:431
constexpr Numeric gl() const noexcept
Returns the lower state g.
Definition: zeemandata.h:401
bool empty() const noexcept
Returns true if the Model represents no Zeeman effect.
Definition: zeemandata.h:381
constexpr void gl(Numeric x) noexcept
Sets the lower state g.
Definition: zeemandata.h:395
constexpr Model(SplittingData gs={NAN, NAN}) noexcept
Default copy/init of Model from its only private variable.
Definition: zeemandata.h:363
constexpr void gu(Numeric x) noexcept
Sets the upper state g.
Definition: zeemandata.h:392
constexpr Numeric gu() const noexcept
Returns the upper state g.
Definition: zeemandata.h:398
Polarization vector for Zeeman Propagation Matrix.
Definition: zeemandata.h:492
Eigen::Matrix4d matrix() const noexcept
Returns the true propagation matrix.
Definition: zeemandata.h:524
Eigen::RowVector3d & dispersion() noexcept
Returns the dispersion vector.
Definition: zeemandata.h:518
Eigen::RowVector4d & attenuation() noexcept
Returns the attenuation vector.
Definition: zeemandata.h:515
const Eigen::RowVector3d & dispersion() const noexcept
Returns the dispersion vector.
Definition: zeemandata.h:512
Eigen::RowVector3d dis
Definition: zeemandata.h:495
Eigen::RowVector4d att
Definition: zeemandata.h:494
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:499
const Eigen::RowVector4d & attenuation() const noexcept
Returns the attenuation vector.
Definition: zeemandata.h:509
Binary output file stream class.
Definition: bifstream.h:42
Binary output file stream class.
Definition: bofstream.h:42
Constants of physical expressions as constexpr.
#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)
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
This file contains the definition of String, the ARTS string class.
char Type type
Implements Zeeman modeling.
Definition: zeemandata.cc:281
std::ostream & operator<<(std::ostream &os, const Model &m)
Definition: zeemandata.cc:291
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:250
constexpr bool GoodHundData(const QuantumNumbers &qns) noexcept
Checks if the quantum numbers are good for this transition.
Definition: zeemandata.h:213
const PolarizationVector & SelectPolarization(const AllPolarizationVectors &data, Polarization type) noexcept
Selects the polarization vector depending on polarization type.
Definition: zeemandata.cc:362
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:78
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:136
constexpr Derived FromPreDerived(Numeric H, Numeric theta, Numeric eta) noexcept
Sets Derived from predefined Derived parameters.
Definition: zeemandata.h:676
constexpr Numeric SimpleGCaseA(Rational Omega, Rational J, Rational Lambda, Rational Sigma, Numeric GS, Numeric GL) noexcept
Computes the Zeeman splitting coefficient.
Definition: zeemandata.h:286
constexpr Numeric PolarizationFactor(Polarization type) noexcept
The renormalization factor of a polarization type.
Definition: zeemandata.h:192
Derived FromGrids(Numeric u, Numeric v, Numeric w, Numeric z, Numeric a) noexcept
Computes the derived plane from ARTS grids.
Definition: zeemandata.cc:227
AllPolarizationVectors AllPolarization_deta(Numeric theta, Numeric eta) noexcept
The derivative of AllPolarization wrt eta.
Definition: zeemandata.cc:344
AllPolarizationVectors AllPolarization_dtheta(Numeric theta, const Numeric eta) noexcept
The derivative of AllPolarization wrt theta.
Definition: zeemandata.cc:327
Polarization
Zeeman polarization selection.
Definition: zeemandata.h:44
Model GetAdvancedModel(const QuantumIdentifier &qid) ARTS_NOEXCEPT
Returns an advanced Zeeman model.
Definition: zeemandata.cc:103
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:389
constexpr Numeric SimpleG(const QuantumNumbers &qns, const Numeric &GS, const Numeric &GL) noexcept
Computes the Zeeman splitting coefficient.
Definition: zeemandata.h:314
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:375
std::istream & operator>>(std::istream &is, Model &m)
Definition: zeemandata.cc:296
Model GetSimpleModel(const QuantumIdentifier &qid) ARTS_NOEXCEPT
Returns a simple Zeeman model.
Definition: zeemandata.cc:32
constexpr Rational Ml(Rational Ju, Rational Jl, Polarization type, Index n) noexcept
Gives the lower state M value at an index.
Definition: zeemandata.h:174
AllPolarizationVectors AllPolarization(Numeric theta, Numeric eta) noexcept
Computes the polarization of each polarization type.
Definition: zeemandata.cc:311
constexpr Rational Mu(Rational Ju, Rational Jl, Polarization type, Index n) noexcept
Gives the upper state M value at an index.
Definition: zeemandata.h:153
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
Definition: zeemandata.h:109
constexpr bool isnan(double d) noexcept
Definition: nonstd.h:39
Stuff related to the propagation matrix.
#define u
#define d
#define v
#define w
#define a
#define c
#define b
Hund
Enum for Hund cases.
Definition: quantum.h:109
Quantum::Identifier QuantumIdentifier
Definition: quantum.h:471
#define N
Definition: rng.cc:164
PolarizationVector for each Polarization.
Definition: zeemandata.h:550
Contains derived values useful for Zeeman calculations.
Definition: zeemandata.h:630
Numeric deta_du
Definition: zeemandata.h:632
Main storage for Zeeman splitting coefficients.
Definition: zeemandata.h:346
Wigner symbol interactions.