ARTS  2.3.1285(git:92a29ea9-dirty)
linescaling.cc
Go to the documentation of this file.
1 /* Copyright (C) 2015
2  Richard Larsson <ric.larsson@gmail.com>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License as published by the
6  Free Software Foundation; either version 2, or (at your option) any
7  later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17  USA. */
18 
19 #include "linescaling.h"
20 #include "interpolation_poly.h"
21 
23  ConstVectorView q_grid) {
24  Numeric result = 0.;
25  Numeric TN = 1;
26 
27  for (Index i = 0; i < q_grid.nelem(); i++) {
28  result += TN * q_grid[i];
29  TN *= T;
30  }
31 
32  return result;
33 }
34 
36  ConstVectorView q_grid) {
37  Numeric result = 0;
38  Numeric TN = 1;
39 
40  for (Index i = 1; i < q_grid.nelem(); i++) {
41  result += Numeric(i) * TN * q_grid[i];
42  TN *= T;
43  }
44 
45  return result;
46 }
47 
49  ConstVectorView t_grid,
50  ConstVectorView q_grid,
51  const Index& interp_order) {
52  GridPosPoly gp;
53  gridpos_poly(gp, t_grid, T, interp_order);
54  Vector itw(gp.idx.nelem());
55  interpweights(itw, gp);
56  return interp(itw, q_grid, gp);
57 }
58 
60  const Numeric& T,
61  const Numeric& dT,
62  ConstVectorView t_grid,
63  ConstVectorView q_grid,
64  const Index& interp_order) {
65  GridPosPoly gp;
66  gridpos_poly(gp, t_grid, T + dT, interp_order);
67  Vector itw(gp.idx.nelem());
68  interpweights(itw, gp);
69  return (interp(itw, q_grid, gp) - QT) / dT;
70 }
71 
73  const SpeciesAuxData::AuxType& partition_type,
74  const ArrayOfGriddedField1& partition_data) {
75  switch (partition_type) {
77  return SingleCalculatePartitionFctFromCoeff(T, partition_data[0].data);
80  T, partition_data[0].get_numeric_grid(0), partition_data[0].data, 1);
81  default:
82  throw std::runtime_error(
83  "Unknown or deprecated partition type requested.\n");
84  }
85 }
86 
88  const Numeric& QT,
89  const Numeric& T,
90  const Numeric& dT,
91  const SpeciesAuxData::AuxType& partition_type,
92  const ArrayOfGriddedField1& partition_data) {
93  switch (partition_type) {
95  return SingleCalculatePartitionFctFromCoeff_dT(T, partition_data[0].data);
98  QT,
99  T,
100  dT,
101  partition_data[0].get_numeric_grid(0),
102  partition_data[0].data,
103  1);
104  default:
105  throw std::runtime_error(
106  "Unknown or deprecated partition type requested.\n");
107  }
108 }
109 
111  using namespace Constant;
112  static constexpr Numeric c1 = -h / k;
113  return std::exp(c1 * F0 / T);
114 }
115 
117  using namespace Constant;
118  static constexpr Numeric c1 = -h / k;
119  return -F0 * c1 * std::exp(F0 * c1 / T) / pow2(T);
120 }
121 
123  using namespace Constant;
124  static constexpr Numeric c1 = -h / k;
125  return c1 * std::exp(F0 * c1 / T) / T;
126 }
127 
129  const Numeric& gamma_ref) {
130  return (1. - gamma) / (1. - gamma_ref);
131 }
132 
134  const Numeric& gamma_ref,
135  const Numeric& F0,
136  const Numeric& T) {
137  extern const Numeric PLANCK_CONST;
138  extern const Numeric BOLTZMAN_CONST;
139  static const Numeric c = -PLANCK_CONST / BOLTZMAN_CONST;
140 
141  return c * F0 * gamma / (T * T * (1. - gamma_ref));
142 }
143 
145  const Numeric& gamma_ref,
146  const Numeric& T,
147  const Numeric& T0) {
148  extern const Numeric PLANCK_CONST;
149  extern const Numeric BOLTZMAN_CONST;
150  static const Numeric c = -PLANCK_CONST / BOLTZMAN_CONST;
151 
152  const Numeric g0 = 1 - gamma_ref;
153  const Numeric g = 1 - gamma;
154 
155  return c * (g * gamma_ref / (T0 * g0 * g0) - gamma / (T * g0));
156 }
157 
158 // Ratio of boltzman emission at T and T0
159 Numeric boltzman_ratio(const Numeric& T, const Numeric& T0, const Numeric& E0) {
160  extern const Numeric BOLTZMAN_CONST;
161  static const Numeric c = 1 / BOLTZMAN_CONST;
162 
163  return exp(E0 * c * (T - T0) / (T * T0));
164 }
165 
166 Numeric dboltzman_ratio_dT(const Numeric& boltzmann_ratio,
167  const Numeric& T,
168  const Numeric& E0) {
169  extern const Numeric BOLTZMAN_CONST;
170  static const Numeric c = 1 / BOLTZMAN_CONST;
171 
172  return E0 * c * boltzmann_ratio / (T * T);
173 }
174 
175 // Boltzmann factor at T
177 {
178  return std::exp(- E0 / (Constant::k*T));
179 }
180 
181 // Boltzmann factor at T
183  using namespace Constant;
184  static constexpr Numeric c1 = -1 / k;
185  return -E0 * c1 * std::exp(E0 * c1 / T) / pow2(T);
186 }
187 
188 // Boltzmann factor at T
190  using namespace Constant;
191  static constexpr Numeric c1 = -1 / k;
192  return c1 * std::exp(E0 * c1 / T) / T;
193 }
194 
196  const Numeric& r_upp,
197  const Numeric& r_low) {
198  return (r_low - r_upp * gamma) / (1 - gamma);
199 }
200 
202  const Numeric& T,
203  const Numeric& F0,
204  const Numeric& El,
205  const Numeric& Eu,
206  const Numeric& r_upp,
207  const Numeric& r_low) {
208  extern const Numeric PLANCK_CONST;
209  extern const Numeric BOLTZMAN_CONST;
210  static const Numeric c = 1 / BOLTZMAN_CONST;
211 
212  if (El < 0 or Eu < 0) {
214  os << "It is considered undefined behavior to NLTE and "
215  << "temperature Jacobian without defining all "
216  << "vibrational energy states";
217  throw std::runtime_error(os.str());
218  }
219 
220  const Numeric x = 1 / (T * (gamma - 1));
221  const Numeric hf = F0 * PLANCK_CONST;
222 
223  return x * x * c *
224  ((gamma - 1) * (El * r_low - Eu * gamma * r_upp) -
225  hf * gamma * (r_low - r_upp));
226 }
227 
229  const Numeric& T,
230  const Numeric& r_upp,
231  const Numeric& r_low) {
232  extern const Numeric PLANCK_CONST;
233  extern const Numeric BOLTZMAN_CONST;
234  static const Numeric c = -PLANCK_CONST / BOLTZMAN_CONST;
235 
236  return c * gamma * (r_low - r_upp) / (T * Constant::pow2(gamma - 1));
237 }
238 
240  const Numeric& T,
241  const Numeric& Tl,
242  const Numeric& El,
243  const Numeric& r_low) {
244  extern const Numeric BOLTZMAN_CONST;
245 
246  const Numeric x = 1 / (BOLTZMAN_CONST * T);
247  const Numeric y = 1 / Tl;
248 
249  return El * x * y * y * T * r_low / (gamma - 1);
250 }
251 
253  const Numeric& T,
254  const Numeric& Tu,
255  const Numeric& Eu,
256  const Numeric& r_upp) {
257  extern const Numeric BOLTZMAN_CONST;
258 
259  const Numeric x = 1 / (BOLTZMAN_CONST * T);
260  const Numeric y = 1 / Tu;
261 
262  return Eu * x * y * y * T * gamma * r_upp / (gamma - 1);
263 }
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
const Numeric PLANCK_CONST
Global constant, the Planck constant [Js].
Namespace containing several constants, physical and mathematical.
Definition: constants.h:61
Numeric dabsorption_nlte_rate_dT(const Numeric &gamma, const Numeric &T, const Numeric &F0, const Numeric &El, const Numeric &Eu, const Numeric &r_upp, const Numeric &r_low)
Computes temperature derivatives of (r_low - r_upp * gamma) / (1 - gamma)
Definition: linescaling.cc:201
Numeric dstimulated_emissiondT(Numeric T, Numeric F0)
Computes temperature derivative of exp(-hf/kT)
Definition: linescaling.cc:116
Numeric dboltzman_factordT(Numeric T, Numeric E0)
Computes temperature derivatives exp(- E0/kT)
Definition: linescaling.cc:182
Index nelem() const
Number of elements.
Definition: array.h:195
const Numeric BOLTZMAN_CONST
Global constant, the Boltzmann constant [J/K].
G0 G2 FVC Y DV Numeric E0
The Vector class.
Definition: matpackI.h:860
Numeric interp(ConstVectorView itw, ConstVectorView a, const GridPos &tc)
Red 1D Interpolate.
Numeric stimulated_relative_emission(const Numeric &gamma, const Numeric &gamma_ref)
Computes (1 - gamma) / (1 - gamma_ref)
Definition: linescaling.cc:128
Numeric boltzman_factor(Numeric T, Numeric E0)
Computes exp(- E0/kT)
Definition: linescaling.cc:176
Numeric dsingle_partition_function_dT(const Numeric &QT, const Numeric &T, const Numeric &dT, const SpeciesAuxData::AuxType &partition_type, const ArrayOfGriddedField1 &partition_data)
Computes the partition function temperature derivative.
Definition: linescaling.cc:87
Numeric stimulated_emission(Numeric T, Numeric F0)
Computes exp(-hf/kT)
Definition: linescaling.cc:110
Numeric dabsorption_nlte_rate_dF0(const Numeric &gamma, const Numeric &T, const Numeric &r_upp, const Numeric &r_low)
Computes frequency derivative of (r_low - r_upp * gamma) / (1 - gamma)
Definition: linescaling.cc:228
Numeric absorption_nlte_ratio(const Numeric &gamma, const Numeric &r_upp, const Numeric &r_low)
Computes (r_low - r_upp * gamma) / (1 - gamma)
Definition: linescaling.cc:195
G0 G2 FVC Y DV Numeric Numeric Numeric Zeeman LowerQuantumNumbers void * data
constexpr T pow2(T x)
power of two
Definition: constants.h:64
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:51
Numeric dboltzman_ratio_dT(const Numeric &boltzmann_ratio, const Numeric &T, const Numeric &E0)
Computes temperature derivatives exp(E0/k (T - T0) / (T * T0))
Definition: linescaling.cc:166
ArrayOfIndex idx
Numeric SingleCalculatePartitionFctFromData_dT(const Numeric &QT, const Numeric &T, const Numeric &dT, ConstVectorView t_grid, ConstVectorView q_grid, const Index &interp_order)
Definition: linescaling.cc:59
Numeric dstimulated_emissiondF0(Numeric T, Numeric F0)
Computes frequency derivative of exp(-hf/kT)
Definition: linescaling.cc:122
Numeric boltzman_ratio(const Numeric &T, const Numeric &T0, const Numeric &E0)
Computes exp(E0/c (T - T0) / (T * T0))
Definition: linescaling.cc:159
Numeric SingleCalculatePartitionFctFromCoeff(const Numeric &T, ConstVectorView q_grid)
Definition: linescaling.cc:22
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
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.
Numeric SingleCalculatePartitionFctFromCoeff_dT(const Numeric &T, ConstVectorView q_grid)
Definition: linescaling.cc:35
basic_ostringstream< char, string_char_traits< char >, alloc > ostringstream
Definition: sstream.h:204
Numeric dstimulated_relative_emission_dT(const Numeric &gamma, const Numeric &gamma_ref, const Numeric &F0, const Numeric &T)
Computes temperature derivative of (1 - gamma) / (1 - gamma_ref)
Definition: linescaling.cc:133
This can be used to make arrays out of anything.
Definition: array.h:40
Numeric SingleCalculatePartitionFctFromData(const Numeric &T, ConstVectorView t_grid, ConstVectorView q_grid, const Index &interp_order)
Definition: linescaling.cc:48
Header file for interpolation_poly.cc.
G0 G2 FVC Y DV F0
Constains various line scaling functions.
A constant view of a Vector.
Definition: matpackI.h:476
Numeric dabsorption_nlte_rate_dTu(const Numeric &gamma, const Numeric &T, const Numeric &Tu, const Numeric &Eu, const Numeric &r_upp)
Computes upper state temperature derivative of (r_low - r_upp * gamma) / (1 - gamma) ...
Definition: linescaling.cc:252
Numeric dboltzman_factordE0(Numeric T, Numeric E0)
Computes lower state energy derivatives exp(- E0/kT)
Definition: linescaling.cc:189
Numeric dstimulated_relative_emission_dF0(const Numeric &gamma, const Numeric &gamma_ref, const Numeric &T, const Numeric &T0)
Computes frequency derivative of (1 - gamma) / (1 - gamma_ref)
Definition: linescaling.cc:144
Structure to store a grid position for higher order interpolation.
Numeric single_partition_function(const Numeric &T, const SpeciesAuxData::AuxType &partition_type, const ArrayOfGriddedField1 &partition_data)
Computes the partition function at one temperature.
Definition: linescaling.cc:72
void interpweights(VectorView itw, const GridPos &tc)
Red 1D interpolation weights.
Numeric dabsorption_nlte_rate_dTl(const Numeric &gamma, const Numeric &T, const Numeric &Tl, const Numeric &El, const Numeric &r_low)
Computes lower state temperature derivative of (r_low - r_upp * gamma) / (1 - gamma) ...
Definition: linescaling.cc:239