Skip to content

Commit

Permalink
Fixed seg. fault when beam heating and power-law radiative losses are…
Browse files Browse the repository at this point in the history
… chosen together.
  • Loading branch information
sjbradshaw authored Jul 29, 2023
1 parent 927758c commit 87fe711
Showing 1 changed file with 54 additions and 38 deletions.
92 changes: 54 additions & 38 deletions Radiation_Model/source/radiation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// *
// * (c) Dr. Stephen J. Bradshaw
// *
// * Date last modified: 10/14/2021
// * Date last modified: 07/29/2023
// *
// ****

Expand All @@ -21,46 +21,62 @@

CRadiation::CRadiation( char *szFilename )
{
#if !defined (USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses ARE NOT being used
// The atomic data are required to calculate the radiative losses
Initialise( szFilename );
#else // !(USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses ARE being used
#ifdef OPTICALLY_THICK_RADIATION
#if defined (NLTE_CHROMOSPHERE) || defined(DECOUPLE_IONISATION_STATE_SOLVER)
// If the NLTE chromosphere is being used or a non-equilibrium ionization calculation is being performed then the atomic data are required
Initialise( szFilename );
#endif // NLTE_CHROMOSPHERE || DECOUPLE_IONISATION_STATE_SOLVER
#else // OPTICALLY_THICK_RADIATION
#ifdef DECOUPLE_IONISATION_STATE_SOLVER
// If a non-equilibrium ionisation calculation is being performed then the atomic data are required
Initialise( szFilename );
#endif // DECOUPLE_IONISATION_STATE_SOLVER
#endif // OPTICALLY_THICK_RADIATION
#endif // !(USE_POWER_LAW_RADIATIVE_LOSSES)
#ifdef BEAM_HEATING
// Beam heating is being used
// The atomic data are required to calculate the non-uniform ionization state along the beam path
Initialise( szFilename );
#else // BEAM_HEATING
// Beam heating is not being used
// The atomic data is only required under certain circumstances
#if !defined (USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses are not being used
// The atomic data are required to calculate the radiative losses
Initialise( szFilename );
#else // !(USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses ARE being used
#ifdef OPTICALLY_THICK_RADIATION
#if defined (NLTE_CHROMOSPHERE) || defined(DECOUPLE_IONISATION_STATE_SOLVER)
// If the NLTE chromosphere is being used or a non-equilibrium ionization calculation is being performed then the atomic data are required
Initialise( szFilename );
#endif // NLTE_CHROMOSPHERE || DECOUPLE_IONISATION_STATE_SOLVER
#else // OPTICALLY_THICK_RADIATION
#ifdef DECOUPLE_IONISATION_STATE_SOLVER
// If a non-equilibrium ionisation calculation is being performed then the atomic data are required
Initialise( szFilename );
#endif // DECOUPLE_IONISATION_STATE_SOLVER
#endif // OPTICALLY_THICK_RADIATION
#endif // !(USE_POWER_LAW_RADIATIVE_LOSSES)
#endif // BEAM_HEATING
}

CRadiation::~CRadiation( void )
{
#if !defined (USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses ARE NOT being used
// The atomic data are required to calculate the radiative losses
FreeAll();
#else // !(USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses ARE being used
#ifdef OPTICALLY_THICK_RADIATION
#if defined (NLTE_CHROMOSPHERE) || defined(DECOUPLE_IONISATION_STATE_SOLVER)
// If the NLTE chromosphere is being used or a non-equilibrium ionization calculation is being performed then the atomic data are required
FreeAll();
#endif // NLTE_CHROMOSPHERE || DECOUPLE_IONISATION_STATE_SOLVER
#else // OPTICALLY_THICK_RADIATION
#ifdef DECOUPLE_IONISATION_STATE_SOLVER
// If a non-equilibrium ionisation calculation is being performed then the atomic data are required
FreeAll();
#endif // DECOUPLE_IONISATION_STATE_SOLVER
#endif // OPTICALLY_THICK_RADIATION
#endif // !(USE_POWER_LAW_RADIATIVE_LOSSES)
#ifdef BEAM_HEATING
// Beam heating is being used
// The atomic data are required to calculate the non-uniform ionization state along the beam path
FreeAll();
#else // BEAM_HEATING
// Beam heating is not being used
// The atomic data is only required under certain circumstances
#if !defined (USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses are not being used
// The atomic data are required to calculate the radiative losses
FreeAll();
#else // !(USE_POWER_LAW_RADIATIVE_LOSSES)
// The power-law radiative losses ARE being used
#ifdef OPTICALLY_THICK_RADIATION
#if defined (NLTE_CHROMOSPHERE) || defined(DECOUPLE_IONISATION_STATE_SOLVER)
// If the NLTE chromosphere is being used or a non-equilibrium ionization calculation is being performed then the atomic data are required
FreeAll();
#endif // NLTE_CHROMOSPHERE || DECOUPLE_IONISATION_STATE_SOLVER
#else // OPTICALLY_THICK_RADIATION
#ifdef DECOUPLE_IONISATION_STATE_SOLVER
// If a non-equilibrium ionisation calculation is being performed then the atomic data are required
FreeAll();
#endif // DECOUPLE_IONISATION_STATE_SOLVER
#endif // OPTICALLY_THICK_RADIATION
#endif // !(USE_POWER_LAW_RADIATIVE_LOSSES)
#endif // BEAM_HEATING
}

void CRadiation::Initialise( char *szFilename )
Expand Down Expand Up @@ -743,4 +759,4 @@ double CRadiation::GetRadiationFromLookupTable( double flog_10T, double fne, dou

return ( fne * fnH ) * pow( 10.0, result );
}
#endif // USE_RADIATION_LOOKUP_TABLE
#endif // USE_RADIATION_LOOKUP_TABLE

0 comments on commit 87fe711

Please sign in to comment.