45 for (
const auto& lines: abs_lines_per_species) {
46 for (
const auto& band: lines) {
47 for (
Index k=0; k<band.NumLines() and (global ? (k==0) :
false); k++) {
52 auto x = band.QuantumIdentityOfLine(k);
62 bool inlower =
false, inupper =
false;
64 if (not inlower and canbeinlower)
65 if (qid[
i] == lower) inlower =
true;
66 if (not inupper and canbeinupper)
67 if (qid[
i] == upper) inupper =
true;
71 if (not inlower and canbeinlower) qid.push_back(lower);
72 if (not inupper and canbeinupper)
73 if (not(lower == upper)) qid.push_back(upper);
83 nlte_field.
Data() *= scale;
95 const Agenda& iy_main_agenda,
96 const Agenda& ppath_agenda,
97 const Agenda& iy_space_agenda,
98 const Agenda& iy_surface_agenda,
99 const Agenda& iy_cloudbox_agenda,
100 const Agenda& propmat_clearsky_agenda,
106 const Index& atmosphere_dim,
107 const Vector& refellipsoid,
108 const Tensor3& surface_props_data,
109 const Index& nlte_do,
111 const Numeric& convergence_limit,
114 const Index& dampened,
115 const Index& iteration_limit,
120 if (not nlte_do)
throw std::runtime_error(
"Must be set to do NLTE");
122 throw std::runtime_error(
"Error in NLTE field, it is empty");
129 throw std::runtime_error(
"Must have more than a four levels");
131 if (atmosphere_dim not_eq 1)
132 throw std::runtime_error(
"Only for 1D atmosphere");
135 if (nlevels >= nlines)
136 throw std::runtime_error(
137 "Bad number of lines... overlapping lines in nlte_level_identifiers?");
143 Vector Cij(nlines), Cji(nlines);
147 upper, lower, abs_lines_per_species, nlte_field);
151 Matrix SEE(nlevels, nlevels, 0.0);
152 Vector r(nlevels, 0.0), x(nlevels, 0.0);
153 Numeric max_change = convergence_limit + 1;
156 while (i < iteration_limit and max_change > convergence_limit) {
166 abs_lines_per_species,
179 propmat_clearsky_agenda,
186 for (
Index ip = 0; ip < np; ip++) {
190 abs_lines_per_species,
192 collision_coefficients,
193 collision_line_identifiers,
195 vmr_field(
joker, ip, 0, 0),
209 line_irradiance(
joker, ip),
210 line_transmission(0,
joker, ip),
220 line_irradiance(
joker, ip),
227 for (
Index il = 0; il < nlevels; il++) {
229 max(
abs(nlte_field.
Data()(il, ip, 0, 0) -
r[il]) /
r[il], max_change);
235 if (i < iteration_limit)
236 out2 <<
"Converged NLTE ratios (within convergence_limit) returned after " 237 << i <<
" iterations\n";
240 <<
"No convergence of NLTE ratios (within convergence_limit) returned even after " 241 << iteration_limit <<
" iterations\n";
252 String tmp_basename = basename, filename;
253 if (basename.length() && basename[basename.length() - 1] !=
'/')
257 filename = tmp_basename +
"qid.xml";
262 const Index n = collision_line_identifiers.
nelem();
265 collision_coefficients.resize(abs_species.
nelem());
270 filename = tmp_basename + abs_species[
i][0].SpeciesNameMain() +
".xml";
272 if (aogf1.
nelem() not_eq
n)
273 throw std::runtime_error(
274 "Mismatch between collision_line_identifiers and some collision_coefficients");
275 collision_coefficients[
i] = aogf1;
286 nlte_level_identifiers.resize(0);
INDEX Index
The type to use for all integer numbers and indices.
bool any_quantumnumbers() const
Check if there are any quantum numbers defined.
Index nelem() const
Number of elements.
void check_collision_line_identifiers(const ArrayOfQuantumIdentifier &collision_line_identifiers)
Checks that a WSV is OK or throws a run-time error.
void nlte_fieldForSingleSpeciesNonOverlappingLines(Workspace &ws, EnergyLevelMap &nlte_field, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const ArrayOfArrayOfGriddedField1 &collision_coefficients, const ArrayOfQuantumIdentifier &collision_line_identifiers, const SpeciesAuxData &isotopologue_ratios, const Agenda &iy_main_agenda, const Agenda &ppath_agenda, const Agenda &iy_space_agenda, const Agenda &iy_surface_agenda, const Agenda &iy_cloudbox_agenda, const Agenda &propmat_clearsky_agenda, const Agenda &, const Tensor4 &vmr_field, const Tensor3 &t_field, const Tensor3 &z_field, const Vector &p_grid, const Index &atmosphere_dim, const Vector &refellipsoid, const Tensor3 &surface_props_data, const Index &nlte_do, const Numeric &df, const Numeric &convergence_limit, const Index &nz, const Index &nf, const Index &dampened, const Index &iteration_limit, const Verbosity &verbosity)
WORKSPACE METHOD: nlte_fieldForSingleSpeciesNonOverlappingLines.
constexpr QuantumIdentifier UpperQuantumId() const noexcept
Return a quantum identifer as if it wants to match to upper energy level.
const Tensor4 & Data() const noexcept
Energy level type.
Linear algebra functions.
void dampened_statistical_equilibrium_equation(MatrixView A, ConstVectorView x, ConstVectorView Aij, ConstVectorView Bij, ConstVectorView Bji, ConstVectorView Cij, ConstVectorView Cji, ConstVectorView Jij, ConstVectorView Lambda, const ArrayOfIndex &upper, const ArrayOfIndex &lower, const Numeric &total_number_count)
Sets up the solution matrix for linear dampened statistical equilibrium equation. ...
Index nelem() const
Returns the number of elements.
void ArrayOfQuantumIdentifierFromLines(ArrayOfQuantumIdentifier &qid, const ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const Index &global, const Verbosity &)
WORKSPACE METHOD: ArrayOfQuantumIdentifierFromLines.
void nlteOff(Index &nlte_do, EnergyLevelMap &nlte_field, ArrayOfQuantumIdentifier &nlte_level_identifiers, const Verbosity &)
WORKSPACE METHOD: nlteOff.
Deep calculations for NLTE.
Vector createBji(const Vector &Bij, const ArrayOfArrayOfAbsorptionLines &abs_lines)
Create a Bji object.
The global header file for ARTS.
void statistical_equilibrium_equation(MatrixView A, ConstVectorView Aij, ConstVectorView Bij, ConstVectorView Bji, ConstVectorView Cij, ConstVectorView Cji, ConstVectorView Jij, const ArrayOfIndex &upper, const ArrayOfIndex &lower)
Sets up the solution matrix for linear statistical equilibrium equation.
const ArrayOfQuantumIdentifier & Levels() const noexcept
Energy level type.
void nlte_positions_in_statistical_equilibrium_matrix(ArrayOfIndex &upper, ArrayOfIndex &lower, const ArrayOfArrayOfAbsorptionLines &abs_lines, const EnergyLevelMap &nlte_field)
Finds upper and lower states in SEE Matrix.
void nlte_collision_factorsCalcFromCoeffs(Vector &Cij, Vector &Cji, const ArrayOfArrayOfAbsorptionLines &abs_lines, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfArrayOfGriddedField1 &collision_coefficients, const ArrayOfQuantumIdentifier &collision_line_identifiers, const SpeciesAuxData &isotopologue_ratios, const ConstVectorView vmr, const Numeric &T, const Numeric &P)
Gets collisional factors from coefficients.
Vector createAij(const ArrayOfArrayOfAbsorptionLines &abs_lines)
Create a Aij object.
Class to identify and match lines by their quantum numbers.
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
Vector createBij(const ArrayOfArrayOfAbsorptionLines &abs_lines)
Create a Bij object.
NUMERIC Numeric
The type to use for all floating point numbers.
constexpr QuantumIdentifier LowerQuantumId() const noexcept
Return a quantum identifer as if it wants to match to lower energy level.
Declarations required for the calculation of absorption coefficients.
This can be used to make arrays out of anything.
void set_constant_statistical_equilibrium_matrix(MatrixView A, VectorView x, const Numeric &sem_ratio, const Index row)
Set a row of the SEE matrix and level distribution vector to constant.
bool empty() const
Check if variable is empty.
Index nelem(const Lines &l)
Number of lines.
void collision_coefficientsFromSplitFiles(ArrayOfArrayOfGriddedField1 &collision_coefficients, ArrayOfQuantumIdentifier &collision_line_identifiers, const ArrayOfArrayOfSpeciesTag &abs_species, const String &basename, const Verbosity &verbosity)
WORKSPACE METHOD: collision_coefficientsFromSplitFiles.
Auxiliary data for isotopologues.
void nlte_fieldRescalePopulationLevels(EnergyLevelMap &nlte_field, const Numeric &scale, const Verbosity &)
WORKSPACE METHOD: nlte_fieldRescalePopulationLevels.
void solve(VectorView w, const CovarianceMatrix &A, ConstVectorView v)
void line_irradianceCalcForSingleSpeciesNonOverlappingLinesPseudo2D(Workspace &ws, Matrix &line_irradiance, Tensor3 &line_transmission, const ArrayOfArrayOfSpeciesTag &abs_species, const ArrayOfArrayOfAbsorptionLines &abs_lines_per_species, const EnergyLevelMap &nlte_field, const Tensor4 &vmr_field, const Tensor3 &t_field, const Tensor3 &z_field, const Vector &p_grid, const Vector &refellipsoid, const Tensor3 &surface_props_data, const Agenda &ppath_agenda, const Agenda &iy_main_agenda, const Agenda &iy_space_agenda, const Agenda &iy_surface_agenda, const Agenda &iy_cloudbox_agenda, const Agenda &propmat_clearsky_agenda, const Numeric &df, const Index &nz, const Index &nf, const Numeric &r, const Verbosity &verbosity)
WORKSPACE METHOD: line_irradianceCalcForSingleSpeciesNonOverlappingLinesPseudo2D. ...
Index find_first_unique_in_lower(const ArrayOfIndex &upper, const ArrayOfIndex &lower) noexcept
Finds a unique lower state if one exists or returns index to last element.