18#define TEMPERATURE_K_ env_data[0]
19#define PRESSURE_PA_ env_data[1]
21#define NUM_REACT_ int_data[0]
22#define NUM_PROD_ int_data[1]
23#define A_ float_data[0]
24#define B_ float_data[1]
25#define C_ float_data[2]
26#define CONV_ float_data[3]
27#define RATE_CONSTANT_ rxn_env_data[0]
28#define NUM_INT_PROP_ 2
29#define NUM_FLOAT_PROP_ 4
30#define NUM_ENV_PARAM_ 1
31#define REACT_(x) (int_data[NUM_INT_PROP_ + x] - 1)
32#define PROD_(x) (int_data[NUM_INT_PROP_ + NUM_REACT_ + x] - 1)
33#define DERIV_ID_(x) int_data[NUM_INT_PROP_ + NUM_REACT_ + NUM_PROD_ + x]
34#define JAC_ID_(x) int_data[NUM_INT_PROP_ + 2 * (NUM_REACT_ + NUM_PROD_) + x]
35#define YIELD_(x) float_data[NUM_FLOAT_PROP_ + x]
44 double *rxn_float_data,
46 int *int_data = rxn_int_data;
47 double *float_data = rxn_float_data;
49 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
50 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++) {
53 for (
int i_dep = 0; i_dep <
NUM_PROD_; i_dep++) {
71 double *rxn_float_data) {
72 int *int_data = rxn_int_data;
73 double *float_data = rxn_float_data;
82 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
83 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++)
86 for (
int i_dep = 0; i_dep <
NUM_PROD_; i_dep++)
105 double *rxn_float_data,
106 double *rxn_env_data) {
107 int *int_data = rxn_int_data;
108 double *float_data = rxn_float_data;
130#ifdef CAMP_USE_SUNDIALS
133 double *rxn_float_data,
double *rxn_env_data,
double time_step) {
134 int *int_data = rxn_int_data;
135 double *float_data = rxn_float_data;
141 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++)
142 rate *= state[
REACT_(i_spec)];
147 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++, i_dep_var++) {
151 for (
int i_spec = 0; i_spec <
NUM_PROD_; i_spec++, i_dep_var++) {
156 if (-rate *
YIELD_(i_spec) * time_step <= state[
PROD_(i_spec)]) {
176#ifdef CAMP_USE_SUNDIALS
179 double *rxn_float_data,
180 double *rxn_env_data,
182 int *int_data = rxn_int_data;
183 double *float_data = rxn_float_data;
189 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
192 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++)
193 if (i_spec != i_ind) rate *= state[
REACT_(i_spec)];
195 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++, i_elem++) {
196 if (
JAC_ID_(i_elem) < 0)
continue;
200 for (
int i_dep = 0; i_dep <
NUM_PROD_; i_dep++, i_elem++) {
201 if (
JAC_ID_(i_elem) < 0)
continue;
204 if (-rate * state[
REACT_(i_ind)] *
YIELD_(i_dep) * time_step <=
205 state[
PROD_(i_dep)]) {
222 int *int_data = rxn_int_data;
223 double *float_data = rxn_float_data;
225 printf(
"\n\nWennberg tunneling reaction\n");
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.
#define JACOBIAN_PRODUCTION
void rxn_wennberg_tunneling_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.
void rxn_wennberg_tunneling_print(int *rxn_int_data, double *rxn_float_data)
Print the Wennberg tunneling reaction parameters.
void rxn_wennberg_tunneling_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, double time_step)
Calculate contributions to the Jacobian from this reaction.
void rxn_wennberg_tunneling_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_wennberg_tunneling_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, double time_step)
Calculate contributions to the time derivative from this reaction.
void rxn_wennberg_tunneling_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void time_derivative_add_value(TimeDerivative time_deriv, unsigned int spec_id, long double rate_contribution)
Add a contribution to the time derivative.