34#ifndef lineshapemodel_h
35#define lineshapemodel_h
86constexpr std::string_view shapetype2metadatastring(Type type)
noexcept {
89 return "The line shape type is the Doppler profile\n";
91 return "The line shape type is the Lorentz profile.\n";
93 return "The line shape type is the Voigt profile.\n";
95 return "The line shape type is the speed-dependent Voigt profile.\n";
97 return "The line shape type is the Hartmann-Tran profile.\n";
99 return "The line shape type is the Lorentz profile per broadener.\n";
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";
105 return "The line shape type is the Hartmann-Tran profile per broadener.\n";
108 return "There's an error.\n";
124constexpr bool independent_per_broadener(Type in) {
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);
176 static_assert(
Index(Options::LineShapeCoeff::FINAL) ==
N,
"Must update either LineShapeCoeff options or ModelParameters");
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) {}
190 template <
typename VectorType>
constexpr
193 const auto n = std::size(
v);
194 ARTS_ASSERT(n <=
N,
"Must have at most ",
N,
" inputs, got: ", n)
196 case 4: X3 =
v[3]; [[fallthrough]];
197 case 3: X2 =
v[2]; [[fallthrough]];
198 case 2: X1 =
v[1]; [[fallthrough]];
216 return X0 + (T - 200.0) * (X1 - X0) / (250.0 - 200.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);
231 return (X1 - X0) / (250.0 - 200.0);
233 return (X3 - X2) / (340.0 - 296.0);
234 return (X2 - X1) / (296.0 - 250.0);
245 return 1 - (T - 200.0) / (250.0 - 200.0);
257 return (T - 200.0) / (250.0 - 200.0);
260 return 1 - (T - 250.0) / (296.0 - 250.0);
273 return 1 - (T - 296.0) / (340.0 - 296.0);
274 return (T - 250.0) / (296.0 - 250.0);
285 return (T - 296.0) / (340.0 - 296.0);
323 case TemperatureModel::None:
324 return {TemperatureModel::None, 0, 0, 0, 0};
325 case TemperatureModel::T0:
326 return {TemperatureModel::T0, 0, 0, 0, 0};
327 case TemperatureModel::T1:
328 return {TemperatureModel::T1, 0, 0, 0, 0};
329 case TemperatureModel::T2:
330 return {TemperatureModel::T2, 0, 0, 0, 0};
331 case TemperatureModel::T3:
332 return {TemperatureModel::T3, 0, 0, 0, 0};
333 case TemperatureModel::T4:
334 return {TemperatureModel::T4, 0, 0, 0, 0};
335 case TemperatureModel::T5:
336 return {TemperatureModel::T5, 0, 0, 0, 0};
337 case TemperatureModel::LM_AER:
338 return {TemperatureModel::LM_AER, 0, 0, 0, 0};
339 case TemperatureModel::DPL:
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};
346 return {TemperatureModel::None, 0, 0, 0, 0};
351 case TemperatureModel::None:
353 case TemperatureModel::T0:
355 case TemperatureModel::T1:
357 case TemperatureModel::T2:
359 case TemperatureModel::T3:
360 return (mp.X0 == 0 and mp.X1 == 0);
361 case TemperatureModel::T4:
362 return (mp.X0 == 0 and mp.X1 == 0);
363 case TemperatureModel::T5:
365 case TemperatureModel::LM_AER:
366 return (mp.X0 == 0 and mp.X1 == 0 and mp.X2 == 0 and mp.X3 == 0);
367 case TemperatureModel::DPL:
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:
379 case TemperatureModel::None:
381 case TemperatureModel::T0:
383 case TemperatureModel::T1:
385 case TemperatureModel::T2:
387 case TemperatureModel::T3:
389 case TemperatureModel::T4:
391 case TemperatureModel::T5:
392 return (0.25 + 1.5*mp.X1);
393 case TemperatureModel::LM_AER:
395 case TemperatureModel::DPL:
397 case TemperatureModel::POLY:
399 case TemperatureModel::FINAL:
400 return std::numeric_limits<Numeric>::quiet_NaN();
402 return std::numeric_limits<Numeric>::quiet_NaN();
429 static_assert(
nVars == 9,
"Must update");
444 if (do_no_linemixing) {
456 std::array<ModelParameters, nVars>
X;
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{})
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
487 constexpr std::array<ModelParameters, nVars>&
Data() noexcept {
return X; }
490 [[nodiscard]]
constexpr const std::array<ModelParameters, nVars>&
Data() const noexcept {
return X; }
498#define MODELPARAMCASESETTER(X) \
512 case Variable::FINAL:
break;
514#undef MODELPARAMCASESETTER
524 #define MODELPARAMCASEGETTER(X) case Variable::X: out = X(); break;
536 case Variable::FINAL:
break;
539 #undef MODELPARAMCASEGETTER
565 return {x.
G0, -x.D0, x.G2, -x.D2, x.FVC, x.ETA, x.Y, x.G, -x.DV};
570 return {-x.
G0, -x.D0, -x.G2, -x.D2, -x.FVC, -x.ETA, -x.Y, -x.G, -x.DV};
576 return {freq2kaycm(x.G0),
649 std::vector<SingleSpeciesModel>
mdata;
656 explicit Model(
const std::vector<SingleSpeciesModel>& assm) noexcept :
mdata(assm) {}
662 explicit Model(std::vector<SingleSpeciesModel>&& assm) noexcept :
mdata(std::move(assm)) {}
687 std::array<Numeric, 12> aer_interp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
noexcept;
693 [[nodiscard]]
bool OK(Type type,
bool self,
bool bath,
694 const std::size_t nspecies)
const noexcept;
736 [[nodiscard]]
auto end()
const {
return mdata.end(); }
739 [[nodiscard]]
auto cend()
const {
return mdata.cend(); }
742 [[nodiscard]]
const std::vector<SingleSpeciesModel>&
Data() const noexcept {
return mdata; }
745 std::vector<SingleSpeciesModel>&
Data() noexcept {
return mdata; }
769 [[nodiscard]] std::pair<bool, bool>
Match(
const Model& other)
const noexcept;
830 std::array<Numeric, 12> aer_interp = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
858 LineShape::Type& type,
866namespace LegacyLineFunctionData {
868#pragma GCC diagnostic push
869#pragma GCC diagnostic ignored "-Wreturn-type"
872 case TemperatureModel::None:
874 case TemperatureModel::T0:
876 case TemperatureModel::T1:
878 case TemperatureModel::T2:
880 case TemperatureModel::T3:
882 case TemperatureModel::T4:
884 case TemperatureModel::T5:
886 case TemperatureModel::LM_AER:
888 case TemperatureModel::DPL:
890 case TemperatureModel::POLY:
892 case TemperatureModel::FINAL:
break;
896#pragma GCC diagnostic pop
906namespace LegacyLineMixingData {
921#pragma GCC diagnostic push
922#pragma GCC diagnostic ignored "-Wreturn-type"
940#pragma GCC diagnostic pop
947namespace LegacyPressureBroadeningData {
969#pragma GCC diagnostic push
970#pragma GCC diagnostic ignored "-Wreturn-type"
984#pragma GCC diagnostic pop
995 Species::Species self_spec);
A constant view of a Vector.
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.
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.
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.
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
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
Binary output file stream class.
Binary output file stream class.
#define ARTS_ASSERT(condition,...)
#define ENUMCLASS(ENUMTYPE, TYPE,...)
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.
INDEX Index
The type to use for all integer numbers and indices.
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.
@ LM_LBLRTM_O2NonResonant
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.
@ PB_AIR_AND_WATER_BROADENING
@ PB_PLANETARY_BROADENING
Computations of line shape derived parameters.
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.
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.
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.