17#define TEMPERATURE_K_ env_data[0]
18#define PRESSURE_PA_ env_data[1]
20#define RXN_ID_ (int_data[0])
21#define REACT_ (int_data[1] - 1)
22#define DERIV_ID_ int_data[2]
23#define JAC_ID_ int_data[3]
24#define SCALING_ float_data[0]
25#define RATE_CONSTANT_ (rxn_env_data[0])
26#define BASE_RATE_ (rxn_env_data[1])
27#define NUM_INT_PROP_ 4
28#define NUM_FLOAT_PROP_ 1
29#define NUM_ENV_PARAM_ 2
38 double *rxn_float_data,
40 int *int_data = rxn_int_data;
41 double *float_data = rxn_float_data;
58 double *rxn_float_data) {
59 int *int_data = rxn_int_data;
60 double *float_data = rxn_float_data;
90 double *rxn_float_data,
91 double *rxn_env_data) {
92 int *int_data = rxn_int_data;
93 double *float_data = rxn_float_data;
95 int *rxn_id = (
int *)update_data;
96 double *base_rate = (
double *)&(rxn_id[1]);
120 double *rxn_float_data,
121 double *rxn_env_data) {
122 int *int_data = rxn_int_data;
123 double *float_data = rxn_float_data;
142#ifdef CAMP_USE_SUNDIALS
145 double *rxn_float_data,
double *rxn_env_data, realtype time_step) {
146 int *int_data = rxn_int_data;
147 double *float_data = rxn_float_data;
170#ifdef CAMP_USE_SUNDIALS
173 double *rxn_float_data,
174 double *rxn_env_data,
175 realtype time_step) {
176 int *int_data = rxn_int_data;
177 double *float_data = rxn_float_data;
196 int *int_data = rxn_int_data;
197 double *float_data = rxn_float_data;
199 printf(
"\n\nFirst-Order loss reaction\n");
209 int *update_data = (
int *)malloc(
sizeof(
int) +
sizeof(double));
210 if (update_data == NULL) {
211 printf(
"\n\nERROR allocating space for first-order loss update data\n\n");
214 return (
void *)update_data;
225 int *new_rxn_id = (
int *)update_data;
226 double *new_base_rate = (
double *)&(new_rxn_id[1]);
227 *new_rxn_id = rxn_id;
228 *new_base_rate = base_rate;
unsigned int jacobian_get_element_id(Jacobian jac, unsigned int dep_id, unsigned int ind_id)
Get an element id in the Jacobian data arrays.
void jacobian_add_value(Jacobian jac, unsigned int elem_id, unsigned int prod_or_loss, long double jac_contribution)
Add a contribution to the Jacobian.
void jacobian_register_element(Jacobian *jac, unsigned int dep_id, unsigned int ind_id)
Adds an element to the sparse matrix.
void rxn_first_order_loss_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
Calculate contributions to the Jacobian from this reaction.
void rxn_first_order_loss_print(int *rxn_int_data, double *rxn_float_data)
Print the reaction parameters.
void rxn_first_order_loss_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_first_order_loss_set_rate_update_data(void *update_data, int rxn_id, double base_rate)
Set rate update data.
void * rxn_first_order_loss_create_rate_update_data()
Create update data for new first-order loss rates.
void rxn_first_order_loss_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
Calculate contributions to the time derivative from this reaction.
void rxn_first_order_loss_update_env_state(ModelData *model_data, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data)
Update reaction data for new environmental conditions.
void rxn_first_order_loss_update_ids(ModelData *model_data, int *deriv_ids, Jacobian jac, int *rxn_int_data, double *rxn_float_data)
Update the time derivative and Jacbobian array indices.
bool rxn_first_order_loss_update_data(void *update_data, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data)
Update reaction data.
void time_derivative_add_value(TimeDerivative time_deriv, unsigned int spec_id, long double rate_contribution)
Add a contribution to the time derivative.