00001
00002
00003
00004 #include "cddefines.h"
00005 #include "physconst.h"
00006 #include "optimize.h"
00007 #include "thermal.h"
00008 #include "dense.h"
00009 #include "pressure.h"
00010 #include "phycon.h"
00011 #include "input.h"
00012 #include "parse.h"
00013
00014 void ParseConstant(char *chCard )
00015 {
00016 bool lgEOL;
00017 long int i;
00018
00019 DEBUG_ENTRY( "ParseConstant()" );
00020
00021 if( nMatch("GRAI",chCard) && nMatch("TEMP",chCard) )
00022 {
00023
00024 i = 5;
00025 thermal.ConstGrainTemp = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00026
00027
00028 if( !nMatch("LINE",chCard) )
00029 {
00030 if( thermal.ConstGrainTemp <= 10. )
00031 thermal.ConstGrainTemp = (realnum)pow((realnum)10.f,thermal.ConstGrainTemp);
00032 }
00033
00034 if( lgEOL )
00035 {
00036 NoNumb(chCard);
00037 }
00038 }
00039
00040 else if( nMatch("TEMP",chCard) )
00041 {
00042
00043 thermal.lgTemperatureConstant = true;
00044 thermal.lgTemperatureConstantCommandParsed = true;
00045
00046
00047
00048 realnum convert_to_Kelvin = 1;
00049 if( nMatch(" EV ",chCard) )
00050 {
00051 convert_to_Kelvin = (realnum)EVDEGK;
00052 }
00053 else if( nMatch(" KEV",chCard) )
00054 {
00055 convert_to_Kelvin = (realnum)(EVDEGK * 1000.);
00056 }
00057
00058 i = 5;
00059
00060
00061
00062 thermal.ConstTemp = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00063 if( lgEOL )
00064 NoNumb(chCard);
00065
00066
00067 if( !nMatch("LINE",chCard) )
00068 {
00069 if( thermal.ConstTemp <= 10. )
00070 thermal.ConstTemp = (realnum)pow((realnum)10.f,thermal.ConstTemp);
00071 }
00072
00073 thermal.ConstTemp *= convert_to_Kelvin;
00074
00075
00076 if( thermal.ConstTemp < 3. )
00077 {
00078 fprintf( ioQQQ, " PROBLEM TE<3K, reset to 3K.\n" );
00079 thermal.ConstTemp = 3.;
00080 }
00081
00082
00083
00084
00085
00086 if( thermal.ConstTemp > phycon.TEMP_LIMIT_HIGH )
00087 {
00088 fprintf( ioQQQ, " The constant temperature (%.3e K) is > %.3e K, Cloudy cannot handle this temperature.\n",
00089 thermal.ConstTemp,
00090 phycon.TEMP_LIMIT_HIGH);
00091 fprintf( ioQQQ, " The upper temperature limit is %.3e K.\n" ,
00092 phycon.TEMP_LIMIT_HIGH);
00093 fprintf( ioQQQ, " Sorry.\n" );
00094 cdEXIT(EXIT_FAILURE);
00095 }
00096
00097
00098 TempChange(thermal.ConstTemp , false);
00099
00100
00101 if( optimize.lgVarOn )
00102 {
00103
00104 optimize.nvarxt[optimize.nparm] = 1;
00105 strcpy( optimize.chVarFmt[optimize.nparm], "CONStant TEMP %f" );
00106
00107
00108 optimize.nvfpnt[optimize.nparm] = input.nRead;
00109
00110
00111 optimize.vparm[0][optimize.nparm] = (realnum)log10(phycon.te);
00112 optimize.vincr[optimize.nparm] = 0.1f;
00113 ++optimize.nparm;
00114 }
00115 }
00116
00117 else if( nMatch("DENS",chCard) )
00118 {
00119
00120 strcpy( dense.chDenseLaw, "CDEN" );
00121
00122 pressure.lgPres_radiation_ON = false;
00123 pressure.lgPres_magnetic_ON = false;
00124 pressure.lgPres_ram_ON = false;
00125 }
00126
00127 else if( nMatch("PRES",chCard) )
00128 {
00129
00130 strcpy( dense.chDenseLaw, "CPRE" );
00131
00132
00133
00134
00135 if( nMatch("RESE",chCard) )
00136 {
00137
00138
00139 dense.lgDenseInitConstant = false;
00140 }
00141 else
00142 {
00143
00144
00145 dense.lgDenseInitConstant = true;
00146 }
00147
00148 if( nMatch(" GAS",chCard) )
00149 {
00150
00151
00152 pressure.lgPres_radiation_ON = false;
00153
00154
00155 pressure.lgContRadPresOn = false;
00156
00157
00158 pressure.lgPres_magnetic_ON = false;
00159 pressure.lgPres_ram_ON = false;
00160
00161
00162 i = 4;
00163 pressure.PresPowerlaw = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00164 }
00165
00166 else
00167 {
00168
00169
00170 pressure.lgPres_radiation_ON = true;
00171 pressure.lgPres_magnetic_ON = true;
00172 pressure.lgPres_ram_ON = true;
00173
00174
00175 if( nMatch("O CO",chCard) )
00176 {
00177 pressure.lgContRadPresOn = false;
00178 }
00179 else
00180 {
00181 pressure.lgContRadPresOn = true;
00182 }
00183
00184
00185 if( nMatch("O AB",chCard) )
00186 {
00187 pressure.lgRadPresAbortOK = false;
00188 }
00189 else
00190 {
00191 pressure.lgRadPresAbortOK = true;
00192 }
00193
00194 pressure.PresPowerlaw = 0.;
00195
00196
00197 if( nMatch(" SET",chCard) )
00198 {
00199
00200 pressure.lgPressureInitialSpecified = true;
00201
00202 i = 5;
00203 pressure.PressureInitialSpecified = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00204 if( lgEOL )
00205 NoNumb( chCard );
00206 else
00207
00208 pressure.PressureInitialSpecified = pow(10.,pressure.PressureInitialSpecified ) *
00209 BOLTZMANN;
00210 }
00211 else
00212 pressure.lgPressureInitialSpecified = false;
00213 }
00214
00215
00216 if( optimize.lgVarOn &&pressure.lgPressureInitialSpecified )
00217 {
00218
00219 optimize.nvarxt[optimize.nparm] = 1;
00220 strcpy( optimize.chVarFmt[optimize.nparm], "CONStant PRESsure SET %f" );
00221
00222
00223 optimize.nvfpnt[optimize.nparm] = input.nRead;
00224
00225
00226 optimize.vparm[0][optimize.nparm] = (realnum)log10(pressure.PressureInitialSpecified);
00227 optimize.vincr[optimize.nparm] = 0.1f;
00228 ++optimize.nparm;
00229 }
00230 }
00231
00232 else
00233 {
00234
00235 fprintf( ioQQQ, " The keyword should be TEMPerature, DENSity, GAS or PRESsure, sorry.\n" );
00236 cdEXIT(EXIT_FAILURE);
00237 }
00238 return;
00239 }