The FARGO_THORIN code developer's guide
 All Data Structures Files Functions Variables Typedefs Macros
Macros | Functions | Variables
EnergySources.c File Reference

Subroutines related to the heating/cooling source terms, numerical solver for the energy equation and radiative diffusion. More...

#include "fargo.h"
Include dependency graph for EnergySources.c:

Go to the source code of this file.

Macros

#define SORMAXITERS   1000
 
#define SOREPS   1.0e-8
 

Functions

void InitRadiatDiffusionFields ()
 Initialises the polar arrays associated with the heating/cooling processes. More...
 
void CalculateQminus (PolarGrid *Rho)
 Estimate of the heat loss due to radiation escape in the vertical direction with respect to the midplane. More...
 
void CalculateQirr (PolarGrid *Rho)
 Calculates the stellar irradiation source term. More...
 
void CalculateFlaring ()
 Calculates the sine of the grazing angle by reconstructing the surface from the pressure scale height. More...
 
void ImplicitRadiativeDiffusion (PolarGrid *Rho, PolarGrid *EnergyInt, PolarGrid *EnergyNew, real dt)
 The main numerical solver of the energy equation. More...
 
void IterateRelaxationParameter ()
 When solving the energy equation for the first time, the function spans through various values of the SOR parameter in order to find its best value to start with. More...
 
int SuccessiveOverrelaxation (real omega, boolean errcheck)
 The SOR method algorithm inspired by the one from Numerical Recipes. More...
 
void ChessBoardIndexing ()
 Function ensures the odd-even ordering of the SOR method when the grid is split on multiple CPUs. More...
 
void DiffusionCoefs ()
 Calculation of the diffusion coefficients. More...
 
void TemperatureGradient ()
 Finds the temperature gradients and their magnitude over the mesh. More...
 
void MidplaneVolumeDensity (PolarGrid *Rho)
 Translates the surface density into the midplane volume density using the local pressure scale height. More...
 
void OpacityProfile ()
 Fills the opacity polar grid, either with a fixed parametric value or using the Bell & Lin (1994) opacity table. More...
 
real FluxLimiterValue (real s)
 Calculates the flux limiter according to Kley (1989) More...
 
real EffectiveOpticalDepth (real tau)
 Calculates the effective optical depth in a simple gray model of the disk's vertical structure; see Hubeny (1990). More...
 
void SynchronizeOverlapFields (real *field, int nr, int nsync)
 For a MPI-split grid, synchronizes the values in a requested number 'nsync' of the overlapping radial rings. More...
 
void CreateTorqueMapInfile (int istep, PolarGrid *Surfdens)
 Writes an input file for the 'torquemap' code written by Bertram Bitsch. More...
 

Variables

static real kappa0 [7] = {2.0e-4, 2.0e16, 0.1, 2.0e81, 1.0e-8, 1.0e-36, 1.5e20}
 
static real a [7] = {0.0, 0.0, 0.0, 1.0, 2.0/3.0, 1.0/3.0, 1.0}
 
static real b [7] = {2.0, -7.0, 0.5, -24.0, 3.0, 10.0, -5.0/2.0}
 
static PolarGridGradTemperRad
 
static PolarGridGradTemperTheta
 
static PolarGridGradTemperMagnitude
 
static PolarGridDiffCoefCentered
 
static PolarGridDiffCoefIfaceRad
 
static PolarGridDiffCoefIfaceTheta
 
static PolarGridOpacity
 
static PolarGridVolumeDensity
 
static PolarGridFlaring
 
static PolarGridQirradiation
 
static PolarGridDiscretizationCoefA
 
static PolarGridDiscretizationCoefB
 
static PolarGridMatrixNexttoTemperl
 
static PolarGridMatrixNexttoTemperlip
 
static PolarGridMatrixNexttoTemperlim
 
static PolarGridMatrixNexttoTemperljp
 
static PolarGridMatrixNexttoTemperljm
 
static PolarGridRightHandSide
 
static real CV
 
static real omegabest
 
static real domega
 
static int Niterbest
 
static int jchess1st
 
