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.StellarModel — Type
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.
Jems.StellarModels.StellarModel — Method
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.
Jems.StellarModels.adjusted_stellar_model_data — Method
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.
Jems.StellarModels.cycle_props! — Method
cycle_props!(sm::StellarModel)Moves the model properties of the StellarModel sm over one state: startstepprops -> props -> prvstepprops -> startstepprops
Jems.StellarModels.uncycle_props! — Method
uncycle_props!(sm::StellarModel)Moves the model properties of the StellarModel sm back one state: startstepprops <- props <- prvstepprops <- startstepprops
StellarModelProperties.jl
Jems.StellarModels.copy_mesh_properties! — Method
function copy_mesh!(sm, props_in, props_out)Copies over the mesh quantities, i.e., nz, m, dm, and ind_vars from props_in into props_out.
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.
OneZone.jl
Jems.StellarModels.OneZone — Type
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
Jems.StellarModels.OneZone — Type
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.
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.
Options.jl
Jems.StellarModels.IOOptions — Type
mutable struct IOOptionsSubstructure of Options containing controls relating to input/output of data
Jems.StellarModels.Options — Type
mutable struct OptionsStructure containing tweakable controls of Jems.
Jems.StellarModels.PhysicsOptions — Type
mutable struct PhysicsOptionsOptions that affect the physics of the computed model
Jems.StellarModels.RemeshOptions — Type
mutable struct RemeshOptionsSubstructure of Options containing controls relating to remeshing
Jems.StellarModels.SolverOptions — Type
mutable struct SolverOptionsSubstructure of Options containing controls relating to the Newton solver
Jems.StellarModels.TerminationOptions — Type
mutable struct TerminationOptionsSubstructure of Options containing controls relating to termination of the simulation
Jems.StellarModels.TimestepOptions — Type
mutable struct TimestepOptionsSubstructure of Options containing controls relating to timestepping
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.
InitialCondition.jl
Jems.StellarModels.RungeKutta_LaneEmden — Method
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].
Jems.StellarModels.get_logdq — Method
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.
Jems.StellarModels.getlnT_NewtonRhapson — Method
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.
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.
IO.jl
Jems.StellarModels.create_output_files! — Method
create_output_files(sm::StellarModel)Creates output files for history and profile data
Jems.StellarModels.get_history_dataframe_from_hdf5 — Method
get_history_dataframe_from_hdf5(hdf5_filename)Returns a DataFrame object built from an hdf5 file, named hdf5_filename.
Jems.StellarModels.get_profile_dataframe_from_hdf5 — Method
get_profile_dataframe_from_hdf5(hdf5_filename, profile_name)Returns a DataFrame object built from an hdf5 file, named hdf5_filename, considering the column named profile_name
Jems.StellarModels.get_profile_names_from_hdf5 — Method
get_profile_names_from_hdf5(hdf5_filename)Retruns the column names of the profile data contained in the hdf5 file hdf5_filename.
Jems.StellarModels.write_data — Method
write_data(sm::StellarModel)Saves data (history/profile) for the current model, as required by the settings in sm.opt.io.
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
Jems.StellarModels.remesher! — Method
remesher!Acts on sm.startstepprops using info from sm.prvstepprops to decide whether to merge/split cells