18#define TEMPERATURE_K_ env_data[0]
19#define PRESSURE_PA_ env_data[1]
21#define NUM_REACT_ int_data[0]
22#define NUM_ALKOXY_PROD_ int_data[1]
23#define NUM_NITRATE_PROD_ int_data[2]
24#define X_ float_data[0]
25#define Y_ float_data[1]
26#define a0_ float_data[2]
27#define n_ float_data[3]
28#define CONV_ float_data[4]
29#define ALKOXY_RATE_CONSTANT_ rxn_env_data[0]
30#define NITRATE_RATE_CONSTANT_ rxn_env_data[1]
31#define NUM_INT_PROP_ 3
32#define NUM_FLOAT_PROP_ 5
33#define NUM_ENV_PARAM_ 2
34#define REACT_(x) (int_data[NUM_INT_PROP_ + x] - 1)
35#define PROD_(x) (int_data[NUM_INT_PROP_ + NUM_REACT_ + x] - 1)
37 int_data[NUM_INT_PROP_ + NUM_REACT_ + NUM_ALKOXY_PROD_ + NUM_NITRATE_PROD_ + \
40 int_data[NUM_INT_PROP_ + \
41 2 * (NUM_REACT_ + NUM_ALKOXY_PROD_ + NUM_NITRATE_PROD_) + x]
42#define YIELD_(x) float_data[NUM_FLOAT_PROP_ + x]
51 double *rxn_float_data,
53 int *int_data = rxn_int_data;
54 double *float_data = rxn_float_data;
56 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
57 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++) {
78 double *rxn_float_data) {
79 int *int_data = rxn_int_data;
80 double *float_data = rxn_float_data;
89 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
90 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++)
113 k0 = 2.0e-22 * exp(n);
114 kinf = 0.43 * pow(T / 298.0, -8);
115 return k0 * M / (1.0 + k0 * M / kinf) *
116 pow(0.41, 1.0 / (1.0 + pow(log10(k0 * M / kinf), 2)));
131 double *rxn_float_data,
132 double *rxn_env_data) {
133 int *int_data = rxn_int_data;
134 double *float_data = rxn_float_data;
137 double base_rate, A, Z, M;
160#ifdef CAMP_USE_SUNDIALS
163 double *rxn_float_data,
double *rxn_env_data,
double time_step) {
164 int *int_data = rxn_int_data;
165 double *float_data = rxn_float_data;
170 long double rate = 1.0;
173 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++)
174 rate *= state[
REACT_(i_spec)];
179 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++, i_dep_var++) {
182 -(k_a + k_n) * rate);
189 if (-k_a * rate *
YIELD_(i_spec) * time_step <= state[
PROD_(i_spec)]) {
191 k_a * rate *
YIELD_(i_spec));
200 if (-k_n * rate *
YIELD_(i_spec) * time_step <= state[
PROD_(i_spec)]) {
202 k_n * rate *
YIELD_(i_spec));
220#ifdef CAMP_USE_SUNDIALS
223 double *rxn_float_data,
224 double *rxn_env_data,
226 int *int_data = rxn_int_data;
227 double *float_data = rxn_float_data;
233 for (
int i_ind = 0; i_ind <
NUM_REACT_; i_ind++) {
238 for (
int i_spec = 0; i_spec <
NUM_REACT_; i_spec++)
239 if (i_spec != i_ind) rate *= state[
REACT_(i_spec)];
241 for (
int i_dep = 0; i_dep <
NUM_REACT_; i_dep++, i_elem++) {
242 if (
JAC_ID_(i_elem) < 0)
continue;
247 if (
JAC_ID_(i_elem) < 0)
continue;
250 if (-k_a * rate * state[
REACT_(i_ind)] *
YIELD_(i_dep) * time_step <=
251 state[
PROD_(i_dep)]) {
258 if (
JAC_ID_(i_elem) < 0)
continue;
261 if (-k_n * rate * state[
REACT_(i_ind)] *
YIELD_(i_dep) * time_step <=
262 state[
PROD_(i_dep)]) {
279 int *int_data = rxn_int_data;
280 double *float_data = rxn_float_data;
282 printf(
"\n\nWennberg NO + RO2 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
double calculate_A(double T, double M, double n)
Calculates the Troe-like parameter A(T, [M], n)
void rxn_wennberg_no_ro2_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.
#define ALKOXY_RATE_CONSTANT_
void rxn_wennberg_no_ro2_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_no_ro2_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
#define NITRATE_RATE_CONSTANT_
#define NUM_NITRATE_PROD_
void rxn_wennberg_no_ro2_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_no_ro2_print(int *rxn_int_data, double *rxn_float_data)
Print the Wennberg NO + RO2 reaction parameters.
void rxn_wennberg_no_ro2_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 time_derivative_add_value(TimeDerivative time_deriv, unsigned int spec_id, long double rate_contribution)
Add a contribution to the time derivative.