Cloudy
Spectral Synthesis Code for Astrophysics
Loading...
Searching...
No Matches
grains.cpp File Reference
#include "cddefines.h"
#include "atmdat.h"
#include "atmdat_adfa.h"
#include "rfield.h"
#include "hmi.h"
#include "trace.h"
#include "conv.h"
#include "ionbal.h"
#include "thermal.h"
#include "phycon.h"
#include "doppvel.h"
#include "heavy.h"
#include "ipoint.h"
#include "elementnames.h"
#include "grainvar.h"
#include "grains.h"
#include "iso.h"
#include "mole.h"
#include "dense.h"
#include "vectorize.h"
#include "parser.h"
Include dependency graph for grains.cpp:

Macros

#define FREE_CHECK(PTR)
 
#define FREE_SAFE(PTR)
 

Functions

double one_elec (long nd)
 
double pot2chrg (double x, long nd)
 
double chrg2pot (double x, long nd)
 
double elec_esc_length (double e, long nd)
 
STATIC void ReadAugerData ()
 
STATIC void InitBinAugerData (size_t, long, long)
 
STATIC void InitEmissivities ()
 
STATIC double PlanckIntegral (double, size_t, long)
 
STATIC void NewChargeData (long)
 
STATIC double GrnStdDpth (long)
 
STATIC void GrainChargeTemp ()
 
STATIC void GrainCharge (size_t, double *)
 
STATIC double GrainElecRecomb1 (size_t, long, double *, double *)
 
STATIC double GrainElecEmis1 (size_t, long, double *, double *, double *, double *)
 
STATIC void GrainScreen (long, size_t, long, double *, double *)
 
STATIC double ThetaNu (double)
 
STATIC void UpdatePot (size_t, long, long, double[], double[])
 
STATIC void GetFracPop (size_t, long, double[], double[], long *)
 
STATIC void UpdatePot1 (size_t, long, long, long)
 
STATIC void UpdatePot2 (size_t, long)
 
STATIC void Yfunc (long, long, const realnum[], const realnum[], const realnum[], double, const double[], const double[], realnum[], realnum[], realnum[], realnum[], long, long)
 
STATIC void Yfunc (long, long, const realnum[], const realnum[], double, double, double, realnum[], realnum[], realnum[], realnum[], long, long)
 
STATIC void y0b (size_t, long, realnum[], long, long)
 
STATIC void y0b01 (size_t, long, realnum[], long, long)
 
STATIC double y0psa (size_t, long, long, double)
 
STATIC double y1psa (size_t, long, double)
 
void y2pa (double, const double[], long, realnum[], realnum[], long, long)
 
void y2s (double, const double[], long, const realnum[], realnum[], realnum[], long, long)
 
STATIC void UpdateRecomZ0 (size_t, long)
 
STATIC void GetPotValues (size_t, long, double *, double *, double *, double *, double *, double *, bool)
 
STATIC void GrainIonColl (size_t, long, long, long, const double[], const double[], long *, realnum *, realnum *)
 
STATIC void GrainChrgTransferRates (long)
 
STATIC void GrainUpdateRadius1 ()
 
STATIC void GrainUpdateRadius2 ()
 
STATIC void GrainTemperature (size_t, realnum *, double *, double *, double *)
 
STATIC void PE_init (size_t, long, long, double *, double *, double *, double *, double *, double *, double *)
 
STATIC void GrainCollHeating (size_t, realnum *, realnum *)
 
STATIC double GrnVryDpth (size_t)
 
void GrainStartIter ()
 
void GrainRestartIter ()
 
void SetNChrgStates (long nChrg)
 
void GrainsInit ()
 
STATIC double PlanckIntegral (double tdust, size_t nd, long int ip)
 
STATIC double GrnStdDpth (long int nd)
 
void GrainDrive ()
 
STATIC void GrainIonColl (size_t nd, long int nz, long int nelem, long int ion, const double phi_s_up[], const double phi_s_dn[], long *Z0, realnum *ChEn, realnum *ChemEn)
 
