| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | #include "cddefines.h" |
|---|
| 5 | #include "physconst.h" |
|---|
| 6 | #include "prt.h" |
|---|
| 7 | #include "hmi.h" |
|---|
| 8 | #include "mole.h" |
|---|
| 9 | #include "struc.h" |
|---|
| 10 | #include "warnings.h" |
|---|
| 11 | #include "dense.h" |
|---|
| 12 | #include "timesc.h" |
|---|
| 13 | |
|---|
| 14 | void AgeCheck(void) |
|---|
| 15 | { |
|---|
| 16 | char chLine[INPUT_LINE_LENGTH]; |
|---|
| 17 | long int i, |
|---|
| 18 | limit; |
|---|
| 19 | double hold, |
|---|
| 20 | tlong, |
|---|
| 21 | tsound; |
|---|
| 22 | |
|---|
| 23 | DEBUG_ENTRY( "AgeCheck()" ); |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | tlong = 0.; |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | timesc.time_therm_long = 0.; |
|---|
| 33 | timesc.time_therm_short = 0.; |
|---|
| 34 | limit = MAX2(1,nzone-1); |
|---|
| 35 | ASSERT( limit < struc.nzlim ); |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | for( i=0; i < limit; i++ ) |
|---|
| 41 | { |
|---|
| 42 | timesc.time_therm_long = |
|---|
| 43 | MAX2( timesc.time_therm_long , |
|---|
| 44 | struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]); |
|---|
| 45 | timesc.time_therm_short = |
|---|
| 46 | MIN2( timesc.time_therm_short , |
|---|
| 47 | struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]); |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | tlong = MAX2(tlong,timesc.time_therm_long); |
|---|
| 53 | if( prt.lgPrnAges ) |
|---|
| 54 | { |
|---|
| 55 | sprintf( chLine, " AGE: longest thermal timescale= %.2es.", |
|---|
| 56 | timesc.time_therm_long ); |
|---|
| 57 | notein(chLine); |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | tlong = MAX2(tlong,timesc.TimeH21cm); |
|---|
| 61 | if( prt.lgPrnAges ) |
|---|
| 62 | { |
|---|
| 63 | sprintf( chLine, " AGE: 21 cm equilibrium timescale= %.2es.", |
|---|
| 64 | timesc.TimeH21cm ); |
|---|
| 65 | notein(chLine); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | if( timesc.CloudAgeSet > 0. && timesc.time_therm_long > timesc.CloudAgeSet ) |
|---|
| 69 | { |
|---|
| 70 | sprintf( chLine, " C-AGE: Thermal equilibrium timescale, %.2es, longer than age", |
|---|
| 71 | timesc.time_therm_long ); |
|---|
| 72 | caunin(chLine); |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | if( strcmp(dense.chDenseLaw,"CPRE") == 0 ) |
|---|
| 77 | { |
|---|
| 78 | tsound = timesc.sound; |
|---|
| 79 | if( prt.lgPrnAges ) |
|---|
| 80 | { |
|---|
| 81 | sprintf( chLine, " AGE: sound travel time= %.2es.", |
|---|
| 82 | tsound ); |
|---|
| 83 | notein(chLine); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | if( timesc.CloudAgeSet > 0. && tsound > timesc.CloudAgeSet ) |
|---|
| 87 | { |
|---|
| 88 | sprintf( chLine, " C-AGE: Sound travel time longer than age in constant pressure model = %.2es", |
|---|
| 89 | timesc.time_therm_long ); |
|---|
| 90 | caunin(chLine); |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | else |
|---|
| 95 | { |
|---|
| 96 | |
|---|
| 97 | tsound = 0.; |
|---|
| 98 | } |
|---|
| 99 | tlong = MAX2(tlong,tsound); |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | if( hmi.BiggestH2<1e-2 ) |
|---|
| 105 | { |
|---|
| 106 | timesc.time_H2_Dest_longest *= -1.; |
|---|
| 107 | timesc.time_H2_Form_longest *= -1.; |
|---|
| 108 | } |
|---|
| 109 | tlong = MAX2( tlong , timesc.time_H2_Dest_longest ); |
|---|
| 110 | tlong = MAX2( tlong , timesc.time_H2_Form_longest ); |
|---|
| 111 | |
|---|
| 112 | if( findspecies("CO")->xFracLim < 1e-2 ) |
|---|
| 113 | { |
|---|
| 114 | timesc.BigCOMoleForm *= -1.; |
|---|
| 115 | } |
|---|
| 116 | tlong = MAX2( tlong , timesc.BigCOMoleForm ); |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | if( prt.lgPrnAges && timesc.time_H2_Dest_longest > 0. ) |
|---|
| 120 | { |
|---|
| 121 | sprintf( chLine, " AGE: longest H2 destruction timescale= %.2es.", |
|---|
| 122 | timesc.time_H2_Dest_longest ); |
|---|
| 123 | notein(chLine); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | if( prt.lgPrnAges && timesc.time_H2_Form_longest > 0. ) |
|---|
| 127 | { |
|---|
| 128 | sprintf( chLine, " AGE: longest H2 formation timescale= %.2es.", |
|---|
| 129 | timesc.time_H2_Form_longest ); |
|---|
| 130 | notein(chLine); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | if( timesc.CloudAgeSet > 0. && timesc.time_H2_Dest_longest > timesc.CloudAgeSet ) |
|---|
| 134 | { |
|---|
| 135 | sprintf( chLine, " C-AGE: H2 destruction timescale longer than age, = %.2es", |
|---|
| 136 | timesc.time_H2_Dest_longest ); |
|---|
| 137 | caunin(chLine); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | if( timesc.CloudAgeSet > 0. && timesc.time_H2_Form_longest > timesc.CloudAgeSet ) |
|---|
| 141 | { |
|---|
| 142 | sprintf( chLine, " C-AGE: H2 formation timescale longer than age, = %.2es", |
|---|
| 143 | timesc.time_H2_Form_longest ); |
|---|
| 144 | caunin(chLine); |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | if( prt.lgPrnAges && timesc.BigCOMoleForm > 0. ) |
|---|
| 148 | { |
|---|
| 149 | sprintf( chLine, " AGE: longest CO formation timescale= %.2es.", |
|---|
| 150 | timesc.BigCOMoleForm ); |
|---|
| 151 | notein(chLine); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | if( timesc.CloudAgeSet > 0. && timesc.BigCOMoleForm > timesc.CloudAgeSet ) |
|---|
| 155 | { |
|---|
| 156 | sprintf( chLine, " C-AGE: CO formation timescale longer than age, = %.2es", |
|---|
| 157 | timesc.BigCOMoleForm ); |
|---|
| 158 | caunin(chLine); |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | timesc.time_Hrecom_long = 0.; |
|---|
| 163 | timesc.time_Hrecom_short = 0.; |
|---|
| 164 | for( i=0; i < limit; i++ ) |
|---|
| 165 | { |
|---|
| 166 | hold = struc.ednstr[i]*2.90e-10*pow(struc.testr[i],(realnum)-0.77f); |
|---|
| 167 | timesc.time_Hrecom_long = MAX2(timesc.time_Hrecom_long , 1./hold); |
|---|
| 168 | timesc.time_Hrecom_short = MAX2(timesc.time_Hrecom_short , 1./hold); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | tlong = MAX2(tlong,timesc.time_Hrecom_long); |
|---|
| 172 | if( prt.lgPrnAges ) |
|---|
| 173 | { |
|---|
| 174 | sprintf( chLine, " AGE: longest H recombination timescale= %.2es.", |
|---|
| 175 | timesc.time_Hrecom_long ); |
|---|
| 176 | notein(chLine); |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | if( timesc.CloudAgeSet > 0. && timesc.time_Hrecom_long > timesc.CloudAgeSet ) |
|---|
| 180 | { |
|---|
| 181 | sprintf( chLine, " C-AGE: Hydrogen recombination timescale longer than age, = %.2es", |
|---|
| 182 | timesc.time_Hrecom_long ); |
|---|
| 183 | caunin(chLine); |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | if( timesc.CloudAgeSet < 0. ) |
|---|
| 188 | { |
|---|
| 189 | |
|---|
| 190 | if( tlong < 3600. ) |
|---|
| 191 | { |
|---|
| 192 | |
|---|
| 193 | sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s.", |
|---|
| 194 | tlong ); |
|---|
| 195 | bangin(chLine); |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | else if( tlong < 8.64e4 ) |
|---|
| 199 | { |
|---|
| 200 | |
|---|
| 201 | sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e hours.", |
|---|
| 202 | tlong, tlong/3600. ); |
|---|
| 203 | bangin(chLine); |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | else if( tlong < 3e7/12. ) |
|---|
| 207 | { |
|---|
| 208 | |
|---|
| 209 | sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e days.", |
|---|
| 210 | tlong, tlong/86400. ); |
|---|
| 211 | bangin(chLine); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | else if( tlong < 3e7 ) |
|---|
| 215 | { |
|---|
| 216 | |
|---|
| 217 | sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e months.", |
|---|
| 218 | tlong, (tlong/3.15569e7)*12. ); |
|---|
| 219 | bangin(chLine); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | else |
|---|
| 223 | { |
|---|
| 224 | |
|---|
| 225 | sprintf( chLine, " !AGE: Cloud age was not set. Longest timescale was %.2e s = %.2e years.", |
|---|
| 226 | tlong, tlong/3.15569e7 ); |
|---|
| 227 | bangin(chLine); |
|---|
| 228 | } |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | else |
|---|
| 232 | { |
|---|
| 233 | |
|---|
| 234 | if( tlong < 3e7 ) |
|---|
| 235 | { |
|---|
| 236 | |
|---|
| 237 | sprintf( chLine, " AGE: Cloud age was %.2es, Longest timescale was %.2e s.", |
|---|
| 238 | timesc.CloudAgeSet, tlong ); |
|---|
| 239 | notein(chLine); |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | else |
|---|
| 243 | { |
|---|
| 244 | |
|---|
| 245 | sprintf( chLine, " AGE: Cloud age was %.2e s. Longest timescale was %.2e s = %.2e years.", |
|---|
| 246 | timesc.CloudAgeSet, tlong, tlong/3.15569e7 ); |
|---|
| 247 | notein(chLine); |
|---|
| 248 | } |
|---|
| 249 | } |
|---|
| 250 | return; |
|---|
| 251 | } |
|---|