Cloudy
Spectral Synthesis Code for Astrophysics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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)   { ASSERT( PTR != NULL ); free( PTR ); PTR = NULL; }
 
#define FREE_SAFE(PTR)   { if( PTR != NULL ) free( PTR ); PTR = NULL; }
 

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

#define FREE_CHECK (   PTR)    { ASSERT( PTR != NULL ); free( PTR ); PTR = NULL; }
#define FREE_SAFE (   PTR)    { if( PTR != NULL ) free( PTR ); PTR = NULL; }

Function Documentation

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:

double elec_esc_length ( double  e,
long  nd 
)
inline

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

References GrainVar::bin, gv, and powpq().

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

Here is the call graph for this function:

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

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

Referenced by GrainCharge().

Here is the call graph for this function:

STATIC void GetPotValues ( size_t  nd,
long  Zg,
double *  ThresInf,
double *  ThresInfVal,
double *  ThresSurf,
double *  ThresSurfVal,
double *  PotSurf,
double *  Emin,
bool  lgUseTunnelCorr 
)
STATIC void GrainChrgTransferRates ( long  nd)
STATIC double GrainElecRecomb1 ( size_t  nd,
long  nz,
double *  sum1,
double *  sum2 
)
STATIC void GrainIonColl ( size_t  ,
long  ,
long  ,
long  ,
const double  [],
const double  [],
long *  ,
realnum ,
realnum  
)

Referenced by UpdateRecomZ0().

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 t_mesh::anu(), GrainVar::bin, DEBUG_ENTRY, GetPotValues(), gv, Heavy, t_Heavy::ipHeavy, NO_TUNNEL, rfield, and save.

Here is the call graph for this function:

void GrainRestartIter ( )

this routine is called by IterRestart()

References GrainVar::bin, DEBUG_ENTRY, gv, GrainVar::lgDustOn(), and GrainVar::lgGrainPhysicsOn.

Referenced by IterRestart().

Here is the call graph for this function:

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

References ASSERT, GrainVar::bin, DEBUG_ENTRY, gv, LIMELM, MIN2, phycon, POW2, powpq(), t_phycon::te, and ThetaNu().

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

Here is the call graph for this function:

void GrainsInit ( )

startup routine for grains, called before first calculations, but after parsecommands

Todo:
xray - StickElec depends on Te ???? use elec_esc_length(1.5*kTe,nd) ????

References t_mesh::anu(), ASSERT, atoms, GrainVar::AugerData, AEInfo::AvNumber, GrainVar::bin, cdEXIT, t_elementnames::chElementName, CHRG_TOLER, t_thermal::ConstGrainTemp, conv, DEBUG_ENTRY, dense, DF_STANDARD, GrainVar::dstab, GrainVar::dstsc, t_conv::EdenErrorAllowed, t_mesh::egamry(), elec_esc_length(), elementnames, GrainVar::elmSumAbund, t_mesh::emm(), ENABLE_QUANTUM_HEATING, AEInfo::Energy, EXIT_FAILURE, fprintf(), t_dense::gas_phase, GrainVar::GasCoolColl, GetPotValues(), GrainVar::GrainEmission, GrainVar::GrainHeatCollSum, GrainVar::GrainHeatDif, GrainVar::GrainHeatInc, GrainVar::GrainHeatLya, GrainVar::GrainHeatSum, GrainVar::GrainMetal, GrainVar::GraphiteEmission, GrainVar::GrnRecomTe, GrnStdDpth(), gv, HEAT_TOLER, HEAT_TOLER_BIN, t_conv::HeatCoolRelErrorAllowed, INCL_TUNNEL, InitBinAugerData(), InitEmissivities(), InitEnthalpy(), AEInfo::IonThres, ioQQQ, ipHYDROGEN, ipLITHIUM, t_mesh::ithreshC(), GrainVar::lgAnyDustVary, t_trace::lgDustBug, GrainVar::lgDustOn(), GrainVar::lgQHeatAll, GrainVar::lgQHeatOn, t_trace::lgTrace, GrainVar::lgWD01, LIMELM, MAT_PAH, MAT_PAH2, MAX2, NCHU, AEInfo::nData, t_rfield::nflux_with_check, nint(), t_rfield::nPositive, AEInfo::nSubShell, GrainVar::nzone, pow(), POW2, powpq(), ReadAugerData(), rfield, t_thermal::setHeating(), GrainVar::SilicateEmission, STICK_ELEC, thermal, TorF(), trace, GrainVar::which_zmin, ZMIN_CAR, and ZMIN_SIL.

Referenced by OpacityCreateAll().

Here is the call graph for this function:

void GrainStartIter ( )
STATIC void GrainUpdateRadius1 ( )

References ASSERT, GrainVar::bin, DEBUG_ENTRY, dense, GrainVar::elmSumAbund, t_dense::gas_phase, GrainVar::GrainMetal, GrnStdDpth(), gv, ipHYDROGEN, and LIMELM.

Referenced by GrainChargeTemp(), and GrainDrive().

Here is the call graph for this function:

STATIC double GrnStdDpth ( long  )

Referenced by GrainsInit(), and GrainUpdateRadius1().

STATIC double GrnVryDpth ( size_t  nd)

References GrainVar::bin, cdEXIT, DEBUG_ENTRY, dense, EXIT_FAILURE, fprintf(), t_dense::gas_phase, gv, ioQQQ, ipHYDROGEN, max(), and t_dense::xIonDense.

Referenced by GrnStdDpth().

Here is the call graph for this function:

STATIC void InitBinAugerData ( size_t  nd,
long  ipBegin,
long  ipEnd 
)
STATIC void NewChargeData ( long  nd)
Todo:
2 should any of the following 3 statements be removed?