void GrainDrift ()
 

Variables

static const long MAGIC_AUGER_DATA = 20060126L
 
static const bool INCL_TUNNEL = true
 
static const bool NO_TUNNEL = false
 
static const long NTOP = NDEMS/5
 
static const double TOLER = CONSERV_TOL/10.
 
static const long BRACKET_MAX = 50L
 
static const long CT_LOOP_MAX = 25L
 
static const long T_LOOP_MAX = 50L
 
static double HEAT_TOLER = DBL_MAX
 
static double HEAT_TOLER_BIN = DBL_MAX
 
static double CHRG_TOLER = DBL_MAX
 
static const double AC0 = 3.e-9
 
static const double AC1G = 4.e-8
 
static const double AC2G = 7.e-8
 
static const double ETILDE = 2.*SQRT2/EVRYD
 
static const double INV_ETILDE = 1./ETILDE
 
static const double THERMCONST = PI4*ELECTRON_MASS*POW2(BOLTZMANN)/POW3(HPLANCK)
 
static const double STICK_ELEC = 0.5
 
static const double STICK_ION = 1.0
 

Macro Definition Documentation

◆ FREE_CHECK

#define FREE_CHECK ( PTR)
Value:
{ ASSERT( PTR != NULL ); free( PTR ); PTR = NULL; }
#define NULL
Definition cddefines.h:115
#define ASSERT(exp)
Definition cddefines.h:637

◆ FREE_SAFE

#define FREE_SAFE ( PTR)
Value:
{ if( PTR != NULL ) free( PTR ); PTR = NULL; }

Function Documentation

◆ chrg2pot()

double chrg2pot ( double x,
long nd )
inline

convert grain charge in electrons into potential in Ryd

References one_elec().

Referenced by GetPotValues(), GrainCharge(), GrainDrive(), and UpdatePot1().

Here is the call graph for this function:

◆ elec_esc_length()

double elec_esc_length ( double e,
long nd )
inline

mean pathlength travelled by electrons inside the grain, in cm (Eq. 11 of WDB06)

References gv, and powpq().

Referenced by GrainsInit(), y0psa(), y1psa(), Yfunc(), and Yfunc().

Here is the call graph for this function:

◆ GetFracPop()

STATIC void GetFracPop ( size_t nd,
long Zlo,
double rate_up[],
double rate_dn[],
long * newZlo )

References ASSERT, cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fnzone, fprintf(), gv, ioQQQ, MAX2, NCHU, safe_div(), ShowMe(), STATIC, x1, and x2.

Referenced by GrainCharge().

Here is the call graph for this function:

◆ GetPotValues()

STATIC void GetPotValues ( size_t nd,
long Zg,
double * ThresInf,
double * ThresInfVal,
double * ThresSurf,
double * ThresSurfVal,
double * PotSurf,
double * Emin,
bool lgUseTunnelCorr )

References AC0, AC1G, AC2G, cdEXIT, chrg2pot(), DEBUG_ENTRY, EXIT_FAILURE, fprintf(), gv, ioQQQ, MAX2, one_elec(), POT_CAR, POT_SIL, pow(), STATIC, and ThetaNu().

Referenced by GrainIonColl(), GrainsInit(), UpdatePot1(), and UpdateRecomZ0().

Here is the call graph for this function:

◆ GrainCharge()

STATIC void GrainCharge ( size_t nd,
double * ThermRatio )

◆ GrainChargeTemp()

STATIC void GrainChargeTemp ( )
Todo
2 this algorithm might be more efficient with Brent
Todo
2 should collisional heating/cooling be included here?
Todo
2 use something like log(ThermRatio) + log(delta) ????
Todo
2 this algorithm might be more efficient with Brent

