00001
00002
00003
00004 #include "cddefines.h"
00005 #include "optimize.h"
00006 #include "stopcalc.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 = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00026
00027
00028 if( !nMatch("LINE",chCard) )
00029 {
00030 if( thermal.ConstGrainTemp <= 10. )
00031 thermal.ConstGrainTemp = (float)pow(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.lgTSetOn = true;
00044
00045 i = 5;
00046
00047
00048
00049 thermal.ConstTemp = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00050
00051 if( !nMatch("LINE",chCard) )
00052 {
00053 if( thermal.ConstTemp <= 10. )
00054 thermal.ConstTemp = (float)pow(10.f,thermal.ConstTemp);
00055 }
00056
00057 if( lgEOL )
00058 {
00059 NoNumb(chCard);
00060 }
00061
00062
00063 if( thermal.ConstTemp < 3. )
00064 {
00065 fprintf( ioQQQ, " PROBLEM TE<3K, reset to 3K.\n" );
00066 thermal.ConstTemp = 3.;
00067 }
00068
00069
00070
00071
00072
00073 if( thermal.ConstTemp > StopCalc.TeHighest )
00074 {
00075 fprintf( ioQQQ, " The constant temperature (%.3e K) is > %.3e K, Cloudy cannot handle this temperature.\n",
00076 thermal.ConstTemp,
00077 StopCalc.TeHighest);
00078 fprintf( ioQQQ, " The upper temperature limit is %.3e K.\n" ,
00079 StopCalc.TeHighest);
00080 fprintf( ioQQQ, " Sorry.\n" );
00081 puts( "[Stop in ParseConstant]" );
00082 cdEXIT(EXIT_FAILURE);
00083 }
00084
00085
00086 phycon.te = thermal.ConstTemp;
00087 tfidle(false);
00088
00089
00090 if( optimize.lgVarOn )
00091 {
00092
00093 optimize.nvarxt[optimize.nparm] = 1;
00094 strcpy( optimize.chVarFmt[optimize.nparm], "CONStant TEMP %f" );
00095
00096
00097 optimize.nvfpnt[optimize.nparm] = input.nRead;
00098
00099
00100 optimize.vparm[0][optimize.nparm] = (float)log10(phycon.te);
00101 optimize.vincr[optimize.nparm] = 0.1f;
00102 ++optimize.nparm;
00103 }
00104 }
00105
00106 else if( nMatch("DENS",chCard) )
00107 {
00108
00109 strcpy( dense.chDenseLaw, "CDEN" );
00110
00111 pressure.lgPres_radiation_ON = false;
00112 pressure.lgPres_magnetic_ON = false;
00113 pressure.lgPres_ram_ON = false;
00114 }
00115
00116 else if( nMatch("PRES",chCard) )
00117 {
00118
00119 strcpy( dense.chDenseLaw, "CPRE" );
00120
00121
00122
00123 if( nMatch("RESE",chCard) )
00124 {
00125
00126
00127 dense.lgDenseInitConstant = false;
00128 }
00129 else
00130 {
00131
00132
00133 dense.lgDenseInitConstant = true;
00134 }
00135
00136 if( nMatch(" GAS",chCard) )
00137 {
00138
00139
00140 pressure.lgPres_radiation_ON = false;
00141
00142
00143 pressure.lgContRadPresOn = false;
00144
00145
00146 pressure.lgPres_magnetic_ON = false;
00147 pressure.lgPres_ram_ON = false;
00148
00149
00150 i = 4;
00151 pressure.PresPowerlaw = (float)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00152 }
00153
00154 else
00155 {
00156
00157
00158 pressure.lgPres_radiation_ON = true;
00159 pressure.lgPres_magnetic_ON = true;
00160 pressure.lgPres_ram_ON = true;
00161
00162
00163 if( nMatch("O CO",chCard) )
00164 {
00165 pressure.lgContRadPresOn = false;
00166 }
00167 else
00168 {
00169 pressure.lgContRadPresOn = true;
00170 }
00171
00172
00173 if( nMatch("O AB",chCard) )
00174 {
00175 pressure.lgRadPresAbortOK = false;
00176 }
00177 else
00178 {
00179 pressure.lgRadPresAbortOK = true;
00180 }
00181
00182 pressure.PresPowerlaw = 0.;
00183 }
00184 }
00185
00186 else
00187 {
00188
00189 fprintf( ioQQQ, " The keyword should be TEMPerature, DENSity, GAS or PRESsure, sorry.\n" );
00190 puts( "[Stop in ParseConstant]" );
00191 cdEXIT(EXIT_FAILURE);
00192 }
00193
00194 DEBUG_EXIT( "ParseConstant()" );
00195 return;
00196 }
00197