36 #include <Faddeeva/Faddeeva.hh> 63 const Numeric b2 = b * b, c2 = c * c, d2 = d * d, u2 = u * u,
v2 = v * v,
66 const Numeric Const2 = b2 + c2 + d2 - u2 - v2 - w2;
69 Const1 = b2 * (b2 * 0.5 + c2 + d2 - u2 - v2 + w2);
70 Const1 += c2 * (c2 * 0.5 + d2 - u2 + v2 - w2);
71 Const1 += d2 * (d2 * 0.5 + u2 - v2 - w2);
72 Const1 += u2 * (u2 * 0.5 + v2 + w2);
73 Const1 += v2 * (v2 * 0.5 + w2);
75 Const1 += 8 * (b * d * u * w - b * c * v * w - c * d * u * v);
79 Const1 =
sqrt(Const1);
94 const Numeric inv_x2y2 = 1.0 / x2y2;
96 std::cout << x <<
" " << y <<
" " << Const1 <<
" " << Const2 <<
"\n";
99 Numeric inv_y = 0.0, inv_x = 0.0;
106 C2 = (1.0 - cos_y) * inv_x2y2;
107 C3 = (1.0 - sin_y * inv_y) * inv_x2y2;
108 }
else if (y == 0.0) {
112 C2 = (cosh_x - 1.0) * inv_x2y2;
113 C3 = (sinh_x * inv_x - 1.0) * inv_x2y2;
118 C0 = (cos_y * x2 + cosh_x * y2) * inv_x2y2;
119 C1 = (sin_y * x2 * inv_y + sinh_x * y2 * inv_x) * inv_x2y2;
120 C2 = (cosh_x - cos_y) * inv_x2y2;
121 C3 = (sinh_x * inv_x - sin_y * inv_y) * inv_x2y2;
124 std::cout << C0 <<
" " << C1 <<
" " << C2 <<
" " << C3 <<
"\n";
129 Eigen::Matrix4d eigA;
130 eigA << 0, b, c, d, b, 0, u, v, c, -u, 0,
w, d, -v, -
w, 0;
132 eigF = C1 * eigA + C2 * eigA * eigA + C3 * eigA * eigA * eigA;
139 std::cout <<
F <<
"\n";
145 std::cout <<
"Initialized TransmissionMatrix(2, 4):\n" << a <<
"\n";
149 A << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16;
150 std::cout <<
"New Matrix:\n" << A <<
"\n\n";
152 std::cout <<
"Updated TransmissionMatrix Position 1 wit New Matrix:\n" 157 "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 125 26 27 28 29 30 31 32";
158 std::cout <<
"Stream:\n" << S <<
"\n\n";
161 std::cout <<
"Streamed into TransmissionMatrix:\n" << a <<
"\n";
165 std::cout <<
"Initialized RadiationVector(3, 3)\n" << b <<
"\n";
170 std::cout <<
"New Vector:\n" << B <<
"\n\n";
171 b.
Vec3(1).noalias() += B;
172 std::cout <<
"Updated RadiationVector Position 1 with New Vector:\n" 176 String T =
"1 2 3 4 5 6 7 8 90";
177 std::cout <<
"Stream:\n" << T <<
"\n\n";
180 std::cout <<
"Streamed into RadiationVector:\n" << b <<
"\n";
184 auto f = [](
Numeric x) {
return 0.1 * x; };
185 auto df = [](
Numeric x) {
return 0.1 + 0 * x; };
191 const Numeric r_extra1 = r_normal + f(x1);
192 const Numeric r_extra2 = r_normal + f(x2);
228 Tensor3 T_normal(1, nstokes, nstokes), T_extra(1, nstokes, nstokes);
229 Tensor4 dT1(1, 1, nstokes, nstokes), dT2(1, 1, nstokes, nstokes);
232 T_normal, dT1, dT2, r_normal, a, b, da, da, df(x1), df(x2), 0);
234 std::cout <<
"Transmission at r=" << r_normal <<
":\n" 237 std::cout <<
"First derivative:\n" 240 std::cout <<
"Second derivative:\n" 246 std::cout <<
"Transmission at perturbed r1=" << r_extra1 <<
":\n" 251 std::cout <<
"First derivative perturbed:\n" 255 std::cout <<
"First derivative perturbed relative:\n" 261 std::cout <<
"Transmission at perturbed r2=" << r_extra2 <<
":\n" 266 std::cout <<
"Second derivative perturbed:\n" 270 std::cout <<
"Second derivative perturbed relative:\n" 303 std::cout << test1 <<
"\n\n" 363 std::cout << ans1 <<
"\n\n" 372 for (
auto&
pm : propmats) {
390 std::cout <<
"Propmats:\n" << propmats <<
"\n\n";
394 for (i = 0; i < 4; i++) {
408 std::cout <<
"Layers:\n" << layers <<
"\n\n";
415 std::cout <<
"Forward accumulation:\n" << cumulative_forward <<
"\n\n";
416 std::cout <<
"Reflect accumulation:\n" << cumulative_reflect <<
"\n\n";
424 Vector x(n), sx(n), shx(n), cx(n), chx(n);
427 for (
int i = 0;
i < n;
i++) {
428 sx[
i] = std::sin(x[
i]);
429 cx[i] = std::cos(x[i]);
430 shx[i] = std::sinh(x[i]);
431 chx[i] = std::cosh(x[i]);
435 << std::scientific << std::setprecision(15)
436 <<
"x\tabs(sx/x-1)\tabs(shx/x-1)\tabs((chx-cx)/2x^2-1/2)\tabs((shx/x-sx/x)/2x^2-1/6)\n";
438 for (
int i = 0;
i < n;
i++)
439 std::cout << x[
i] <<
'\t' <<
std::abs(sx[
i] / x[
i] - 1.0) <<
'\t' 441 <<
std::abs((chx[
i] - cx[
i]) / (2 * x[i] * x[i]) - 0.5) <<
'\t' 442 <<
std::abs((shx[i] / x[i] - sx[i] / x[i]) / (2 * x[i] * x[i]) -
461 std::cout <<
"Table from Larsson, Lankhaar, Eriksson (2019)\n";
466 std::cout <<
i <<
"_" <<
i - 1;
471 std::cout <<
'\t' << g;
476 std::cout <<
'\t' << g;
481 std::cout <<
'\t' << g;
484 std::cout <<
'\t' << i <<
"_" << i;
489 std::cout <<
'\t' << g;
494 std::cout <<
'\t' << g;
499 std::cout <<
'\t' << g;
502 std::cout <<
'\t' << i <<
"_" << i + 1;
507 std::cout <<
'\t' << g;
512 std::cout <<
'\t' << g;
517 std::cout <<
'\t' << g;
531 "Bad last entry in QuantumNumbers. Did you recently expand the list?");
541 constexpr
Index nf = 501;
542 constexpr
Numeric fstart = 25e9;
543 constexpr
Numeric fend = 165e9;
556 constexpr
auto df = 1000;
557 constexpr
auto dt = 0.1;
559 Matrix pxsec_dt(nf, 1, 0);
560 Matrix pxsec_df(nf, 1, 0);
563 PWR93O2AbsModel(pxsec, 0, 1, 1, 1,
"user",
"PWR98", f, {p}, {t}, {0.5}, {1},
Verbosity());
564 PWR93O2AbsModel(pxsec_dt, 0, 1, 1, 1,
"user",
"PWR98", f, {p}, {t+dt}, {0.5}, {1},
Verbosity());
565 PWR93O2AbsModel(pxsec_df, 0, 1, 1, 1,
"user",
"PWR98", f_pert, {p}, {t}, {0.5}, {1},
Verbosity());
567 std::cout<<
"xr = np.array([";
569 std::cout<<
'['<<xsec(
i, 0)<<
','<<
' '<<pxsec(
i, 0) <<
']' <<
',' <<
' ';
570 std::cout <<
']' <<
')' <<
'\n';
572 std::cout<<
"dxr_dt = np.array([";
574 std::cout<<
'['<<dxsec[0](
i, 0)<<
','<<
' '<<(pxsec_dt(
i, 0)-pxsec(
i, 0))/dt <<
']' <<
',' <<
' ';
575 std::cout <<
']' <<
')' <<
'\n';
577 std::cout<<
"dxr_df = np.array([";
579 std::cout<<
'['<<dxsec[1](
i, 0)<<
','<<
' '<<(pxsec_df(
i, 0)-pxsec(
i, 0))/df <<
']' <<
',' <<
' ';
580 std::cout <<
']' <<
')' <<
'\n';
586 constexpr
Index nf = 501;
587 constexpr
Numeric fstart = 45e9;
590 constexpr
Numeric p = 1.00658388e5;
609 std::cout<<
"I = np.array([";
611 std::cout<<I[
i].real()<<
",\n";
614 std::cout<<
"I2 = np.array([";
616 std::cout<<xsec(
i,0)<<
",\n";
629 const Numeric stotmax = 0.1e-21;
631 const Index nsig =
Index(((sigmax - sigmin) / dsig) + 0.5) + 1;
635 for (
Index isig=0; isig<nsig; isig++) {
637 invcm_grid[isig] = sigc;
643 std::array<std::pair<lm_hitran_2017::ModeOfLineMixing, lm_hitran_2017::calctype>, 6>{
661 Vector vmrs = {1-xco2/100-xh2o/100, xh2o/100, xco2/100};
672 for (
Index j=0; j<n; j++) {
673 std::cout<<absorption[j][
i]<<
' ';
688 if (n == 2 and
String(argc[1]) ==
"new") {
689 std::cout<<
"new test\n";
693 std::cout<<
"old test\n";
INDEX Index
The type to use for all integer numbers and indices.
Array< PropagationMatrix > ArrayOfPropagationMatrix
Class to keep track of Transmission Matrices for Stokes Dim 1-4.
Vector vmrs(const ConstVectorView &atmospheric_vmrs, const ArrayOfArrayOfSpeciesTag &atmospheric_species, const QuantumIdentifier &self, const ArrayOfSpeciesTag &lineshape_species, bool self_in_list, bool bath_in_list, Type type)
Returns a VMR vector for this model's main calculations.
void compute_transmission_matrix_and_derivative(Tensor3View T, Tensor4View dT_dx_upper_level, Tensor4View dT_dx_lower_level, const Numeric &r, const PropagationMatrix &upper_level, const PropagationMatrix &lower_level, const ArrayOfPropagationMatrix &dupper_level_dx, const ArrayOfPropagationMatrix &dlower_level_dx, const Numeric &dr_dTu, const Numeric &dr_dTl, const Index it, const Index iz, const Index ia)
constexpr T hitran2arts_linestrength(T x)
Index make_wigner_ready(int largest, [[maybe_unused]] int fastest, int size)
constexpr Numeric atm2pa(T x)
void read(HitranRelaxationMatrixData &hitran, ArrayOfAbsorptionLines &bands, const String &basedir, const Numeric linemixinglimit, const Numeric fmin, const Numeric fmax, const Numeric stot, const ModeOfLineMixing mode)
Read from HITRAN online line mixing file.
Eigen::Map< MatrixType, 0, StrideType > MatrixViewMap
void test_r_deriv_propagationmatrix()
void stepwise_transmission(TransmissionMatrix &T, ArrayOfTransmissionMatrix &dT1, ArrayOfTransmissionMatrix &dT2, const PropagationMatrix &K1, const PropagationMatrix &K2, const ArrayOfPropagationMatrix &dK1, const ArrayOfPropagationMatrix &dK2, const Numeric &r, const Numeric &dr_dtemp1, const Numeric &dr_dtemp2, const Index temp_deriv_pos)
Set the stepwise transmission matrix.
VectorView K24(const Index iz=0, const Index ia=0)
Vector view to K(1, 3) elements.
Namespace and functions to deal with HITRAN linemixing.
Model GetAdvancedModel(const QuantumIdentifier &qid) noexcept
Returns an advanced Zeeman model.
cmplx FADDEEVA() w(cmplx z, double relerr)
void compute_transmission_matrix(Tensor3View T, const Numeric &r, const PropagationMatrix &upper_level, const PropagationMatrix &lower_level, const Index iz, const Index ia)
Compute the matrix exponent as the transmission matrix of this propagation matrix.
void define_species_map()
basic_istringstream< char, string_char_traits< char >, alloc > istringstream
Wigner symbol interactions.
VectorView K23(const Index iz=0, const Index ia=0)
Vector view to K(1, 2) elements.
Index nelem() const
Returns the number of elements.
VectorView K13(const Index iz=0, const Index ia=0)
Vector view to K(0, 2) elements.
Model GetSimpleModel(const QuantumIdentifier &qid) noexcept
Returns a simple Zeeman model.
Stuff related to lineshape functions.
VectorView K12(const Index iz=0, const Index ia=0)
Vector view to K(0, 1) elements.
The global header file for ARTS.
VectorView K34(const Index iz=0, const Index ia=0)
Vector view to K(2, 3) elements.
void makarov2020_o2_lines_mpm(Matrix &xsec, ArrayOfMatrix &dxsec, const Vector &f, const Vector &p, const Vector &t, const Vector &water_vmr, const ArrayOfRetrievalQuantity &jacs, const ArrayOfIndex &jacs_pos)
Adds Makarov MPM2020 O2 absorption lines to the absorption matrix.
ArrayOfTransmissionMatrix cumulative_transmission(const ArrayOfTransmissionMatrix &T, const CumulativeTransmission type)
Accumulate the transmission matrix over all layers.
std::complex< Numeric > Complex
void partition_functionsInitFromBuiltin(SpeciesAuxData &partition_functions, const Verbosity &)
WORKSPACE METHOD: partition_functionsInitFromBuiltin.
Stuff related to the transmission matrix.
Implements rational numbers to work with other ARTS types.
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
A tag group can consist of the sum of several of these.
void test_hitran2017(bool newtest=true)
constexpr Numeric kaycm2freq(T x)
Class to identify and match lines by their quantum numbers.
NUMERIC Numeric
The type to use for all floating point numbers.
constexpr bool test_quantum_numbers(const QuantumNumbers qns, const Index i)
Tensor4 & Data()
Get full view to data.
Contains the line shape namespace.
Declarations required for the calculation of absorption coefficients.
void nlogspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlogspace
Radiation Vector for Stokes dimension 1-4.
void test_transmat_to_cumulativetransmat()
void Set(Index qn, Rational r)
Set quantum number at position.
const Eigen::Matrix4d & Mat4(size_t i) const
Get Matrix at position.
void define_species_data()
Vector compute(const Numeric p, const Numeric t, const Numeric xco2, const Numeric xh2o, const ConstVectorView invcm_grid, const Numeric stotmax, const calctype type)
void test_matrix_buildup()
Container class for Quantum Numbers.
VectorView K14(const Index iz=0, const Index ia=0)
Vector view to K(0, 3) elements.
Headers and class definition of Zeeman modeling.
This can be used to make arrays out of anything.
VectorView Kjj(const Index iz=0, const Index ia=0)
Vector view to diagonal elements.
void PWR93O2AbsModel(MatrixView pxsec, const Numeric CCin, const Numeric CLin, const Numeric CWin, const Numeric COin, const String &model, const String &version, ConstVectorView f_grid, ConstVectorView abs_p, ConstVectorView abs_t, ConstVectorView vmrh2o, ConstVectorView vmr, const Verbosity &verbosity)
Oxygen complex at 60 GHz plus mm O2 lines plus O2 continuum.
Constains various line scaling functions.
void test_transmat_from_propmat()
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
void test_sinc_likes_0limit()
void makarov2020_o2_lines_ecs(ComplexVector &I, const Vector &f, Numeric P, Numeric T, Numeric water_vmr)
const Eigen::Vector3d & Vec3(size_t i) const
Return Vector at position.
void test_transmissionmatrix()
Auxiliary data for isotopologues.
constexpr Rational end(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the largest M for a polarization type of this transition.
int main(int n, char **argc)
ComplexConstMatrixViewMap MapToEigen(const ConstComplexMatrixView &A)
invlib::Matrix< ArtsMatrix > Matrix
invlib wrapper type for ARTS matrices.
Numeric & gl() noexcept
Returns the lower state g.
my_basic_string< char > String
The String type for ARTS.
Numeric sqrt(const Rational r)
Square root.