References ASSERT, CHRG_TOLER, conv, ConvFail(), DEBUG_ENTRY, dense, elementnames, fnzone, fp_equal(), fprintf(), fudge(), GRAIN_TMAX, GRAIN_TMIN, GrainCharge(), GrainChrgTransferRates(), GrainTemperature(), GrainUpdateRadius1(), GrainUpdateRadius2(), gv, HEAT_TOLER, HEAT_TOLER_BIN, ionbal, ioQQQ, ipHYDROGEN, LIMELM, MAT_PAH, MAT_PAH2, NDEMS, NewChargeData(), nzone, phycon, POW2, splint_safe(), STATIC, T_LOOP_MAX, thermal, TOLER, TorF(), TotalInsanity(), and trace.

Referenced by GrainDrive().

Here is the call graph for this function:

◆ GrainChrgTransferRates()

STATIC void GrainChrgTransferRates ( long nd)

References atmdat, DEBUG_ENTRY, dense, ChargeBin::FracPop, GetAveVelocity(), GrainScreen(), gv, LIMELM, MAX2, ChargeBin::RecomZ0, STATIC, and STICK_ION.

Referenced by GrainChargeTemp().

Here is the call graph for this function:

◆ GrainCollHeating()

◆ GrainDrift()

void GrainDrift ( )

GrainDrift computes grains drift velocity

References ASSERT, DEBUG_ENTRY, dense, fprintf(), gv, ioQQQ, ipHELIUM, ipHYDROGEN, phycon, POW2, POW3, rfield, and trace.

Referenced by ConvPresTempEdenIoniz().

Here is the call graph for this function:

◆ GrainDrive()

void GrainDrive ( )

GrainDrive main routine to converge grains thermal solution

References chrg2pot(), conv, DEBUG_ENTRY, dense, fp_equal(), fprintf(), GrainChargeTemp(), GrainUpdateRadius1(), GrainUpdateRadius2(), gv, hmi, ioQQQ, ipHYDROGEN, LIMELM, nzone, phycon, pow(), SDIV(), thermal, and trace.

Referenced by ConvBase(), and mole_h2_grain_form().

Here is the call graph for this function:

◆ GrainElecEmis1()

STATIC double GrainElecEmis1 ( size_t nd,
long nz,
double * sum1a,
double * sum1b,
double * sum2,
double * sum3 )

◆ GrainElecRecomb1()

STATIC double GrainElecRecomb1 ( size_t nd,
long nz,
double * sum1,
double * sum2 )

References ASSERT, DEBUG_ENTRY, dense, GetAveVelocity(), GrainScreen(), gv, LIMELM, MAX2, phycon, STATIC, and STICK_ION.

Referenced by GrainCharge(), GrainCollHeating(), and UpdatePot().

Here is the call graph for this function:

◆ GrainIonColl() [1/2]

STATIC void GrainIonColl ( size_t nd,
long int nz,
long int nelem,
long int ion,
const double phi_s_up[],
const double phi_s_dn[],
long * Z0,
realnum * ChEn,
realnum * ChemEn )

References DEBUG_ENTRY, GetPotValues(), gv, Heavy, NO_TUNNEL, rfield, save, and STATIC.

Here is the call graph for this function:

◆ GrainIonColl() [2/2]

STATIC void GrainIonColl ( size_t ,
long ,
long ,
long ,
const double [],
const double [],
long * ,
realnum * ,
realnum *  )

References STATIC.

Referenced by UpdateRecomZ0().

◆ GrainRestartIter()

void GrainRestartIter ( )

this routine is called by IterRestart()

References DEBUG_ENTRY, and gv.

Referenced by IterRestart().

◆ GrainScreen()

STATIC void GrainScreen ( long ion,
size_t nd,
long nz,
double * eta,
double * xi )

References ASSERT, DEBUG_ENTRY, gv, LIMELM, MIN2, phycon, POW2, powpq(), STATIC, and ThetaNu().

Referenced by GrainChrgTransferRates(), GrainCollHeating(), GrainElecEmis1(), and GrainElecRecomb1().

Here is the call graph for this function:

◆ GrainsInit()

◆ GrainStartIter()

void GrainStartIter ( )

this routine is called by IterStart()

