00001
00002
00003
00004 #include "cddefines.h"
00005 #include "physconst.h"
00006 #include "prt.h"
00007 #include "hmi.h"
00008 #include "mole.h"
00009 #include "struc.h"
00010 #include "warnings.h"
00011 #include "dense.h"
00012 #include "timesc.h"
00013
00014 void AgeCheck(void)
00015 {
00016 char chLine[INPUT_LINE_LENGTH];
00017 long int i,
00018 limit;
00019 double hold,
00020 tlong,
00021 tsound;
00022
00023 DEBUG_ENTRY( "AgeCheck()" );
00024
00025
00026
00027
00028
00029 tlong = 0.;
00030
00031
00032 timesc.time_therm_long = 0.;
00033 timesc.time_therm_short = 0.;
00034 limit = MAX2(1,nzone-1);
00035 ASSERT( limit < struc.nzlim );
00036
00037
00038
00039
00040 for( i=0; i < limit; i++ )
00041 {
00042 timesc.time_therm_long =
00043 MAX2( timesc.time_therm_long ,
00044 struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]);
00045 timesc.time_therm_short =
00046 MIN2( timesc.time_therm_short ,
00047 struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]);
00048
00049
00050 }
00051
00052 tlong = MAX2(tlong,timesc.time_therm_long);
00053 if( prt.lgPrnAges )
00054 {
00055 sprintf( chLine, " AGE: longest thermal timescale= %.2es.",
00056 timesc.time_therm_long );
00057 notein(chLine);
00058 }
00059
00060 tlong = MAX2(tlong,timesc.TimeH21cm);
00061 if( prt.lgPrnAges )
00062 {
00063 sprintf( chLine, " AGE: 21 cm equilibrium timescale= %.2es.",
00064 timesc.TimeH21cm );
00065 notein(chLine);
00066 }
00067
00068 if( timesc.CloudAgeSet > 0. && timesc.time_therm_long > timesc.CloudAgeSet )
00069 {
00070 sprintf( chLine, " C-AGE: Thermal equilibrium timescale, %.2es, longer than age",
00071 timesc.time_therm_long );
00072 caunin(chLine);
00073 }
00074
00075
00076 if( strcmp(dense.chDenseLaw,"CPRE") == 0 )
00077 {
00078 tsound = timesc.sound;
00079 if( prt.lgPrnAges )
00080 {
00081 sprintf( chLine, " AGE: sound travel time= %.2es.",
00082 tsound );
00083 notein(chLine);
00084 }
00085
00086 if( timesc.CloudAgeSet > 0. && tsound > timesc.CloudAgeSet )
00087 {
00088 sprintf( chLine, " C-AGE: Sound travel time longer than age in constant pressure model = %.2es",
00089 timesc.time_therm_long );
00090 caunin(chLine);
00091 }
00092 }
00093
00094 else
00095 {
00096
00097 tsound = 0.;
00098 }
00099 tlong = MAX2(tlong,tsound);
00100
00101
00102
00103
00104 if( hmi.BiggestH2<1e-2 )
00105 {
00106 timesc.time_H2_Dest_longest *= -1.;
00107 timesc.time_H2_Form_longest *= -1.;
00108 }
00109 if( findspecies("CO")->xMoleFracMax < 1e-2 )
00110 {
00111 timesc.BigCOMoleForm *= -1.;
00112 }
00113 tlong = MAX2( tlong , timesc.time_H2_Dest_longest );
00114 tlong = MAX2( tlong , timesc.time_H2_Form_longest );
00115 tlong = MAX2( tlong , timesc.BigCOMoleForm );
00116
00117
00118 if( prt.lgPrnAges && timesc.time_H2_Dest_longest > 0. )
00119 {
00120 sprintf( chLine, " AGE: longest H2 destruction timescale= %.2es.",
00121 timesc.time_H2_Dest_longest );
00122 notein(chLine);
00123 }
00124
00125 if( prt.lgPrnAges && timesc.time_H2_Form_longest > 0. )
00126 {
00127 sprintf( chLine, " AGE: longest H2 formation timescale= %.2es.",
00128 timesc.time_H2_Form_longest );
00129 notein(chLine);
00130 }
00131
00132 if( timesc.CloudAgeSet > 0. && timesc.time_H2_Dest_longest > timesc.CloudAgeSet )
00133 {
00134 sprintf( chLine, " C-AGE: H2 destruction timescale longer than age, = %.2es",
00135 timesc.time_H2_Dest_longest );
00136 caunin(chLine);
00137 }
00138
00139 if( timesc.CloudAgeSet > 0. && timesc.time_H2_Form_longest > timesc.CloudAgeSet )
00140 {
00141 sprintf( chLine, " C-AGE: H2 formation timescale longer than age, = %.2es",
00142 timesc.time_H2_Form_longest );
00143 caunin(chLine);
00144 }
00145
00146 if( prt.lgPrnAges && timesc.BigCOMoleForm > 0. )
00147 {
00148 sprintf( chLine, " AGE: longest CO formation timescale= %.2es.",
00149 timesc.BigCOMoleForm );
00150 notein(chLine);
00151 }
00152
00153 if( timesc.CloudAgeSet > 0. && timesc.BigCOMoleForm > timesc.CloudAgeSet )
00154 {
00155 sprintf( chLine, " C-AGE: CO formation timescale longer than age, = %.2es",
00156 timesc.BigCOMoleForm );
00157 caunin(chLine);
00158 }
00159
00160
00161 timesc.time_Hrecom_long = 0.;
00162 timesc.time_Hrecom_short = 0.;
00163 for( i=0; i < limit; i++ )
00164 {
00165 hold = struc.ednstr[i]*2.90e-10*pow(struc.testr[i],(realnum)-0.77f);
00166 timesc.time_Hrecom_long = MAX2(timesc.time_Hrecom_long , 1./hold);
00167 timesc.time_Hrecom_short = MAX2(timesc.time_Hrecom_short , 1./hold);
00168 }
00169
00170 tlong = MAX2(tlong,timesc.time_Hrecom_long);
00171 if( prt.lgPrnAges )
00172 {
00173 sprintf( chLine, " AGE: longest H recombination timescale= %.2es.",
00174 timesc.time_Hrecom_long );
00175 notein(chLine);
00176 }
00177
00178 if( timesc.CloudAgeSet > 0. && timesc.time_Hrecom_long > timesc.CloudAgeSet )
00179 {
00180 sprintf( chLine, " C-AGE: Hydrogen recombination timescale longer than age, = %.2es",
00181 timesc.time_Hrecom_long );
00182 caunin(chLine);
00183 }
00184
00185
00186 if( timesc.CloudAgeSet < 0. )
00187 {
00188
00189 if( tlong < 3600. )
00190 {
00191
00192 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s.",
00193 tlong );
00194 bangin(chLine);
00195 }
00196
00197 else if( tlong < 8.64e4 )
00198 {
00199
00200 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e hours.",
00201 tlong, tlong/3600. );
00202 bangin(chLine);
00203 }
00204
00205 else if( tlong < 3e7/12. )
00206 {
00207
00208 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e days.",
00209 tlong, tlong/86400. );
00210 bangin(chLine);
00211 }
00212
00213 else if( tlong < 3e7 )
00214 {
00215
00216 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e months.",
00217 tlong, (tlong/3.15569e7)*12. );
00218 bangin(chLine);
00219 }
00220
00221 else
00222 {
00223
00224 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e years.",
00225 tlong, tlong/3.15569e7 );
00226 bangin(chLine);
00227 }
00228 }
00229
00230 else
00231 {
00232
00233 if( tlong < 3e7 )
00234 {
00235
00236 sprintf( chLine, " AGE: Cloud age was %.2es, Longest timescale was %.2e s.",
00237 timesc.CloudAgeSet, tlong );
00238 notein(chLine);
00239 }
00240
00241 else
00242 {
00243
00244 sprintf( chLine, " AGE: Cloud age was %.2e s. Longest timescale was %.2e s = %.2e years.",
00245 timesc.CloudAgeSet, tlong, tlong/3.15569e7 );
00246 notein(chLine);
00247 }
00248 }
00249 return;
00250 }