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 K0_A_ float_data[0]
24#define K0_B_ float_data[1]
25#define K0_C_ float_data[2]
26#define KINF_A_ float_data[3]
27#define KINF_B_ float_data[4]
28#define KINF_C_ float_data[5]
29#define FC_ float_data[6]
30#define N_ float_data[7]
31#define SCALING_ float_data[8]
32#define CONV_ float_data[9]
33#define RATE_CONSTANT_ (rxn_env_data[0])
34#define NUM_INT_PROP_ 2
35#define NUM_FLOAT_PROP_ 10
36#define REACT_(x) (int_data[NUM_INT_PROP_ + x] - 1)
37#define PROD_(x) (int_data[NUM_INT_PROP_ + NUM_REACT_ + x] - 1)
38#define DERIV_ID_(x) int_data[NUM_INT_PROP_ + NUM_REACT_ + NUM_PROD_ + x]
39#define JAC_ID_(x) int_data[NUM_INT_PROP_ + 2 * (NUM_REACT_ + NUM_PROD_) + x]
40#define YIELD_(x) float_data[NUM_FLOAT_PROP_ + x]
49 double *rxn_float_data,
51 int *int_data = rxn_int_data;
52 double *float_data = rxn_float_data;
54 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
55 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++) {
58 for (
int i_dep = 0; i_dep <
NUM_PROD_; i_dep++) {
77 double *rxn_float_data) {
78 int *int_data = rxn_int_data;
79 double *float_data = rxn_float_data;
88 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
89 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++) {
93 for (
int i_dep = 0; i_dep <
NUM_PROD_; i_dep++) {
113 double *rxn_float_data,
114 double *rxn_env_data) {
115 int *int_data = rxn_int_data;
116 double *float_data = rxn_float_data;
131 pow(
FC_, (1.0 / (1.0 + pow(log10(kinf) /
N_, 2)))) *
147#ifdef CAMP_USE_SUNDIALS
150 double *rxn_float_data,
double *rxn_env_data, realtype time_step) {
151 int *int_data = rxn_int_data;
152 double *float_data = rxn_float_data;
158 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++)
159 rate *= state[
REACT_(i_spec)];
164 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++, i_dep_var++) {
168 for (
int i_spec = 0; i_spec <
NUM_PROD_; i_spec++, i_dep_var++) {
172 if (-rate *
YIELD_(i_spec) * time_step <= state[
PROD_(i_spec)]) {
192#ifdef CAMP_USE_SUNDIALS
195 double *rxn_float_data,
double *rxn_env_data, realtype time_step) {
196 int *int_data = rxn_int_data;
197 double *float_data = rxn_float_data;
203 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
206 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++)
207 if (i_ind != i_spec) rate *= state[
REACT_(i_spec)];
209 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++, i_elem++) {
210 if (
JAC_ID_(i_elem) < 0)
continue;
214 for (
int i_dep = 0; i_dep <
NUM_PROD_; i_dep++, i_elem++) {
215 if (
JAC_ID_(i_elem) < 0)
continue;
218 if (-rate * state[
REACT_(i_ind)] *
YIELD_(i_dep) * time_step <=
219 state[
PROD_(i_dep)]) {
236 double *rxn_float_data) {
237 int *int_data = rxn_int_data;
238 double *float_data = rxn_float_data;
240 printf(
"\n\nTernary Chemical Activation 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_ternary_chemical_activation_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_ternary_chemical_activation_print(int *rxn_int_data, double *rxn_float_data)
Print the Ternary Chemical Activation reaction parameters.
void rxn_ternary_chemical_activation_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_ternary_chemical_activation_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_ternary_chemical_activation_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_ternary_chemical_activation_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 time_derivative_add_value(TimeDerivative time_deriv, unsigned int spec_id, long double rate_contribution)
Add a contribution to the time derivative.