References DEBUG_ENTRY, and gv.

Referenced by IterStart().

◆ GrainTemperature()

◆ GrainUpdateRadius1()

STATIC void GrainUpdateRadius1 ( )

References ASSERT, DEBUG_ENTRY, dense, GrnStdDpth(), gv, ipHYDROGEN, LIMELM, and STATIC.

Referenced by GrainChargeTemp(), and GrainDrive().

Here is the call graph for this function:

◆ GrainUpdateRadius2()

STATIC void GrainUpdateRadius2 ( )

References ASSERT, ChargeBin::cs_pdt, DEBUG_ENTRY, ChargeBin::DustZ, ChargeBin::FracPop, get_ptr(), gv, ChargeBin::ipThresInf, rfield, and STATIC.

Referenced by GrainChargeTemp(), and GrainDrive().

Here is the call graph for this function:

◆ GrnStdDpth() [1/2]

STATIC double GrnStdDpth ( long int nd)

◆ GrnStdDpth() [2/2]

STATIC double GrnStdDpth ( long )

References STATIC.

Referenced by GrainsInit(), and GrainUpdateRadius1().

◆ GrnVryDpth()

STATIC double GrnVryDpth ( size_t nd)

References cdEXIT, DEBUG_ENTRY, dense, EXIT_FAILURE, fprintf(), gv, ioQQQ, ipHYDROGEN, max(), and STATIC.

Referenced by GrnStdDpth().

Here is the call graph for this function:

◆ InitBinAugerData()

STATIC void InitBinAugerData ( size_t nd,
long ipBegin,
long ipEnd )

initialize the Auger data for grain bin nd between index ipBegin <= i < ipEnd

Todo
xray - Compton recoil still needs to be added here

References ShellData::AvNr, flex_arr< T, lgBC >::clear(), DEBUG_ENTRY, ShellData::Ener, gv, Heavy, Singleton< t_ADfA >::Inst(), ShellData::ionPot, ipHYDROGEN, ShellData::ipLo, LIMELM, max(), MAX2, ShellData::nData, t_ADfA::phfit(), flex_arr< T, lgBC >::realloc(), rfield, STATIC, ShellData::y01, ShellData::y01A, y0psa(), y1psa(), and flex_arr< T, lgBC >::zero().

Referenced by GrainsInit(), and UpdatePot().

Here is the call graph for this function:

◆ InitEmissivities()

STATIC void InitEmissivities ( )

References ASSERT, cdEXIT, DEBUG_ENTRY, EXIT_SUCCESS, exp10(), fprintf(), fudge(), GRAIN_TMAX, GRAIN_TMID, GRAIN_TMIN, gv, ioQQQ, NDEMS, nint(), NTOP, PlanckIntegral(), powi(), spline(), splint(), STATIC, and trace.

Referenced by GrainsInit().

Here is the call graph for this function:

◆ NewChargeData()

STATIC void NewChargeData ( long nd)
Todo
2 should any of the following 3 statements be removed?

References DEBUG_ENTRY, fp_equal(), gv, LIMELM, NCHS, nzone, phycon, and STATIC.

Referenced by GrainChargeTemp().

Here is the call graph for this function:

◆ one_elec()

double one_elec ( long nd)
inline

evaluate e^2/a, the potential of one electron

References gv.

Referenced by chrg2pot(), GetPotValues(), and pot2chrg().

◆ PE_init()

STATIC void PE_init ( size_t nd,
long nz,
long i,
double * cs1,
double * cs2,
double * cs_tot,
double * cool1,
double * cool2,
double * ehat1,
double * ehat2 )

◆ PlanckIntegral() [1/2]

STATIC double PlanckIntegral ( double tdust,
size_t nd,
long int ip )

References ASSERT, DEBUG_ENTRY, fprintf(), gv, ioQQQ, POW2, powi(), avx_ptr< T, lgBC >::ptr0(), rfield, STATIC, trace, and vexp().

Here is the call graph for this function:

◆ PlanckIntegral() [2/2]