static int jchess2nd
 

Detailed Description

Subroutines related to the heating/cooling source terms, numerical solver for the energy equation and radiative diffusion.

Author
Ondřej Chrenko chren.nosp@m.ko@s.nosp@m.irrah.nosp@m..tro.nosp@m.ja.mf.nosp@m.f.cu.nosp@m.ni.cz

Calculates the individual energy source terms according to Chrenko et al. (2017). Then solves the energy equation in a linearised implicit form using the successive over-relaxation (SOR) method (see Appendix A in Chrenko et al. 2017).

LICENSE

Copyright (c) 2017 Ondřej Chrenko. See the LICENSE file of the distribution.

Definition in file EnergySources.c.

Macro Definition Documentation

#define SOREPS   1.0e-8

Definition at line 23 of file EnergySources.c.

Referenced by SuccessiveOverrelaxation().

#define SORMAXITERS   1000

Definition at line 22 of file EnergySources.c.

Referenced by IterateRelaxationParameter(), and SuccessiveOverrelaxation().

Function Documentation

void CalculateFlaring ( )

Calculates the sine of the grazing angle by reconstructing the surface from the pressure scale height.

See Eq. (15) in Chrenko et al. (2017).

Definition at line 147 of file EnergySources.c.

References AU_SI, polargrid::Field, InvDiffRsup, InvRmed, polargrid::Nrad, polargrid::Nsec, OmegaInv, Rinf, Rmed, Rsup, SoundSpeed, SQRT_ADIABIND_INV, and STELLARRADIUS.

Referenced by ImplicitRadiativeDiffusion().

Here is the caller graph for this function:

void CalculateQirr ( PolarGrid Rho)

Calculates the stellar irradiation source term.

See Eq. (13) in Chrenko et al. (2017).

Definition at line 104 of file EnergySources.c.

References AU_SI, DISCALBEDO, EffectiveOpticalDepth(), EFFECTIVETEMPERATURE, polargrid::Field, OPACITYDROP, Rmed2, STEFANBOLTZMANN, STELLARRADIUS, and T2SI.

Referenced by ImplicitRadiativeDiffusion().

Here is the call graph for this function:

Here is the caller graph for this function:

void CalculateQminus ( PolarGrid Rho)

Estimate of the heat loss due to radiation escape in the vertical direction with respect to the midplane.

See Eq. (9) in Chrenko et al. (2017).

Definition at line 76 of file EnergySources.c.

References EffectiveOpticalDepth(), polargrid::Field, polargrid::Nrad, OPACITYDROP, Qminus, STEFANBOLTZMANN, and Temperature.

Referenced by ImplicitRadiativeDiffusion().

Here is the call graph for this function:

Here is the caller graph for this function:

void ChessBoardIndexing ( )

Function ensures the odd-even ordering of the SOR method when the grid is split on multiple CPUs.

Definition at line 486 of file EnergySources.c.

References CPU_Master, CPU_Number, CPU_Rank, CPUOVERLAP, fargostat, jchess1st, jchess2nd, MPI_COMM_WORLD, MPI_INT, MPI_Recv(), MPI_Send(), and NRAD.

Referenced by SuccessiveOverrelaxation().

Here is the call graph for this function:

Here is the caller graph for this function:

void CreateTorqueMapInfile ( int  istep,
PolarGrid Surfdens 
)

Writes an input file for the 'torquemap' code written by Bertram Bitsch.

Definition at line 816 of file EnergySources.c.

References a, ADIABIND, ALPHAVISCOSITY, b, CPU_Master, polargrid::Field, fopenp(), GLOBALNRAD, GlobalRmed, kappa0, masterprint(), MAX1D, mpi_make1Dprofile(), Opacity, OUTPUTDIR, PARAMETRICOPACITY, PI, PRESS2CGS, Pressure, RHO2CGS, Sigma(), SIGMA2CGS, SoundSpeed, T2SI, Temperature, VISCOSITY, and ViscosityAlpha.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void DiffusionCoefs ( )

Calculation of the diffusion coefficients.

Definition at line 527 of file EnergySources.c.

