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 #include "parser.h"
00014
00015 void ParseConstant(Parser &p )
00016 {
00017 DEBUG_ENTRY( "ParseConstant()" );
00018
00019 if( p.nMatch("GRAI") && p.nMatch("TEMP") )
00020 {
00021
00022 thermal.ConstGrainTemp = (realnum)p.FFmtRead();
00023
00024
00025 if( !p.nMatch("LINE") )
00026 {
00027 if( thermal.ConstGrainTemp <= 10. )
00028 thermal.ConstGrainTemp = (realnum)pow((realnum)10.f,thermal.ConstGrainTemp);
00029 }
00030
00031 if( p.lgEOL() )
00032 {
00033 p.NoNumb("grain temperature");
00034 }
00035 }
00036
00037 else if( p.nMatch("TEMP") )
00038 {
00039
00040 thermal.lgTemperatureConstant = true;
00041 thermal.lgTemperatureConstantCommandParsed = true;
00042
00043
00044
00045 realnum convert_to_Kelvin = 1;
00046 if( p.nMatch(" EV ") )
00047 {
00048 convert_to_Kelvin = (realnum)EVDEGK;
00049 }
00050 else if( p.nMatch(" KEV") )
00051 {
00052 convert_to_Kelvin = (realnum)(EVDEGK * 1000.);
00053 }
00054
00055
00056
00057
00058 thermal.ConstTemp = (realnum)p.FFmtRead();
00059 if( p.lgEOL() )
00060 p.NoNumb("temperature");
00061
00062
00063 if( p.nMatch(" LOG") || (thermal.ConstTemp <= 10. && !p.nMatch("LINE")) )
00064 {
00065 if( thermal.ConstTemp > log10(BIGFLOAT) )
00066 {
00067 fprintf(ioQQQ," PROBLEM temperature entered as a log but is too large "\
00068 "for this processor. I am interpreting it as the linear temperature.\n");
00069 }
00070 else
00071 thermal.ConstTemp = (realnum)pow((realnum)10.f,thermal.ConstTemp);
00072 }
00073
00074 thermal.ConstTemp *= convert_to_Kelvin;
00075
00076
00077 if( thermal.ConstTemp < phycon.TEMP_LIMIT_LOW )
00078 {
00079 thermal.ConstTemp = (realnum)(1.0001*phycon.TEMP_LIMIT_LOW);
00080 fprintf( ioQQQ, " PROBLEM Te too low, reset to %g K.\n",
00081 thermal.ConstTemp );
00082 }
00083 if( thermal.ConstTemp > phycon.TEMP_LIMIT_HIGH )
00084 {
00085 thermal.ConstTemp = (realnum)(0.9999*phycon.TEMP_LIMIT_HIGH);
00086 fprintf( ioQQQ, " PROBLEM Te too high, reset to %g K.\n",
00087 thermal.ConstTemp );
00088 }
00089
00090
00091 TempChange( thermal.ConstTemp, false );
00092
00093
00094 if( optimize.lgVarOn )
00095 {
00096
00097 optimize.nvarxt[optimize.nparm] = 1;
00098
00099 strcpy( optimize.chVarFmt[optimize.nparm], "CONSTANT TEMP %f LOG" );
00100
00101
00102 optimize.nvfpnt[optimize.nparm] = input.nRead;
00103
00104
00105 optimize.vparm[0][optimize.nparm] = (realnum)log10(thermal.ConstTemp);
00106 optimize.vincr[optimize.nparm] = 0.1f;
00107 optimize.varang[optimize.nparm][0] = (realnum)log10(1.00001*phycon.TEMP_LIMIT_LOW);
00108 optimize.varang[optimize.nparm][1] = (realnum)log10(0.99999*phycon.TEMP_LIMIT_HIGH);
00109 ++optimize.nparm;
00110 }
00111 }
00112
00113 else if( p.nMatch("DENS") )
00114 {
00115
00116 strcpy( dense.chDenseLaw, "CDEN" );
00117
00118 pressure.lgPres_radiation_ON = false;
00119 pressure.lgPres_magnetic_ON = false;
00120 pressure.lgPres_ram_ON = false;
00121 }
00122
00123 else if( p.nMatch("PRES") )
00124 {
00125
00126 strcpy( dense.chDenseLaw, "CPRE" );
00127
00128
00129
00130
00131 if( p.nMatch("RESE") )
00132 {
00133
00134
00135 dense.lgDenseInitConstant = false;
00136 }
00137 else
00138 {
00139
00140
00141 dense.lgDenseInitConstant = true;
00142 }
00143
00144 if( p.nMatch("TIME") )
00145 {
00146
00147
00148
00149 dense.lgDenseInitConstant = false;
00150 dense.lgPressureVaryTime = true;
00151
00152
00153 dense.PressureVaryTimeTimescale = (realnum)p.FFmtRead();
00154 if( dense.PressureVaryTimeTimescale<SMALLFLOAT )
00155 {
00156
00157 fprintf(ioQQQ," PROBLEM the constant pressure time command requires"
00158 " a positive timescale.\n");
00159 cdEXIT(EXIT_FAILURE);
00160 }
00161
00162 dense.PressureVaryTimeIndex = (realnum)p.FFmtRead();
00163
00164
00165 if( p.lgEOL() )
00166 {
00167
00168 fprintf(ioQQQ," PROBLEM the constant pressure time command requires"
00169 " two numbers, the timescale for the variation and an index.\n");
00170 cdEXIT(EXIT_FAILURE);
00171 }
00172 }
00173
00174 if( p.nMatch(" GAS") )
00175 {
00176
00177
00178 pressure.lgPres_radiation_ON = false;
00179
00180
00181 pressure.lgContRadPresOn = false;
00182
00183
00184 pressure.lgPres_magnetic_ON = false;
00185 pressure.lgPres_ram_ON = false;
00186
00187
00188 pressure.PresPowerlaw = (realnum)p.FFmtRead();
00189 }
00190
00191 else
00192 {
00193
00194
00195 pressure.lgPres_radiation_ON = true;
00196 pressure.lgPres_magnetic_ON = true;
00197 pressure.lgPres_ram_ON = true;
00198
00199
00200 if( p.nMatch("NO CO") )
00201 {
00202 pressure.lgContRadPresOn = false;
00203 }
00204 else
00205 {
00206 pressure.lgContRadPresOn = true;
00207 }
00208
00209
00210 if( p.nMatch("NO AB") )
00211 {
00212 pressure.lgRadPresAbortOK = false;
00213 }
00214 else
00215 {
00216 pressure.lgRadPresAbortOK = true;
00217 }
00218
00219 pressure.PresPowerlaw = 0.;
00220
00221
00222 if( p.nMatch(" SET") )
00223 {
00224
00225 pressure.lgPressureInitialSpecified = true;
00226
00227 pressure.PressureInitialSpecified = p.FFmtRead();
00228 if( p.lgEOL() )
00229 p.NoNumb("initial pressure" );
00230 else
00231
00232 pressure.PressureInitialSpecified = pow(10.,pressure.PressureInitialSpecified)*
00233 BOLTZMANN;
00234 }
00235 else
00236 pressure.lgPressureInitialSpecified = false;
00237 }
00238
00239
00240 if( optimize.lgVarOn && pressure.lgPressureInitialSpecified )
00241 {
00242
00243 optimize.nvarxt[optimize.nparm] = 1;
00244
00245 strcpy( optimize.chVarFmt[optimize.nparm], "CONSTANT PRESSURE SET %f LOG" );
00246 if( !dense.lgDenseInitConstant )
00247 strcat( optimize.chVarFmt[optimize.nparm], " RESET" );
00248 if( !pressure.lgContRadPresOn )
00249 strcat( optimize.chVarFmt[optimize.nparm], " NO CONTINUUM" );
00250 if( !pressure.lgRadPresAbortOK )
00251 strcat( optimize.chVarFmt[optimize.nparm], " NO ABORT" );
00252
00253
00254 optimize.nvfpnt[optimize.nparm] = input.nRead;
00255
00256
00257 optimize.vparm[0][optimize.nparm] = (realnum)log10(pressure.PressureInitialSpecified/BOLTZMANN);
00258 optimize.vincr[optimize.nparm] = 0.1f;
00259 ++optimize.nparm;
00260 }
00261 }
00262
00263 else
00264 {
00265
00266 fprintf( ioQQQ, " The keyword should be TEMPerature, DENSity, GAS or PRESsure, sorry.\n" );
00267 cdEXIT(EXIT_FAILURE);
00268 }
00269 return;
00270 }