From c00522d3520bd839d2b460c84a06ba04f677d915 Mon Sep 17 00:00:00 2001 From: "Gary J. Ferland" Date: Sat, 9 Apr 2022 21:22:14 +0100 Subject: [PATCH 1/3] provide workaround to assert --- source/dense.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/dense.cpp b/source/dense.cpp index b813060..e27640b 100644 --- a/source/dense.cpp +++ b/source/dense.cpp @@ -179,6 +179,9 @@ bool lgElemsConserved (void) sum_monatomic + sum_molecules, sum_gas_phase, (sum_monatomic + sum_molecules - sum_gas_phase)/sum_gas_phase ); + fprintf(ioQQQ," Consider increasing value of conv.GasPhaseAbundErrorAllowed with SET DENSITY TOLERANCE as a workaround. " + "Its current value is %.2e\n" , conv.GasPhaseAbundErrorAllowed ); + fprintf(ioQQQ," Temperature %.2e H density %.2e zone %ld \n", phycon.te, dense.gas_phase[ipHYDROGEN], nzone); lgOK=false; } -- GitLab From 7a61cef81f8fb6ab2a1dbebfb0a3c68cca884363 Mon Sep 17 00:00:00 2001 From: "Gary J. Ferland" Date: Tue, 12 Apr 2022 23:01:43 +0100 Subject: [PATCH 2/3] Protection against division by zero cooling. These protect against division by zero. Problems were exposed by the lab sim posted in gtests / bugs / Mancini. The sim does get now much farther along but aborts when the line stack becomes misaligned. The sim is a lab plasma, so it is far from our home base, but we should be able to compute it. It is non-equilibrium. It is unclear why the cooling is zero - perhaps the total is net heating. The changes seem safe since they are have never been needed and will have no effect in most cases. --- source/age_check.cpp | 19 +++++++++++-------- source/cool_save.cpp | 5 ++++- source/timesc.cpp | 14 +++++++++----- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/source/age_check.cpp b/source/age_check.cpp index 3093052..bada1db 100644 --- a/source/age_check.cpp +++ b/source/age_check.cpp @@ -39,14 +39,17 @@ void AgeCheck(void) for( i=0; i < limit; i++ ) { - timesc.time_therm_long = - MAX2( timesc.time_therm_long , - struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]); - timesc.time_therm_short = - MIN2( timesc.time_therm_short , - struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]); - /*>>chng 99 feb 01, had div by heating, changed to cooling so constant - * temperature models are more realistic */ + if( struc.coolstr[i]>SMALLFLOAT ) + { + timesc.time_therm_long = + MAX2( timesc.time_therm_long , + struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]); + timesc.time_therm_short = + MIN2( timesc.time_therm_short , + struc.DenParticles[i]*BOLTZMANN*1.5*struc.testr[i]/struc.coolstr[i]); + /*>>chng 99 feb 01, had div by heating, changed to cooling so constant + * temperature models are more realistic */ + } } tlong = MAX2(tlong,timesc.time_therm_long); diff --git a/source/cool_save.cpp b/source/cool_save.cpp index ea4c0db..e13bb98 100644 --- a/source/cool_save.cpp +++ b/source/cool_save.cpp @@ -67,7 +67,10 @@ void CoolSave(FILE * io, const char chJob[]) if( strncmp( thermal.chClntLab[i], "adve", 4 ) == 0 ) continue; - csav[ip] = (realnum)( safe_div( MAX2(thermal.cooling[i],thermal.heatnt[i]), cool_total, 0. )); + if( cool_total>SMALLFLOAT ) + csav[ip] = (realnum)( safe_div( MAX2(thermal.cooling[i],thermal.heatnt[i]), cool_total, 0. )); + else + csav[ip] = 0.; /* save sign to remember if heating or cooling line */ if( thermal.heatnt[i] == 0. ) { diff --git a/source/timesc.cpp b/source/timesc.cpp index 3454f30..3f57c7c 100644 --- a/source/timesc.cpp +++ b/source/timesc.cpp @@ -41,12 +41,16 @@ void t_timesc::calc_therm_timesc( long int izone ) { /* >>chng 99 feb 01, had div by heating, changed to cooling so constant * temperature models are more realistic */ - double dt = 1.5 * BOLTZMANN * struc.DenParticles[i] * struc.testr[i] / struc.coolstr[i]; - time_therm_long = MAX2( time_therm_long , dt ); - time_therm_short= MIN2( time_therm_short, dt ); - // printf("dt = %g\t long = %g\t short = %g\n", dt, time_therm_long, time_therm_short); - } + if( struc.coolstr[i] > SMALLFLOAT ) + { + double dt = 1.5 * BOLTZMANN * struc.DenParticles[i] * struc.testr[i] / struc.coolstr[i]; + //double dt = 1.5 * BOLTZMANN * struc.DenParticles[i] * safe_div( (double)struc.testr[i] , struc.coolstr[i] ); + time_therm_long = MAX2( time_therm_long , dt ); + time_therm_short= MIN2( time_therm_short, dt ); + // printf("dt = %g\t long = %g\t short = %g\n", dt, time_therm_long, time_therm_short);} + } // printf( "*** long = %g\t short = %g\n", time_therm_long, time_therm_short ); + } return; } -- GitLab From ce780fa2087beeca055ede0f6cd87b929f550d7e Mon Sep 17 00:00:00 2001 From: "Gary J. Ferland" Date: Wed, 27 Apr 2022 13:53:44 +0100 Subject: [PATCH 3/3] demote cautions of parts of SED being zero to notes The demotes cautions that parts of the SED are zero to notes. The following wc on auto shows that we have a large number of these. They are benign - they occur if we use a blackbody that does go to zero far out in the Wien tail. They are a minor note about the SED rather than something deserving of raising a caution. the number of cautions in tsuite/auto went from Alien20:auto:wc ~gary/cloudy/cautions.txt 5267 72721 544951 /home/gary/cloudy/cautions.txt to Alien20:auto:wc cautions2.txt 3846 64015 460146 cautions2.txt --- source/prt_comment.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/prt_comment.cpp b/source/prt_comment.cpp index 048f124..3bc9698 100644 --- a/source/prt_comment.cpp +++ b/source/prt_comment.cpp @@ -792,35 +792,35 @@ void PrtComment(void) if( !rfield.lgMMok ) { sprintf( chLine, - " C-Continuum not defined in extreme infrared - Compton scat, grain heating, not treated properly?" ); - caunin(chLine); + " !Continuum not defined in extreme infrared - Compton scat, grain heating, not treated properly?" ); + bangin(chLine); } if( !rfield.lgHPhtOK ) { sprintf( chLine, - " C-Continuum not defined at photon energies which ionize excited states of H, important for H- and ff heating." ); - caunin(chLine); + " !Continuum not defined at photon energies which ionize excited states of H, important for H- and ff heating." ); + bangin(chLine); } if( !rfield.lgXRayOK ) { sprintf( chLine, - " C-Continuum not defined at X-Ray energies - Compton scattering and Auger ionization wrong?" ); - caunin(chLine); + " !Continuum not defined at X-Ray energies - Compton scattering and Auger ionization wrong?" ); + bangin(chLine); } if( !rfield.lgGamrOK ) { sprintf( chLine, - " C-Continuum not defined at gamma-ray energies - pair production and Compton scattering OK?" ); - caunin(chLine); + " !Continuum not defined at gamma-ray energies - pair production and Compton scattering OK?" ); + bangin(chLine); } if( continuum.lgCon0 ) { - sprintf( chLine, " C-Continuum zero at some energies." ); - caunin(chLine); + sprintf( chLine, " !Continuum zero at some energies." ); + bangin(chLine); } if( continuum.lgCoStarInterpolationCaution ) -- GitLab