141 double timestep_return = dynamics.
timestep;
152 fprintf(
ioQQQ,
"DEBUG timestep_next returns %.3e\n", timestep_return );
154 return( timestep_return );
199 for(
long ion=0; ion<nelem+2; ++ion )
201 dynamics.
Source[nelem][ion] = 0.;
206 for(
long nelem=ipISO; nelem<
LIMELM; ++nelem)
212 dynamics.
StatesElem[nelem][nelem-ipISO][level] = 0.;
246 "dynamics cool-heat\t%li\t%.3e\t%i\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\n",
288 "PROBLEM conservation error: zn %li elem %li upstream %.8e abund %.8e (up-ab)/up %.2e\n",
303 dynamics.
Source[nelem][ion] =
312 dynamics.
Source[nelem][ion] = 0.;
316 for(
long ion=
dense.
IonHigh[nelem]+1;ion<nelem+2; ++ion )
318 dynamics.
Source[nelem][ion] = 0.;
327 for(
long nelem=ipISO; nelem<
LIMELM; ++nelem)
333 dynamics.
StatesElem[nelem][nelem-ipISO][level] =
341 fprintf(
ioQQQ,
"dynamiccc\t%li\t%.2e\t%.2e\t%.2e\t%.2e\n",
352 fprintf(
ioQQQ,
"dynaionizeeee\t%li\t%i\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\n",
364 dynamics.
Source[nelem][ion]
369 fprintf(
ioQQQ,
" DynaIonize, %4li photo=%.2e , H recom= %.2e \n",
391 double upstream, dilution, dilutionleft, dilutionright, frac_next;
394 double hupstream, hnextfrac=-
BIGFLOAT, hion, hmol, hiso;
397 double ynextfrac=-
BIGFLOAT, yion, ymol, yiso;
399 long int nelem , ion, mol;
410 for( ion=0; ion<nelem+2; ++ion )
417 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
471 if (! (frac_next >= 0.0 && frac_next <= 1.0))
473 fprintf(
ioQQQ,
"PROBLEM frac_next out of range %.16e %.16e %.16e %.16e\n",
477 ASSERT (frac_next >= 0.0 && frac_next <= 1.0);
498 fprintf(
ioQQQ,
"PROBLEM interpolated enthalpy density is not within range %.16e\t%.16e\t%.16e\t%e\t%e\n",
499 lo, x, hi, (hi-x)/(hi-lo), (x-lo)/(hi-lo));
507 for( ion=0; ion<nelem+2; ++ion )
528 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
555 for(molecule::nNucsMap::iterator atom=
mole_global.
list[mol]->nNuclide.begin();
578 for( ion=0; ion<nelem+2; ++ion )
589 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
609 for(molecule::nNucsMap::iterator atom=
mole_global.
list[mol]->nNuclide.begin();
651 if(ipUpstream != -1 && ipUpstream <
nOld_zone-1)
657 const double STEP_FACTOR=0.05;
661 for( ion=0; ion<nelem+2; ++ion )
716 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
723 if(ipyUpstream != -1 && ipyUpstream !=
nOld_zone-1 &&
739 if(iphUpstream != -1 && iphUpstream !=
nOld_zone-1 &&
828 fprintf(
ioQQQ,
" DynaStartZone, %4li photo=%.2e , H recom= %.2e dil %.2e \n",
863 static long int nTime_dt_array_element = 0;
875 fprintf(
ioQQQ,
"DYNAMICS DynaIterEnd sets stop radius to %.2e after "
876 "dynamics.n_initial_relax=%li iterations.\n",
942 static double HeatInitial=-1. , HeatRadiated=-1. ,
949 "DEBUG times enter dynamics.timestep %.2e elapsed_time %.2e iteration %li relax %li \n",
993 fprintf(
ioQQQ,
"DEBUG relaxing times requested %li this is step %li\n",
997 fprintf(
ioQQQ,
"DEBUG heat conser HeatInitial=%.2e HeatRadiated=%.2e\n",
998 HeatInitial , HeatRadiated );
1004 fprintf(
ioQQQ,
"DEBUG lgtimes -- stop time reached.\n" );
1012 ++nTime_dt_array_element;
1021 fprintf(
ioQQQ,
"DEBUG dynamics turn on recombination logic\n");
1034 fprintf(
ioQQQ,
"DEBUG lgtimes increment Time to %li %.2e\n" ,nTime_dt_array_element,
1048 fprintf(
ioQQQ,
"DEBUG lgtimes increment Timeby dynamics.timestep_factor to %li %.2e\n" ,
1049 nTime_dt_array_element,
1072 fprintf(
ioQQQ,
"DEBUG times exit dynamics.timestep %.2e elapsed_time %.2e scale %.2e ",
1121 for(i=0;i<
nzone;++i)
1147 for( ion=0; ion<nelem+2; ++ion )
1169 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
1220 fprintf(
ioQQQ,
"DYNAMICS DynaNewStep: Dyn_dr %.2e convergence_error %.2e discretization_error %.2e error_scale1 %.2e error_scale2 %.2e\n",
1245 for( i=0; i<
nzone; ++i )
1269 for( ion=0; ion<nelem+2; ++ion )
1276 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
1382 lgISO[ipISO] =
true;
1419 dynamics.
Source[nelem] = ((
double*)
MALLOC( (
size_t)(nelem+2)*
sizeof(
double) ));
1421 for( ion=0; ion<nelem+2; ++ion )
1423 dynamics.
Source[nelem][ion] = 0.;
1433 for(
long ion=0; ion<nelem+1; ion++ )
1435 long ipISO = nelem-ion;
1442 fixit(
"for now, point non-iso ions to NULL");
1450 dynamics.
StatesElem = ((
double***)
MALLOC( (
size_t)LIMELM*
sizeof(
double **) ));
1455 dynamics.
StatesElem[nelem] = (
double**)
MALLOC(
sizeof(
double*)*(unsigned)(nelem+1) );
1456 for(
long ion=0; ion<nelem+1; ion++ )
1458 long ipISO = nelem-ion;
1461 dynamics.
StatesElem[nelem][nelem-ipISO] = (
double*)
MALLOC(
sizeof(
double)*(unsigned)
iso_sp[ipISO][nelem].numLevels_max);
1465 fixit(
"for now, point non-iso ions to NULL");
1466 dynamics.
StatesElem[nelem][nelem-ipISO] = NULL;
1524 for( nelem=0; nelem<
LIMELM; ++nelem )
1530 for( nelem=0; nelem<
LIMELM; ++nelem )
1536 for( ion=0; ion<nelem+1; ion++ )
1538 long ipISO = nelem-ion;
1546 fixit(
"for now, point non-iso ions to NULL");
1570 for( nelem=0; nelem<
LIMELM; ++nelem )
1572 for( ion=0; ion<LIMELM+1; ++ion )
1579 for( nelem=ipISO; nelem<
LIMELM; ++nelem)
1709 " Hit EOF while reading time-continuum list; use END to end list.\n" );
1722 " Too many time points have been entered; the limit is %d. Increase variable NTIME in dynamics.c.\n",
1741 fprintf(
ioQQQ,
" Adding cycles with period = %e s.\n", period );
1747 fprintf(
ioQQQ,
" Hit EOF while reading line list; use END to end list.\n" );
1768 "scale factor to increase time",-1.);
1771 if( p.
nMatch(
"RECOMBIN") )
1789 fprintf(
ioQQQ,
" Hit EOF while reading line list; use END to end list.\n" );
1797 fprintf(
ioQQQ,
" At least two instances of time must be specified. There is an implicit instance at t=0.\n"
1798 " The user must specify at least one additional time. Sorry.\n" );
1806 fprintf(
ioQQQ,
"DEBUG time dep %.2e %.2e %.2e %.2e\n",
1821 bool lgModeSet=
false;
1860 if ( 1 == iVelocity_Type && !lgModeSet)
1864 fprintf(
ioQQQ,
"CAUTION, BALListic option needed to switch off pressure gradient terms\n");
1868 fprintf(
ioQQQ,
"CAUTION, STATic option needed for zero speed solutions\n");
1884 "centre of mass flux distribution");
1892 "power law index of mass flux distribution");
1896 if(iVelocity_Type == 1)
1924 else if(iVelocity_Type == 2)
1928 fprintf(
ioQQQ,
"Can't specify gradient when flux is constant!\n");
1999 fprintf(
ioQQQ,
" >>>>Initial wind velocity should be greater than speed of sound; calculation only valid above sonic point.\n" );
2038 fprintf(
ioQQQ,
" DYNAMICS Advection: Uad %.2f Uwd%.2e FRCcool: %4.2f Heat %4.2f\n",
2047 fprintf(
ioQQQ,
" DYNAMICS Eexcit:%.4e Eion:%.4e Ebin:%.4e Ekin:%.4e ET+pdv %.4e EnthalpyDensity/rho%.4e AdvSpWork%.4e\n",
2064 if( strcmp( chJob ,
"END" ) == 0 )
2146 "%.12e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\t%.5e\n" ,
2175 fprintf( ipPnunit ,
"%.5e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\t%.3e\n",
2247 fprintf(
ioQQQ,
" PROBLEM - DynaIterStart - I need the continuum at time %.2e but the table ends at %.2e.\n" ,
2266 fprintf(
ioQQQ,
"DEBUG time dep reset continuum iter %ld dynamics.timestep %.2e elapsed time %.2e scale %.2e",
2278 long int nTimeVary = 0;
bool nMatch(const char *chKey) const
t_mole_global mole_global
void calc_therm_timesc(long izone)
bool hasCommand(const char *s2)
static realnum *** Old_xIonDense
static vector< realnum > Old_DenMass
static vector< double > time_elapsed_time
STATIC void advection_set_default(bool lgWind)
static vector< realnum > Old_density
void ParseDynaWind(Parser &p)
static vector< realnum > Old_xLyman_depth
double convergence_tolerance
static vector< realnum > Old_pressure
NORETURN void TotalInsanity(void)
static double *** UpstreamStatesElem
STATIC void InitDynaTimestep()
static vector< realnum > Old_histr
vector< double > molecules
void DynaCreateArrays(void)
static realnum ** Old_molecules
static vector< double > time_dt_scale_factor
long int IonHigh[LIMELM+1]
static vector< double > Upstream_molecules
static vector< double > UpstreamElem
void DynaSave(FILE *ipPnunit, char chJob)
bool lgTimeDependentStatic
int cdIonFrac(const char *chLabel, long int IonStage, double *fracin, const char *chWeight, bool lgDensity)
static double ** UpstreamIon
double getNumberDefaultAlwaysLog(const char *chDesc, double fdef)
int cdTemp(const char *chLabel, long int IonStage, double *TeMean, const char *chWeight)
static const bool lgPrintDynamics
bool lgTemperatureConstant
vector< double > StopThickness
molezone * findspecieslocal(const char buf[])
realnum time_continuum_scale
realnum PressureErrorAllowed
double getNumberPlain(const char *chDesc)
static vector< int > lgtime_Recom
t_iso_sp iso_sp[NISO][LIMELM]
static vector< realnum > Old_hiistr
static long int nOld_zone
STATIC void DynaNewStep(void)
double xIonDense[LIMELM][LIMELM+1]
STATIC double timestep_next(void)
long int IonLow[LIMELM+1]
realnum DynaFlux(double depth)
valarray< class molezone > species
double discretization_error
STATIC bool lgNeedTimestep()
STATIC void DynaSaveLast(void)
bool fp_bound(sys_float lo, sys_float x, sys_float hi, int n=3)
double column(const genericState &gs)
void ParseDynaTime(Parser &p)
realnum HeatCoolRelErrorAllowed
realnum scalingZoneDensity(long i)
static long int nTime_flux
realnum gas_phase[LIMELM]
realnum TempLoStopIteration
double getNumberCheckAlwaysLogLim(const char *chDesc, double flim)
double sound_speed_adiabatic
static realnum ** Old_gas_phase
#define DEBUG_ENTRY(funcname)
realnum scalingDensity(void)
double linint(const double x[], const double y[], long n, double xval)
double getNumberCheckAlwaysLog(const char *chDesc)
static vector< realnum > EnthalpyDensity
double getNumberDefault(const char *chDesc, double fdef)
int fprintf(const Output &stream, const char *format,...)
realnum GetHubbleFactor(realnum z)
sys_float SDIV(sys_float x)
static vector< realnum > Old_EnthalpyDensity
void DynaPunchTimeDep(FILE *ipPnunit, const char *chJob)
bool lgStatic(void) const
static realnum **** Old_StatesElem
static vector< double > time_dt
static vector< double > Old_depth
static double AdvecSpecificEnthalpy
bool lg_coronal_time_init
static vector< realnum > Old_ednstr
static bool lgtime_dt_specified
realnum TempHiStopIteration
static vector< double > time_flux_ratio
double getNumberCheck(const char *chDesc)