STATIC double PlanckIntegral ( double ,
size_t ,
long  )

References STATIC.

Referenced by InitEmissivities().

◆ pot2chrg()

double pot2chrg ( double x,
long nd )
inline

convert grain potential in Ryd to charge in electrons

References one_elec().

Referenced by GrainCharge().

Here is the call graph for this function:

◆ ReadAugerData()

◆ SetNChrgStates()

void SetNChrgStates ( long nChrg)

this routine is called by ParseSet()

References ASSERT, DEBUG_ENTRY, gv, and NCHU.

Referenced by ParseSet().

◆ ThetaNu()

STATIC double ThetaNu ( double nu)

References DEBUG_ENTRY, POW2, and STATIC.

Referenced by GetPotValues(), and GrainScreen().

◆ UpdatePot()

STATIC void UpdatePot ( size_t nd,
long Zlo,
long stride,
double rate_up[],
double rate_dn[] )

◆ UpdatePot1()

STATIC void UpdatePot1 ( size_t nd,
long nz,
long Zg,
long ipStart )
Todo
xray - secondaries from incident electrons still need to be added in
Todo
xray - primary, secondary, auger electrons need to be added into suprathermals

References ASSERT, ShellData::AvNr, chrg2pot(), DEBUG_ENTRY, ShellData::Ener, GetPotValues(), gv, INCL_TUNNEL, ShellData::ionPot, ShellData::ipLo, LIMELM, max(), MAX2, min(), ShellData::nData, NO_TUNNEL, NULL, ShellData::p, PE_init(), POW2, avx_ptr< T, lgBC >::ptr0(), flex_arr< T, lgBC >::ptr0(), rfield, STATIC, UpdateRecomZ0(), ShellData::y01, ShellData::y01A, y0b(), and Yfunc().

Referenced by UpdatePot().

Here is the call graph for this function:

◆ UpdatePot2()

STATIC void UpdatePot2 ( size_t nd,
long nz )

References DEBUG_ENTRY, gv, POW2, STATIC, and THERMCONST.

Referenced by UpdatePot().

◆ UpdateRecomZ0()

STATIC void UpdateRecomZ0 ( size_t nd,
long nz )

References DEBUG_ENTRY, dense, GetPotValues(), GrainIonColl(), gv, INCL_TUNNEL, LIMELM, NO_TUNNEL, and STATIC.

Referenced by UpdatePot1().

Here is the call graph for this function:

◆ y0b()

STATIC void y0b ( size_t nd,
long nz,
realnum yzero[],
long ilo,
long ihi )

References ASSERT, DEBUG_ENTRY, gv, max(), min(), avx_ptr< T, lgBC >::ptr0(), rfield, STATIC, vexp(), vlog(), and y0b01().

Referenced by UpdatePot1().

Here is the call graph for this function:

◆ y0b01()

STATIC void y0b01 ( size_t nd,
long nz,
realnum yzero[],
long ilo,
long ihi )

References cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fprintf(), gv, ioQQQ, max(), PE_CAR, PE_SIL, rfield, and STATIC.

Referenced by y0b().

Here is the call graph for this function:

◆ y0psa()

STATIC double y0psa ( size_t nd,
long ns,
long i,
double Eel )

References ASSERT, DEBUG_ENTRY, elec_esc_length(), gv, and STATIC.

Referenced by InitBinAugerData().

Here is the call graph for this function:

◆ y1psa()

STATIC double y1psa ( size_t nd,
long i,
double Eel )

References ASSERT, DEBUG_ENTRY, elec_esc_length(), gv, pow2, pow3, and STATIC.

Referenced by InitBinAugerData().

Here is the call graph for this function:

◆ y2pa()

void y2pa ( double Elo,
const double Ehi[],
long Zg,
realnum Ehp[],
realnum y2pr[],
long ilo,
long ihi )
inline

References ASSERT, DEBUG_ENTRY, and pow3.

Referenced by Yfunc(), and Yfunc().

◆ y2s()

