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( findspecieslocal("H2")->xFracLim < 1e-2 )
00105 {
00106 timesc.time_H2_Dest_longest *= -1.;
00107 timesc.time_H2_Form_longest *= -1.;
00108 }
00109 tlong = MAX2( tlong , timesc.time_H2_Dest_longest );
00110 tlong = MAX2( tlong , timesc.time_H2_Form_longest );
00111
00112 if( findspecieslocal("CO")->xFracLim < 1e-2 )
00113 {
00114 timesc.BigCOMoleForm *= -1.;
00115 }
00116 tlong = MAX2( tlong , timesc.BigCOMoleForm );
00117
00118
00119 if( prt.lgPrnAges && timesc.time_H2_Dest_longest > 0. )
00120 {
00121 sprintf( chLine, " AGE: longest H2 destruction timescale= %.2es.",
00122 timesc.time_H2_Dest_longest );
00123 notein(chLine);
00124 }
00125
00126 if( prt.lgPrnAges && timesc.time_H2_Form_longest > 0. )
00127 {
00128 sprintf( chLine, " AGE: longest H2 formation timescale= %.2es.",
00129 timesc.time_H2_Form_longest );
00130 notein(chLine);
00131 }
00132
00133 if( timesc.CloudAgeSet > 0. && timesc.time_H2_Dest_longest > timesc.CloudAgeSet )
00134 {
00135 sprintf( chLine, " C-AGE: H2 destruction timescale longer than age, = %.2es",
00136 timesc.time_H2_Dest_longest );
00137 caunin(chLine);
00138 }
00139
00140 if( timesc.CloudAgeSet > 0. && timesc.time_H2_Form_longest > timesc.CloudAgeSet )
00141 {
00142 sprintf( chLine, " C-AGE: H2 formation timescale longer than age, = %.2es",
00143 timesc.time_H2_Form_longest );
00144 caunin(chLine);
00145 }
00146
00147 if( prt.lgPrnAges && timesc.BigCOMoleForm > 0. )
00148 {
00149 sprintf( chLine, " AGE: longest CO formation timescale= %.2es.",
00150 timesc.BigCOMoleForm );
00151 notein(chLine);
00152 }
00153
00154 if( timesc.CloudAgeSet > 0. && timesc.BigCOMoleForm > timesc.CloudAgeSet )
00155 {
00156 sprintf( chLine, " C-AGE: CO formation timescale longer than age, = %.2es",
00157 timesc.BigCOMoleForm );
00158 caunin(chLine);
00159 }
00160
00161
00162 timesc.time_Hrecom_long = 0.;
00163 timesc.time_Hrecom_short = 0.;
00164 for( i=0; i < limit; i++ )
00165 {
00166 if( struc.ednstr[i]>SMALLFLOAT )
00167 {
00168 hold = struc.ednstr[i]*2.90e-10*pow(struc.testr[i],(realnum)-0.77f);
00169 timesc.time_Hrecom_long = MAX2(timesc.time_Hrecom_long , 1./hold);
00170 timesc.time_Hrecom_short = MAX2(timesc.time_Hrecom_short , 1./hold);
00171 }
00172 }
00173
00174 tlong = MAX2(tlong,timesc.time_Hrecom_long);
00175 if( prt.lgPrnAges )
00176 {
00177 sprintf( chLine, " AGE: longest H recombination timescale= %.2es.",
00178 timesc.time_Hrecom_long );
00179 notein(chLine);
00180 }
00181
00182 if( timesc.CloudAgeSet > 0. && timesc.time_Hrecom_long > timesc.CloudAgeSet )
00183 {
00184 sprintf( chLine, " C-AGE: Hydrogen recombination timescale longer than age, = %.2es",
00185 timesc.time_Hrecom_long );
00186 caunin(chLine);
00187 }
00188
00189
00190 if( timesc.CloudAgeSet < 0. )
00191 {
00192
00193 if( tlong < 3600. )
00194 {
00195
00196 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s.",
00197 tlong );
00198 bangin(chLine);
00199 }
00200
00201 else if( tlong < 8.64e4 )
00202 {
00203
00204 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e hours.",
00205 tlong, tlong/3600. );
00206 bangin(chLine);
00207 }
00208
00209 else if( tlong < 3e7/12. )
00210 {
00211
00212 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e days.",
00213 tlong, tlong/86400. );
00214 bangin(chLine);
00215 }
00216
00217 else if( tlong < 3e7 )
00218 {
00219
00220 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e months.",
00221 tlong, (tlong/3.15569e7)*12. );
00222 bangin(chLine);
00223 }
00224
00225 else
00226 {
00227
00228 sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e years.",
00229 tlong, tlong/3.15569e7 );
00230 bangin(chLine);
00231 }
00232 }
00233
00234 else
00235 {
00236
00237 if( tlong < 3e7 )
00238 {
00239
00240 sprintf( chLine, " AGE: Cloud age was %.2es, Longest timescale was %.2e s.",
00241 timesc.CloudAgeSet, tlong );
00242 notein(chLine);
00243 }
00244
00245 else
00246 {
00247
00248 sprintf( chLine, " AGE: Cloud age was %.2e s. Longest timescale was %.2e s = %.2e years.",
00249 timesc.CloudAgeSet, tlong, tlong/3.15569e7 );
00250 notein(chLine);
00251 }
00252 }
00253 return;
00254 }