cloudy
trunk
|
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*ParseAtomH2 parse information from the atom command line */ 00004 #include "cddefines.h" 00005 #include "hmi.h" 00006 #include "mole.h" 00007 #include "h2.h" 00008 #include "h2_priv.h" 00009 #include "parse.h" 00010 #include "thirdparty.h" 00011 00012 /*ParseAtomH2 parse information from the atom command line */ 00013 void ParseAtomH2(char *chCard ) 00014 { 00015 bool lgEOL; 00016 long int i , j; 00017 00018 DEBUG_ENTRY( "ParseAtomH2()" ); 00019 00020 /* this command has a 2 in the H2 label - must not parse the two by 00021 * accident. Get the first number off the line image, and confirm that 00022 * it is a 2 */ 00023 i = 5; 00024 j = (long int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00025 if( j != 2 ) 00026 { 00027 fprintf( ioQQQ, " Something is wrong with the order of the numbers on this line.\n" ); 00028 fprintf( ioQQQ, " The first number I encounter should be a 2.\n Sorry.\n" ); 00029 cdEXIT(EXIT_FAILURE); 00030 } 00031 00032 /* the mere calling of this routine turns the large H2 molecule on */ 00033 h2.lgH2ON = true; 00034 00035 if( nMatch("LEVE",chCard) ) 00036 { 00037 /* number of electronic levels */ 00038 00039 /* lgH2_READ_DATA is false at start of calculation, set true when 00040 * space allocated for the H lines. Once done we must ignore all 00041 * future changes in the number of levels */ 00042 if( !lgH2_READ_DATA ) 00043 { 00044 mole.n_h2_elec_states = (long int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00045 if( lgEOL ) 00046 { 00047 if( nMatch("LARG",chCard) ) 00048 { 00049 /* LARGE is option to use the most number of electronic levels */ 00050 mole.n_h2_elec_states = N_H2_ELEC; 00051 } 00052 else 00053 { 00054 NoNumb(chCard); 00055 } 00056 } 00057 00058 /* do not allow fewer than 3 - that includes Lyman & Werner bands */ 00059 if( mole.n_h2_elec_states < 3 ) 00060 { 00061 fprintf( ioQQQ, " This would be too few electronic levels - resetting to 3.\n" ); 00062 mole.n_h2_elec_states = 3; 00063 } 00064 /* N_H2_ELEC is in h2.h and is the greatest number of elec lev possible */ 00065 else if( mole.n_h2_elec_states > N_H2_ELEC ) 00066 { 00067 fprintf( ioQQQ, 00068 " This would be too many levels, the limit is %i.\n" , 00069 N_H2_ELEC); 00070 cdEXIT(EXIT_FAILURE); 00071 } 00072 } 00073 } 00074 00075 else if( nMatch("LIMI",chCard) ) 00076 { 00077 /* the limit to the H2 / Htot ratio - 00078 * if smaller than this, do not compute large H2 mole */ 00079 mole.H2_to_H_limit = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00080 if( lgEOL ) 00081 { 00082 /* did not find a number, either mistake or key " off" */ 00083 if( nMatch( " OFF" , chCard ) ) 00084 { 00085 /* turn off limit */ 00086 mole.H2_to_H_limit = -1.; 00087 } 00088 else 00089 { 00090 fprintf( ioQQQ," The limit must appear on this line.\n"); 00091 NoNumb( chCard ); 00092 } 00093 } 00094 else 00095 { 00096 /* got a number, check if negative and so a log */ 00097 /* a number <= 0 is the log of the ratio */ 00098 if( mole.H2_to_H_limit <= 0. ) 00099 mole.H2_to_H_limit = pow(10., mole.H2_to_H_limit); 00100 } 00101 } 00102 else if( nMatch("GBAR",chCard ) ) 00103 { 00104 /* option to either use, or not use, gbar approximation for low X 00105 * levels with no collision data - by default it is on */ 00106 if( nMatch(" OFF",chCard ) ) 00107 { 00108 mole.lgColl_gbar = false; 00109 } 00110 else if( nMatch(" ON ",chCard ) ) 00111 { 00112 mole.lgColl_gbar = true; 00113 } 00114 else 00115 { 00116 fprintf( ioQQQ, 00117 " The gbar approximation must be off (\" OFF\") or on (\" ON \").\n"); 00118 cdEXIT(EXIT_FAILURE); 00119 } 00120 } 00121 /* option to turn collisional effects off or on */ 00122 else if( nMatch("COLL",chCard ) ) 00123 { 00124 /* option to turn collisional dissociation off or on */ 00125 if( nMatch("DISS",chCard ) ) 00126 { 00127 /* option to turn collisions off */ 00128 if( nMatch(" ON ",chCard ) ) 00129 { 00130 /* this is the default, leave collisions off */ 00131 mole.lgColl_dissoc_coll = true; 00132 } 00133 else 00134 { 00135 /* default (and only reason for this command) is to turn off collisions */ 00136 mole.lgColl_dissoc_coll = false; 00137 } 00138 } 00139 /* option to turn collisional dissociation off or on 00140 * >>chng 06 mar 01, had been simply if - so all collisions were turned off 00141 * when dissociation collisions turned off - 00142 * due to bucket else at end */ 00143 else if( nMatch("ORTH",chCard ) && nMatch("PARA",chCard ) ) 00144 { 00145 /* option to turn ortho - para collisions with particles off */ 00146 if( nMatch(" ON ",chCard ) ) 00147 { 00148 /* this is the default, leave collisions off */ 00149 mole.lgH2_ortho_para_coll_on = true; 00150 } 00151 else 00152 { 00153 /* default (and only reason for this command) is to turn off 00154 * ortho-para collisions */ 00155 mole.lgH2_ortho_para_coll_on = false; 00156 } 00157 } 00158 00159 /* option to turn collisional effects off or on */ 00160 else if( nMatch("GRAI",chCard ) ) 00161 { 00162 /* option to turn collisions off */ 00163 if( nMatch(" ON",chCard ) ) 00164 { 00165 /* this is the default, leave collisions off */ 00166 mole.lgH2_grain_deexcitation = true; 00167 } 00168 else 00169 { 00170 /* default (and only reason for this command) is to turn off collisions */ 00171 mole.lgH2_grain_deexcitation = false; 00172 } 00173 } 00174 else if( nMatch(" HE ",chCard ) ) 00175 { 00176 /* atom H2 He collisions ORNL (the default), Le BOURlot, and OFF 00177 * which data set for He collisions, 00178 * Teck Lee et al. ApJ to be submitted */ 00179 if( nMatch(" NEW",chCard ) || nMatch("ORNL",chCard ) ) 00180 { 00181 /* use the new coefficients */ 00182 mole.lgH2_He_ORNL = true; 00183 } 00184 else if( nMatch(" OLD",chCard ) || nMatch("BOUR",chCard ) ) 00185 { 00186 /* use the coefficients from 00187 *>>refer H2 collision Le Bourlot, J., Pineau des Forets, 00188 *>>refercon G., & Flower, D.R. 1999, MNRAS, 305, 802*/ 00189 mole.lgH2_He_ORNL = false; 00190 } 00191 else 00192 { 00193 fprintf( ioQQQ, 00194 " I did not find a keyword on this ATOM H2 HE command - I know about the keys ORNL and Le BOURlot\n"); 00195 cdEXIT(EXIT_FAILURE); 00196 } 00197 } 00198 else 00199 { 00200 /* option to turn all collisions off */ 00201 if( nMatch(" ON ",chCard ) ) 00202 { 00203 /* this is the default, leave collisions on */ 00204 mole.lgColl_deexec_Calc = true; 00205 } 00206 else 00207 { 00208 /* default (and only reason for this command) is to turn off collisions */ 00209 mole.lgColl_deexec_Calc = false; 00210 } 00211 } 00212 } 00213 00214 /* set number of levels in matrix, but not trace matrix option */ 00215 else if( nMatch("MATR",chCard ) && !nMatch("TRAC",chCard ) ) 00216 { 00217 /* matrix option sets the number of levels that will 00218 * be included in the matrix solution */ 00219 nXLevelsMatrix = (long)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00220 if( nMatch(" ALL",chCard) ) 00221 { 00222 /* " all" means do all of X, but space has not yet been allocated, 00223 * so we do know know how many levels are within X - set special 00224 * flag that will be used then this is known */ 00225 /*nXLevelsMatrix = nLevels_per_elec[0];*/ 00226 nXLevelsMatrix = -1; 00227 } 00228 else if( lgEOL && !(nMatch(" OFF",chCard) || nMatch("NONE",chCard) ) ) 00229 { 00230 /* this branch hit eol but OFF or NONE is not on line - this is a mistake */ 00231 fprintf( ioQQQ, 00232 " The total number of levels used in the matrix solver must be entered, or keywords ALL or NONE entered.\n Sorry.\n"); 00233 cdEXIT(EXIT_FAILURE); 00234 } 00235 /* cannot check less than total number of levels within x since not yet set 00236 * We do not certify that matrix limits are greater than 1 - 00237 * zero or <0 limits just turns if off, as did the off option */ 00238 } 00239 else if( nMatch(" LTE",chCard ) ) 00240 { 00241 /* LTE option causes code to assume LTE for level populations */ 00242 mole.lgH2_LTE = true; 00243 } 00244 00245 else if( nMatch("TRAC",chCard ) ) 00246 { 00247 /* these are used to set trace levels of output 00248 mole.nH2_trace_final = 1; 00249 mole.nH2_trace_iterations = 2; 00250 mole.nH2_trace_full = 3; 00251 mole.nH2_trace_matrix = 4*/ 00252 00253 /* turns on trace printout - there are multiple levels */ 00254 if( nMatch("FINA",chCard ) ) 00255 { 00256 /* FINAL gives only final information when solver exits */ 00257 mole.nH2_TRACE = mole.nH2_trace_final; 00258 } 00259 else if( nMatch("ITER",chCard ) ) 00260 { 00261 /* follow iterations within each call */ 00262 mole.nH2_TRACE = mole.nH2_trace_iterations; 00263 } 00264 else if( nMatch("FULL",chCard ) ) 00265 { 00266 /* full details of solution - this is also the default*/ 00267 mole.nH2_TRACE = mole.nH2_trace_full; 00268 } 00269 else if( nMatch("MATR",chCard ) ) 00270 { 00271 /* print the matrices used for X */ 00272 mole.nH2_TRACE = mole.nH2_trace_matrix; 00273 } 00274 else 00275 { 00276 /* full details of solution is also the default*/ 00277 mole.nH2_TRACE = mole.nH2_trace_full; 00278 } 00279 } 00280 else if( nMatch("NOIS",chCard ) ) 00281 { 00282 unsigned int iseed; 00283 /* check on effects of uncertainties in collision rates */ 00284 mole.lgH2_NOISE = true; 00285 mole.lgH2_NOISECOSMIC = true; 00286 00287 /* optional mean - default is 0 */ 00288 mole.xMeanNoise = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00289 if( lgEOL ) 00290 mole.xMeanNoise = 0.; 00291 00292 /* this is the standard deviation for the mole, with default */ 00293 mole.xSTDNoise = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00294 if( lgEOL ) 00295 mole.xSTDNoise = 0.5; 00296 00297 /* this may be a seed for the random number generator. if no seed is 00298 * set then use system time, and always get different sequence */ 00299 iseed = (unsigned int)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00300 /* returned 0 if eol hit */ 00301 if( iseed > 0 ) 00302 { 00303 /* user set seed */ 00304 init_genrand( iseed ); 00305 } 00306 else 00307 { 00308 init_genrand( (unsigned)time( NULL ) ); 00309 } 00310 } 00311 00312 else if( nMatch("THER",chCard ) ) 00313 { 00314 /* change the treatment of the heating - cooling effects of H2, 00315 * options are simple (use TH85 expressions) and full (use large molecule)*/ 00316 if( nMatch("SIMP",chCard ) ) 00317 { 00318 hmi.lgH2_Thermal_BigH2 = false; 00319 } 00320 else if( nMatch("FULL",chCard ) ) 00321 { 00322 /* this is the default - use big atom */ 00323 hmi.lgH2_Thermal_BigH2 = true; 00324 } 00325 } 00326 00327 else if( nMatch("CHEM",chCard ) ) 00328 { 00329 /* atom h2 chemistry simple command 00330 * change the treatment of the chemistry - formation and destruction, 00331 * options are simple (use TH85 expressions) and full (use large molecule)*/ 00332 if( nMatch("SIMP",chCard ) ) 00333 { 00334 hmi.lgH2_Chemistry_BigH2 = false; 00335 } 00336 else if( nMatch("FULL",chCard ) ) 00337 { 00338 /* this is the default - use big atom */ 00339 hmi.lgH2_Chemistry_BigH2 = true; 00340 } 00341 } 00342 00343 /* there is no final branch - if we do not find a keyword, simply 00344 * turn on the H2 molecule */ 00345 return; 00346 }