References polargrid::Field, FluxLimiterValue(), polargrid::Nrad, polargrid::Nsec, STEFANBOLTZMANN, Temperature, and TemperatureGradient().

Referenced by ImplicitRadiativeDiffusion().

Here is the call graph for this function:

Here is the caller graph for this function:

real EffectiveOpticalDepth ( real  tau)

Calculates the effective optical depth in a simple gray model of the disk's vertical structure; see Hubeny (1990).

Definition at line 736 of file EnergySources.c.

References StellarIrradiation.

Referenced by CalculateQirr(), and CalculateQminus().

Here is the caller graph for this function:

real FluxLimiterValue ( real  s)

Calculates the flux limiter according to Kley (1989)

Definition at line 719 of file EnergySources.c.

Referenced by DiffusionCoefs().

Here is the caller graph for this function:

void ImplicitRadiativeDiffusion ( PolarGrid Rho,
PolarGrid EnergyInt,
PolarGrid EnergyNew,
real  dt 
)
void InitRadiatDiffusionFields ( )

Initialises the polar arrays associated with the heating/cooling processes.

Definition at line 46 of file EnergySources.c.

References ADIABIND, CreatePolarGrid(), CV, GASCONST, MOLWEIGHT, NRAD, NSEC, Qbalance, Qminus, and Write_Qbalance.

Referenced by InitEuler().

Here is the call graph for this function:

Here is the caller graph for this function:

void IterateRelaxationParameter ( )

When solving the energy equation for the first time, the function spans through various values of the SOR parameter in order to find its best value to start with.

Definition at line 338 of file EnergySources.c.

References domega, polargrid::Field, masterprint(), Niterbest, NO, polargrid::Nrad, polargrid::Nsec, omegabest, prs_exit(), SORMAXITERS, SuccessiveOverrelaxation(), Temperature, and YES.

Referenced by ImplicitRadiativeDiffusion().

Here is the call graph for this function:

Here is the caller graph for this function:

void MidplaneVolumeDensity ( PolarGrid Rho)

Translates the surface density into the midplane volume density using the local pressure scale height.

Definition at line 629 of file EnergySources.c.

References polargrid::Field, polargrid::Nrad, OmegaInv, SoundSpeed, SQRT2PI_INV, and SQRT_ADIABIND_INV.

Referenced by ImplicitRadiativeDiffusion().

Here is the caller graph for this function:

void OpacityProfile ( )

Fills the opacity polar grid, either with a fixed parametric value or using the Bell & Lin (1994) opacity table.

Definition at line 656 of file EnergySources.c.

References a, b, polargrid::Field, kappa0, NO, polargrid::Nrad, polargrid::Nsec, OPA2CU, PARAMETRICOPACITY, RHO2CGS, T2SI, Temperature, and YES.

Referenced by ImplicitRadiativeDiffusion().

Here is the caller graph for this function:

int SuccessiveOverrelaxation ( real  omega,
boolean  errcheck 
)

The SOR method algorithm inspired by the one from Numerical Recipes.

Definition at line 396 of file EnergySources.c.

References ChessBoardIndexing(), CPU_Number, polargrid::Field, jchess1st, jchess2nd, masterprint(), MaxMO_or_active, MPI_Allreduce(), MPI_COMM_WORLD, MPI_DOUBLE, MPI_SUM, NO, polargrid::Nrad, polargrid::Nsec, One_or_active, prs_exit(), SOREPS, SORMAXITERS, SynchronizeOverlapFields(), Temperature, and YES.

Referenced by ImplicitRadiativeDiffusion(), and IterateRelaxationParameter().

Here is the call graph for this function:

Here is the caller graph for this function:

void SynchronizeOverlapFields ( real field,
int  nr,
int  nsync 
)

For a MPI-split grid, synchronizes the values in a requested number 'nsync' of the overlapping radial rings.

Definition at line 751 of file EnergySources.c.

References CPU_Number, CPU_Rank, CPUOVERLAP, fargostat, MPI_COMM_WORLD, MPI_DOUBLE, MPI_Irecv(), MPI_Isend(), MPI_Wait(), NO, NSEC, prs_exit(), and YES.

