00001
00002
00003
00004 #include "cddefines.h"
00005 #include "physconst.h"
00006 #include "rfield.h"
00007 #include "radius.h"
00008 #include "parse.h"
00009
00010 void ParseBlackbody(char *chCard,
00011
00012 long int *nqh,
00013
00014 float *ar1)
00015 {
00016 bool lgEOL;
00017 long int i;
00018 double a,
00019 dil,
00020 rlogl;
00021
00022 DEBUG_ENTRY( "ParseBlackbody()" );
00023
00024
00025 strcpy( rfield.chSpType[rfield.nspec], "BLACK" );
00026
00027
00028 rfield.cutoff[rfield.nspec][0] = 0.;
00029 rfield.cutoff[rfield.nspec][1] = 0.;
00030
00031
00032 i = 5;
00033 rfield.slope[rfield.nspec] = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00034
00035
00036 if( lgEOL )
00037 {
00038 fprintf( ioQQQ, " There must be at least 1 number on a BLACKBODY command line. Sorry.\n" );
00039 puts( "[Stop in ParseBlackbody]" );
00040 cdEXIT(EXIT_FAILURE);
00041 }
00042
00043
00044
00045
00046 if( (rfield.slope[rfield.nspec] <= 10. && !nMatch("LINE",chCard)) ||
00047 nMatch(" LOG",chCard) )
00048 {
00049
00050 rfield.slope[rfield.nspec] = pow(10.,rfield.slope[rfield.nspec]);
00051 }
00052
00053
00054 if( rfield.slope[rfield.nspec] < 1e4 )
00055 {
00056 fprintf( ioQQQ, " Is T(star)=%10.2e correct???\n",
00057 rfield.slope[rfield.nspec] );
00058 }
00059
00060
00061
00062
00063 if( rfield.slope[rfield.nspec]/TE1RYD < rfield.emm )
00064 {
00065 fprintf( ioQQQ, " This temperature is very low - the blackbody will have significant flux low the low energy limit of the code, presently %10.2e Ryd.\n",
00066 rfield.emm );
00067 fprintf( ioQQQ, " Was this intended?\n" );
00068 }
00069
00070
00071
00072
00073 if( rfield.slope[rfield.nspec]/TE1RYD*2. > rfield.egamry )
00074 {
00075 fprintf( ioQQQ, " This temperature is very high - the blackbody will have significant flux above the high-energy limit of the code,%10.2e Ryd.\n",
00076 rfield.egamry );
00077 fprintf( ioQQQ, " Was this intended?\n" );
00078 }
00079
00080
00081 ++rfield.nspec;
00082 if( rfield.nspec >= LIMSPC )
00083 {
00084 fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
00085 puts( "[Stop in ParseBackgrd]" );
00086 cdEXIT(EXIT_FAILURE);
00087 }
00088
00089
00090 a = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
00091 if( lgEOL )
00092 {
00093
00094 if( nMatch(" LTE",chCard) || nMatch("LTE ",chCard) ||
00095 nMatch(" STE",chCard) || nMatch("STE ",chCard) )
00096 {
00097
00098 strcpy( rfield.chSpNorm[*nqh], "LUMI" );
00099
00100
00101 a = log10(rfield.slope[rfield.nspec-1]);
00102 rlogl = log10(2.99792e10*7.56464e-15) + 4.*a;
00103
00104
00105
00106 if( !radius.lgRadiusKnown )
00107 {
00108 *ar1 = (float)radius.rdfalt;
00109 radius.Radius = pow(10.,radius.rdfalt);
00110 }
00111 strcpy( rfield.chRSpec[*nqh], "SQCM" );
00112 rfield.range[*nqh][0] = rfield.emm;
00113 rfield.range[*nqh][1] = rfield.egamry;
00114 rfield.totpow[*nqh] = rlogl;
00115 *nqh = MIN2(*nqh+1,LIMSPC);
00116
00117
00118
00119
00120 if( rfield.nspec != *nqh )
00121 {
00122 fprintf( ioQQQ, " This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
00123 fprintf( ioQQQ, " Sorry.\n" );
00124 puts( "[Stop in ParseBlackbody]" );
00125 cdEXIT(EXIT_FAILURE);
00126 }
00127 }
00128
00129 DEBUG_EXIT( "ParseBlackbody()" );
00130
00131 return;
00132 }
00133
00134 strcpy( rfield.chSpNorm[*nqh], "LUMI" );
00135
00136
00137 if( nMatch("LUMI",chCard) )
00138 {
00139 rlogl = a;
00140 strcpy( rfield.chRSpec[*nqh], "4 PI" );
00141 }
00142
00143 else if( nMatch("RADI",chCard) )
00144 {
00145
00146 rlogl = -3.147238 + 2.*a + 4.*log10(rfield.slope[rfield.nspec-1]);
00147 strcpy( rfield.chRSpec[*nqh], "4 PI" );
00148 }
00149
00150 else if( nMatch("DENS",chCard) )
00151 {
00152
00153
00154
00155 if( nMatch("LINE",chCard) || a > 10. )
00156 {
00157 a = log10(a);
00158 }
00159 rlogl = log10(2.99792e10*7.56464e-15) + 4.*a;
00160
00161
00162 if( !radius.lgRadiusKnown )
00163 {
00164 *ar1 = (float)radius.rdfalt;
00165 radius.Radius = pow(10.,radius.rdfalt);
00166 }
00167 strcpy( rfield.chRSpec[*nqh], "SQCM" );
00168 }
00169
00170 else if( nMatch("DILU",chCard) )
00171 {
00172
00173 if( a < 0. )
00174 {
00175 dil = a;
00176 }
00177 else
00178 {
00179 dil = log10(a);
00180 }
00181 if( dil > 0. )
00182 {
00183 fprintf( ioQQQ, " Is a dilution factor greater than one physical?\n" );
00184 }
00185
00186
00187 a = log10(rfield.slope[rfield.nspec-1]);
00188 rlogl = log10(2.99792e10*7.56464e-15) + 4.*a;
00189
00190
00191 rlogl += dil;
00192
00193
00194
00195 if( !radius.lgRadiusKnown )
00196 {
00197 *ar1 = (float)radius.rdfalt;
00198 radius.Radius = pow(10.,radius.rdfalt);
00199 }
00200 strcpy( rfield.chRSpec[*nqh], "SQCM" );
00201
00202 }
00203 else
00204 {
00205 fprintf( ioQQQ, " I do not understand what the second number was- keywords are LUMINOSITY, RADIUS, DILUTION, and DENSITY.\n" );
00206 puts( "[Stop in ParseBlackbody]" );
00207 cdEXIT(EXIT_FAILURE);
00208 }
00209
00210 rfield.range[*nqh][0] = rfield.emm;
00211 rfield.range[*nqh][1] = rfield.egamry;
00212 rfield.totpow[*nqh] = rlogl;
00213
00214 *nqh = MIN2(*nqh+1,LIMSPC);
00215
00216
00217
00218
00219 if( rfield.nspec != *nqh )
00220 {
00221 fprintf( ioQQQ, " This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
00222 fprintf( ioQQQ, " Sorry.\n" );
00223 puts( "[Stop in ParseBlackbody]" );
00224 cdEXIT(EXIT_FAILURE);
00225 }
00226
00227 DEBUG_EXIT( "ParseBlackbody()" );
00228
00229 return;
00230 }
00231