ARTS  2.0.49
physics_funcs.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 /*===========================================================================
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 
61 
72  const Numeric& i,
73  const Numeric& f )
74 {
75  assert( i >= 0 );
76  assert( f > 0 );
77 
78  // Use always double to avoid numerical problem (see invrayjean)
79  static const double a = PLANCK_CONST / BOLTZMAN_CONST;
80  static const double b = 2 * PLANCK_CONST / ( SPEED_OF_LIGHT*SPEED_OF_LIGHT );
81 
82  const double d = b * pow((double)f,3) / (double)i;
83  const double binv = a * (double)f / log( d + 1 );
84 
85  return pow(binv,2) / ( a * (double)f * (double)i * (1/d+1) );
86 }
87 
88 
89 
91 
110 void fresnel(
111  Complex& Rv,
112  Complex& Rh,
113  const Complex& n1,
114  const Complex& n2,
115  const Numeric& theta )
116 {
117  const Numeric theta1 = DEG2RAD * theta;
118  const Numeric costheta1 = cos( theta1 );
119  const Numeric costheta2 = cos( asin( n1.real() * sin(theta1) / n2.real() ) );
120 
121  Complex a, b;
122  a = n2 * costheta1;
123  b = n1 * costheta2;
124  Rv = ( a - b ) / ( a + b );
125  a = n1 * costheta1;
126  b = n2 * costheta2;
127  Rh = ( a - b ) / ( a + b );
128 }
129 
130 
132 
143  const Numeric& i,
144  const Numeric& f )
145 {
146  assert( i >= 0 );
147  assert( f > 0 );
148 
149  // Use always double to avoid numerical problem (see invrayjean)
150  static const double a = PLANCK_CONST / BOLTZMAN_CONST;
151  // Double clealrly needed. b likely too small for float. b is approx 1e-50
152  static const double b = 2 * PLANCK_CONST / ( SPEED_OF_LIGHT*SPEED_OF_LIGHT );
153 
154  return ( a * (double)f ) / log( (b*pow((double)f,3))/(double)i + 1 );
155 }
156 
157 
158 
160 
171  const Numeric& i,
172  const Numeric& f )
173 {
174  assert( f > 0 );
175 
176  // Double must be used here (if not, the result can be NaN when using float)
177 
178  static const double a = SPEED_OF_LIGHT*SPEED_OF_LIGHT/(2*BOLTZMAN_CONST);
179 
180  return ( a * (double)i ) / ( (double)f * (double)f );
181 }
182 
183 
185 
196  const Numeric& p,
197  const Numeric& t )
198 {
199  assert( p >= 0 );
200  assert( t > 0 );
201  return p / ( t * BOLTZMAN_CONST );
202 }
203 
204 
205 
207 
220  const Numeric& f,
221  const Numeric& t )
222 {
223  assert( t >= 0 );
224  assert( f > 0 );
225 
226  if( t == 0 )
227  { return 0; }
228 
229  else
230  {
231  // Double must be used here (if not, a becomes 0 when using float)
232  static const double a = 2 * PLANCK_CONST / (SPEED_OF_LIGHT*SPEED_OF_LIGHT);
233  static const double b = PLANCK_CONST / BOLTZMAN_CONST;
234 
235  return ( a * pow((double)f,3) ) / ( exp( (b*(double)f)/(double)t ) - 1 );
236  }
237 }
238 
239 
240 
242 
253  const Numeric& f,
254  const Numeric& t )
255 {
256  assert( f > 0 );
257 
258  // Double must be used here (if not, the result can be NaN when using float)
259 
260  static const double a = SPEED_OF_LIGHT*SPEED_OF_LIGHT/(2*BOLTZMAN_CONST);
261 
262  return ( (double)f * (double)f ) / ( a * (double)t );
263 }
264 
265 
266 
267 
BOLTZMAN_CONST
const Numeric BOLTZMAN_CONST
dinvplanckdI
Numeric dinvplanckdI(const Numeric &i, const Numeric &f)
dinvplanckdI
Definition: physics_funcs.cc:71
DEG2RAD
const Numeric DEG2RAD
invrayjean
Numeric invrayjean(const Numeric &i, const Numeric &f)
invrayjean
Definition: physics_funcs.cc:170
number_density
Numeric number_density(const Numeric &p, const Numeric &t)
number_density
Definition: physics_funcs.cc:195
messages.h
Declarations having to do with the four output streams.
rayjean
Numeric rayjean(const Numeric &f, const Numeric &t)
rayjean
Definition: physics_funcs.cc:252
physics_funcs.h
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
invplanck
Numeric invplanck(const Numeric &i, const Numeric &f)
invplanck
Definition: physics_funcs.cc:142
planck
Numeric planck(const Numeric &f, const Numeric &t)
planck
Definition: physics_funcs.cc:219
fresnel
void fresnel(Complex &Rv, Complex &Rh, const Complex &n1, const Complex &n2, const Numeric &theta)
fresnel
Definition: physics_funcs.cc:110
PLANCK_CONST
const Numeric PLANCK_CONST
SPEED_OF_LIGHT
const Numeric SPEED_OF_LIGHT
mystring.h
This file contains the definition of String, the ARTS string class.
complex
Definition: continua.cc:12953