00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00038
00039
00040
00041
00042 #include <cmath>
00043 #include <stdexcept>
00044 #include "physics_funcs.h"
00045 #include "messages.h"
00046 #include "mystring.h"
00047 #include "physics_funcs.h"
00048
00049 extern const Numeric BOLTZMAN_CONST;
00050 extern const Numeric DEG2RAD;
00051 extern const Numeric PLANCK_CONST;
00052 extern const Numeric SPEED_OF_LIGHT;
00053
00054
00055
00056
00057
00058
00059
00061
00080 void fresnel(
00081 Complex& Rv,
00082 Complex& Rh,
00083 const Complex& n1,
00084 const Complex& n2,
00085 const Numeric& theta )
00086 {
00087 const Numeric theta1 = DEG2RAD * theta;
00088 const Numeric costheta1 = cos( theta1 );
00089 const Numeric costheta2 = cos( asin( n1.real() * sin(theta1) / n2.real() ) );
00090
00091 Complex a, b;
00092 a = n2 * costheta1;
00093 b = n1 * costheta2;
00094 Rv = ( a - b ) / ( a + b );
00095 a = n1 * costheta1;
00096 b = n2 * costheta2;
00097 Rh = ( a - b ) / ( a + b );
00098 }
00099
00100
00102
00112 Numeric invplanck(
00113 const Numeric& i,
00114 const Numeric& f )
00115 {
00116 assert( i >= 0 );
00117 assert( f > 0 );
00118
00119
00120 static const double a = PLANCK_CONST / BOLTZMAN_CONST;
00121 static const double b = 2 * PLANCK_CONST / ( SPEED_OF_LIGHT*SPEED_OF_LIGHT );
00122
00123 return a * f / log( b*pow(f,3)/i + 1 );
00124 }
00125
00126
00127
00129
00139 Numeric invrayjean(
00140 const Numeric& i,
00141 const Numeric& f )
00142 {
00143 assert( f > 0 );
00144
00145
00146
00147
00148
00149
00150
00151 return SPEED_OF_LIGHT / ((double)f * (double)f)
00152 * (double)i * SPEED_OF_LIGHT / (2 * BOLTZMAN_CONST);
00153 }
00154
00155
00157
00167 Numeric number_density(
00168 const Numeric& p,
00169 const Numeric& t )
00170 {
00171 assert( p >= 0 );
00172 assert( t > 0 );
00173 return p / ( t * BOLTZMAN_CONST );
00174 }
00175
00176
00177
00179
00191 Numeric planck(
00192 const Numeric& f,
00193 const Numeric& t )
00194 {
00195 assert( f > 0 );
00196 assert( t >= 0 );
00197
00198
00199 static const double a = 2 * PLANCK_CONST / (SPEED_OF_LIGHT*SPEED_OF_LIGHT);
00200 static const double b = PLANCK_CONST / BOLTZMAN_CONST;
00201
00202 return a * f*f*f / ( exp( b*f/t ) - 1 );
00203 }
00204
00205
00206
00207