Referenced by ImplicitRadiativeDiffusion(), SuccessiveOverrelaxation(), and SynchronizePebbleDisc().

Here is the call graph for this function:

Here is the caller graph for this function:

void TemperatureGradient ( )

Finds the temperature gradients and their magnitude over the mesh.

Definition at line 580 of file EnergySources.c.

References polargrid::Field, InvDiffRmed, polargrid::Nrad, polargrid::Nsec, PI, Rmed, and Temperature.

Referenced by DiffusionCoefs().

Here is the caller graph for this function:

Variable Documentation

real a[7] = {0.0, 0.0, 0.0, 1.0, 2.0/3.0, 1.0/3.0, 1.0}
static
real b[7] = {2.0, -7.0, 0.5, -24.0, 3.0, 10.0, -5.0/2.0}
static

Definition at line 28 of file EnergySources.c.

Referenced by CreateTorqueMapInfile(), max2(), min2(), and OpacityProfile().

real CV
static

Definition at line 39 of file EnergySources.c.

Referenced by ImplicitRadiativeDiffusion(), and InitRadiatDiffusionFields().

PolarGrid* DiffCoefCentered
static

Definition at line 31 of file EnergySources.c.

PolarGrid * DiffCoefIfaceRad
static

Definition at line 31 of file EnergySources.c.

PolarGrid * DiffCoefIfaceTheta
static

Definition at line 31 of file EnergySources.c.

PolarGrid* DiscretizationCoefA
static

Definition at line 35 of file EnergySources.c.

PolarGrid * DiscretizationCoefB
static

Definition at line 35 of file EnergySources.c.

real domega
static

Definition at line 40 of file EnergySources.c.

Referenced by AlgoGas(), ImplicitRadiativeDiffusion(), and IterateRelaxationParameter().

PolarGrid* Flaring
static

Definition at line 33 of file EnergySources.c.

PolarGrid * GradTemperMagnitude
static

Definition at line 30 of file EnergySources.c.

PolarGrid* GradTemperRad
static

Definition at line 30 of file EnergySources.c.

PolarGrid * GradTemperTheta
static

Definition at line 30 of file EnergySources.c.

int jchess1st
static

Definition at line 42 of file EnergySources.c.

Referenced by ChessBoardIndexing(), and SuccessiveOverrelaxation().

int jchess2nd
static

Definition at line 42 of file EnergySources.c.

Referenced by ChessBoardIndexing(), and SuccessiveOverrelaxation().

real kappa0[7] = {2.0e-4, 2.0e16, 0.1, 2.0e81, 1.0e-8, 1.0e-36, 1.5e20}
static

Definition at line 26 of file EnergySources.c.

Referenced by CreateTorqueMapInfile(), and OpacityProfile().

PolarGrid* MatrixNexttoTemperl
static

Definition at line 36 of file EnergySources.c.

PolarGrid * MatrixNexttoTemperlim
static

Definition at line 36 of file EnergySources.c.

PolarGrid * MatrixNexttoTemperlip
static

Definition at line 36 of file EnergySources.c.

PolarGrid * MatrixNexttoTemperljm
static

Definition at line 37 of file EnergySources.c.

PolarGrid* MatrixNexttoTemperljp
static

Definition at line 37 of file EnergySources.c.

int Niterbest
static

Definition at line 41 of file EnergySources.c.

Referenced by ImplicitRadiativeDiffusion(), and IterateRelaxationParameter().

real omegabest
static

Definition at line 40 of file EnergySources.c.

Referenced by ImplicitRadiativeDiffusion(), and IterateRelaxationParameter().

PolarGrid* Opacity
static

Definition at line 32 of file EnergySources.c.

Referenced by CreateTorqueMapInfile().

PolarGrid * Qirradiation
static

Definition at line 33 of file EnergySources.c.

PolarGrid * RightHandSide
static

Definition at line 37 of file EnergySources.c.

PolarGrid * VolumeDensity
static

Definition at line 32 of file EnergySources.c.