References GrainVar::bin, DEBUG_ENTRY, fp_equal(), GrainVar::GrnRecomTe, gv, LIMELM, NCHS, nzone, GrainVar::nzone, phycon, and t_phycon::te.

Referenced by GrainChargeTemp().

Here is the call graph for this function:

double one_elec ( long  nd)
inline

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

References GrainVar::bin, and gv.

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

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 
)
STATIC double PlanckIntegral ( double  ,
size_t  ,
long   
)

Referenced by InitEmissivities().

STATIC double PlanckIntegral ( double  tdust,
size_t  nd,
long int  ip 
)
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:

void SetNChrgStates ( long  )

this routine is called by ParseSet()

References ASSERT, DEBUG_ENTRY, gv, GrainVar::nChrgRequested, and NCHU.

Referenced by ParseSet().

STATIC double ThetaNu ( double  nu)

References DEBUG_ENTRY, and POW2.

Referenced by GetPotValues(), and GrainScreen().

STATIC void UpdatePot ( size_t  nd,
long  Zlo,
long  stride,
double  rate_up[],
double  rate_dn[] 
)
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 t_mesh::anuptr(), ASSERT, ShellData::AvNr, GrainVar::bin, chrg2pot(), DEBUG_ENTRY, ShellData::Ener, GetPotValues(), gv, INCL_TUNNEL, ShellData::ionPot, ShellData::ipLo, t_mesh::ithreshC(), LIMELM, max(), MAX2, min(), ShellData::nData, t_rfield::nflux, t_rfield::nflux_with_check, NO_TUNNEL, t_rfield::nPositive, NULL, ShellData::p, PE_init(), POW2, avx_ptr< T, lgBC >::ptr0(), flex_arr< T, lgBC >::ptr0(), rfield, UpdateRecomZ0(), ShellData::y01, ShellData::y01A, y0b(), and Yfunc().

Referenced by UpdatePot().

Here is the call graph for this function:

STATIC void UpdatePot2 ( size_t  nd,
long  nz 
)

References GrainVar::bin, DEBUG_ENTRY, gv, POW2, and THERMCONST.

Referenced by UpdatePot().

STATIC void UpdateRecomZ0 ( size_t  nd,
long  nz 
)

References GrainVar::bin, DEBUG_ENTRY, dense, GetPotValues(), GrainIonColl(), gv, INCL_TUNNEL, t_dense::lgElmtOn, LIMELM, and NO_TUNNEL.

Referenced by UpdatePot1().

Here is the call graph for this function:

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

References t_mesh::anu(), ASSERT, GrainVar::bin, DEBUG_ENTRY, gv, t_mesh::ithreshC(), GrainVar::lgWD01, max(), min(), avx_ptr< T, lgBC >::ptr0(), rfield, vexp(), vlog(), and y0b01().

Referenced by UpdatePot1().

Here is the call graph for this function:

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

References t_mesh::anu(), GrainVar::bin, cdEXIT, DEBUG_ENTRY, EXIT_FAILURE, fprintf(), gv, ioQQQ, max(), PE_CAR, PE_SIL, rfield, and GrainVar::which_pe.

Referenced by y0b().

Here is the call graph for this function:

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

References ASSERT, GrainVar::bin, DEBUG_ENTRY, elec_esc_length(), and gv.

Referenced by InitBinAugerData().

Here is the call graph for this function:

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

References ASSERT, GrainVar::bin, DEBUG_ENTRY, elec_esc_length(), gv, pow2(), and pow3().

Referenced by InitBinAugerData().

Here is the call graph for this function:

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().

Here is the call graph for this function:

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, GrainVar::lgWD01, avx_ptr< T, lgBC >::ptr0(), vfast_asinh(), vsqrt(), and x2.

Referenced by Yfunc().

Here is the call graph for this function:

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, GrainVar::bin, cdEXIT, DEBUG_ENTRY, elec_esc_length(), EXIT_FAILURE, fprintf(), gv, ioQQQ, max(), min(), NULL, PE_CAR, PE_SIL, GrainVar::which_pe, y2pa(), and y2s().

Referenced by UpdatePot1().

Here is the call graph for this function:

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 
)

Variable Documentation

const double AC0 = 3.e-9
static

Referenced by GetPotValues().

const double AC1G = 4.e-8
static

Referenced by GetPotValues().

const double AC2G = 7.e-8
static

Referenced by GetPotValues().

const long BRACKET_MAX = 50L
static

Referenced by GrainCharge().

double CHRG_TOLER = DBL_MAX
static

Referenced by GrainChargeTemp(), and GrainsInit().

const long CT_LOOP_MAX = 25L
static
const double ETILDE = 2.*SQRT2/EVRYD
static

Referenced by y2s().

double HEAT_TOLER = DBL_MAX
static

Referenced by GrainChargeTemp(), and GrainsInit().

double HEAT_TOLER_BIN = DBL_MAX
static

Referenced by GrainChargeTemp(), and GrainsInit().

const bool INCL_TUNNEL = true
static
const double INV_ETILDE = 1./ETILDE
static

Referenced by y2s().

const long MAGIC_AUGER_DATA = 20060126L
static

Referenced by ReadAugerData().

const bool NO_TUNNEL = false
static
const long NTOP = NDEMS/5
static

Referenced by InitEmissivities().

const double STICK_ELEC = 0.5
static

Referenced by GrainsInit().

const double STICK_ION = 1.0
static
const long T_LOOP_MAX = 50L
static

Referenced by GrainChargeTemp().

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

Referenced by UpdatePot2().

const double TOLER = CONSERV_TOL/10.
static