void y2s ( double Elo,
const double Ehi[],
long Zg,
const realnum y2pr[],
realnum Ehs[],
realnum y2sec[],
long ilo,
long ihi )
inline

References ASSERT, avx_ptr< T, lgBC >::data(), DEBUG_ENTRY, ETILDE, gv, INV_ETILDE, avx_ptr< T, lgBC >::ptr0(), vfast_asinh(), vsqrt(), and x2.

Referenced by Yfunc(), and Yfunc().

Here is the call graph for this function:

◆ Yfunc() [1/2]

STATIC void Yfunc ( long nd,
long nz,
const realnum y0[],
const realnum y1[],
const realnum maxval[],
double Elo,
const double Ehi[],
const double Eel[],
realnum Yp[],
realnum Ys[],
realnum Ehp[],
realnum Ehs[],
long ilo,
long ihi )

References ASSERT, cdEXIT, DEBUG_ENTRY, elec_esc_length(), EXIT_FAILURE, fprintf(), gv, ioQQQ, max(), min(), NULL, PE_CAR, PE_SIL, STATIC, y2pa(), and y2s().

Referenced by UpdatePot1().

Here is the call graph for this function:

◆ Yfunc() [2/2]

STATIC void Yfunc ( long nd,
long nz,
const realnum y01[],
const realnum maxval[],
double Elo,
double Ehi,
double Eel,
realnum Yp[],
realnum Ys[],
realnum Ehp[],
realnum Ehs[],
long ilo,
long ihi )

References ASSERT, cdEXIT, DEBUG_ENTRY, elec_esc_length(), EXIT_FAILURE, fprintf(), gv, ioQQQ, max(), min(), PE_CAR, PE_SIL, avx_ptr< T, lgBC >::ptr0(), STATIC, y2pa(), and y2s().

Here is the call graph for this function:

Variable Documentation

◆ AC0

const double AC0 = 3.e-9
static

Referenced by GetPotValues().

◆ AC1G

const double AC1G = 4.e-8
static

Referenced by GetPotValues().

◆ AC2G

const double AC2G = 7.e-8
static

Referenced by GetPotValues().

◆ BRACKET_MAX

const long BRACKET_MAX = 50L
static

Referenced by GrainCharge().

◆ CHRG_TOLER

double CHRG_TOLER = DBL_MAX
static

Referenced by GrainChargeTemp(), and GrainsInit().

◆ CT_LOOP_MAX

const long CT_LOOP_MAX = 25L
static

◆ ETILDE

const double ETILDE = 2.*SQRT2/EVRYD
static

Referenced by y2s().

◆ HEAT_TOLER

double HEAT_TOLER = DBL_MAX
static

Referenced by GrainChargeTemp(), and GrainsInit().

◆ HEAT_TOLER_BIN

double HEAT_TOLER_BIN = DBL_MAX
static

Referenced by GrainChargeTemp(), and GrainsInit().

◆ INCL_TUNNEL

const bool INCL_TUNNEL = true
static

◆ INV_ETILDE

const double INV_ETILDE = 1./ETILDE
static

Referenced by y2s().

◆ MAGIC_AUGER_DATA

const long MAGIC_AUGER_DATA = 20060126L
static

Referenced by ReadAugerData().

◆ NO_TUNNEL

const bool NO_TUNNEL = false
static

◆ NTOP

const long NTOP = NDEMS/5
static

Referenced by InitEmissivities().

◆ STICK_ELEC

const double STICK_ELEC = 0.5
static

Referenced by GrainsInit().

◆ STICK_ION

const double STICK_ION = 1.0
static

◆ T_LOOP_MAX

const long T_LOOP_MAX = 50L
static

Referenced by GrainChargeTemp().

◆ THERMCONST

const double THERMCONST = PI4*ELECTRON_MASS*POW2(BOLTZMANN)/POW3(HPLANCK)
static

Referenced by UpdatePot2().

◆ TOLER

const double TOLER = CONSERV_TOL/10.
static