ARTS 2.5.10 (git: 2f1c442c)
lineshapemodel.h
Go to the documentation of this file.
1/* Copyright (C) 2018
2 Richard Larsson <ric.larsson@gmail.com>
3
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 USA. */
21
34#ifndef lineshapemodel_h
35#define lineshapemodel_h
36
37#include "arts_conversions.h"
38#include "enums.h"
39#include "file.h"
40#include "jacobian.h"
41#include "species_tags.h"
42#include <algorithm>
43#include <numeric>
44#include <utility>
45
53Jacobian::Line select_derivativeLineShape(const String& var,
54 const String& coeff);
55
63namespace LineShape {
65ENUMCLASS(Type, char,
66 DP, // Doppler
67 LP, // Lorentz
68 VP, // Voigt
69 SDVP, // Speed-dependent Voigt
70 HTP, // Hartmann-Tran
71 SplitLP, // Lorentz split by broadening species
72 SplitVP, // Voigt split by broadening species
73 SplitSDVP, // Speed-dependent Voigt split by broadening species
74 SplitHTP // Hartmann-Tran split by broadening species
75)
76
77
86constexpr std::string_view shapetype2metadatastring(Type type) noexcept {
87 switch (type) {
88 case Type::DP:
89 return "The line shape type is the Doppler profile\n";
90 case Type::LP:
91 return "The line shape type is the Lorentz profile.\n";
92 case Type::VP:
93 return "The line shape type is the Voigt profile.\n";
94 case Type::SDVP:
95 return "The line shape type is the speed-dependent Voigt profile.\n";
96 case Type::HTP:
97 return "The line shape type is the Hartmann-Tran profile.\n";
98 case Type::SplitLP:
99 return "The line shape type is the Lorentz profile per broadener.\n";
100 case Type::SplitVP:
101 return "The line shape type is the Voigt profile per broadener.\n";
102 case Type::SplitSDVP:
103 return "The line shape type is the speed-dependent Voigt profile per broadener.\n";
104 case Type::SplitHTP:
105 return "The line shape type is the Hartmann-Tran profile per broadener.\n";
106 case Type::FINAL: {}
107 }
108 return "There's an error.\n";
109}
110
124constexpr bool independent_per_broadener(Type in) {
125 using enum Type;
126 constexpr std::array data{SplitLP, SplitVP, SplitSDVP, SplitHTP};
127 static_assert(std::is_sorted(data.begin(), data.end()), "Not sorted");
128 return std::binary_search(data.begin(), data.end(), in);
129}
130
131
141ENUMCLASS(TemperatureModel, char,
142 None, // 0
143 T0, // Constant, X0
144 T1, // Standard, X0 * (T0/T) ^ X1
145 T2, // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
146 T3, // X0 + X1 * (T - T0)
147 T4, // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
148 T5, // X0 * (T0/T)^(0.25 + 1.5*X1)
149 LM_AER, // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
150 DPL, // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
151 POLY // X0 + X1 * T + X2 * T ^ 2 + X3 * T ^ 3
152)
153
154
158ENUMCLASS(Variable, char,
159 G0, // Pressure broadening speed-independent
160 D0, // Pressure f-shifting speed-dependent
161 G2, // Pressure broadening speed-dependent
162 D2, // Pressure f-shifting speed-independent
163 FVC, // Frequency of velocity-changing collisions
164 ETA, // Correlation
165 Y, // First order line mixing coefficient
166 G, // Second order line mixing coefficient
167 DV // Second order line mixing f-shifting
168)
169
175 static constexpr Index N = 4;
176 static_assert(Index(Options::LineShapeCoeff::FINAL) == N, "Must update either LineShapeCoeff options or ModelParameters");
177 TemperatureModel type;
182
183 constexpr ModelParameters(TemperatureModel intype=TemperatureModel::None,
184 Numeric inX0=std::numeric_limits<Numeric>::quiet_NaN(),
185 Numeric inX1=std::numeric_limits<Numeric>::quiet_NaN(),
186 Numeric inX2=std::numeric_limits<Numeric>::quiet_NaN(),
187 Numeric inX3=std::numeric_limits<Numeric>::quiet_NaN())
188 noexcept : type(intype), X0(inX0), X1(inX1), X2(inX2), X3(inX3) {}
189
190 template <typename VectorType> constexpr
191 ModelParameters(TemperatureModel intype, VectorType&& v) ARTS_NOEXCEPT :
192 ModelParameters(intype) {
193 const auto n = std::size(v);
194 ARTS_ASSERT(n <= N, "Must have at most ", N, " inputs, got: ", n)
195 switch (n) {
196 case 4: X3 = v[3]; [[fallthrough]];
197 case 3: X2 = v[2]; [[fallthrough]];
198 case 2: X1 = v[1]; [[fallthrough]];
199 case 1: X0 = v[0];
200 }
201 }
202
214 [[nodiscard]] constexpr Numeric special_linemixing_aer(Numeric T) const noexcept {
215 if (T < 250.0)
216 return X0 + (T - 200.0) * (X1 - X0) / (250.0 - 200.0);
217 if (T > 296.0)
218 return X2 + (T - 296.0) * (X3 - X2) / (340.0 - 296.0);
219 return X1 + (T - 250.0) * (X2 - X1) / (296.0 - 250.0);
220 }
221
229 [[nodiscard]] constexpr Numeric special_linemixing_aer_dT(Numeric T) const noexcept {
230 if (T < 250.0)
231 return (X1 - X0) / (250.0 - 200.0);
232 if (T > 296.0)
233 return (X3 - X2) / (340.0 - 296.0);
234 return (X2 - X1) / (296.0 - 250.0);
235 }
236
243 static constexpr Numeric special_linemixing_aer_dX0(Numeric T) noexcept {
244 if (T < 250.0)
245 return 1 - (T - 200.0) / (250.0 - 200.0);
246 return 0;
247 }
248
255 static constexpr Numeric special_linemixing_aer_dX1(Numeric T) noexcept {
256 if (T < 250.0)
257 return (T - 200.0) / (250.0 - 200.0);
258 if (T > 296.0)
259 return 0;
260 return 1 - (T - 250.0) / (296.0 - 250.0);
261 }
262
269 static constexpr Numeric special_linemixing_aer_dX2(Numeric T) noexcept {
270 if (T < 250.0)
271 return 0;
272 if (T > 296.0)
273 return 1 - (T - 296.0) / (340.0 - 296.0);
274 return (T - 250.0) / (296.0 - 250.0);
275 }
276
283 static constexpr Numeric special_linemixing_aer_dX3(Numeric T) noexcept {
284 if (T > 296.0)
285 return (T - 296.0) / (340.0 - 296.0);
286 return 0;
287 }
288
289 [[nodiscard]] Numeric at(Numeric T, Numeric T0) const noexcept;
290
291 [[nodiscard]] Numeric dX0(Numeric T, Numeric T0) const noexcept;
292
293 [[nodiscard]] Numeric dX1(Numeric T, Numeric T0) const noexcept;
294
295 [[nodiscard]] Numeric dX2(Numeric T, Numeric T0) const noexcept;
296
297 [[nodiscard]] Numeric dX3(Numeric T, Numeric T0) const noexcept;
298
299 [[nodiscard]] Numeric dT(Numeric T, Numeric T0) const noexcept;
300
301 [[nodiscard]] Numeric dT0(Numeric T, Numeric T0) const noexcept;
302
303 friend std::ostream& operator<<(std::ostream& os, const ModelParameters& mp);
304
305 friend std::istream& operator>>(std::istream& is, ModelParameters& mp);
306};
307
308String modelparameters2metadata(const ModelParameters mp, const Numeric T0);
309
319Numeric& SingleModelParameter(ModelParameters& mp, const String& type);
320
321constexpr ModelParameters modelparameterGetEmpty(const TemperatureModel t) noexcept {
322 switch(t) {
323 case TemperatureModel::None: // 0
324 return {TemperatureModel::None, 0, 0, 0, 0};
325 case TemperatureModel::T0: // Constant, X0
326 return {TemperatureModel::T0, 0, 0, 0, 0};
327 case TemperatureModel::T1: // Standard, X0 * (T0/T) ^ X1
328 return {TemperatureModel::T1, 0, 0, 0, 0};
329 case TemperatureModel::T2: // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
330 return {TemperatureModel::T2, 0, 0, 0, 0};
331 case TemperatureModel::T3: // X0 + X1 * (T - T0)
332 return {TemperatureModel::T3, 0, 0, 0, 0};
333 case TemperatureModel::T4: // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
334 return {TemperatureModel::T4, 0, 0, 0, 0};
335 case TemperatureModel::T5: // X0 * (T0/T)^(0.25 + 1.5*X1)
336 return {TemperatureModel::T5, 0, 0, 0, 0};
337 case TemperatureModel::LM_AER: // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
338 return {TemperatureModel::LM_AER, 0, 0, 0, 0};
339 case TemperatureModel::DPL: // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
340 return {TemperatureModel::DPL, 0, 0, 0, 0};
341 case TemperatureModel::POLY:
342 return {TemperatureModel::POLY, 0, 0, 0, 0};
343 case TemperatureModel::FINAL:
344 return {TemperatureModel::None, 0, 0, 0, 0};
345 }
346 return {TemperatureModel::None, 0, 0, 0, 0};
347}
348
349constexpr bool modelparameterEmpty(const ModelParameters mp) noexcept {
350 switch(mp.type) {
351 case TemperatureModel::None: // 0
352 return true;
353 case TemperatureModel::T0: // Constant, X0
354 return (mp.X0 == 0);
355 case TemperatureModel::T1: // Standard, X0 * (T0/T) ^ X1
356 return (mp.X0 == 0);
357 case TemperatureModel::T2: // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
358 return (mp.X0 == 0);
359 case TemperatureModel::T3: // X0 + X1 * (T - T0)
360 return (mp.X0 == 0 and mp.X1 == 0);
361 case TemperatureModel::T4: // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
362 return (mp.X0 == 0 and mp.X1 == 0);
363 case TemperatureModel::T5: // X0 * (T0/T)^(0.25 + 1.5*X1)
364 return (mp.X0 == 0);
365 case TemperatureModel::LM_AER: // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
366 return (mp.X0 == 0 and mp.X1 == 0 and mp.X2 == 0 and mp.X3 == 0);
367 case TemperatureModel::DPL: // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
368 return (mp.X0 == 0 and mp.X2 == 0);
369 case TemperatureModel::POLY:
370 return (mp.X0 == 0 and mp.X1 == 0 and mp.X2 == 0 and mp.X3 == 0);
371 case TemperatureModel::FINAL:
372 return true;
373 }
374 return true;
375}
376
378 switch(mp.type) {
379 case TemperatureModel::None: // 0
380 return 0;
381 case TemperatureModel::T0: // Constant, X0
382 return 0;
383 case TemperatureModel::T1: // Standard, X0 * (T0/T) ^ X1
384 return mp.X1;
385 case TemperatureModel::T2: // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
386 return mp.X1;
387 case TemperatureModel::T3: // X0 + X1 * (T - T0)
388 return 0;
389 case TemperatureModel::T4: // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
390 return mp.X2;
391 case TemperatureModel::T5: // X0 * (T0/T)^(0.25 + 1.5*X1)
392 return (0.25 + 1.5*mp.X1);
393 case TemperatureModel::LM_AER: // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
394 return 0;
395 case TemperatureModel::DPL: // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
396 return mp.X1;
397 case TemperatureModel::POLY:
398 return 0;
399 case TemperatureModel::FINAL:
400 return std::numeric_limits<Numeric>::quiet_NaN();
401 }
402 return std::numeric_limits<Numeric>::quiet_NaN();
403}
404
406constexpr Index nVars = Index(Variable::FINAL);
407
409struct Output {
410 Numeric G0{0}, // Pressure broadening speed-independent
411 D0{0}, // Pressure f-shifting speed-independent
412 G2{0}, // Pressure broadening speed-dependent
413 D2{0}, // Pressure f-shifting speed-dependent
414 FVC{0}, // Frequency of velocity-changing collisions
415 ETA{0}, // Correlation
416 Y{0}, // First order line mixing coefficient
417 G{0}, // Second order line mixing coefficient
418 DV{0}; // Second order line mixing f-shifting
419 constexpr Output() noexcept = default;
420 constexpr Output(Numeric g0, Numeric d0, Numeric g2, Numeric d2, Numeric fvc,
421 Numeric eta, Numeric y, Numeric g, Numeric dv) noexcept
422 : G0(g0), D0(d0), G2(g2), D2(d2), FVC(fvc), ETA(eta), Y(y), G(g), DV(dv) {
423 }
424 constexpr Output(const Output &) noexcept = default;
425 constexpr Output(Output &&) noexcept = default;
426 constexpr Output &operator=(const Output &) noexcept = default;
427 constexpr Output &operator=(Output &&) noexcept = default;
428 constexpr Output &operator-=(Output&& other) noexcept {
429 static_assert(nVars == 9, "Must update");
430 G0 -= other.G0;
431 D0 -= other.D0;
432 G2 -= other.G2;
433 D2 -= other.D2;
434 FVC -= other.FVC;
435 ETA -= other.ETA;
436 Y -= other.Y;
437 G -= other.G;
438 DV -= other.DV;
439 return *this;
440 }
441
443 constexpr Output& no_linemixing(bool do_no_linemixing) {
444 if (do_no_linemixing) {
445 Y = G = DV = 0;
446 }
447 return *this;
448 }
449
450 friend std::ostream &operator<<(std::ostream &os, Output x);
451};
452
455 private:
456 std::array<ModelParameters, nVars> X;
457
458 public:
463 ModelParameters G2=ModelParameters{},
464 ModelParameters D2=ModelParameters{},
465 ModelParameters FVC=ModelParameters{},
466 ModelParameters ETA=ModelParameters{},
467 ModelParameters Y=ModelParameters{},
468 ModelParameters G=ModelParameters{},
469 ModelParameters DV=ModelParameters{})
470 : X({G0, D0, G2, D2, FVC, ETA, Y, G, DV}) {}
471
472#define ACCESS_INTERNAL(VARPOS) \
473 constexpr ModelParameters& VARPOS() noexcept { return std::get<Index(Variable::VARPOS)>(X); } \
474 constexpr ModelParameters VARPOS() const noexcept { return std::get<Index(Variable::VARPOS)>(X); }
484#undef ACCESS_INTERNAL
485
487 constexpr std::array<ModelParameters, nVars>& Data() noexcept { return X; }
488
490 [[nodiscard]] constexpr const std::array<ModelParameters, nVars>& Data() const noexcept { return X; }
491
497 constexpr void Set(Variable var, const ModelParameters& x) noexcept {
498#define MODELPARAMCASESETTER(X) \
499 case Variable::X: \
500 X() = x; \
501 break
502 switch (var) {
512 case Variable::FINAL: break;
513 }
514#undef MODELPARAMCASESETTER
515 }
516
523 [[nodiscard]] constexpr ModelParameters Get(Variable var) const noexcept {
524 #define MODELPARAMCASEGETTER(X) case Variable::X: out = X(); break;
525 ModelParameters out{};
526 switch (var) {
536 case Variable::FINAL: break;
537 }
538 return out;
539 #undef MODELPARAMCASEGETTER
540 }
541
543 bifstream& read(bifstream& bif);
544
546 bofstream& write(bofstream& bof) const;
547
548 [[nodiscard]] std::pair<bool, bool> MatchTypes(const SingleSpeciesModel& other) const noexcept;
549
550 friend std::ostream& operator<<(std::ostream& os, const SingleSpeciesModel& ssm);
551
552 friend std::istream& operator>>(std::istream& is, SingleSpeciesModel& ssm);
553
554 [[nodiscard]] Output at(Numeric T, Numeric T0, Numeric P) const noexcept;
555
556 [[nodiscard]] Numeric dX(Numeric T, Numeric T0, Numeric P, Jacobian::Line) const noexcept;
557
558 [[nodiscard]] Output dT(Numeric T, Numeric T0, Numeric P) const noexcept;
559
560 [[nodiscard]] Output dT0(Numeric T, Numeric T0, Numeric P) const noexcept;
561};
562
564constexpr Output mirroredOutput(Output x) noexcept {
565 return {x.G0, -x.D0, x.G2, -x.D2, x.FVC, x.ETA, x.Y, x.G, -x.DV};
566}
567
569constexpr Output negativeOutput(Output x) noexcept {
570 return {-x.G0, -x.D0, -x.G2, -x.D2, -x.FVC, -x.ETA, -x.Y, -x.G, -x.DV};
571}
572
574constexpr Output si2cgs(Output x) noexcept {
576 return {freq2kaycm(x.G0),
577 freq2kaycm(x.D0),
578 freq2kaycm(x.D2),
579 freq2kaycm(x.G2),
580 freq2kaycm(x.FVC),
581 x.ETA,
582 x.Y,
583 x.G,
584 freq2kaycm(x.DV)};
585}
586
588constexpr Output differenceOutput(Output y, Output x) noexcept {
589 return {y.G0 - x.G0,
590 y.D0 - x.D0,
591 y.G2 - x.G2,
592 y.D2 - x.D2,
593 y.FVC - x.FVC,
594 y.ETA - x.ETA,
595 y.Y - x.Y,
596 y.G - x.G,
597 y.DV - x.DV};
598}
599
614Vector vmrs(const ConstVectorView& atmospheric_vmrs,
615 const ArrayOfArrayOfSpeciesTag& atmospheric_species,
616 const ArrayOfSpecies& lineshape_species) ARTS_NOEXCEPT;
617
632Vector mass(const ConstVectorView& atmospheric_vmrs,
633 const ArrayOfArrayOfSpeciesTag& atmospheric_species,
634 const ArrayOfSpecies& lineshape_species,
636
638inline constexpr std::string_view bath_broadening = "AIR";
639
641inline constexpr std::string_view self_broadening = "SELF";
642
647class Model {
648 private:
649 std::vector<SingleSpeciesModel> mdata;
650
651 public:
653 Model(Index n=0) noexcept : mdata(n) {}
654
656 explicit Model(const std::vector<SingleSpeciesModel>& assm) noexcept : mdata(assm) {}
657
659 Model(const Model& m) noexcept : Model(m.mdata) {}
660
662 explicit Model(std::vector<SingleSpeciesModel>&& assm) noexcept : mdata(std::move(assm)) {}
663
665 Model(Model&& m) noexcept : Model(std::move(m.mdata)) {}
666
668 Model& operator=(const Model& m) = default;
669
671 Model& operator=(Model&& m) = default;
672
682 Model(Numeric sgam,
683 Numeric nself,
684 Numeric agam,
685 Numeric nair,
686 Numeric psf,
687 std::array<Numeric, 12> aer_interp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) noexcept;
688
693 [[nodiscard]] bool OK(Type type, bool self, bool bath,
694 const std::size_t nspecies) const noexcept;
695
697 [[nodiscard]] Index nelem() const noexcept { return Index(mdata.size()); }
698
700 [[nodiscard]] Index size() const { return Index(mdata.size()); }
701
708 void resize(Index n) {mdata.resize(n);}
709
716 void reserve(Index n) {mdata.reserve(n);}
717
724
730 const SingleSpeciesModel& operator[](Index i) const {return mdata[i];}
731
732 [[nodiscard]] auto begin() { return mdata.begin(); }
733 [[nodiscard]] auto end() { return mdata.end(); }
734
735 [[nodiscard]] auto begin() const { return mdata.begin(); }
736 [[nodiscard]] auto end() const { return mdata.end(); }
737
738 [[nodiscard]] auto cbegin() const { return mdata.cbegin(); }
739 [[nodiscard]] auto cend() const { return mdata.cend(); }
740
742 [[nodiscard]] const std::vector<SingleSpeciesModel>& Data() const noexcept { return mdata; }
743
745 std::vector<SingleSpeciesModel>& Data() noexcept { return mdata; }
746
754 void Remove(Index i, ArrayOfSpeciesTag& specs);
755 void Remove(Index i, ArrayOfSpecies& specs);
756
768
769 [[nodiscard]] std::pair<bool, bool> Match(const Model& other) const noexcept;
770
771 friend
772 std::istream& from_linefunctiondata(std::istream& data,
773 Type& type,
774 bool& self,
775 bool& bath,
776 Model& m,
777 ArrayOfSpecies& species);
778
779 friend
780 std::istream& from_artscat4(std::istream& is,
781 Type& type,
782 bool& self,
783 bool& bath,
784 Model& m,
785 ArrayOfSpecies& species,
786 const QuantumIdentifier& qid);
787
788 friend std::ostream& operator<<(std::ostream&, const Model&);
789
790 friend std::istream& operator>>(std::istream&, Model&);
791
793 bifstream& read(bifstream& bif);
794
796 bofstream& write(bofstream& bof) const;
797
798[[nodiscard]] Numeric G0(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
799[[nodiscard]] Numeric D0(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
800[[nodiscard]] Numeric G2(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
801[[nodiscard]] Numeric D2(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
802[[nodiscard]] Numeric ETA(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
803[[nodiscard]] Numeric FVC(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
804[[nodiscard]] Numeric Y(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
805[[nodiscard]] Numeric G(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
806[[nodiscard]] Numeric DV(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
807
808[[nodiscard]] Numeric dG0dT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
809[[nodiscard]] Numeric dD0dT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
810[[nodiscard]] Numeric dG2dT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
811[[nodiscard]] Numeric dD2dT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
812[[nodiscard]] Numeric dETAdT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
813[[nodiscard]] Numeric dFVCdT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
814[[nodiscard]] Numeric dYdT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
815[[nodiscard]] Numeric dGdT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
816[[nodiscard]] Numeric dDVdT(Numeric T, Numeric T0, Numeric P, const Vector& vmrs) const ARTS_NOEXCEPT;
817}; // Model;
818
820 Numeric nself,
821 Numeric agam,
822 Numeric nair,
823 Numeric psf);
824
826 Numeric nself,
827 Numeric agam,
828 Numeric nair,
829 Numeric psf,
830 std::array<Numeric, 12> aer_interp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
831
832String ModelShape2MetaData(const Model& m);
833
834Model MetaData2ModelShape(const String& s);
835
836ArrayOfString ModelMetaDataArray(const Model& m, const bool self, const ArrayOfSpecies& sts, const Numeric T0);
837
838std::istream& from_artscat4(std::istream& is,
839 Type& type,
840 bool& self,
841 bool& bath,
842 Model& m,
843 ArrayOfSpecies& species,
844 const QuantumIdentifier& qid);
845
846std::istream& from_linefunctiondata(std::istream& data,
847 Type& type,
848 bool& self,
849 bool& bath,
850 Model& m,
851 ArrayOfSpecies& species);
852
854std::istream& from_linemixingdata(std::istream& data, Model& lsc);
855
857std::istream& from_pressurebroadeningdata(std::istream& data,
858 LineShape::Type& type,
859 bool& self,
860 bool& bath,
861 Model& m,
862 ArrayOfSpecies& species,
863 const QuantumIdentifier& qid);
864
866namespace LegacyLineFunctionData {
868#pragma GCC diagnostic push
869#pragma GCC diagnostic ignored "-Wreturn-type"
870constexpr Index temperaturemodel2legacynelem(TemperatureModel type) noexcept {
871 switch (type) {
872 case TemperatureModel::None:
873 return 0;
874 case TemperatureModel::T0:
875 return 1;
876 case TemperatureModel::T1:
877 return 2;
878 case TemperatureModel::T2:
879 return 3;
880 case TemperatureModel::T3:
881 return 2;
882 case TemperatureModel::T4:
883 return 3;
884 case TemperatureModel::T5:
885 return 2;
886 case TemperatureModel::LM_AER:
887 return 12;
888 case TemperatureModel::DPL:
889 return 4;
890 case TemperatureModel::POLY:
891 return 4;
892 case TemperatureModel::FINAL: break;
893 }
894 return -1;
895}
896#pragma GCC diagnostic pop
897
899std::vector<Variable> lineshapetag2variablesvector(String type);
900
902std::vector<Variable> linemixingtag2variablesvector(String type);
903}; // namespace LegacyLineFunctionData
904
906namespace LegacyLineMixingData {
908enum class TypeLM {
909 LM_NONE, // Reserved for no line mixing
910 LM_LBLRTM, // Reserved for LBLRTM line mixing
911 LM_LBLRTM_O2NonResonant, // Reserved for the non-resonant O2 line in LBLRTM
912 LM_1STORDER, // Reserved for Tretyakov et al. 2005 1st order of line mixing
913 LM_2NDORDER, // Reserved for Makarov et al. 2011 second order of line mixing
914 LM_BYBAND // Reserved for Paris data of relaxation matrix line mixing for band
915};
916
919
921#pragma GCC diagnostic push
922#pragma GCC diagnostic ignored "-Wreturn-type"
924 switch (type) {
925 case TypeLM::LM_NONE: // The standard case
926 return 0;
927 case TypeLM::LM_LBLRTM: // The LBLRTM case
928 return 12;
929 case TypeLM::LM_LBLRTM_O2NonResonant: // Nonresonant is just a tag
930 return 1;
931 case TypeLM::LM_2NDORDER: // The 2nd order case
932 return 10;
933 case TypeLM::LM_1STORDER: // The 2nd order case
934 return 3;
935 case TypeLM::LM_BYBAND: // The band class
936 return 1;
937 }
938 return -1;
939}
940#pragma GCC diagnostic pop
941
944}; // namespace LegacyLineMixingData
945
947namespace LegacyPressureBroadeningData {
949enum class TypePB {
950 PB_NONE, // No pressure broadening
951 PB_AIR_BROADENING, // Air broadening and self broadening only
952 PB_AIR_AND_WATER_BROADENING, // Air, water, and self broadening
953 PB_PLANETARY_BROADENING, // Gas broadening as done for solar system planets
954 // PB_SD_AIR_VOLUME, // HTP in air for SD limit NOT SUPPORTED
955 // PB_HTP_AIR_VOLUME, // HTP in air NOT SUPPORTED
956 // PB_VOIGT_TEST_WATER, // Voigt parameters for testing NOT SUPPORTED
957 // PB_SD_TEST_WATER, // SD parameters for testing NOT SUPPORTED
958 // PB_PURELY_FOR_TESTING // Testing tag for new input structures --- can be changed by anyone... NOT SUPPORTED
959};
960
963
967
969#pragma GCC diagnostic push
970#pragma GCC diagnostic ignored "-Wreturn-type"
972 switch (type) {
973 case TypePB::PB_NONE:
974 return 0;
976 return 10;
978 return 9;
980 return 20;
981 }
982 return -1;
983}
984#pragma GCC diagnostic pop
985
987void vector2modelpb(LineShape::Type& mtype,
988 bool& self,
989 bool& bath,
990 Model& m,
991 ArrayOfSpecies& species,
992 Vector x,
994 bool self_in_list,
995 Species::Species self_spec);
996}; // namespace LegacyPressureBroadeningData
997}; // namespace LineShape
998
1002
1003using LineShapeType = LineShape::Type;
1004using LineShapeVariable = LineShape::Variable;
1005using LineShapeTemperatureModel = LineShape::TemperatureModel;
1006
1007#endif // lineshapemodel_h
1008
Common ARTS conversions.
A constant view of a Vector.
Definition: matpackI.h:521
Main line shape model class.
Numeric D2(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
void resize(Index n)
Resize function for Model.
void SetLineMixingModel(SingleSpeciesModel x)
Sets the same line mixing model to all species.
void Remove(Index i, ArrayOfSpeciesTag &specs)
Remove species and data at position.
Numeric G0(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
SingleSpeciesModel & operator[](Index i)
Get a SingleSpeciesModel.
Model(const Model &m) noexcept
Init from copying itself.
Model(std::vector< SingleSpeciesModel > &&assm) noexcept
Init from moving a vector.
auto cend() const
Model(const std::vector< SingleSpeciesModel > &assm) noexcept
Init from copying a vector.
Numeric dD2dT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
Numeric dGdT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
Numeric dD0dT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
std::vector< SingleSpeciesModel > mdata
Model(Model &&m) noexcept
Init from moving a itself.
auto cbegin() const
Model(Index n=0) noexcept
Default init just sets the size.
Numeric ETA(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
friend std::ostream & operator<<(std::ostream &, const Model &)
Numeric dYdT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
void reserve(Index n)
Reserve function for Model.
Model & operator=(Model &&m)=default
Move and equals.
friend std::istream & from_linefunctiondata(std::istream &data, Type &type, bool &self, bool &bath, Model &m, ArrayOfSpecies &species)
Numeric dG0dT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
const SingleSpeciesModel & operator[](Index i) const
Get a SingleSpeciesModel.
Numeric G(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
bool OK(Type type, bool self, bool bath, const std::size_t nspecies) const noexcept
The Model is good to use.
Index nelem() const noexcept
Number of species in Model.
Numeric G2(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
friend std::istream & from_artscat4(std::istream &is, Type &type, bool &self, bool &bath, Model &m, ArrayOfSpecies &species, const QuantumIdentifier &qid)
std::vector< SingleSpeciesModel > & Data() noexcept
The line shape model data reference.
bifstream & read(bifstream &bif)
Binary read for Model.
Numeric FVC(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
bofstream & write(bofstream &bof) const
Binary write for Model.
Numeric Y(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
friend std::istream & operator>>(std::istream &, Model &)
Numeric dFVCdT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
const std::vector< SingleSpeciesModel > & Data() const noexcept
The line shape model data.
auto begin() const
Numeric DV(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
Numeric dG2dT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
Numeric dETAdT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
Index size() const
Number of species in Model.
std::pair< bool, bool > Match(const Model &other) const noexcept
Numeric D0(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
Numeric dDVdT(Numeric T, Numeric T0, Numeric P, const Vector &vmrs) const ARTS_NOEXCEPT
auto end() const
Model & operator=(const Model &m)=default
Copy and equals.
Compute the line shape parameters for a single broadening species.
constexpr const std::array< ModelParameters, nVars > & Data() const noexcept
Get const internal Data reference.
constexpr std::array< ModelParameters, nVars > & Data() noexcept
Get internal Data reference.
constexpr ModelParameters Get(Variable var) const noexcept
Get variable by type.
friend std::ostream & operator<<(std::ostream &os, const SingleSpeciesModel &ssm)
Output dT0(Numeric T, Numeric T0, Numeric P) const noexcept
Output at(Numeric T, Numeric T0, Numeric P) const noexcept
Numeric dX(Numeric T, Numeric T0, Numeric P, Jacobian::Line) const noexcept
std::array< ModelParameters, nVars > X
constexpr SingleSpeciesModel(ModelParameters G0=ModelParameters{}, ModelParameters D0=ModelParameters{}, ModelParameters G2=ModelParameters{}, ModelParameters D2=ModelParameters{}, ModelParameters FVC=ModelParameters{}, ModelParameters ETA=ModelParameters{}, ModelParameters Y=ModelParameters{}, ModelParameters G=ModelParameters{}, ModelParameters DV=ModelParameters{})
Default initialization.
bofstream & write(bofstream &bof) const
Binary write for SingleSpeciesModel.
bifstream & read(bifstream &bif)
Binary read for SingleSpeciesModel.
friend std::istream & operator>>(std::istream &is, SingleSpeciesModel &ssm)
constexpr void Set(Variable var, const ModelParameters &x) noexcept
Set variable to a different ModelParameters.
std::pair< bool, bool > MatchTypes(const SingleSpeciesModel &other) const noexcept
Output dT(Numeric T, Numeric T0, Numeric P) const noexcept
The Vector class.
Definition: matpackI.h:910
Binary output file stream class.
Definition: bifstream.h:43
Binary output file stream class.
Definition: bofstream.h:42
#define ARTS_NOEXCEPT
Definition: debug.h:99
#define ARTS_ASSERT(condition,...)
Definition: debug.h:102
#define ENUMCLASS(ENUMTYPE, TYPE,...)
Definition: enums.h:142
This file contains basic functions to handle ASCII files.
Routines for setting up the jacobian.
LineShape::TemperatureModel LineShapeTemperatureModel
LineShape::Variable LineShapeVariable
LineShape::Type LineShapeType
#define MODELPARAMCASEGETTER(X)
Jacobian::Line select_derivativeLineShape(const String &var, const String &coeff)
Return the derivative type based on string input.
#define MODELPARAMCASESETTER(X)
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
constexpr auto freq2kaycm(auto x) noexcept
Conversion from Hz to Kayser wavenumber.
std::vector< Variable > linemixingtag2variablesvector(String type)
Line mixing models from string.
std::vector< Variable > lineshapetag2variablesvector(String type)
Line shape models from string.
constexpr Index temperaturemodel2legacynelem(TemperatureModel type) noexcept
Length per variable for temperature model.
LegacyLineMixingData::TypeLM string2typelm(String type)
Line mixing types from string.
constexpr Index typelm2nelem(LegacyLineMixingData::TypeLM type)
Line mixing types to number.
Model vector2modellm(Vector x, LegacyLineMixingData::TypeLM type)
LineShape::Model from legacy input vector.
TypeLM
Line mixing types that used to exist.
Index self_listed(const QuantumIdentifier &qid, LegacyPressureBroadeningData::TypePB t)
Pressure broadening if self exist.
void vector2modelpb(LineShape::Type &mtype, bool &self, bool &bath, Model &m, ArrayOfSpecies &species, Vector x, LegacyPressureBroadeningData::TypePB type, bool self_in_list, Species::Species self_spec)
LineShape::Model from legacy input vector.
constexpr Index typepb2nelem(LegacyPressureBroadeningData::TypePB type)
Pressure broadening types to number of elements.
LegacyPressureBroadeningData::TypePB string2typepb(String type)
Pressure broadening types from string.
TypePB
Pressure broadening types that used to exist.
Computations of line shape derived parameters.
Definition: lineshape.cc:27
constexpr Output negativeOutput(Output x) noexcept
Output turned negative.
Model lblrtm_model(Numeric sgam, Numeric nself, Numeric agam, Numeric nair, Numeric psf, std::array< Numeric, 12 > aer_interp)
constexpr Output differenceOutput(Output y, Output x) noexcept
Diff of two output.
Numeric & SingleModelParameter(ModelParameters &mp, const String &type)
Get a coefficient from ModelParameters by name.
constexpr Output mirroredOutput(Output x) noexcept
Output to be used by mirroring calls.
constexpr std::string_view bath_broadening
Name for bath broadening in printing and reading user input.
Model MetaData2ModelShape(const String &s)
constexpr ModelParameters modelparameterGetEmpty(const TemperatureModel t) noexcept
std::istream & from_linefunctiondata(std::istream &data, Type &type, bool &self, bool &bath, Model &m, ArrayOfSpecies &species)
constexpr bool modelparameterEmpty(const ModelParameters mp) noexcept
Model hitran_model(Numeric sgam, Numeric nself, Numeric agam, Numeric nair, Numeric psf)
constexpr Numeric modelparameterFirstExponent(const ModelParameters mp) noexcept
Vector mass(const ConstVectorView &atmospheric_vmrs, const ArrayOfArrayOfSpeciesTag &atmospheric_species, const ArrayOfSpecies &lineshape_species, const SpeciesIsotopologueRatios &ir) ARTS_NOEXCEPT
Returns a mass vector for this model's main calculations.
constexpr std::string_view self_broadening
Name for self broadening in printing and reading user input.
std::istream & from_pressurebroadeningdata(std::istream &data, LineShape::Type &type, bool &self, bool &bath, Model &m, ArrayOfSpecies &species, const QuantumIdentifier &qid)
Legacy reading of old deprecated PressureBroadeningData class.
ArrayOfString ModelMetaDataArray(const LineShape::Model &m, const bool self, const ArrayOfSpecies &sts, const Numeric T0)
String modelparameters2metadata(const ModelParameters mp, const Numeric T0)
std::istream & operator>>(std::istream &is, Model &m)
constexpr Output si2cgs(Output x) noexcept
Output turned from SI to CGS units.
String ModelShape2MetaData(const Model &m)
std::istream & from_artscat4(std::istream &is, Type &type, bool &self, bool &bath, Model &m, ArrayOfSpecies &species, const QuantumIdentifier &qid)
std::ostream & operator<<(std::ostream &os, const Model &m)
std::istream & from_linemixingdata(std::istream &data, Model &lsc)
Legacy reading of old deprecated LineMixingData class.
constexpr Index nVars
Current max number of line shape variables.
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.
#define N
Definition: rng.cc:164
Coefficients and temperature model for SingleSpeciesModel.
static constexpr Numeric special_linemixing_aer_dX1(Numeric T) noexcept
The derivative of special_linemixing_aer wrt X1.
constexpr ModelParameters(TemperatureModel intype, VectorType &&v) ARTS_NOEXCEPT
static constexpr Numeric special_linemixing_aer_dX0(Numeric T) noexcept
The derivative of special_linemixing_aer wrt X0.
constexpr Numeric special_linemixing_aer_dT(Numeric T) const noexcept
The temperature derivative of special_linemixing_aer.
static constexpr Numeric special_linemixing_aer_dX2(Numeric T) noexcept
The derivative of special_linemixing_aer wrt X2.
static constexpr Numeric special_linemixing_aer_dX3(Numeric T) noexcept
The derivative of special_linemixing_aer wrt X3.
constexpr ModelParameters(TemperatureModel intype=TemperatureModel::None, Numeric inX0=std::numeric_limits< Numeric >::quiet_NaN(), Numeric inX1=std::numeric_limits< Numeric >::quiet_NaN(), Numeric inX2=std::numeric_limits< Numeric >::quiet_NaN(), Numeric inX3=std::numeric_limits< Numeric >::quiet_NaN()) noexcept
constexpr Numeric special_linemixing_aer(Numeric T) const noexcept
Line mixing as done by AER data in ARTS.
Main output of Model.
constexpr Output(const Output &) noexcept=default
constexpr Output & no_linemixing(bool do_no_linemixing)
Turns of line mixing if true. Return *this.
friend std::ostream & operator<<(std::ostream &os, Output x)
constexpr Output() noexcept=default
constexpr Output(Output &&) noexcept=default
A logical struct for global quantum numbers with species identifiers.
#define v