ARTS 2.5.4 (git: 31ce4f0e)
m_gas_scattering.cc
Go to the documentation of this file.
1/* Copyright (C) 2021
2 Jon Petersen <jon.petersen@studium.uni-hamburg.de>
3 Manfred Brath <manfred.brath@uni-hamburg.de>
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
8 later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18 USA. */
19
20/*===========================================================================
21 === File description
22 ===========================================================================*/
23
24#include "agenda_class.h"
25#include "physics_funcs.h"
26#include "arts_conversions.h"
27#include "gas_scattering.h"
28#include "optproperties.h"
29#include "rte.h"
30#include "transmissionmatrix.h"
31#include <cmath>
32
33using Constant::pi;
35
36
49/*===========================================================================
50 === The functions
51 ===========================================================================*/
52
53/* Workspace method: Doxygen documentation will be auto-generated */
55 Index& gas_scattering_do,
56 Agenda& gas_scattering_agenda,
57 const Verbosity&) {
58 // set flag to False (default)
59 gas_scattering_do = 0;
60
61 gas_scattering_agenda = Agenda(ws);
62 gas_scattering_agenda.set_name("gas_scattering_agenda");
63}
64
65/* Workspace method: Doxygen documentation will be auto-generated */
67 const Vector& f_grid,
68 const Numeric& rtp_pressure,
69 const Numeric& rtp_temperature,
70 const Index& stokes_dim,
71 const Numeric& ConstXsec,
72 const Verbosity&) {
73 gas_scattering_coef = PropagationMatrix(f_grid.nelem(), stokes_dim, 1, 1, ConstXsec * number_density(rtp_pressure, rtp_temperature));
74}
75
76/* Workspace method: Doxygen documentation will be auto-generated */
78 const Vector& f_grid,
79 const Numeric& rtp_pressure,
80 const Numeric& rtp_temperature,
81 const Index& stokes_dim,
82 const Verbosity&) {
83 static constexpr std::array coefficients{
84 3.9729066, 4.6547659e-2, 4.5055995e-4, 2.3229848e-5};
85
86 gas_scattering_coef = PropagationMatrix(f_grid.nelem(), stokes_dim);
87
88 for (Index f = 0; f < f_grid.nelem(); f++) {
89 const Numeric wavelen = Conversion::freq2wavelen(f_grid[f]) * 1e6;
90 Numeric sum = 0;
91 Numeric pows = 1;
92 for (auto& coef: coefficients) {
93 sum += coef * pows;
94 pows /= Math::pow2(wavelen);
95 }
96 gas_scattering_coef.Kjj()[f] = 1e-32 * sum / Math::pow4(wavelen);
97 }
98
99 gas_scattering_coef.Kjj() *= number_density(rtp_pressure, rtp_temperature);
100}
101
102/* Workspace method: Doxygen documentation will be auto-generated */
104 Vector& gas_scattering_fct_legendre,
105 const Vector& gas_scattering_los_in,
106 const Vector& gas_scattering_los_out,
107 const Index& stokes_dim,
108 const Index& gas_scattering_output_type,
109 const Verbosity&) {
110 //out
111 if (gas_scattering_output_type) {
112 gas_scattering_fct_legendre.resize(1);
113 gas_scattering_fct_legendre = 1.;
114
115 } else {
116 if (gas_scattering_los_in.nelem() > 0 && gas_scattering_los_out.nelem() > 0) {
117 TransmissionMatrix sca_mat_temp(1, stokes_dim);
118 sca_mat_temp.setIdentity();
119 gas_scattering_mat = sca_mat_temp;
120 } else {
121 // set the scattering matrics empty in case the in and out los are empty
122 gas_scattering_mat = TransmissionMatrix();
123 }
124 }
125}
126
127/* Workspace method: Doxygen documentation will be auto-generated */
129 Vector& gas_scattering_fct_legendre,
130 const Vector& gas_scattering_los_in,
131 const Vector& gas_scattering_los_out,
132 const Index& stokes_dim,
133 const Index& gas_scattering_output_type,
134 const Numeric& depolarization_factor,
135 const Verbosity&) {
136
137 ARTS_USER_ERROR_IF(gas_scattering_los_in.nelem() != gas_scattering_los_out.nelem(),
138 "The length of the vectors of incoming and outgoing direction must be the same.")
139
140
141
142 if (gas_scattering_output_type) {
143 gas_scattering_fct_legendre.resize(3);
144 gas_scattering_fct_legendre = {1, 0, 0.1};
145
146 } else {
147
148 //if gas_scattering_los_in or gas_scattering_los_out is empty then gas_scattering_mat is empty.
149 if (gas_scattering_los_in.nelem()>0 && gas_scattering_los_out.nelem()>0){
150
151 Index atmosphere_dim = 1;
152 if (gas_scattering_los_in.nelem()==2){
153 atmosphere_dim=3;
154 }
155
156 //For the scattering calculation we need the propagation direction of incoming
157 //and outgoing radiation. Therefore we have to convert the line of sights to
158 //propagation directions.
159 Vector in_prop;
160 Vector out_prop;
161
162 mirror_los(in_prop, gas_scattering_los_in,atmosphere_dim);
163 mirror_los(out_prop, gas_scattering_los_out,atmosphere_dim);
164
165 // calc_scatteringAngle() between gas_scattering_los_in and gas_scattering_los_out
166 Numeric za_inc = in_prop[0];
167 Numeric za_sca = out_prop[0];
168
169 Numeric aa_inc = 0;
170 Numeric aa_sca = 0;
171 if (atmosphere_dim==3){
172 aa_inc = in_prop[1];
173 aa_sca = out_prop[1];
174 }
175
176 Numeric theta_rad = scat_angle(za_sca, aa_sca, za_inc, aa_inc);
177
178 // Rayleigh phase matrix in scattering system
179 Vector pha_mat_int = calc_rayleighPhaMat(theta_rad, stokes_dim);
180
181 // transform the phase matrix
182 Matrix pha_mat(stokes_dim, stokes_dim, 0.0);
183
184 // account for depolarization factor
185 Numeric delta =
186 (1 - depolarization_factor) / (1 + 0.5 * depolarization_factor);
187 Numeric delta_prime =
188 (1 - 2 * depolarization_factor) / (1 - depolarization_factor);
189 Vector depol(6, 0.0);
190
191 switch (stokes_dim) {
192 case 4:
193 depol[5] = 1;
194 pha_mat_int[5] *= delta_prime;
195 [[fallthrough]];
196 case 1:
197 depol[0] = 1;
198 depol *= 1 - delta;
199 pha_mat_int += depol;
200 }
201
202 pha_mat_labCalc(pha_mat,
203 pha_mat_int,
204 gas_scattering_los_out[0],
205 gas_scattering_los_out[1],
206 gas_scattering_los_in[0],
207 gas_scattering_los_in[1],
208 theta_rad);
209
210 TransmissionMatrix sca_mat_temp(pha_mat);
211
212 gas_scattering_mat = sca_mat_temp;
213 } else {
214 // set the scattering matrics empty in case the in and out los are empty
215 gas_scattering_mat = TransmissionMatrix();
216 }
217 }
218}
Declarations for agendas.
Common ARTS conversions.
The Agenda class.
Definition: agenda_class.h:69
void set_name(const String &nname)
Set agenda name.
Index nelem() const noexcept
Returns the number of elements.
Definition: matpackI.h:536
The Matrix class.
Definition: matpackI.h:1261
VectorView Kjj(const Index iz=0, const Index ia=0)
Vector view to diagonal elements.
The Vector class.
Definition: matpackI.h:899
void resize(Index n)
Resize function.
Definition: matpackI.cc:390
Workspace class.
Definition: workspace_ng.h:53
#define ARTS_USER_ERROR_IF(condition,...)
Definition: debug.h:134
Vector calc_rayleighPhaMat(const Numeric &theta_rad, const Index &stokes_dim)
Header file for functions related to gas scattering.
void gas_scatteringOff(Workspace &ws, Index &gas_scattering_do, Agenda &gas_scattering_agenda, const Verbosity &)
WORKSPACE METHOD: gas_scatteringOff.
void gas_scattering_coefXsecConst(PropagationMatrix &gas_scattering_coef, const Vector &f_grid, const Numeric &rtp_pressure, const Numeric &rtp_temperature, const Index &stokes_dim, const Numeric &ConstXsec, const Verbosity &)
WORKSPACE METHOD: gas_scattering_coefXsecConst.
void gas_scattering_matIsotropic(TransmissionMatrix &gas_scattering_mat, Vector &gas_scattering_fct_legendre, const Vector &gas_scattering_los_in, const Vector &gas_scattering_los_out, const Index &stokes_dim, const Index &gas_scattering_output_type, const Verbosity &)
WORKSPACE METHOD: gas_scattering_matIsotropic.
void gas_scattering_matRayleigh(TransmissionMatrix &gas_scattering_mat, Vector &gas_scattering_fct_legendre, const Vector &gas_scattering_los_in, const Vector &gas_scattering_los_out, const Index &stokes_dim, const Index &gas_scattering_output_type, const Numeric &depolarization_factor, const Verbosity &)
WORKSPACE METHOD: gas_scattering_matRayleigh.
void gas_scattering_coefAirSimple(PropagationMatrix &gas_scattering_coef, const Vector &f_grid, const Numeric &rtp_pressure, const Numeric &rtp_temperature, const Index &stokes_dim, const Verbosity &)
WORKSPACE METHOD: gas_scattering_coefAirSimple.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
constexpr Numeric boltzmann_constant
Boltzmann constant [J/K] From: https://en.wikipedia.org/wiki/2019_redefinition_of_SI_base_units Date:...
constexpr Numeric pi
The following mathematical constants are generated in python Decimal package by the code:
constexpr Numeric e
Elementary charge convenience name [C].
constexpr auto freq2wavelen(auto x) noexcept
Conversion from Hz to wavelength.
constexpr auto pow4(auto x) noexcept
power of four
constexpr auto pow2(auto x) noexcept
power of two
void sum(PropagationMatrix &pm, const ComplexVectorView &abs, const PolarizationVector &polvec, const bool do_phase) ARTS_NOEXCEPT
Sums the Zeeman components into a propagation matrix.
Definition: zeemandata.cc:433
Numeric scat_angle(const Numeric &za_sca, const Numeric &aa_sca, const Numeric &za_inc, const Numeric &aa_inc)
Calculates the scattering angle.
void pha_mat_labCalc(MatrixView pha_mat_lab, ConstVectorView pha_mat_int, const Numeric &za_sca, const Numeric &aa_sca, const Numeric &za_inc, const Numeric &aa_inc, const Numeric &theta_rad)
Calculate phase matrix in laboratory coordinate system.
Scattering database structure and functions.
This file contains declerations of functions of physical character.
constexpr Numeric number_density(Numeric p, Numeric t) noexcept
number_density
Definition: physics_funcs.h:70
void mirror_los(Vector &los_mirrored, const ConstVectorView &los, const Index &atmosphere_dim)
Determines the backward direction for a given line-of-sight.
Definition: rte.cc:1812
Declaration of functions in rte.cc.
Class to keep track of Transmission Matrices for Stokes Dim 1-4.
void setIdentity()
Set to identity matrix.
Stuff related to the transmission matrix.