ARTS 2.5.9 (git: 825fa5f2)
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 {
64
74ENUMCLASS(TemperatureModel, char,
75 None, // 0
76 T0, // Constant, X0
77 T1, // Standard, X0 * (T0/T) ^ X1
78 T2, // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
79 T3, // X0 + X1 * (T - T0)
80 T4, // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
81 T5, // X0 * (T0/T)^(0.25 + 1.5*X1)
82 LM_AER, // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
83 DPL, // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
84 POLY // X0 + X1 * T + X2 * T ^ 2 + X3 * T ^ 3
85)
86
87
91ENUMCLASS(Variable, char,
92 G0, // Pressure broadening speed-independent
93 D0, // Pressure f-shifting speed-dependent
94 G2, // Pressure broadening speed-dependent
95 D2, // Pressure f-shifting speed-independent
96 FVC, // Frequency of velocity-changing collisions
97 ETA, // Correlation
98 Y, // First order line mixing coefficient
99 G, // Second order line mixing coefficient
100 DV // Second order line mixing f-shifting
101)
102
108 static constexpr Index N = 4;
109 static_assert(Index(Options::LineShapeCoeff::FINAL) == N, "Must update either LineShapeCoeff options or ModelParameters");
110 TemperatureModel type;
115
116 constexpr ModelParameters(TemperatureModel intype=TemperatureModel::None,
117 Numeric inX0=std::numeric_limits<Numeric>::quiet_NaN(),
118 Numeric inX1=std::numeric_limits<Numeric>::quiet_NaN(),
119 Numeric inX2=std::numeric_limits<Numeric>::quiet_NaN(),
120 Numeric inX3=std::numeric_limits<Numeric>::quiet_NaN())
121 noexcept : type(intype), X0(inX0), X1(inX1), X2(inX2), X3(inX3) {}
122
123 template <typename VectorType> constexpr
124 ModelParameters(TemperatureModel intype, VectorType&& v) ARTS_NOEXCEPT :
125 ModelParameters(intype) {
126 const auto n = std::size(v);
127 ARTS_ASSERT(n <= N, "Must have at most ", N, " inputs, got: ", n)
128 switch (n) {
129 case 4: X3 = v[3]; [[fallthrough]];
130 case 3: X2 = v[2]; [[fallthrough]];
131 case 2: X1 = v[1]; [[fallthrough]];
132 case 1: X0 = v[0];
133 }
134 }
135
147 [[nodiscard]] constexpr Numeric special_linemixing_aer(Numeric T) const noexcept {
148 if (T < 250.0)
149 return X0 + (T - 200.0) * (X1 - X0) / (250.0 - 200.0);
150 if (T > 296.0)
151 return X2 + (T - 296.0) * (X3 - X2) / (340.0 - 296.0);
152 return X1 + (T - 250.0) * (X2 - X1) / (296.0 - 250.0);
153 }
154
162 [[nodiscard]] constexpr Numeric special_linemixing_aer_dT(Numeric T) const noexcept {
163 if (T < 250.0)
164 return (X1 - X0) / (250.0 - 200.0);
165 if (T > 296.0)
166 return (X3 - X2) / (340.0 - 296.0);
167 return (X2 - X1) / (296.0 - 250.0);
168 }
169
176 static constexpr Numeric special_linemixing_aer_dX0(Numeric T) noexcept {
177 if (T < 250.0)
178 return 1 - (T - 200.0) / (250.0 - 200.0);
179 return 0;
180 }
181
188 static constexpr Numeric special_linemixing_aer_dX1(Numeric T) noexcept {
189 if (T < 250.0)
190 return (T - 200.0) / (250.0 - 200.0);
191 if (T > 296.0)
192 return 0;
193 return 1 - (T - 250.0) / (296.0 - 250.0);
194 }
195
202 static constexpr Numeric special_linemixing_aer_dX2(Numeric T) noexcept {
203 if (T < 250.0)
204 return 0;
205 if (T > 296.0)
206 return 1 - (T - 296.0) / (340.0 - 296.0);
207 return (T - 250.0) / (296.0 - 250.0);
208 }
209
216 static constexpr Numeric special_linemixing_aer_dX3(Numeric T) noexcept {
217 if (T > 296.0)
218 return (T - 296.0) / (340.0 - 296.0);
219 return 0;
220 }
221
222 [[nodiscard]] Numeric at(Numeric T, Numeric T0) const noexcept;
223
224 [[nodiscard]] [[nodiscard]] Numeric dX0(Numeric T, Numeric T0) const noexcept;
225
226 [[nodiscard]] Numeric dX1(Numeric T, Numeric T0) const noexcept;
227
228 [[nodiscard]] Numeric dX2(Numeric T, Numeric T0) const noexcept;
229
230 [[nodiscard]] Numeric dX3(Numeric T, Numeric T0) const noexcept;
231
232 [[nodiscard]] Numeric dT(Numeric T, Numeric T0) const noexcept;
233
234 [[nodiscard]] Numeric dT0(Numeric T, Numeric T0) const noexcept;
235
236 friend std::ostream& operator<<(std::ostream& os, const ModelParameters& mp);
237
238 friend std::istream& operator>>(std::istream& is, ModelParameters& mp);
239};
240
241String modelparameters2metadata(const ModelParameters mp, const Numeric T0);
242
252Numeric& SingleModelParameter(ModelParameters& mp, const String& type);
253
254constexpr ModelParameters modelparameterGetEmpty(const TemperatureModel t) noexcept {
255 switch(t) {
256 case TemperatureModel::None: // 0
257 return {TemperatureModel::None, 0, 0, 0, 0};
258 case TemperatureModel::T0: // Constant, X0
259 return {TemperatureModel::T0, 0, 0, 0, 0};
260 case TemperatureModel::T1: // Standard, X0 * (T0/T) ^ X1
261 return {TemperatureModel::T1, 0, 0, 0, 0};
262 case TemperatureModel::T2: // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
263 return {TemperatureModel::T2, 0, 0, 0, 0};
264 case TemperatureModel::T3: // X0 + X1 * (T - T0)
265 return {TemperatureModel::T3, 0, 0, 0, 0};
266 case TemperatureModel::T4: // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
267 return {TemperatureModel::T4, 0, 0, 0, 0};
268 case TemperatureModel::T5: // X0 * (T0/T)^(0.25 + 1.5*X1)
269 return {TemperatureModel::T5, 0, 0, 0, 0};
270 case TemperatureModel::LM_AER: // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
271 return {TemperatureModel::LM_AER, 0, 0, 0, 0};
272 case TemperatureModel::DPL: // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
273 return {TemperatureModel::DPL, 0, 0, 0, 0};
274 case TemperatureModel::POLY:
275 return {TemperatureModel::POLY, 0, 0, 0, 0};
276 case TemperatureModel::FINAL:
277 return {TemperatureModel::None, 0, 0, 0, 0};
278 }
279 return {TemperatureModel::None, 0, 0, 0, 0};
280}
281
282constexpr bool modelparameterEmpty(const ModelParameters mp) noexcept {
283 switch(mp.type) {
284 case TemperatureModel::None: // 0
285 return true;
286 case TemperatureModel::T0: // Constant, X0
287 return (mp.X0 == 0);
288 case TemperatureModel::T1: // Standard, X0 * (T0/T) ^ X1
289 return (mp.X0 == 0);
290 case TemperatureModel::T2: // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
291 return (mp.X0 == 0);
292 case TemperatureModel::T3: // X0 + X1 * (T - T0)
293 return (mp.X0 == 0 and mp.X1 == 0);
294 case TemperatureModel::T4: // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
295 return (mp.X0 == 0 and mp.X1 == 0);
296 case TemperatureModel::T5: // X0 * (T0/T)^(0.25 + 1.5*X1)
297 return (mp.X0 == 0);
298 case TemperatureModel::LM_AER: // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
299 return (mp.X0 == 0 and mp.X1 == 0 and mp.X2 == 0 and mp.X3 == 0);
300 case TemperatureModel::DPL: // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
301 return (mp.X0 == 0 and mp.X2 == 0);
302 case TemperatureModel::POLY:
303 return (mp.X0 == 0 and mp.X1 == 0 and mp.X2 == 0 and mp.X3 == 0);
304 case TemperatureModel::FINAL:
305 return true;
306 }
307 return true;
308}
309
311 switch(mp.type) {
312 case TemperatureModel::None: // 0
313 return 0;
314 case TemperatureModel::T0: // Constant, X0
315 return 0;
316 case TemperatureModel::T1: // Standard, X0 * (T0/T) ^ X1
317 return mp.X1;
318 case TemperatureModel::T2: // X0 * (T0/T) ^ X1 * (1 + X2 * log(T/T0));
319 return mp.X1;
320 case TemperatureModel::T3: // X0 + X1 * (T - T0)
321 return 0;
322 case TemperatureModel::T4: // (X0 + X1 * (T0/T - 1)) * (T0/T)^X2;
323 return mp.X2;
324 case TemperatureModel::T5: // X0 * (T0/T)^(0.25 + 1.5*X1)
325 return (0.25 + 1.5*mp.X1);
326 case TemperatureModel::LM_AER: // X(200) = X0; X(250) = X1; X(298) = X2; X(340) = X3; Linear interpolation in between
327 return 0;
328 case TemperatureModel::DPL: // X0 * (T0/T) ^ X1 + X2 * (T0/T) ^ X3
329 return mp.X1;
330 case TemperatureModel::POLY:
331 return 0;
332 case TemperatureModel::FINAL:
333 return std::numeric_limits<Numeric>::quiet_NaN();
334 }
335 return std::numeric_limits<Numeric>::quiet_NaN();
336}
337
339constexpr Index nVars = Index(Variable::FINAL);
340
343 private:
344 std::array<ModelParameters, nVars> X;
345
346 public:
351 ModelParameters G2=ModelParameters{},
352 ModelParameters D2=ModelParameters{},
353 ModelParameters FVC=ModelParameters{},
354 ModelParameters ETA=ModelParameters{},
355 ModelParameters Y=ModelParameters{},
356 ModelParameters G=ModelParameters{},
357 ModelParameters DV=ModelParameters{})
358 : X({G0, D0, G2, D2, FVC, ETA, Y, G, DV}) {}
359
360#define ACCESS_INTERNAL(VARPOS) \
361 constexpr ModelParameters& VARPOS() noexcept { return std::get<Index(Variable::VARPOS)>(X); } \
362 constexpr ModelParameters VARPOS() const noexcept { return std::get<Index(Variable::VARPOS)>(X); }
372#undef ACCESS_INTERNAL
373
375 constexpr std::array<ModelParameters, nVars>& Data() noexcept { return X; }
376
378 [[nodiscard]] constexpr const std::array<ModelParameters, nVars>& Data() const noexcept { return X; }
379
385 constexpr void Set(Variable var, const ModelParameters& x) noexcept {
386#define MODELPARAMCASESETTER(X) \
387 case Variable::X: \
388 X() = x; \
389 break
390 switch (var) {
400 case Variable::FINAL: break;
401 }
402#undef MODELPARAMCASESETTER
403 }
404
411 [[nodiscard]] constexpr ModelParameters Get(Variable var) const noexcept {
412 #define MODELPARAMCASEGETTER(X) case Variable::X: out = X(); break;
413 ModelParameters out{};
414 switch (var) {
424 case Variable::FINAL: break;
425 }
426 return out;
427 #undef MODELPARAMCASEGETTER
428 }
429
431 bifstream& read(bifstream& bif);
432
434 bofstream& write(bofstream& bof) const;
435
436 [[nodiscard]] std::pair<bool, bool> MatchTypes(const SingleSpeciesModel& other) const noexcept;
437
438 friend std::ostream& operator<<(std::ostream& os, const SingleSpeciesModel& ssm);
439
440 friend std::istream& operator>>(std::istream& is, SingleSpeciesModel& ssm);
441};
442
444ENUMCLASS(Type, char,
445 DP, // Doppler
446 LP, // Lorentz
447 VP, // Voigt
448 SDVP, // Speed-dependent Voigt
449 HTP // Hartmann-Tran
450)
451
452
461#pragma GCC diagnostic push
462#pragma GCC diagnostic ignored "-Wreturn-type"
463constexpr std::string_view shapetype2metadatastring(Type type) noexcept {
464 switch (type) {
465 case Type::DP:
466 return "The line shape type is the Doppler profile\n";
467 case Type::LP:
468 return "The line shape type is the Lorentz profile.\n";
469 case Type::VP:
470 return "The line shape type is the Voigt profile.\n";
471 case Type::SDVP:
472 return "The line shape type is the speed-dependent Voigt profile.\n";
473 case Type::HTP:
474 return "The line shape type is the Hartmann-Tran profile.\n";
475 case Type::FINAL: {}
476 }
477 return "There's an error.\n";
478}
479#pragma GCC diagnostic pop
480
482struct Output {
483 Numeric G0{0}, // Pressure broadening speed-independent
484 D0{0}, // Pressure f-shifting speed-independent
485 G2{0}, // Pressure broadening speed-dependent
486 D2{0}, // Pressure f-shifting speed-dependent
487 FVC{0}, // Frequency of velocity-changing collisions
488 ETA{0}, // Correlation
489 Y{0}, // First order line mixing coefficient
490 G{0}, // Second order line mixing coefficient
491 DV{0}; // Second order line mixing f-shifting
492 constexpr Output() noexcept = default;
493 constexpr Output(Numeric g0, Numeric d0, Numeric g2,
494 Numeric d2, Numeric fvc, Numeric eta,
495 Numeric y, Numeric g, Numeric dv) noexcept :
496 G0(g0), D0(d0), G2(g2), D2(d2), FVC(fvc), ETA(eta), Y(y), G(g), DV(dv) {}
497 constexpr Output(const Output&) noexcept = default;
498 constexpr Output(Output&&) noexcept = default;
499 constexpr Output& operator=(const Output&) noexcept = default;
500 constexpr Output& operator=(Output&&) noexcept = default;
501
502 friend std::ostream& operator<<(std::ostream& os, Output x);
503};
504
506constexpr Output mirroredOutput(Output x) noexcept {
507 return {x.G0, -x.D0, x.G2, -x.D2, x.FVC, x.ETA, x.Y, x.G, -x.DV};
508}
509
511constexpr Output negativeOutput(Output x) noexcept {
512 return {-x.G0, -x.D0, -x.G2, -x.D2, -x.FVC, -x.ETA, -x.Y, -x.G, -x.DV};
513}
514
516constexpr Output si2cgs(Output x) noexcept {
518 return {freq2kaycm(x.G0),
519 freq2kaycm(x.D0),
520 freq2kaycm(x.D2),
521 freq2kaycm(x.G2),
522 freq2kaycm(x.FVC),
523 x.ETA,
524 x.Y,
525 x.G,
526 freq2kaycm(x.DV)};
527}
528
530constexpr Output differenceOutput(Output y, Output x) noexcept {
531 return {y.G0 - x.G0,
532 y.D0 - x.D0,
533 y.G2 - x.G2,
534 y.D2 - x.D2,
535 y.FVC - x.FVC,
536 y.ETA - x.ETA,
537 y.Y - x.Y,
538 y.G - x.G,
539 y.DV - x.DV};
540}
541
556Vector vmrs(const ConstVectorView& atmospheric_vmrs,
557 const ArrayOfArrayOfSpeciesTag& atmospheric_species,
558 const ArrayOfSpecies& lineshape_species) ARTS_NOEXCEPT;
559
574Vector mass(const ConstVectorView& atmospheric_vmrs,
575 const ArrayOfArrayOfSpeciesTag& atmospheric_species,
576 const ArrayOfSpecies& lineshape_species,
578
580static constexpr std::string_view bath_broadening = "AIR";
581
583static constexpr std::string_view self_broadening = "SELF";
584
589class Model {
590 private:
591 std::vector<SingleSpeciesModel> mdata;
592
593 public:
595 Model(Index n=0) noexcept : mdata(n) {}
596
598 explicit Model(const std::vector<SingleSpeciesModel>& assm) noexcept : mdata(assm) {}
599
601 Model(const Model& m) noexcept : Model(m.mdata) {}
602
604 explicit Model(std::vector<SingleSpeciesModel>&& assm) noexcept : mdata(std::move(assm)) {}
605
607 Model(Model&& m) noexcept : Model(std::move(m.mdata)) {}
608
610 Model& operator=(const Model& m) = default;
611
613 Model& operator=(Model&& m) = default;
614
624 Model(Numeric sgam,
625 Numeric nself,
626 Numeric agam,
627 Numeric nair,
628 Numeric psf,
629 std::array<Numeric, 12> aer_interp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) noexcept;
630
635 [[nodiscard]] bool OK(Type type, bool self, bool bath,
636 const std::size_t nspecies) const noexcept;
637
638#define LSPC(XVAR, PVAR) \
639 Numeric XVAR( \
640 Numeric T, Numeric T0, Numeric P [[maybe_unused]], const ConstVectorView& vmrs) \
641 const noexcept;
642 LSPC(G0, P)
643 LSPC(D0, P)
644 LSPC(G2, P)
645 LSPC(D2, P)
646 LSPC(FVC, P)
647 LSPC(ETA, 1)
648 LSPC(Y, P)
649 LSPC(G, P* P)
650 LSPC(DV, P* P)
651#undef LSPC
652
653#define LSPCV(XVAR, PVAR) \
654 Numeric d##XVAR##_dVMR(Numeric T, \
655 Numeric T0, \
656 Numeric P [[maybe_unused]], \
657 const Index deriv_pos) const noexcept;
658 LSPCV(G0, P)
659 LSPCV(D0, P)
660 LSPCV(G2, P)
661 LSPCV(D2, P)
662 LSPCV(FVC, P)
663 LSPCV(ETA, 1)
664 LSPCV(Y, P)
665 LSPCV(G, P* P)
666 LSPCV(DV, P* P)
667#undef LSPCV
668
669#define LSPCT(XVAR, PVAR) \
670 Numeric d##XVAR##_dT( \
671 Numeric T, Numeric T0, Numeric P [[maybe_unused]], const ConstVectorView& vmrs) \
672 const noexcept;
673 LSPCT(G0, P)
674 LSPCT(D0, P)
675 LSPCT(G2, P)
676 LSPCT(D2, P)
677 LSPCT(FVC, P)
678 LSPCT(ETA, 1)
679 LSPCT(Y, P)
680 LSPCT(G, P* P)
681 LSPCT(DV, P* P)
682#undef LSPCT
683
684// All shape model derivatives
685#define LSPDC(XVAR, DERIV, PVAR) \
686 Numeric d##XVAR##DERIV(Numeric T, \
687 Numeric T0, \
688 Numeric P [[maybe_unused]], \
689 Index deriv_pos, \
690 const ConstVectorView& vmrs) const noexcept;
691 LSPDC(G0, _dT0, P)
692 LSPDC(G0, _dX0, P)
693 LSPDC(G0, _dX1, P)
694 LSPDC(G0, _dX2, P)
695 LSPDC(G0, _dX3, P)
696 LSPDC(D0, _dT0, P)
697 LSPDC(D0, _dX0, P)
698 LSPDC(D0, _dX1, P)
699 LSPDC(D0, _dX2, P)
700 LSPDC(D0, _dX3, P)
701 LSPDC(G2, _dT0, P)
702 LSPDC(G2, _dX0, P)
703 LSPDC(G2, _dX1, P)
704 LSPDC(G2, _dX2, P)
705 LSPDC(G2, _dX3, P)
706 LSPDC(D2, _dT0, P)
707 LSPDC(D2, _dX0, P)
708 LSPDC(D2, _dX1, P)
709 LSPDC(D2, _dX2, P)
710 LSPDC(D2, _dX3, P)
711 LSPDC(FVC, _dT0, P)
712 LSPDC(FVC, _dX0, P)
713 LSPDC(FVC, _dX1, P)
714 LSPDC(FVC, _dX2, P)
715 LSPDC(FVC, _dX3, P)
716 LSPDC(ETA, _dT0, 1)
717 LSPDC(ETA, _dX0, 1)
718 LSPDC(ETA, _dX1, 1)
719 LSPDC(ETA, _dX2, 1)
720 LSPDC(ETA, _dX3, 1)
721 LSPDC(Y, _dT0, P)
722 LSPDC(Y, _dX0, P)
723 LSPDC(Y, _dX1, P)
724 LSPDC(Y, _dX2, P)
725 LSPDC(Y, _dX3, P)
726 LSPDC(G, _dT0, P* P)
727 LSPDC(G, _dX0, P* P)
728 LSPDC(G, _dX1, P* P)
729 LSPDC(G, _dX2, P* P)
730 LSPDC(G, _dX3, P* P)
731 LSPDC(DV, _dT0, P* P)
732 LSPDC(DV, _dX0, P* P)
733 LSPDC(DV, _dX1, P* P)
734 LSPDC(DV, _dX2, P* P)
735 LSPDC(DV, _dX3, P* P)
736#undef LSPDC
737
747 [[nodiscard]] Output GetParams(Numeric T,
748 Numeric T0,
749 Numeric P,
750 const ConstVectorView& vmrs) const noexcept;
751
761 [[nodiscard]] Output GetParams(Numeric T,
762 Numeric T0,
763 Numeric P,
764 size_t k) const noexcept;
765
775 [[nodiscard]] Output GetTemperatureDerivs(Numeric T,
776 Numeric T0,
777 Numeric P,
778 ConstVectorView vmrs) const noexcept;
779
789 [[nodiscard]] Output GetVMRDerivs(Numeric T, Numeric T0, Numeric P, const Index pos) const noexcept;
790
802 [[nodiscard]] Numeric GetInternalDeriv(Numeric T,
803 Numeric T0,
804 Numeric P,
805 Index pos,
806 const Vector& vmrs,
807 Jacobian::Line deriv) const noexcept;
808
810 [[nodiscard]] Index nelem() const noexcept { return Index(mdata.size()); }
811
813 [[nodiscard]] Index size() const { return Index(mdata.size()); }
814
821 void resize(Index n) {mdata.resize(n);}
822
829 void reserve(Index n) {mdata.reserve(n);}
830
836 SingleSpeciesModel& operator[](Index i) {return mdata[i];}
837
843 const SingleSpeciesModel& operator[](Index i) const {return mdata[i];}
844
845 auto begin() { return mdata.begin(); }
846 auto end() { return mdata.end(); }
847
849 [[nodiscard]] const std::vector<SingleSpeciesModel>& Data() const noexcept { return mdata; }
850
852 std::vector<SingleSpeciesModel>& Data() noexcept { return mdata; }
853
861 void Remove(Index i, ArrayOfSpeciesTag& specs);
862 void Remove(Index i, ArrayOfSpecies& specs);
863
874 void SetLineMixingModel(SingleSpeciesModel x);
875
876 [[nodiscard]] std::pair<bool, bool> Match(const Model& other) const noexcept;
877
878 friend
879 std::istream& from_linefunctiondata(std::istream& data,
880 Type& type,
881 bool& self,
882 bool& bath,
883 Model& m,
884 ArrayOfSpecies& species);
885
886 friend
887 std::istream& from_artscat4(std::istream& is,
888 Type& type,
889 bool& self,
890 bool& bath,
891 Model& m,
892 ArrayOfSpecies& species,
893 const QuantumIdentifier& qid);
894
895 friend std::ostream& operator<<(std::ostream&, const Model&);
896
897 friend std::istream& operator>>(std::istream&, Model&);
898
900 bifstream& read(bifstream& bif);
901
903 bofstream& write(bofstream& bof) const;
904}; // Model;
905
906
908 Numeric nself,
909 Numeric agam,
910 Numeric nair,
911 Numeric psf);
912
914 Numeric nself,
915 Numeric agam,
916 Numeric nair,
917 Numeric psf,
918 std::array<Numeric, 12> aer_interp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
919
920String ModelShape2MetaData(const Model& m);
921
922Model MetaData2ModelShape(const String& s);
923
924ArrayOfString ModelMetaDataArray(const Model& m, const bool self, const ArrayOfSpecies& sts, const Numeric T0);
925
926std::istream& from_artscat4(std::istream& is,
927 Type& type,
928 bool& self,
929 bool& bath,
930 Model& m,
931 ArrayOfSpecies& species,
932 const QuantumIdentifier& qid);
933
934std::istream& from_linefunctiondata(std::istream& data,
935 Type& type,
936 bool& self,
937 bool& bath,
938 Model& m,
939 ArrayOfSpecies& species);
940
942std::istream& from_linemixingdata(std::istream& data, Model& lsc);
943
945std::istream& from_pressurebroadeningdata(std::istream& data,
946 LineShape::Type& type,
947 bool& self,
948 bool& bath,
949 Model& m,
950 ArrayOfSpecies& species,
951 const QuantumIdentifier& qid);
952
954namespace LegacyLineFunctionData {
956#pragma GCC diagnostic push
957#pragma GCC diagnostic ignored "-Wreturn-type"
958constexpr Index temperaturemodel2legacynelem(TemperatureModel type) noexcept {
959 switch (type) {
960 case TemperatureModel::None:
961 return 0;
962 case TemperatureModel::T0:
963 return 1;
964 case TemperatureModel::T1:
965 return 2;
966 case TemperatureModel::T2:
967 return 3;
968 case TemperatureModel::T3:
969 return 2;
970 case TemperatureModel::T4:
971 return 3;
972 case TemperatureModel::T5:
973 return 2;
974 case TemperatureModel::LM_AER:
975 return 12;
976 case TemperatureModel::DPL:
977 return 4;
978 case TemperatureModel::POLY:
979 return 4;
980 case TemperatureModel::FINAL: break;
981 }
982 return -1;
983}
984#pragma GCC diagnostic pop
985
987std::vector<Variable> lineshapetag2variablesvector(String type);
988
990std::vector<Variable> linemixingtag2variablesvector(String type);
991}; // namespace LegacyLineFunctionData
992
994namespace LegacyLineMixingData {
996enum class TypeLM {
997 LM_NONE, // Reserved for no line mixing
998 LM_LBLRTM, // Reserved for LBLRTM line mixing
999 LM_LBLRTM_O2NonResonant, // Reserved for the non-resonant O2 line in LBLRTM
1000 LM_1STORDER, // Reserved for Tretyakov et al. 2005 1st order of line mixing
1001 LM_2NDORDER, // Reserved for Makarov et al. 2011 second order of line mixing
1002 LM_BYBAND // Reserved for Paris data of relaxation matrix line mixing for band
1003};
1004
1006LegacyLineMixingData::TypeLM string2typelm(String type);
1007
1009#pragma GCC diagnostic push
1010#pragma GCC diagnostic ignored "-Wreturn-type"
1012 switch (type) {
1013 case TypeLM::LM_NONE: // The standard case
1014 return 0;
1015 case TypeLM::LM_LBLRTM: // The LBLRTM case
1016 return 12;
1017 case TypeLM::LM_LBLRTM_O2NonResonant: // Nonresonant is just a tag
1018 return 1;
1019 case TypeLM::LM_2NDORDER: // The 2nd order case
1020 return 10;
1021 case TypeLM::LM_1STORDER: // The 2nd order case
1022 return 3;
1023 case TypeLM::LM_BYBAND: // The band class
1024 return 1;
1025 }
1026 return -1;
1027}
1028#pragma GCC diagnostic pop
1029
1031Model vector2modellm(Vector x, LegacyLineMixingData::TypeLM type);
1032}; // namespace LegacyLineMixingData
1033
1035namespace LegacyPressureBroadeningData {
1037enum class TypePB {
1038 PB_NONE, // No pressure broadening
1039 PB_AIR_BROADENING, // Air broadening and self broadening only
1040 PB_AIR_AND_WATER_BROADENING, // Air, water, and self broadening
1041 PB_PLANETARY_BROADENING, // Gas broadening as done for solar system planets
1042 // PB_SD_AIR_VOLUME, // HTP in air for SD limit NOT SUPPORTED
1043 // PB_HTP_AIR_VOLUME, // HTP in air NOT SUPPORTED
1044 // PB_VOIGT_TEST_WATER, // Voigt parameters for testing NOT SUPPORTED
1045 // PB_SD_TEST_WATER, // SD parameters for testing NOT SUPPORTED
1046 // PB_PURELY_FOR_TESTING // Testing tag for new input structures --- can be changed by anyone... NOT SUPPORTED
1047};
1048
1051
1053Index self_listed(const QuantumIdentifier& qid,
1055
1057#pragma GCC diagnostic push
1058#pragma GCC diagnostic ignored "-Wreturn-type"
1060 switch (type) {
1061 case TypePB::PB_NONE:
1062 return 0;
1063 case TypePB::PB_AIR_BROADENING:
1064 return 10;
1065 case TypePB::PB_AIR_AND_WATER_BROADENING:
1066 return 9;
1067 case TypePB::PB_PLANETARY_BROADENING:
1068 return 20;
1069 }
1070 return -1;
1071}
1072#pragma GCC diagnostic pop
1073
1075void vector2modelpb(LineShape::Type& mtype,
1076 bool& self,
1077 bool& bath,
1078 Model& m,
1079 ArrayOfSpecies& species,
1080 Vector x,
1082 bool self_in_list,
1083 Species::Species self_spec);
1084}; // namespace LegacyPressureBroadeningData
1085}; // namespace LineShape
1086
1090
1091using LineShapeType = LineShape::Type;
1092using LineShapeVariable = LineShape::Variable;
1093using LineShapeTemperatureModel = LineShape::TemperatureModel;
1094
1095#endif // lineshapemodel_h
1096
std::ostream & operator<<(std::ostream &os, AbsorptionCutoffTagTypeStatus val)
Common ARTS conversions.
std::istream & operator>>(std::istream &is, Time &t)
Definition: artstime.cc:122
A constant view of a Vector.
Definition: matpackI.h:521
Main line shape model class.
void resize(Index n)
Resize function for Model.
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.
Model(const std::vector< SingleSpeciesModel > &assm) noexcept
Init from copying a vector.
std::vector< SingleSpeciesModel > mdata
Model(Model &&m) noexcept
Init from moving a itself.
Model(Index n=0) noexcept
Default init just sets the size.
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)
const SingleSpeciesModel & operator[](Index i) const
Get a SingleSpeciesModel.
Index nelem() const noexcept
Number of species in Model.
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.
const std::vector< SingleSpeciesModel > & Data() const noexcept
The line shape model data.
Index size() const
Number of species in Model.
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)
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
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:79
#define ARTS_ASSERT(condition,...)
Definition: debug.h:82
#define ENUMCLASS(ENUMTYPE, TYPE,...)
Definition: enums.h:142
This file contains basic functions to handle ASCII files.
Routines for setting up the jacobian.
#define LSPCV(XVAR, PVAR)
#define LSPCT(XVAR, PVAR)
#define LSPC(XVAR, PVAR)
#define LSPDC(XVAR, DERIV, PVAR)
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.
constexpr Index temperaturemodel2legacynelem(TemperatureModel type) noexcept
Length per variable for temperature model.
constexpr Index typelm2nelem(LegacyLineMixingData::TypeLM type)
Line mixing types to number.
TypeLM
Line mixing types that used to exist.
constexpr Index typepb2nelem(LegacyPressureBroadeningData::TypePB type)
Pressure broadening types to number of elements.
TypePB
Pressure broadening types that used to exist.
Computations of line shape derived parameters.
Definition: lineshape.cc:23
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 ModelParameters modelparameterGetEmpty(const TemperatureModel t) noexcept
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
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.
std::ostream & operator<<(std::ostream &os, const Model &m)
constexpr Index nVars
Current max number of line shape variables.
#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.
A logical struct for global quantum numbers with species identifiers.
#define v