ARTS  2.2.66
physics_funcs.cc
Go to the documentation of this file.
1 /* Copyright (C) 2002-2012
2  Patrick Eriksson <Patrick.Eriksson@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 /*===========================================================================
24  === File description
25  ===========================================================================*/
26 
38 /*===========================================================================
39  === External declarations
40  ===========================================================================*/
41 
42 #include <cmath>
43 #include <stdexcept>
44 #include "physics_funcs.h"
45 #include "messages.h"
46 #include "mystring.h"
47 #include "physics_funcs.h"
48 
49 extern const Numeric BOLTZMAN_CONST;
50 extern const Numeric DEG2RAD;
51 extern const Numeric PLANCK_CONST;
52 extern const Numeric SPEED_OF_LIGHT;
53 
54 
55 
56 /*===========================================================================
57  === The functions (in alphabetical order)
58  ===========================================================================*/
59 
71  //input
72  const Numeric& p,
73  const Numeric& dh
74  )
75 
76 {
77  /* taken from: Seite „Barometrische Höhenformel“. In: Wikipedia,
78  * Die freie Enzyklopädie. Bearbeitungsstand: 3. April 2011, 20:28 UTC.
79  * URL: http://de.wikipedia.org/w/index.php?title=Barometrische_H%C3%B6henformel&oldid=87257486
80  * (Abgerufen: 15. April 2011, 15:41 UTC)
81  */
82 
83 
84  //barometric height formula
85  Numeric M = 0.02896; //mean molar mass of air [kg mol^-1]
86  Numeric g = 9.807; //earth acceleration [kg m s^-1]
87  Numeric R = 8.314; //universal gas constant [J K^−1 mol^−1]
88  Numeric T = 253; //median tropospheric reference temperature [K]
89 
90  // calculation
91  Numeric p1 = p * exp(-(-dh)/(R*T/(M*g)));
92 
93  return p1;
94 
95 }
96 
97 
98 
100 
111  const Numeric& i,
112  const Numeric& f )
113 {
114  assert( i >= 0 );
115  assert( f > 0 );
116 
117  static const Numeric a = PLANCK_CONST / BOLTZMAN_CONST;
118  static const Numeric b = 2 * PLANCK_CONST / ( SPEED_OF_LIGHT*SPEED_OF_LIGHT );
119 
120  const Numeric d = b * f*f*f / i;
121  const Numeric binv = a * f / log( d + 1 );
122 
123  return binv*binv / ( a * f * i * (1/d+1) );
124 }
125 
126 
127 
129 
148 void fresnel(
149  Complex& Rv,
150  Complex& Rh,
151  const Complex& n1,
152  const Complex& n2,
153  const Numeric& theta )
154 {
155  const Numeric theta1 = DEG2RAD * theta;
156  const Numeric costheta1 = cos( theta1 );
157  const Numeric costheta2 = cos( asin( n1.real() * sin(theta1) / n2.real() ) );
158 
159  Complex a, b;
160  a = n2 * costheta1;
161  b = n1 * costheta2;
162  Rv = ( a - b ) / ( a + b );
163  a = n1 * costheta1;
164  b = n2 * costheta2;
165  Rh = ( a - b ) / ( a + b );
166 }
167 
168 
170 
181  const Numeric& i,
182  const Numeric& f )
183 {
184  if (i < 0)
185  {
186  ostringstream os;
187  os << "Conversion to Planck brightness temperature failed: Radiance must be >= 0.\n"
188  << "r = " << i;
189  throw runtime_error(os.str());
190  }
191 
192 // assert( i >= 0 );
193  assert( f > 0 );
194 
195  static const Numeric a = PLANCK_CONST / BOLTZMAN_CONST;
196  static const Numeric b = 2 * PLANCK_CONST / ( SPEED_OF_LIGHT*SPEED_OF_LIGHT );
197 
198  return ( a * f ) / log( (b*f*f*f)/i + 1.0 );
199 }
200 
201 
202 
204 
215  const Numeric& i,
216  const Numeric& f )
217 {
218  assert( f > 0 );
219 
221 
222  return ( a * i ) / ( f * f );
223 }
224 
225 
227 
238  const Numeric& p,
239  const Numeric& t )
240 {
241  assert( p >= 0 );
242  assert( t > 0 );
243  return p / ( t * BOLTZMAN_CONST );
244 }
245 
246 
247 
249 
262  const Numeric& f,
263  const Numeric& t )
264 {
265  assert( t >= 0 );
266  assert( f > 0 );
267 
268  if( t == 0 )
269  { return 0; }
270 
271  else
272  {
273  static const Numeric a = 2 * PLANCK_CONST / (SPEED_OF_LIGHT*SPEED_OF_LIGHT);
274  static const Numeric b = PLANCK_CONST / BOLTZMAN_CONST;
275 
276  return ( a * f*f*f ) / ( exp( (b*f)/t ) - 1.0 );
277  }
278 }
279 
280 
281 
283 
294  const Numeric& f,
295  const Numeric& t )
296 {
297  assert( f > 0 );
298 
300 
301  return ( f * f ) / ( a * t );
302 }
#define M
Definition: rng.cc:196
Declarations having to do with the four output streams.
Numeric invrayjean(const Numeric &i, const Numeric &f)
invrayjean
Numeric dinvplanckdI(const Numeric &i, const Numeric &f)
dinvplanckdI
void fresnel(Complex &Rv, Complex &Rh, const Complex &n1, const Complex &n2, const Numeric &theta)
fresnel
Numeric number_density(const Numeric &p, const Numeric &t)
number_density
Numeric barometric_heightformula(const Numeric &p, const Numeric &dh)
std::complex< Numeric > Complex
Definition: complex.h:32
Numeric rayjean(const Numeric &f, const Numeric &t)
rayjean
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
const Numeric PLANCK_CONST
Numeric planck(const Numeric &f, const Numeric &t)
planck
Numeric invplanck(const Numeric &i, const Numeric &f)
invplanck
const Numeric BOLTZMAN_CONST
const Numeric SPEED_OF_LIGHT
const Numeric DEG2RAD
This file contains the definition of String, the ARTS string class.