|
| CVODERHSOutputData | calculate_rhs (sunrealtype t, N_Vector y, N_Vector ydot, const CVODEUserData *data) const |
| | Compute RHS into ydot at time t from the engine and current state y.
|
| |
| void | initialize_cvode_integration_resources (PointSolverContext *ctx, uint64_t N, size_t numSpecies, double current_time, const fourdst::composition::Composition &composition, double absTol, double relTol, double accumulatedEnergy) const |
| | Allocate and initialize CVODE vectors, linear algebra, tolerances, and constraints.
|
| |
| void | log_step_diagnostics (PointSolverContext *sctx_p, engine::scratch::StateBlob &ctx, const CVODEUserData &user_data, bool displayJacobianStiffness, bool displaySpeciesBalance, bool to_file, std::optional< std::string > filename) const |
| | Compute and print per-component error ratios; run diagnostic helpers.
|
| |
|
| static int | cvode_rhs_wrapper (sunrealtype t, N_Vector y, N_Vector ydot, void *user_data) |
| | CVODE RHS C-wrapper that delegates to calculate_rhs and captures exceptions.
|
| |
| static int | cvode_jac_wrapper (sunrealtype t, N_Vector y, N_Vector ydot, SUNMatrix J, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) |
| | CVODE dense Jacobian C-wrapper that fills SUNDenseMatrix using the engine.
|
| |
| static void | cvode_error_handler (int line, const char *func, const char *file, const char *msg, SUNErrCode err_code, void *err_user_data, SUNContext sunctx) |
| | CVODE error handler that logs errors and warnings from SUNDIALS using the solver's logger.
|
| |
Stiff ODE integrator backed by SUNDIALS CVODE (BDF) for network + energy.
Integrates the nuclear network abundances along with a final accumulator entry for specific energy using CVODE's BDF method and a dense linear solver. The state vector layout is: [y_0, y_1, ..., y_{N-1}, eps], where eps is the accumulated specific energy (erg/g).
Implementation summary:
- Creates a SUNContext and CVODE memory; initializes the state from a Composition.
- Enforces non-negativity on species via CVodeSetConstraints (>= 0 for all species slots).
- Uses a user-provided DynamicEngine to compute RHS and to fill the dense Jacobian.
- The Jacobian is assembled column-major into a SUNDenseMatrix; the energy row/column is currently set to zero (decoupled from abundances in the linearization).
- An internal trigger can rebuild the engine/network; when triggered, CVODE resources are torn down and recreated with the new network size, preserving the energy accumulator.
- The CVODE RHS wrapper captures exceptions::StaleEngineTrigger from the engine evaluation path as recoverable (return code 1) and stores a copy in user-data for the driver loop.
- Example
using gridfire::solver::CVODESolverStrategy;
using gridfire::solver::NetIn;
auto out =
solver.evaluate(in);
std::cout << "Final energy: " << out.energy << " erg/g\n";
Definition dynamic_engine_diagnostics.h:39
Definition GridSolver.h:7
double density
Density in g/cm^3.
Definition types.h:32
double tMax
Maximum time.
Definition types.h:29
fourdst::composition::Composition composition
Composition of the network.
Definition types.h:28
double temperature
Temperature in Kelvin.
Definition types.h:31
| void gridfire::solver::PointSolver::initialize_cvode_integration_resources |
( |
PointSolverContext * | ctx, |
|
|
uint64_t | N, |
|
|
size_t | numSpecies, |
|
|
double | current_time, |
|
|
const fourdst::composition::Composition & | composition, |
|
|
double | absTol, |
|
|
double | relTol, |
|
|
double | accumulatedEnergy ) const |
|
private |
Allocate and initialize CVODE vectors, linear algebra, tolerances, and constraints.
State vector m_Y is sized to N (numSpecies + 1). Species slots are initialized from Composition molar abundances when present, otherwise a tiny positive value; the last slot is set to accumulatedEnergy. Sets scalar tolerances, non-negativity constraints for species, maximum step size, creates a dense matrix and dense linear solver, and registers the Jacobian.