43 const Index i = upper[iline];
44 const Index j = lower[iline];
46 A(j, j) -= Bji[iline] * Jij[iline] + Cji[iline];
47 A(i, i) -= Aij[iline] + Bij[iline] * Jij[iline] + Cij[iline];
49 A(j, i) += Aij[iline] + Bij[iline] * Jij[iline] + Cij[iline];
50 A(i, j) += Bji[iline] * Jij[iline] + Cji[iline];
66 const Numeric& total_number_count) {
71 const Index i = upper[iline];
72 const Index j = lower[iline];
76 (x[i] * Aij[iline] / (x[j] * Bji[iline] - x[i] * Bij[iline]));
78 A(j, j) -= Bji[iline] * (Jij[iline] - Lambda[iline] * Source) + Cji[iline];
79 A(i, i) -= Aij[iline] * (1.0 - Lambda[iline]) +
80 Bij[iline] * (Jij[iline] - Lambda[iline] * Source) + Cij[iline];
82 A(j, i) += Aij[iline] * (1.0 - Lambda[iline]) +
83 Bij[iline] * (Jij[iline] - Lambda[iline] * Source) + Cij[iline];
84 A(i, j) += Bji[iline] * (Jij[iline] - Lambda[iline] * Source) + Cji[iline];
102 for (
auto& lines: abs_lines) {
103 for (
auto& band: lines) {
104 for (
Index k=0; k<band.NumLines(); k++) {
124 for (
auto& lines: abs_lines) {
125 for (
auto& band: lines) {
126 for (
Index k=0; k<band.NumLines(); k++) {
127 Bij[i] = band.A(k) / (c0 * band.F0(k) * band.F0(k) * band.F0(k));
142 for (
auto& lines: abs_lines) {
143 for (
auto& band: lines) {
144 for (
Index k=0; k<band.NumLines();k++) {
145 Bji[i] = Bij[i] * band.g_upp(k) / band.g_low(k);
158 setCji(Cji, Cij, abs_lines, T);
168 const Numeric constant = c0 / T;
172 for (
auto& lines: abs_lines) {
173 for (
auto& band: lines) {
174 for (
Index k=0; k<band.NumLines(); k++) {
175 Cji[i] = Cij[i] * exp(constant * band.F0(k)) * band.g_upp(k) / band.g_low(k);
197 const Index ntrans = collision_line_identifiers.
nelem();
206 vmr[
i] * (abs_species[
i][0].SpeciesNameMain() ==
"free_electrons" 208 : P / (BOLTZMAN_CONST * T));
210 for (
Index j = 0; j < ntrans; j++) {
212 for (
auto& lines: abs_lines) {
213 for (
auto& band: lines) {
215 isotopologue_ratios.
getParam(band.Species(), band.Isotopologue())[0]
217 for (
Index k=0; k<band.NumLines(); k++) {
219 const auto& transition = collision_line_identifiers[j];
220 const auto& gf1 = collision_coefficients[
i][j];
229 Cij[iline] +=
interp(itw, gf1.data, gp) * numden * isot_ratio;
241 setCji(Cji, Cij, abs_lines, T);
255 for (
auto& lines: abs_lines) {
257 for (
Index k=0; k<band.NumLines(); k++) {
258 for (
Index iq = 0; iq < nq; iq++) {
270 for (
Index il = 0; il < nl; il++)
271 if (upper[il] < 0 or lower[il] < 0) i++;
273 throw std::runtime_error(
274 "Must set upper and lower levels completely for all but one level");
279 for (
const Index& l : lower) {
280 if (std::find(upper.cbegin(), upper.cend(), l) == upper.cend())
283 return upper.nelem() - 1;
287 auto p = std::find_if(collision_line_identifiers.cbegin(), collision_line_identifiers.cend(),
288 [spec=collision_line_identifiers.front().Species(), isot=collision_line_identifiers.front().Isotopologue()]
291 spec not_eq x.Species() or
292 isot not_eq x.Isotopologue() or
294 if (p not_eq collision_line_identifiers.cend()) {
297 <<
"does not match the requirements for a line identifier\n" 298 <<
"Your list of species is:\n" 299 << collision_line_identifiers <<
"\n" 300 <<
"This contains more than one isotopologue or it contains some non-transition type identifiers.\n" 301 <<
"It will therefore fail in current code. You can only input transitions, and a single isotopologue.\n";
303 throw std::runtime_error(os.str());
INDEX Index
The type to use for all integer numbers and indices.
const Numeric PLANCK_CONST
Global constant, the Planck constant [Js].
Vector createCji(const Vector &Cij, const ArrayOfArrayOfAbsorptionLines &abs_lines, const Numeric &T)
Create a Cji object.
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.
const Numeric BOLTZMAN_CONST
Global constant, the Boltzmann constant [J/K].
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
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. ...
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
Index nelem() const
Returns the number of elements.
Array< Index > ArrayOfIndex
An array of Index.
Deep calculations for NLTE.
Vector createBji(const Vector &Bij, const ArrayOfArrayOfAbsorptionLines &abs_lines)
Create a Bji object.
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.
bool id_in_line_upper(const Lines &band, const QuantumIdentifier &id, size_t line_index)
Checks if the external quantum identifier match a line's ID.
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.
const ArrayOfGriddedField1 & getParam(const Index species, const Index isotopologue) const
Return a constant reference to the parameters.
Vector createBij(const ArrayOfArrayOfAbsorptionLines &abs_lines)
Create a Bij object.
NUMERIC Numeric
The type to use for all floating point numbers.
void gridpos_poly(ArrayOfGridPosPoly &gp, ConstVectorView old_grid, ConstVectorView new_grid, const Index order, const Numeric &extpolfac)
The maximum difference from 1 that we allow for a sum check.
basic_ostringstream< char, string_char_traits< char >, alloc > ostringstream
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.
Header file for interpolation_poly.cc.
bool id_in_line(const Lines &band, const QuantumIdentifier &id, size_t line_index)
Checks if the external quantum identifier match a line's ID.
A constant view of a Vector.
Index nelem(const Lines &l)
Number of lines.
void setCji(Vector &Cji, const Vector &Cij, const ArrayOfArrayOfAbsorptionLines &abs_lines, const Numeric &T)
Set the Cji object.
Structure to store a grid position for higher order interpolation.
Auxiliary data for isotopologues.
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
const Numeric SPEED_OF_LIGHT
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.
bool id_in_line_lower(const Lines &band, const QuantumIdentifier &id, size_t line_index)
Checks if the external quantum identifier match a line's ID.