ARTS 2.5.4 (git: bcd8c674)
linemixing.h
Go to the documentation of this file.
1#ifndef linemixing_h
2#define linemixing_h
3
4#include <functional>
5#include <utility>
6
7#include "absorption.h"
8#include "constants.h"
9#include "gridded_fields.h"
10#include "linescaling.h"
11#include "matpack_complex.h"
12#include "species.h"
13#include "zeemandata.h"
14
15namespace Absorption::LineMixing {
16
21
26 explicit EquivalentLines(Index n=0) noexcept : val(n, 0), str(n, 0) {}
27
36 EquivalentLines(const ComplexMatrix& W, const Vector& pop, const Vector& dip) noexcept;
37
40
43
46
49
50 void sort_by_frequency(Vector& f, const ArrayOfIndex& sorting);
51
52 friend std::ostream& operator<<(std::ostream& os, const EquivalentLines& eqv);
53}; // EquivalentLines
54
59
66 const AbsorptionLines& band) noexcept;
67
73 ArrayOfIndex sort(const AbsorptionLines& band) noexcept;
74
79 void sort(const ArrayOfIndex& presorting) noexcept;
80}; // PopulationAndDipole
81
82using EnergyFunction = std::function<Numeric (const Rational)>;
83
85 Species::Species spec{Species::Species::Bath};
91
92 constexpr SpeciesErrorCorrectedSuddenData() noexcept :
93 scaling(LineShapeTemperatureModel::T0, 0, 0, 0, 0),
94 beta(LineShapeTemperatureModel::T0, 0, 0, 0, 0),
95 lambda(LineShapeTemperatureModel::T0, 0, 0, 0, 0),
97
98 constexpr SpeciesErrorCorrectedSuddenData(Species::Species inspec) noexcept :
99 spec(inspec), scaling(LineShapeTemperatureModel::T0, 0, 0, 0, 0),
100 beta(LineShapeTemperatureModel::T0, 0, 0, 0, 0),
101 lambda(LineShapeTemperatureModel::T0, 0, 0, 0, 0),
102 collisional_distance(LineShapeTemperatureModel::T0, 0, 0, 0, 0) {}
103
104 [[nodiscard]] Numeric Q(const Rational J,
105 const Numeric T,
106 const Numeric T0,
107 const Numeric energy) const noexcept;
108
109 [[nodiscard]] Numeric Omega(const Numeric T,
110 const Numeric T0,
111 const Numeric other_mass,
112 const Numeric energy_x,
113 const Numeric energy_xm2) const noexcept;
114
115 friend std::ostream& operator<<(std::ostream& os, const SpeciesErrorCorrectedSuddenData& srbd);
116
117 friend std::istream& operator>>(std::istream& is, SpeciesErrorCorrectedSuddenData& srbd);
118
119 constexpr bool operator==(Species::Species species) const noexcept {
120 return species == spec;
121 }
122}; // SpeciesErrorCorrectedSuddenData
123
136
141
142 explicit ErrorCorrectedSuddenData(QuantumIdentifier qid={}) noexcept :
143 id(std::move(qid)), data({SpeciesErrorCorrectedSuddenData()}) {}
144
145 friend std::ostream& operator<<(std::ostream& os, const ErrorCorrectedSuddenData& rbd) {
146 for (Index i=0; i<rbd.data.nelem(); i++) {
147 if (i) os << '\n';
148 os << rbd.data[i];
149 }
150 return os;
151 }
152
153 friend std::istream& operator>>(std::istream& is, ErrorCorrectedSuddenData& rbd) {
154 for (auto& x: rbd.data) is >> x;
155 return is;
156 }
157
158 bool operator==(const QuantumIdentifier& band_id) const noexcept {
159 return band_id.part_of(id);
160 }
161
162 [[nodiscard]] Index pos(Species::Species spec) const noexcept {
163 return std::distance(data.begin(), std::find(data.cbegin(), data.cend(), spec));
164 }
165
166 [[nodiscard]] Index size() const noexcept {
167 return data.size();
168 }
169
170 const SpeciesErrorCorrectedSuddenData& operator[](Species::Species spec) const noexcept {
171 if(auto ptr = std::find(data.cbegin(), data.cend(), spec); ptr not_eq data.cend())
172 return *ptr;
173 return *std::find(data.cbegin(), data.cend(), Species::Species::Bath);
174 }
175
176 SpeciesErrorCorrectedSuddenData& operator[](Species::Species spec) noexcept {
177 if(auto ptr = std::find(data.begin(), data.end(), spec); ptr not_eq data.end())
178 return *ptr;
179 return data.emplace_back(spec);
180 }
181}; // ErrorCorrectedSuddenData
182
183struct MapOfErrorCorrectedSuddenData : public Array<ErrorCorrectedSuddenData> {
185 if(auto ptr = std::find(begin(), end(), id); ptr not_eq end())
186 return *ptr;
187 return emplace_back(id);
188
189 }
190
192 if(auto ptr = std::find(cbegin(), cend(), id); ptr not_eq cend()) {
193 return *ptr;
194 }
195 ARTS_USER_ERROR("Cannot find data for QuantumIdentifier:\n", id, '\n',
196 "Available data:\n", *this);
197 return front(); // To get rid of potential warnings...
198 }
199
201 ARTS_ASSERT(i >= 0 and i < nelem())
202 return * (begin() + i);
203 }
204
206 ARTS_ASSERT(i >= 0 and i < nelem())
207 return * (begin() + i);
208 }
209
210 friend std::ostream& operator<<(std::ostream& os, const MapOfErrorCorrectedSuddenData& m) {
211 std::for_each(m.cbegin(), m.cend(), [&](auto& x){os << x << '\n';});
212 return os;
213 }
214}; // MapOfErrorCorrectedSuddenData
215
216// Return struct from calculations
217struct EcsReturn {
220 bool error;
221 EcsReturn(EcsReturn&&) noexcept = default;
222 EcsReturn(ComplexVector&& abs_, ArrayOfComplexVector&& dabs_, bool error_) noexcept :
223 abs(std::move(abs_)), dabs(std::move(dabs_)), error(error_) {}
224};
225
226
242EcsReturn ecs_absorption(const Numeric T,
243 const Numeric H,
244 const Numeric P,
245 const Numeric this_vmr,
246 const Vector& vmrs,
247 const ErrorCorrectedSuddenData& ecs_data,
248 const Vector& f_grid,
249 const Zeeman::Polarization zeeman_polarization,
250 const AbsorptionLines& band,
251 const ArrayOfRetrievalQuantity& jacobian_quantities={});
252
259 const Tensor4& tempdata,
260 const Vector& temperatures,
261 const Numeric P0,
262 const Index ord);
263
264
285EquivalentLines eigenvalue_adaptation_of_relmat(const ComplexMatrix& W,
286 const Vector& pop,
287 const Vector& dip,
288 const AbsorptionLines& band,
289 const Numeric frenorm,
290 const Numeric T,
291 const Numeric P,
292 const Numeric QT,
293 const Numeric QT0,
294 const Index broadener);
295
296
322 const Vector& temperatures,
323 const ErrorCorrectedSuddenData& ecs_data,
324 const Numeric P0,
325 const Index ord,
326 const bool robust,
327 const bool rosenkranz_adaptation,
328 const Verbosity& verbosity);
329
342 const Vector& temperatures,
343 const ErrorCorrectedSuddenData& ecs_data,
344 const Vector& pressures);
345} // namespace Absorption::LineMixing
346
350
351#endif // linemixing_h
Declarations required for the calculation of absorption coefficients.
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
The ComplexMatrix class.
The ComplexVector class.
Implements rational numbers to work with other ARTS types.
Definition: rational.h:43
The Tensor4 class.
Definition: matpackIV.h:429
The Tensor5 class.
Definition: matpackV.h:516
The Vector class.
Definition: matpackI.h:922
Constants of physical expressions as constexpr.
#define ARTS_NOEXCEPT
Definition: debug.h:80
#define ARTS_ASSERT(condition,...)
Definition: debug.h:83
#define ARTS_USER_ERROR(...)
Definition: debug.h:150
Implementation of gridded fields.
Absorption::LineMixing::ErrorCorrectedSuddenData ErrorCorrectedSuddenData
Definition: linemixing.h:347
Absorption::LineMixing::MapOfErrorCorrectedSuddenData MapOfErrorCorrectedSuddenData
Definition: linemixing.h:348
Absorption::LineMixing::SpeciesErrorCorrectedSuddenData SpeciesErrorCorrectedSuddenData
Definition: linemixing.h:349
Constains various line scaling functions.
LineShape::TemperatureModel LineShapeTemperatureModel
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
EquivalentLines eigenvalue_adaptation_of_relmat(const ComplexMatrix &W, const Vector &pop, const Vector &dip, const AbsorptionLines &band, const Numeric frenorm, const Numeric T, const Numeric P, const Numeric QT, const Numeric QT0, const Index broadener)
Adapts the relaxation matrix eigenvalues to a form where they represent additions towards the three R...
Definition: linemixing.cc:1224
void ecs_eigenvalue_adaptation(AbsorptionLines &band, const Vector &temperatures, const ErrorCorrectedSuddenData &ecs_data, const Numeric P0, const Index ord, const bool robust, const bool rosenkranz_adaptation, const Verbosity &verbosity)
Definition: linemixing.cc:1394
EcsReturn ecs_absorption(const Numeric T, const Numeric H, const Numeric P, const Numeric this_vmr, const Vector &vmrs, const ErrorCorrectedSuddenData &ecs_data, const Vector &f_grid, const Zeeman::Polarization zeeman_polarization, const AbsorptionLines &band, const ArrayOfRetrievalQuantity &jacobian_quantities)
Definition: linemixing.cc:705
Index band_eigenvalue_adaptation(AbsorptionLines &band, const Tensor4 &tempdata, const Vector &temperatures, const Numeric P0, const Index ord)
Adapts the band to the temperature data.
Definition: linemixing.cc:1052
Tensor5 ecs_eigenvalue_adaptation_test(const AbsorptionLines &band, const Vector &temperatures, const ErrorCorrectedSuddenData &ecs_data, const Vector &pressures)
Definition: linemixing.cc:1442
std::function< Numeric(const Rational)> EnergyFunction
Definition: linemixing.h:82
Vector vmrs(const ConstVectorView &atmospheric_vmrs, const ArrayOfArrayOfSpeciesTag &atmospheric_species, const ArrayOfSpecies &lineshape_species) ARTS_NOEXCEPT
Returns a VMR vector for this model's main calculations.
VectorView std(VectorView std, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the standard deviation of the ranged ys.
Definition: raw.cc:205
Polarization
Zeeman polarization selection.
Definition: zeemandata.h:44
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
ArrayOfComplexVector dabs
Definition: linemixing.h:219
EcsReturn(EcsReturn &&) noexcept=default
Contains recomputed equivalent lines (sorting is unknown)
Definition: linemixing.h:18
EquivalentLines & operator=(const EquivalentLines &)=delete
Explicitly deleted.
void sort_by_frequency(Vector &f, const ArrayOfIndex &sorting)
Definition: linemixing.cc:69
EquivalentLines & operator=(EquivalentLines &&)=default
Explicitly defaulted.
EquivalentLines(EquivalentLines &&)=default
Explicitly defaulted.
friend std::ostream & operator<<(std::ostream &os, const EquivalentLines &eqv)
Definition: linemixing.cc:93
EquivalentLines(const EquivalentLines &)=delete
Explicitly deleted.
Rovibrational line mixing data following the ideas of Collisional Effects On Molecular Spectra by J.
Definition: linemixing.h:134
friend std::istream & operator>>(std::istream &is, ErrorCorrectedSuddenData &rbd)
Definition: linemixing.h:153
bool operator==(const QuantumIdentifier &band_id) const noexcept
Definition: linemixing.h:158
SpeciesErrorCorrectedSuddenData & operator[](Species::Species spec) noexcept
Definition: linemixing.h:176
friend std::ostream & operator<<(std::ostream &os, const ErrorCorrectedSuddenData &rbd)
Definition: linemixing.h:145
Index pos(Species::Species spec) const noexcept
Definition: linemixing.h:162
Array< SpeciesErrorCorrectedSuddenData > data
Data of species data The program is considered ill-formed if data does not contain a Bath-species,...
Definition: linemixing.h:140
const SpeciesErrorCorrectedSuddenData & operator[](Species::Species spec) const noexcept
Definition: linemixing.h:170
ErrorCorrectedSuddenData(QuantumIdentifier qid={}) noexcept
Definition: linemixing.h:142
friend std::ostream & operator<<(std::ostream &os, const MapOfErrorCorrectedSuddenData &m)
Definition: linemixing.h:210
ErrorCorrectedSuddenData & operator[](Index i) ARTS_NOEXCEPT
Definition: linemixing.h:205
ErrorCorrectedSuddenData & operator[](const QuantumIdentifier &id) noexcept
Definition: linemixing.h:184
const ErrorCorrectedSuddenData & operator[](const QuantumIdentifier &id) const
Definition: linemixing.h:191
const ErrorCorrectedSuddenData & operator[](Index i) const ARTS_NOEXCEPT
Definition: linemixing.h:200
Contains the population distribution and dipole.
Definition: linemixing.h:56
ArrayOfIndex sort(const AbsorptionLines &band) noexcept
Definition: linemixing.cc:165
PopulationAndDipole(const Numeric T, const AbsorptionLines &band) noexcept
Definition: linemixing.cc:139
friend std::istream & operator>>(std::istream &is, SpeciesErrorCorrectedSuddenData &srbd)
Definition: linemixing.cc:112
Numeric Q(const Rational J, const Numeric T, const Numeric T0, const Numeric energy) const noexcept
Definition: linemixing.cc:232
constexpr SpeciesErrorCorrectedSuddenData(Species::Species inspec) noexcept
Definition: linemixing.h:98
constexpr bool operator==(Species::Species species) const noexcept
Definition: linemixing.h:119
friend std::ostream & operator<<(std::ostream &os, const SpeciesErrorCorrectedSuddenData &srbd)
Definition: linemixing.cc:102
Numeric Omega(const Numeric T, const Numeric T0, const Numeric other_mass, const Numeric energy_x, const Numeric energy_xm2) const noexcept
Definition: linemixing.cc:239
Coefficients and temperature model for SingleSpeciesModel.
A logical struct for global quantum numbers with species identifiers.
Headers and class definition of Zeeman modeling.