Skip to content

Commit

Permalink
Fixes #577 where the old radiation temperature was not being recorde…
Browse files Browse the repository at this point in the history
…d properly.

 Modifications to windsave2table to print out information about convergence
  • Loading branch information
kslong committed Aug 7, 2019
1 parent cd0a31d commit a036c39
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 23 deletions.
2 changes: 1 addition & 1 deletion source/emission.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ photo_gen_wind (p, weight, freqmin, freqmax, photstart, nphot)

nplasma = wmain[icell].nplasma;
ndom = wmain[icell].ndom;
plasmamain[nplasma].nrad += 1; /* Increment the counter for the number of photons generatd in the cell */
plasmamain[nplasma].nrad += 1; /* Increment the counter for the number of photons generated in the cell */



Expand Down
20 changes: 12 additions & 8 deletions source/ionization.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ to match heating and cooling in the wind element! */
xplasma->dt_e_old = xplasma->dt_e;
xplasma->dt_e = xplasma->t_e - xplasma->t_e_old;
xplasma->t_e_old = xplasma->t_e;
xplasma->t_r_old = xplasma->t_r;
//OLD xplasma->t_r_old = xplasma->t_r;
xplasma->lum_tot_old = xplasma->lum_tot;
xplasma->heat_tot_old = xplasma->heat_tot;

ireturn = one_shot (xplasma, mode);

Expand All @@ -95,8 +96,9 @@ to match heating and cooling in the wind element! */
xplasma->dt_e_old = xplasma->dt_e;
xplasma->dt_e = xplasma->t_e - xplasma->t_e_old;
xplasma->t_e_old = xplasma->t_e;
xplasma->t_r_old = xplasma->t_r;
//OLD xplasma->t_r_old = xplasma->t_r;
xplasma->lum_tot_old = xplasma->lum_tot;
xplasma->heat_tot_old = xplasma->heat_tot;

ireturn = one_shot (xplasma, mode);

Expand All @@ -113,8 +115,9 @@ to match heating and cooling in the wind element! */
xplasma->dt_e_old = xplasma->dt_e;
xplasma->dt_e = xplasma->t_e - xplasma->t_e_old;
xplasma->t_e_old = xplasma->t_e;
xplasma->t_r_old = xplasma->t_r;
//OLD xplasma->t_r_old = xplasma->t_r;
xplasma->lum_tot_old = xplasma->lum_tot;
xplasma->heat_tot_old = xplasma->heat_tot;


ireturn = one_shot (xplasma, mode);
Expand Down Expand Up @@ -327,12 +330,13 @@ check_convergence ()
xconverging = ((double) nconverging) / ntot;
geo.fraction_converged = xconverge;
Log
("!!Check_converging: %4d (%.3f) converged and %4d (%.3f) converging of %d cells\n",
nconverge, xconverge, nconverging, xconverging, ntot);
Log ("!!Check_convergence_breakdown: t_r %4d t_e(real) %4d t_e(maxed) %4d hc(real) %4d\n", ntr, nte, nmax, nhc);
Log
("Summary convergence %4d %.3f %4d %.3f %d # n_converged fraction_converged converging fraction_converging total cells\n",
("!!Check_convergence: %4d (%.3f) converged and %4d (%.3f) converging of %d cells\n",
nconverge, xconverge, nconverging, xconverging, ntot);
Log ("!!Check_convergence: t_r %4d t_e(real) %4d t_e(maxed) %4d hc(real) %4d\n", ntr, nte, nmax, nhc);
// The information in the next statement is identical to that two lines above so ksl has eliminated it
//Old Log
//Old ("Summary convergence %4d %.3f %4d %.3f %d # n_converged fraction_converged converging fraction_converging total cells\n",
//Old nconverge, xconverge, nconverging, xconverging, ntot);
Log_flush ();
return (0);
}
Expand Down
13 changes: 7 additions & 6 deletions source/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ typedef struct plasma
and heat_photo. SS June 04. */
double heat_photo, heat_z; /*photoionization heating total and of metals */
double heat_auger; /* photoionization heating due to inner shell ionizations */
double abs_photo, abs_auger; /* this is the energy absorbed from the photon filed by these processes - different to the heating rate because of the binding energy */
double abs_photo, abs_auger; /* this is the energy absorbed from the photon due to these processes - different from
the heating rate because of the binding energy */
double w; /*The dilution factor of the wind */

int ntot; /*Total number of photon passages */
Expand All @@ -819,10 +820,10 @@ typedef struct plasma
int nscat_es; /* The number of electrons scatters in the cell */
int nscat_res; /* The number of resonant line scatters in the cell */

double mean_ds; /* NSH 6/9/12 Added to allow a check that a thin shell is really optcially thin */
double mean_ds; /* NSH 6/9/12 Added to allow a check that a thin shell is really optically thin */
int n_ds; /* NSH 6/9/12 Added to allow the mean dsto be computed */
int nrad; /* Total number of photons created within the cell */
int nioniz; /* Total number of photons capable of ionizing H */
int nioniz; /* Total number of photon passages by photons capable of ionizing H */
double *ioniz, *recomb; /* Number of ionizations and recombinations for each ion.
The sense is ionization from ion[n], and recombinations
to each ion[n] . 78 - changed to dynamic allocation */
Expand All @@ -849,7 +850,7 @@ typedef struct plasma

