StellarModels

The StellarModels module of Jems defines models that it can evolve, along with their properties, initialization, IO operations, and option configuration.

StellarModel.jl

Jems.StellarModels.StellarModelType
mutable struct StellarModel{TN<:Real,TD<:Real,TEOS<:EOS.AbstractEOS,TKAP<:Opacity.AbstractOpacity}

An evolutionary model for a star, containing information about the star's current state, as well as the independent variables of the model and its equations.

The struct has four parametric types, TN for 'normal' numbers, TD for dual numbers used in automatic differentiation, TEOS for the type of EOS being used and TKAP for the type of opacity law being used.

source
Jems.StellarModels.StellarModelMethod
StellarModel(varnames::Vector{Symbol}, structure_equations::Vector{Function},
            nvars::Int, nspecies::Int, nz::Int, eos::AbstractEOS, opacity::AbstractOpacity)

Constructor for a StellarModel instance, using varnames for the independent variables, functions of the structure_equations to be solved, number of independent variables nvars, number of species in the network nspecies number of zones in the model nz and an iterface to the EOS and Opacity laws.

source
Jems.StellarModels.adjusted_stellar_model_dataMethod
adjusted_stellar_model_data(sm, new_nz::Int, new_nextra::Int)

Returns a new copy of sm with an adjusted allocated size. This creates a full duplicate without removing the old stellar model, which is not very memory friendly. One possible optimization for the future. The new model is created to have new_nz zones with an extra padding of new_nextra zones to allow for remeshing. The new model will copy the contents of

  • ind_vars
  • mstar
  • m
  • dm
  • time
  • dt
  • model_number
  • psi, ssi, esi
  • opt As well as the nuclear network, opacity and EOS.
source
Jems.StellarModels.cycle_props!Method
cycle_props!(sm::StellarModel)

Moves the model properties of the StellarModel sm over one state: startstepprops -> props -> prvstepprops -> startstepprops

source
Jems.StellarModels.uncycle_props!Method
uncycle_props!(sm::StellarModel)

Moves the model properties of the StellarModel sm back one state: startstepprops <- props <- prvstepprops <- startstepprops

source

StellarModelProperties.jl

Jems.StellarModels.evaluate_stellar_model_properties!Method
function evaluate_stellar_model_properties!(sm, props::StellarModelProperties{TDual, TCellDualData}) where
    {TDual <: ForwardDiff.Dual, TCellDualData}

Evaluates the stellar model properties props from the ind_vars array. The goal is to save the 'state' of the StellarModel so we can easily get properties like rates, eos, opacity values, and retrace if a retry is called. This does not update the mesh/ind_vars arrays.

source

OneZone.jl

Jems.StellarModels.OneZoneType
mutable struct OneZone{TNUMBER<:Real,TDUALFULL<:ForwardDiff.Dual,
                          TPROPS<:StellarModels.AbstractModelProperties,
                          TNET<:NuclearNetworks.AbstractNuclearNetwork,
                          TSOLVER<:StellarModels.AbstractSolverData}

Structure definition of a model having one internal zone.

source
Jems.StellarModels.OneZoneType
OneZone(varnames::Vector{Symbol}, composition_equation::Function,
            nvars::Int, nspecies::Int)

Constructor for a OneZone instance, using varnames for the independent variables, the composition equation to be solved, number of independent variables nvars, number of species in the network nspecies

source
Jems.StellarModels.evaluate_one_zone_properties!Method
function evaluate_stellar_model_properties!(oz, props::StellarModelProperties{TDual, TCellDualData}) where
    {TDual <: ForwardDiff.Dual, TCellDualData}

Evaluates the stellar model properties props from the ind_vars array. The goal is to save the 'state' of the StellarModel so we can easily get properties like rates, eos, opacity values, and retrace if a retry is called. This does not update the mesh/ind_vars arrays.

source

Options.jl

Jems.StellarModels.set_options!Method
set_options!(opt::Options, toml_path::String)

Sets the controls in opt to the values supplied in the TOML file toml_path, containing key: value pairs. Invalid keys are not allowed, and an Exception will be thrown.

source

InitialCondition.jl

Jems.StellarModels.RungeKutta_LaneEmdenMethod
RungeKutta_LaneEmden(n)

Computes the solution of the Lane-Emden equation for polytropic index n until the first zero by returning xvals, containing ξ values; yvals, containing the corresponding function values θn; and zvals, containing the derivative. This naming convention for x (=independent variable), y (=corresponding solution values) and z (=corresponding derivative values) is used throughout this function. The Lane-Emden equation is solved by performing the Runge-Kutta method of order 4. The stepsize is allowed to decrease as the function reaches the first zero. The function takes care of the core boundary conditions at ξ=0. The last ξ value (i.e. the first zero of the Lane-Emden solution) is calculated by linearly extrapolating the last two points of the solution. This first zero ξ1 can be found as xvals[end].

source
Jems.StellarModels.get_logdqMethod
get_logdq(k::Int, nz::Int, logdq_low::TT, logdq_high::TT, numregion::Int)::TT where {TT<:Real}

Computes the logarithm mass chunk logdq for zone k of a profile with total zones nz, while keeping in mind to better resolve the first and last numregion zones of the profile. It linearly interpolates the value from the inputs logdq_low and logdq_high in these regions, while keeping logdq_high in the middle zones.

source
Jems.StellarModels.getlnT_NewtonRhapsonMethod
getlnT_NewtonRhapson(lnT_initial, lnρ, P, massfractions, eos)

Computes the temperature lnT starting from a density lnρ, a pressure P, a composition xa, a species species and an equation of state eos. The equation of state gives us the pressure, given a certain temperature and density. The idea is to match this pressure with the given pressure P by fitting the temperature. Starting from an initial guess lnT_initial, the Newton-Rhapson method is used to converge to the final temperature in an interative way. Each iteration, a new lnT is computed according to the Newton-Rhapson formula using the derivative dlnP/dlnT. Next, based on this new lnT, the equation of state returns a new pressure. The algorithm stops when the difference between the calculated pressure and the given pressure is smaller than a certain threshold. The temperature at which this occurs is returned.

source
Jems.StellarModels.n_polytrope_initial_condition!Method
n_polytrope_initial_condition(n,sm::StellarModel, M::Real, R::Real; initial_dt=100 * SECYEAR)

Initializes the stellar model properties sm.props with a mesh of size nz with values corresponding to a polytrope of index n, setting sm.props.m, sm.props.dm and the independent variables sm.props.ind_vars, etc. accordingly. Also sets the initial timestep to be taken, initial_dt. It first calls the solution to the Lane-Emden equation for index n and then sets radii, densities, pressures and luminosities.

source

IO.jl

Remesher.jl

Jems.StellarModels.adjust_props_size!Method
adjust_props_size(sm, new_nz::Int, nextra::Int)

Returns a new StellarModelProperties object with an adjusted size. Copies over the following from the currect active properties:

  • nz
  • dt
  • time
  • ind_vars
  • mstar
  • m
  • dm
source

PlotterInterface.jl

Jems.StellarModels.PlotterType
mutable struct Plotter

Structure that contains references to windows, axes and observables to be plotted with Jems.Plotting

source