00001
00002
00003
00004 #include "cddefines.h"
00005 #include "dense.h"
00006 #include "parser.h"
00007
00008 void ParseFluc(Parser &p )
00009 {
00010 double flmax,
00011 flmin,
00012 period,
00013 temp;
00014
00015 DEBUG_ENTRY( "ParseFluc()" );
00016
00017
00018
00019 if( p.nMatch("ABUN") )
00020 {
00021
00022 dense.lgDenFlucOn = false;
00023 }
00024 else
00025 {
00026
00027 dense.lgDenFlucOn = true;
00028 }
00029
00030
00031 if( p.nMatch("COLU") )
00032 {
00033
00034 dense.lgDenFlucRadius = false;
00035 }
00036 else
00037 {
00038
00039 dense.lgDenFlucRadius = true;
00040 }
00041
00042
00043 period = pow(10.,p.FFmtRead());
00044 dense.flong = (realnum)(6.2831853/period);
00045 temp = p.FFmtRead();
00046
00047
00048 if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) )
00049 {
00050 fprintf(ioQQQ,
00051 " DISASTER - the log of the entered max hydrogen density is %.3f - too extreme for this processor.\n",
00052 temp);
00053 if( temp > 0. )
00054 fprintf(ioQQQ,
00055 " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
00056 log10(FLT_MAX) );
00057 else
00058 fprintf(ioQQQ,
00059 " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
00060 log10(FLT_MIN) );
00061 fprintf(ioQQQ," Sorry.\n" );
00062 cdEXIT(EXIT_FAILURE);
00063 }
00064
00065
00066 flmax = pow(10.,temp);
00067
00068 temp = p.FFmtRead();
00069
00070
00071 if( temp > log10(FLT_MAX) || temp < log10(FLT_MIN) )
00072 {
00073 fprintf(ioQQQ,
00074 " DISASTER - the log of the entered min hydrogen density is %.3f - too extreme for this processor.\n",
00075 temp);
00076 if( temp > 0. )
00077 fprintf(ioQQQ,
00078 " DISASTER - the log of the largest hydrogen density this processor can do is %.3f.\n",
00079 log10(FLT_MAX) );
00080 else
00081 fprintf(ioQQQ,
00082 " DISASTER - the log of the smallest hydrogen density this processor can do is %.3f.\n",
00083 log10(FLT_MIN) );
00084 fprintf(ioQQQ," Sorry.\n" );
00085 cdEXIT(EXIT_FAILURE);
00086 }
00087
00088
00089 flmin = pow(10.,temp);
00090
00091 if( flmax/flmin > 100. )
00092 {
00093 fprintf( ioQQQ, "This range of density probably will not work.\n" );
00094 }
00095 if( flmax > 1e15 )
00096 {
00097 fprintf( ioQQQ, "These parameters look funny to me. Please check Hazy.\n" );
00098 }
00099 if( p.lgEOL() || (flmin > flmax) )
00100 {
00101 fprintf( ioQQQ, "There MUST be three numbers on this line.\n" );
00102 fprintf( ioQQQ, "These must be the period(cm), max, min densities, all logs, in that order.\n" );
00103 if( flmin > flmax )
00104 fprintf( ioQQQ, "The max density must be greater or equal than the min density.\n" );
00105 cdEXIT(EXIT_FAILURE);
00106 }
00107
00108
00109 dense.flcPhase = (realnum)p.FFmtRead();
00110
00111
00112 dense.cfirst = (realnum)((flmax - flmin)/2.);
00113 dense.csecnd = (realnum)((flmax + flmin)/2.);
00114
00115
00116 ASSERT( dense.cfirst < dense.csecnd );
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 if( dense.lgDenFlucOn )
00130 {
00131 strcpy( dense.chDenseLaw, "SINE" );
00132
00133 if( dense.gas_phase[ipHYDROGEN] > 0. )
00134 {
00135 fprintf( ioQQQ, " PROBLEM DISASTER More than one density command was entered.\n" );
00136 cdEXIT(EXIT_FAILURE);
00137 }
00138
00139
00140 dense.SetGasPhaseDensity( ipHYDROGEN, dense.cfirst*(realnum)cos(dense.flcPhase) + dense.csecnd );
00141
00142 if( dense.gas_phase[ipHYDROGEN] <= 0. )
00143 {
00144 fprintf( ioQQQ, " PROBLEM DISASTER Hydrogen density must be > 0.\n" );
00145 cdEXIT(EXIT_FAILURE);
00146 }
00147 }
00148 return;
00149 }