ARTS  2.0.49
m_physics.cc
Go to the documentation of this file.
1 /* Copyright (C) 2002-2008
2  Patrick Eriksson <Patrick.Eriksson@rss.chalmers.se>
3  Stefan Buehler <sbuehler@ltu.se>
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 
22 /*===========================================================================
23  === File description
24  ===========================================================================*/
25 
44 /*===========================================================================
45  === External declarations
46  ===========================================================================*/
47 
48 #include "arts.h"
49 #include "auto_md.h"
50 #include "check_input.h"
51 #include "logic.h"
52 #include "math_funcs.h"
53 #include "messages.h"
54 #include "physics_funcs.h"
55 
56 extern const Numeric COSMIC_BG_TEMP;
57 extern const Numeric TEMP_0_C;
58 
59 
60 /*===========================================================================
61  === The functions (in alphabetical order)
62  ===========================================================================*/
63 
64 
65 /* Workspace method: Doxygen documentation will be auto-generated */
66 void complex_nWaterLiebe93(Matrix& complex_n,
67  const Vector& f_grid,
68  const Numeric& t,
69  const Verbosity& verbosity)
70 {
73 
74  chk_if_in_range( "t", t, TEMP_0_C, TEMP_0_C+100 );
75  chk_if_in_range( "min of f_grid", min(f_grid), 10e9, 1000e9 );
76  chk_if_in_range( "max of f_grid", max(f_grid), 10e9, 1000e9 );
77 
78  out2 << " Sets *complex_n* to model properties of liquid water,\n"
79  << " according to Liebe 1993\n";
80  out3 << " temperature : " << t << " K.\n";
81 
82  const Index nf = f_grid.nelem();
83 
84  complex_n.resize( nf, 2 );
85 
86  // Values from epswater93.m (by C. Mätzler), part of Atmlab.
87  // The constant e2 is here set to 3.52, which according to Mätzler
88  // corresponds to Liebe 1993.
89  const Numeric theta = 1 - 300 / t;
90  const Numeric e0 = 77.66 - 103.3 * theta;
91  const Numeric e1 = 0.0671 * e0;
92  const Numeric f1 = 20.2 + 146.4 * theta + 316 * theta * theta;
93  const Numeric e2 = 3.52;
94  const Numeric f2 = 39.8 * f1;
95 
96  for( Index iv=0; iv<nf; iv++ )
97  {
98  const Complex ifGHz( 0.0, f_grid[iv]/1e9 );
99 
100  Complex n = sqrt( e2 + (e1-e2) / (Numeric(1.0)-ifGHz/f2) +
101  (e0-e1) / (Numeric(1.0)-ifGHz/f1) );
102 
103  complex_n(iv,0) = n.real();
104  complex_n(iv,1) = n.imag();
105  }
106 }
107 
108 
109 /* Workspace method: Doxygen documentation will be auto-generated */
110 void emissionPlanck(Vector& emission,
111  const Vector& f,
112  const Numeric& t,
113  const Verbosity&)
114 {
115  const Index n = f.nelem();
116 
117  emission.resize(n);
118 
119  for( Index i=0; i<n; i++ )
120  { emission[i] = planck( f[i], t ); }
121 }
122 
123 
124 /* Workspace method: Doxygen documentation will be auto-generated */
125 void MatrixCBR(// WS Output:
126  Matrix& m,
127  // WS Input:
128  const Index& stokes_dim,
129  // WS Generic Input:
130  const Vector& f,
131  const Verbosity&)
132 {
133  const Index n = f.nelem();
134 
135  if( n == 0 )
136  throw runtime_error( "The given frequency vector is empty." );
137 
138  m.resize(n,stokes_dim);
139  m = 0;
140 
141  for( Index i=0; i<n; i++ )
142  { m(i,0) = planck( f[i], COSMIC_BG_TEMP ); }
143 }
144 
145 
146 /* Workspace method: Doxygen documentation will be auto-generated */
147 void MatrixPlanck(// WS Output:
148  Matrix& m,
149  // WS Input:
150  const Index& stokes_dim,
151  // WS Generic Input:
152  const Vector& f,
153  const Numeric& t,
154  const Verbosity& verbosity)
155 {
157 
158  const Index n = f.nelem();
159 
160  if( n == 0 )
161  throw runtime_error( "The given frequency vector is empty." );
162 
163  out2 << " Setting blackbody radiation for a temperature of " << t << " K.\n";
164 
165  m.resize(n,stokes_dim);
166  m = 0;
167 
168  for( Index i=0; i<n; i++ )
169  { m(i,0) = planck( f[i], t ); }
170 }
171 
172 
173 
174 
175 /* Workspace method: Doxygen documentation will be auto-generated */
176 void MatrixUnitIntensity(// WS Output:
177  Matrix& m,
178  // WS Input:
179  const Index& stokes_dim,
180  // WS Generic Input:
181  const Vector& f,
182  const Verbosity& verbosity)
183 {
185 
186  const Index n = f.nelem();
187 
188  if( n == 0 )
189  throw runtime_error( "The given frequency vector is empty." );
190 
191  out2 << " Setting unpolarised radiation with an intensity of 1.\n";
192 
193  m.resize(n,stokes_dim);
194  m = 0;
195 
196  for( Index i=0; i<n; i++ )
197  { m(i,0) = 1.0; }
198 }
Matrix
The Matrix class.
Definition: matpackI.h:767
auto_md.h
TEMP_0_C
const Numeric TEMP_0_C
COSMIC_BG_TEMP
const Numeric COSMIC_BG_TEMP
Vector::resize
void resize(Index n)
Resize function.
Definition: matpackI.cc:771
CREATE_OUT2
#define CREATE_OUT2
Definition: messages.h:207
MatrixCBR
void MatrixCBR(Matrix &m, const Index &stokes_dim, const Vector &f, const Verbosity &)
WORKSPACE METHOD: MatrixCBR.
Definition: m_physics.cc:125
CREATE_OUT3
#define CREATE_OUT3
Definition: messages.h:208
messages.h
Declarations having to do with the four output streams.
ConstVectorView::nelem
Index nelem() const
Returns the number of elements.
Definition: matpackI.cc:175
physics_funcs.h
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:50
math_funcs.h
emissionPlanck
void emissionPlanck(Vector &emission, const Vector &f, const Numeric &t, const Verbosity &)
WORKSPACE METHOD: emissionPlanck.
Definition: m_physics.cc:110
Matrix::resize
void resize(Index r, Index c)
Resize function.
Definition: matpackI.cc:1549
max
#define max(a, b)
Definition: continua.cc:13097
planck
Numeric planck(const Numeric &f, const Numeric &t)
planck
Definition: physics_funcs.cc:219
MatrixPlanck
void MatrixPlanck(Matrix &m, const Index &stokes_dim, const Vector &f, const Numeric &t, const Verbosity &verbosity)
WORKSPACE METHOD: MatrixPlanck.
Definition: m_physics.cc:147
complex_nWaterLiebe93
void complex_nWaterLiebe93(Matrix &complex_n, const Vector &f_grid, const Numeric &t, const Verbosity &verbosity)
WORKSPACE METHOD: complex_nWaterLiebe93.
Definition: m_physics.cc:66
logic.h
Header file for logic.cc.
MatrixUnitIntensity
void MatrixUnitIntensity(Matrix &m, const Index &stokes_dim, const Vector &f, const Verbosity &verbosity)
WORKSPACE METHOD: MatrixUnitIntensity.
Definition: m_physics.cc:176
min
#define min(a, b)
Definition: continua.cc:13096
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
chk_if_in_range
void chk_if_in_range(const String &x_name, const Index &x, const Index &x_low, const Index &x_high)
chk_if_in_range
Definition: check_input.cc:95
check_input.h
Vector
The Vector class.
Definition: matpackI.h:555
complex
Definition: continua.cc:12953
arts.h
The global header file for ARTS.