double j_direct, j_scatt; /* 1309 NSH mean intensity due to direct photons and scattered photons */
double ip_direct, ip_scatt; /* 1309 NSH mean intensity due to direct photons and scattered photons */
double xsd_freq[NXBANDS]; /*1208 NSH the standard deviation of the frequency in the band */
double xsd_freq[NXBANDS]; /* 1208 NSH the standard deviation of the frequency in the band */
int nxtot[NXBANDS]; /* 1108 NSH the total number of photon passages in frequency bands */
double max_freq; /*1208 NSH The maximum frequency photon seen in this cell */
double cool_tot; /*The total cooling in a cell */
Expand Down Expand Up @@ -881,7 +882,7 @@ typedef struct plasma
ionization pool */
double bf_simple_ionpool_in, bf_simple_ionpool_out;

double comp_nujnu; /* 1701 NSH The integral of alpha(nu)nuj(nu) used to computecompton cooling- only needs computing once per cycle */
double comp_nujnu; /* 1701 NSH The integral of alpha(nu)nuj(nu) used to compute compton cooling- only needs computing once per cycle */

double dmo_dt[3]; /*Radiative force of wind */
double rad_force_es[3]; /*Radiative force of wind */
Expand Down Expand Up @@ -919,7 +920,7 @@ typedef struct plasma


double exp_temp[NXBANDS]; /*NSH 120817 - The effective temperature of an exponential representation of the radiation field in a cell */
double exp_w[NXBANDS]; /*NSH 120817 - The prefector of an exponential representation of the radiation field in a cell */
double exp_w[NXBANDS]; /*NSH 120817 - The prefactor of an exponential representation of the radiation field in a cell */
double ip; /*NSH 111004 Ionization parameter calculated as number of photons over the lyman limit entering a cell, divided by the number density of hydrogen for the cell */
double xi; /*NSH 151109 Ionization parameter as defined by Tartar et al 1969 and described in Hazy. Its the ionizing flux over the number of hydrogen atoms */
} plasma_dummy, *PlasmaPtr;
Expand Down
2 changes: 1 addition & 1 deletion source/radiation.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ radiation (p, ds)
which also updates the ionization parameters and scattered and direct contributions */


//Floowing bug #391, we now wish to use the mean, doppler shifted freqiency in the cell.
//Following bug #391, we now wish to use the mean, doppler shifted freqiency in the cell.
freq_store = p->freq; //Store the packets 'intrinsic' frequency
p->freq = freq; //Temporarily set the photon frequency to the mean doppler shifter frequency
update_banded_estimators (xplasma, p, ds, w_ave); //Update estimators
Expand Down
2 changes: 1 addition & 1 deletion source/resonate.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ calculate_ds (w, p, tau_scat, tau, nres, smax, istat)
* photonionization is passed remotely via the PlasmaPtr.
*
* In a program running in the two level approxiamtion, electron scattering
* and ff emsision are treated as scattering processes, but photionionization
* and ff emission are treated as scattering processes, but photionionization
* is not. In macro-atom mode, photoionization is treated as a scattering
* process.
*
Expand Down
2 changes: 2 additions & 0 deletions source/templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ int macro_pops(PlasmaPtr xplasma, double xne);
int do_windsave2table(char *root, int ion_switch);
int create_master_table(int ndom, char rootname[]);
int create_heat_table(int ndom, char rootname[]);
int create_convergence_table(int ndom, char rootname[]);
int create_ion_table(int ndom, char rootname[], int iz, int ion_switch);
double *get_ion(int ndom, int element, int istate, int iswitch);
double *get_one(int ndom, char variable_name[]);
Expand Down Expand Up @@ -634,6 +635,7 @@ int main(int argc, char *argv[]);
int do_windsave2table(char *root, int ion_switch);
int create_master_table(int ndom, char rootname[]);
int create_heat_table(int ndom, char rootname[]);
int create_convergence_table(int ndom, char rootname[]);
int create_ion_table(int ndom, char rootname[], int iz, int ion_switch);
double *get_ion(int ndom, int element, int istate, int iswitch);
double *get_one(int ndom, char variable_name[]);
1 change: 1 addition & 0 deletions source/wind_updates2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ WindPtr (w);
plasmamain[n].j_direct /= (4. * PI * volume);
plasmamain[n].j_scatt /= (4. * PI * volume);

plasmamain[n].t_r_old = plasmamain[n].t_r; // Store the previous t_r in t_r_old immediately before recalculating
trad = plasmamain[n].t_r = H * plasmamain[n].ave_freq / (BOLTZMANN * 3.832);
plasmamain[n].w = PI * plasmamain[n].j / (STEFAN_BOLTZMANN * trad * trad * trad * trad);

Expand Down
Loading

0 comments on commit a036c39

Please sign in to comment.