16void *
solver_new(
int n_state_var,
int n_cells,
int *var_type,
int n_rxn,
17 int n_rxn_int_param,
int n_rxn_float_param,
18 int n_rxn_env_param,
int n_aero_phase,
19 int n_aero_phase_int_param,
int n_aero_phase_float_param,
20 int n_aero_rep,
int n_aero_rep_int_param,
21 int n_aero_rep_float_param,
int n_aero_rep_env_param,
22 int n_sub_model,
int n_sub_model_int_param,
23 int n_sub_model_float_param,
int n_sub_model_env_param);
25 int max_steps,
int max_conv_fails);
27int solver_set_debug_out(
void *solver_data,
bool do_output);
28int solver_set_eval_jac(
void *solver_data,
bool eval_Jac);
30int solver_run(
void *solver_data,
double *state,
double *env,
double t_initial,
33 int *RHS_evals,
int *LS_setups,
34 int *error_test_fails,
int *NLS_iters,
35 int *NLS_convergence_fails,
int *DLS_Jac_evals,
36 int *DLS_RHS_evals,
double *last_time_step__s,
37 double *next_time_step__s,
int *Jac_eval_fails,
38 int *RHS_evals_total,
int *Jac_evals_total,
39 double *RHS_time__s,
double *Jac_time__s,
40 double *max_loss_precision);
44#ifdef CAMP_USE_SUNDIALS
46int f(realtype t, N_Vector y, N_Vector deriv,
void *model_data);
47int Jac(realtype t, N_Vector y, N_Vector deriv, SUNMatrix J,
void *model_data,
48 N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
49int guess_helper(
const realtype t_n,
const realtype h_n, N_Vector y_n,
50 N_Vector y_n1, N_Vector hf,
void *solver_data, N_Vector tmp1,
52void error_handler(
int error_code,
const char *module,
const char *function,
58 realtype replacement_value);
60bool check_Jac(realtype t, N_Vector y, SUNMatrix J, N_Vector deriv,
61 N_Vector tmp, N_Vector tmp1,
void *solver_data);
62int check_flag(
void *flag_value,
char *func_name,
int opt);
Header file for common constants and structures.
void model_free(ModelData model_data)
Free a ModelData object.
int check_flag(void *flag_value, char *func_name, int opt)
Check the return value of a SUNDIALS function.
void solver_get_statistics(void *solver_data, int *solver_flag, int *num_steps, int *RHS_evals, int *LS_setups, int *error_test_fails, int *NLS_iters, int *NLS_convergence_fails, int *DLS_Jac_evals, int *DLS_RHS_evals, double *last_time_step__s, double *next_time_step__s, int *Jac_eval_fails, int *RHS_evals_total, int *Jac_evals_total, double *RHS_time__s, double *Jac_time__s, double *max_loss_precision)
Get solver statistics after an integration attempt.
int camp_solver_update_model_state(N_Vector solver_state, ModelData *model_data, realtype threshhold, realtype replacement_value)
Update the model state from the current solver state.
int guess_helper(const realtype t_n, const realtype h_n, N_Vector y_n, N_Vector y_n1, N_Vector hf, void *solver_data, N_Vector tmp1, N_Vector corr)
bool is_anything_going_on_here(SolverData *sd, realtype t_initial, realtype t_final)
Determine if there is anything to solve.
void solver_initialize(void *solver_data, double *abs_tol, double rel_tol, int max_steps, int max_conv_fails)
Solver initialization.
SUNMatrix get_jac_init(SolverData *solver_data)
Try to improve guesses of y sent to the linear solver.
static void print_jacobian(SUNMatrix M)
void * solver_new(int n_state_var, int n_cells, int *var_type, int n_rxn, int n_rxn_int_param, int n_rxn_float_param, int n_rxn_env_param, int n_aero_phase, int n_aero_phase_int_param, int n_aero_phase_float_param, int n_aero_rep, int n_aero_rep_int_param, int n_aero_rep_float_param, int n_aero_rep_env_param, int n_sub_model, int n_sub_model_int_param, int n_sub_model_float_param, int n_sub_model_env_param)
Get a new solver object.
void check_flag_fail(void *flag_value, char *func_name, int opt)
Check the return value of a SUNDIALS function and exit on failure.
int Jac(realtype t, N_Vector y, N_Vector deriv, SUNMatrix J, void *model_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
Compute the Jacobian.
int f(realtype t, N_Vector y, N_Vector deriv, void *model_data)
Compute the time derivative f(t,y)
void solver_free(void *solver_data)
Free a SolverData object.
static void print_derivative(N_Vector deriv)
static void solver_print_stats(void *cvode_mem)
void error_handler(int error_code, const char *module, const char *function, char *msg, void *sd)
Custom error handling function.
bool check_Jac(realtype t, N_Vector y, SUNMatrix J, N_Vector deriv, N_Vector tmp, N_Vector tmp1, void *solver_data)
Check a Jacobian for accuracy.
static void print_data_sizes(ModelData *md)
void solver_reset_timers(void *solver_data)
Reset the timers for solver functions.
int solver_run(void *solver_data, double *state, double *env, double t_initial, double t_final)
Solve for a given timestep.