CAMP 1.0.0
Chemistry Across Multiple Phases
rxn_solver.c
Go to the documentation of this file.
1/* Copyright (C) 2021 Barcelona Supercomputing Center and University of
2 * Illinois at Urbana-Champaign
3 * SPDX-License-Identifier: MIT
4 *
5 * Reaction-specific functions for use by the solver
6 *
7 */
8/** \file
9 * \brief Reaction solver functions
10 */
11#define CAMP_DEBUG_SPEC_ 118
12
13#include "rxn_solver.h"
14#include <stdio.h>
15#include <stdlib.h>
16#include "rxns.h"
17
18// Reaction types (Must match parameters defined in camp_rxn_factory)
19#define RXN_ARRHENIUS 1
20#define RXN_TROE 2
21#define RXN_CMAQ_H2O2 3
22#define RXN_CMAQ_OH_HNO3 4
23#define RXN_PHOTOLYSIS 5
24#define RXN_HL_PHASE_TRANSFER 6
25#define RXN_AQUEOUS_EQUILIBRIUM 7
26#define RXN_SIMPOL_PHASE_TRANSFER 10
27#define RXN_CONDENSED_PHASE_ARRHENIUS 11
28#define RXN_FIRST_ORDER_LOSS 12
29#define RXN_EMISSION 13
30#define RXN_WET_DEPOSITION 14
31#define RXN_TERNARY_CHEMICAL_ACTIVATION 15
32#define RXN_WENNBERG_TUNNELING 16
33#define RXN_WENNBERG_NO_RO2 17
34#define RXN_CONDENSED_PHASE_PHOTOLYSIS 18
35#define RXN_SURFACE 19
36
37/** \brief Get the Jacobian elements used by a particular reaction
38 *
39 * \param model_data A pointer to the model data
40 * \param jac Jacobian
41 */
42void rxn_get_used_jac_elem(ModelData *model_data, Jacobian *jac) {
43 // Get the number of reactions
44 int n_rxn = model_data->n_rxn;
45
46 // Loop through the reactions to determine the Jacobian elements used
47 // advancing the rxn_data pointer each time
48 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
49 // Get pointers to the reaction data
50 int *rxn_int_data =
51 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
52 double *rxn_float_data =
53 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
54
55 // Get the reaction type
56 int rxn_type = *(rxn_int_data++);
57
58 // Call the appropriate function
59 switch (rxn_type) {
61 rxn_aqueous_equilibrium_get_used_jac_elem(rxn_int_data, rxn_float_data,
62 jac);
63 break;
64 case RXN_ARRHENIUS:
65 rxn_arrhenius_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
66 break;
67 case RXN_CMAQ_H2O2:
68 rxn_CMAQ_H2O2_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
69 break;
71 rxn_CMAQ_OH_HNO3_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
72 break;
75 rxn_float_data, jac);
76 break;
79 rxn_float_data, jac);
80 break;
81 case RXN_EMISSION:
82 rxn_emission_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
83 break;
85 rxn_first_order_loss_get_used_jac_elem(rxn_int_data, rxn_float_data,
86 jac);
87 break;
89 rxn_HL_phase_transfer_get_used_jac_elem(model_data, rxn_int_data,
90 rxn_float_data, jac);
91 break;
92 case RXN_PHOTOLYSIS:
93 rxn_photolysis_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
94 break;
96 rxn_SIMPOL_phase_transfer_get_used_jac_elem(model_data, rxn_int_data,
97 rxn_float_data, jac);
98 break;
99 case RXN_SURFACE:
100 rxn_surface_get_used_jac_elem(model_data, rxn_int_data,
101 rxn_float_data, jac);
102 break;
105 rxn_float_data, jac);
106 break;
107 case RXN_TROE:
108 rxn_troe_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
109 break;
111 rxn_wennberg_no_ro2_get_used_jac_elem(rxn_int_data, rxn_float_data,
112 jac);
113 break;
115 rxn_wennberg_tunneling_get_used_jac_elem(rxn_int_data, rxn_float_data,
116 jac);
117 break;
119 rxn_wet_deposition_get_used_jac_elem(rxn_int_data, rxn_float_data, jac);
120 break;
121 }
122 }
123}
124
125/** \brief Update the time derivative and Jacobian array ids
126 *
127 * \param model_data Pointer to the model data
128 * \param deriv_ids Ids for state variables on the time derivative array
129 * \param jac Jacobian
130 */
131void rxn_update_ids(ModelData *model_data, int *deriv_ids, Jacobian jac) {
132 // Get the number of reactions
133 int n_rxn = model_data->n_rxn;
134
135 // Loop through the reactions advancing the rxn_data pointer each time
136 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
137 // Get pointers to the reaction data
138 int *rxn_int_data =
139 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
140 double *rxn_float_data =
141 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
142
143 // Get the reaction type
144 int rxn_type = *(rxn_int_data++);
145
146 // Call the appropriate function
147 switch (rxn_type) {
149 rxn_aqueous_equilibrium_update_ids(model_data, deriv_ids, jac,
150 rxn_int_data, rxn_float_data);
151 break;
152 case RXN_ARRHENIUS:
153 rxn_arrhenius_update_ids(model_data, deriv_ids, jac, rxn_int_data,
154 rxn_float_data);
155 break;
156 case RXN_CMAQ_H2O2:
157 rxn_CMAQ_H2O2_update_ids(model_data, deriv_ids, jac, rxn_int_data,
158 rxn_float_data);
159 break;
160 case RXN_CMAQ_OH_HNO3:
161 rxn_CMAQ_OH_HNO3_update_ids(model_data, deriv_ids, jac, rxn_int_data,
162 rxn_float_data);
163 break;
165 rxn_condensed_phase_arrhenius_update_ids(model_data, deriv_ids, jac,
166 rxn_int_data, rxn_float_data);
167 break;
169 rxn_condensed_phase_photolysis_update_ids(model_data, deriv_ids, jac,
170 rxn_int_data, rxn_float_data);
171 break;
172 case RXN_EMISSION:
173 rxn_emission_update_ids(model_data, deriv_ids, jac, rxn_int_data,
174 rxn_float_data);
175 break;
177 rxn_first_order_loss_update_ids(model_data, deriv_ids, jac,
178 rxn_int_data, rxn_float_data);
179 break;
181 rxn_HL_phase_transfer_update_ids(model_data, deriv_ids, jac,
182 rxn_int_data, rxn_float_data);
183 break;
184 case RXN_PHOTOLYSIS:
185 rxn_photolysis_update_ids(model_data, deriv_ids, jac, rxn_int_data,
186 rxn_float_data);
187 break;
189 rxn_SIMPOL_phase_transfer_update_ids(model_data, deriv_ids, jac,
190 rxn_int_data, rxn_float_data);
191 break;
192 case RXN_SURFACE:
193 rxn_surface_update_ids(model_data, deriv_ids, jac,
194 rxn_int_data, rxn_float_data);
195 break;
198 model_data, deriv_ids, jac, rxn_int_data, rxn_float_data);
199 break;
200 case RXN_TROE:
201 rxn_troe_update_ids(model_data, deriv_ids, jac, rxn_int_data,
202 rxn_float_data);
203 break;
205 rxn_wennberg_no_ro2_update_ids(model_data, deriv_ids, jac, rxn_int_data,
206 rxn_float_data);
207 break;
209 rxn_wennberg_tunneling_update_ids(model_data, deriv_ids, jac,
210 rxn_int_data, rxn_float_data);
211 break;
213 rxn_wet_deposition_update_ids(model_data, deriv_ids, jac, rxn_int_data,
214 rxn_float_data);
215 break;
216 }
217 }
218}
219
220/** \brief Update reaction data for new environmental state
221 *
222 * \param model_data Pointer to the model data with updated env state
223 */
225 // Get the number of reactions
226 int n_rxn = model_data->n_rxn;
227
228 // Loop through the reactions advancing the rxn_data pointer each time
229 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
230 // Get pointers to the reaction data
231 int *rxn_int_data =
232 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
233 double *rxn_float_data =
234 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
235 double *rxn_env_data =
236 &(model_data->grid_cell_rxn_env_data[model_data->rxn_env_idx[i_rxn]]);
237
238 // Get the reaction type
239 int rxn_type = *(rxn_int_data++);
240
241 // Call the appropriate function
242 switch (rxn_type) {
244 rxn_aqueous_equilibrium_update_env_state(model_data, rxn_int_data,
245 rxn_float_data, rxn_env_data);
246 break;
247 case RXN_ARRHENIUS:
248 rxn_arrhenius_update_env_state(model_data, rxn_int_data, rxn_float_data,
249 rxn_env_data);
250 break;
251 case RXN_CMAQ_H2O2:
252 rxn_CMAQ_H2O2_update_env_state(model_data, rxn_int_data, rxn_float_data,
253 rxn_env_data);
254 break;
255 case RXN_CMAQ_OH_HNO3:
256 rxn_CMAQ_OH_HNO3_update_env_state(model_data, rxn_int_data,
257 rxn_float_data, rxn_env_data);
258 break;
261 model_data, rxn_int_data, rxn_float_data, rxn_env_data);
262 break;
265 model_data, rxn_int_data, rxn_float_data, rxn_env_data);
266 break;
267 case RXN_EMISSION:
268 rxn_emission_update_env_state(model_data, rxn_int_data, rxn_float_data,
269 rxn_env_data);
270 break;
272 rxn_first_order_loss_update_env_state(model_data, rxn_int_data,
273 rxn_float_data, rxn_env_data);
274 break;
276 rxn_HL_phase_transfer_update_env_state(model_data, rxn_int_data,
277 rxn_float_data, rxn_env_data);
278 break;
279 case RXN_PHOTOLYSIS:
280 rxn_photolysis_update_env_state(model_data, rxn_int_data,
281 rxn_float_data, rxn_env_data);
282 break;
285 model_data, rxn_int_data, rxn_float_data, rxn_env_data);
286 break;
287 case RXN_SURFACE:
289 model_data, rxn_int_data, rxn_float_data, rxn_env_data);
290 break;
293 model_data, rxn_int_data, rxn_float_data, rxn_env_data);
294 break;
295 case RXN_TROE:
296 rxn_troe_update_env_state(model_data, rxn_int_data, rxn_float_data,
297 rxn_env_data);
298 break;
300 rxn_wennberg_no_ro2_update_env_state(model_data, rxn_int_data,
301 rxn_float_data, rxn_env_data);
302 break;
304 rxn_wennberg_tunneling_update_env_state(model_data, rxn_int_data,
305 rxn_float_data, rxn_env_data);
306 break;
308 rxn_wet_deposition_update_env_state(model_data, rxn_int_data,
309 rxn_float_data, rxn_env_data);
310 break;
311 }
312 }
313}
314
315/** \brief Calculate the time derivative \f$f(t,y)\f$
316 *
317 * \param model_data Pointer to the model data
318 * \param time_deriv TimeDerivative to use to build derivative array
319 * \param time_step Current model time step (s)
320 */
321#ifdef CAMP_USE_SUNDIALS
322void rxn_calc_deriv(ModelData *model_data, TimeDerivative time_deriv,
323 realtype time_step) {
324 // Get the number of reactions
325 int n_rxn = model_data->n_rxn;
326
327 // Loop through the reactions advancing the rxn_data pointer each time
328 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
329 // Get pointers to the reaction data
330 int *rxn_int_data =
331 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
332 double *rxn_float_data =
333 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
334 double *rxn_env_data =
335 &(model_data->grid_cell_rxn_env_data[model_data->rxn_env_idx[i_rxn]]);
336
337 // Get the reaction type
338 int rxn_type = *(rxn_int_data++);
339
340 // Call the appropriate function
341 switch (rxn_type) {
343 rxn_aqueous_equilibrium_calc_deriv_contrib(model_data, time_deriv,
344 rxn_int_data, rxn_float_data,
345 rxn_env_data, time_step);
346 break;
347 case RXN_ARRHENIUS:
348 rxn_arrhenius_calc_deriv_contrib(model_data, time_deriv, rxn_int_data,
349 rxn_float_data, rxn_env_data,
350 time_step);
351 break;
352 case RXN_CMAQ_H2O2:
353 rxn_CMAQ_H2O2_calc_deriv_contrib(model_data, time_deriv, rxn_int_data,
354 rxn_float_data, rxn_env_data,
355 time_step);
356 break;
357 case RXN_CMAQ_OH_HNO3:
358 rxn_CMAQ_OH_HNO3_calc_deriv_contrib(model_data, time_deriv,
359 rxn_int_data, rxn_float_data,
360 rxn_env_data, time_step);
361 break;
364 model_data, time_deriv, rxn_int_data, rxn_float_data, rxn_env_data,
365 time_step);
366 break;
369 model_data, time_deriv, rxn_int_data, rxn_float_data, rxn_env_data,
370 time_step);
371 break;
372 case RXN_EMISSION:
373 rxn_emission_calc_deriv_contrib(model_data, time_deriv, rxn_int_data,
374 rxn_float_data, rxn_env_data,
375 time_step);
376 break;
378 rxn_first_order_loss_calc_deriv_contrib(model_data, time_deriv,
379 rxn_int_data, rxn_float_data,
380 rxn_env_data, time_step);
381 break;
383 rxn_HL_phase_transfer_calc_deriv_contrib(model_data, time_deriv,
384 rxn_int_data, rxn_float_data,
385 rxn_env_data, time_step);
386 break;
387 case RXN_PHOTOLYSIS:
388 rxn_photolysis_calc_deriv_contrib(model_data, time_deriv, rxn_int_data,
389 rxn_float_data, rxn_env_data,
390 time_step);
391 break;
394 model_data, time_deriv, rxn_int_data, rxn_float_data, rxn_env_data,
395 time_step);
396 break;
397 case RXN_SURFACE:
399 model_data, time_deriv, rxn_int_data, rxn_float_data, rxn_env_data,
400 time_step);
401 break;
404 model_data, time_deriv, rxn_int_data, rxn_float_data, rxn_env_data,
405 time_step);
406 break;
407 case RXN_TROE:
408 rxn_troe_calc_deriv_contrib(model_data, time_deriv, rxn_int_data,
409 rxn_float_data, rxn_env_data, time_step);
410 break;
412 rxn_wennberg_no_ro2_calc_deriv_contrib(model_data, time_deriv,
413 rxn_int_data, rxn_float_data,
414 rxn_env_data, time_step);
415 break;
417 rxn_wennberg_tunneling_calc_deriv_contrib(model_data, time_deriv,
418 rxn_int_data, rxn_float_data,
419 rxn_env_data, time_step);
420 break;
422 rxn_wet_deposition_calc_deriv_contrib(model_data, time_deriv,
423 rxn_int_data, rxn_float_data,
424 rxn_env_data, time_step);
425 break;
426 }
427 }
428}
429#endif
430
431/** \brief Calculate the time derivative \f$f(t,y)\f$ for only some specific
432 * types
433 *
434 * \param model_data Pointer to the model data
435 * \param time_deriv TimeDerivative to use to build derivative array
436 * \param time_step Current model time step (s)
437 */
438#ifdef CAMP_USE_SUNDIALS
440 TimeDerivative time_deriv,
441 realtype time_step) {
442 // Get the number of reactions
443 int n_rxn = model_data->n_rxn;
444
445 // Loop through the reactions advancing the rxn_data pointer each time
446 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
447 // Get pointers to the reaction data
448 int *rxn_int_data =
449 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
450 double *rxn_float_data =
451 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
452 double *rxn_env_data =
453 &(model_data->grid_cell_rxn_env_data[model_data->rxn_env_idx[i_rxn]]);
454
455 // Get the reaction type
456 int rxn_type = *(rxn_int_data++);
457
458 // Call the appropriate function
459 switch (rxn_type) {
461 rxn_HL_phase_transfer_calc_deriv_contrib(model_data, time_deriv,
462 rxn_int_data, rxn_float_data,
463 rxn_env_data, time_step);
464 break;
467 model_data, time_deriv, rxn_int_data, rxn_float_data, rxn_env_data,
468 time_step);
469 break;
470 }
471 }
472}
473#endif
474
475/** \brief Calculate the Jacobian
476 *
477 * \param model_data Pointer to the model data
478 * \param jac The reaction Jacobian (for one grid cell)
479 * \param time_step Current model time step (s)
480 */
481#ifdef CAMP_USE_SUNDIALS
482void rxn_calc_jac(ModelData *model_data, Jacobian jac, realtype time_step) {
483 // Get the number of reactions
484 int n_rxn = model_data->n_rxn;
485
486 // Loop through the reactions advancing the rxn_data pointer each time
487 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
488 // Get pointers to the reaction data
489 int *rxn_int_data =
490 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
491 double *rxn_float_data =
492 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
493 double *rxn_env_data =
494 &(model_data->grid_cell_rxn_env_data[model_data->rxn_env_idx[i_rxn]]);
495
496 // Get the reaction type
497 int rxn_type = *(rxn_int_data++);
498
499 // Call the appropriate function
500 switch (rxn_type) {
502 rxn_aqueous_equilibrium_calc_jac_contrib(model_data, jac, rxn_int_data,
503 rxn_float_data, rxn_env_data,
504 time_step);
505 break;
506 case RXN_ARRHENIUS:
507 rxn_arrhenius_calc_jac_contrib(model_data, jac, rxn_int_data,
508 rxn_float_data, rxn_env_data, time_step);
509 break;
510 case RXN_CMAQ_H2O2:
511 rxn_CMAQ_H2O2_calc_jac_contrib(model_data, jac, rxn_int_data,
512 rxn_float_data, rxn_env_data, time_step);
513 break;
514 case RXN_CMAQ_OH_HNO3:
515 rxn_CMAQ_OH_HNO3_calc_jac_contrib(model_data, jac, rxn_int_data,
516 rxn_float_data, rxn_env_data,
517 time_step);
518 break;
521 model_data, jac, rxn_int_data, rxn_float_data, rxn_env_data,
522 time_step);
523 break;
526 model_data, jac, rxn_int_data, rxn_float_data, rxn_env_data,
527 time_step);
528 break;
529 case RXN_EMISSION:
530 rxn_emission_calc_jac_contrib(model_data, jac, rxn_int_data,
531 rxn_float_data, rxn_env_data, time_step);
532 break;
534 rxn_first_order_loss_calc_jac_contrib(model_data, jac, rxn_int_data,
535 rxn_float_data, rxn_env_data,
536 time_step);
537 break;
539 rxn_HL_phase_transfer_calc_jac_contrib(model_data, jac, rxn_int_data,
540 rxn_float_data, rxn_env_data,
541 time_step);
542 break;
543 case RXN_PHOTOLYSIS:
544 rxn_photolysis_calc_jac_contrib(model_data, jac, rxn_int_data,
545 rxn_float_data, rxn_env_data,
546 time_step);
547 break;
550 rxn_int_data, rxn_float_data,
551 rxn_env_data, time_step);
552 break;
553 case RXN_SURFACE:
554 rxn_surface_calc_jac_contrib(model_data, jac,
555 rxn_int_data, rxn_float_data,
556 rxn_env_data, time_step);
557 break;
560 model_data, jac, rxn_int_data, rxn_float_data, rxn_env_data,
561 time_step);
562 break;
563 case RXN_TROE:
564 rxn_troe_calc_jac_contrib(model_data, jac, rxn_int_data, rxn_float_data,
565 rxn_env_data, time_step);
566 break;
568 rxn_wennberg_no_ro2_calc_jac_contrib(model_data, jac, rxn_int_data,
569 rxn_float_data, rxn_env_data,
570 time_step);
571 break;
573 rxn_wennberg_tunneling_calc_jac_contrib(model_data, jac, rxn_int_data,
574 rxn_float_data, rxn_env_data,
575 time_step);
576 break;
578 rxn_wet_deposition_calc_jac_contrib(model_data, jac, rxn_int_data,
579 rxn_float_data, rxn_env_data,
580 time_step);
581 break;
582 }
583 }
584}
585#endif
586
587/** \brief Calculate the Jacobian for only some specific types
588 *
589 * \param model_data Pointer to the model data
590 * \param jac The reaction Jacobian (for one grid cell)
591 * \param time_step Current model time step (s)
592 */
593#ifdef CAMP_USE_SUNDIALS
594
596 realtype time_step) {
597 // Get the number of reactions
598 int n_rxn = model_data->n_rxn;
599
600 // Loop through the reactions advancing the rxn_data pointer each time
601 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
602 // Get pointers to the reaction data
603 int *rxn_int_data =
604 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
605 double *rxn_float_data =
606 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
607 double *rxn_env_data =
608 &(model_data->grid_cell_rxn_env_data[model_data->rxn_env_idx[i_rxn]]);
609
610 // Get the reaction type
611 int rxn_type = *(rxn_int_data++);
612
613 // Call the appropriate function
614 switch (rxn_type) {
616 rxn_aqueous_equilibrium_calc_jac_contrib(model_data, jac, rxn_int_data,
617 rxn_float_data, rxn_env_data,
618 time_step);
619 break;
622 model_data, jac, rxn_int_data, rxn_float_data, rxn_env_data,
623 time_step);
624 break;
627 model_data, jac, rxn_int_data, rxn_float_data, rxn_env_data,
628 time_step);
629 break;
631 rxn_HL_phase_transfer_calc_jac_contrib(model_data, jac, rxn_int_data,
632 rxn_float_data, rxn_env_data,
633 time_step);
634 break;
637 rxn_int_data, rxn_float_data,
638 rxn_env_data, time_step);
639 break;
640 }
641 }
642}
643
644#endif
645
646/** \brief Add condensed data to the condensed data block of memory
647 *
648 * \param rxn_type Reaction type
649 * \param n_int_param Number of integer parameters
650 * \param n_float_param Number of floating-point parameters
651 * \param n_env_param Number of environment-dependent parameters
652 * \param int_param Pointer to integer parameter array
653 * \param float_param Pointer to floating-point parameter array
654 * \param solver_data Pointer to solver data
655 */
656// TODO: question: move n_added_rxns out of struct to function parameter since
657// is only used in this function
658void rxn_add_condensed_data(int rxn_type, int n_int_param, int n_float_param,
659 int n_env_param, int *int_param,
660 double *float_param, void *solver_data) {
661 ModelData *model_data =
662 (ModelData *)&(((SolverData *)solver_data)->model_data);
663
664 // Get pointers to the reaction data
665 int *rxn_int_data =
666 &(model_data->rxn_int_data
667 [model_data->rxn_int_indices[model_data->n_added_rxns]]);
668 double *rxn_float_data =
669 &(model_data->rxn_float_data
670 [model_data->rxn_float_indices[model_data->n_added_rxns]]);
671
672 // Save next indices by adding lengths
673 model_data->rxn_int_indices[model_data->n_added_rxns + 1] =
674 (n_int_param + 1) +
675 model_data->rxn_int_indices[model_data->n_added_rxns]; //+1 is type
676 model_data->rxn_float_indices[model_data->n_added_rxns + 1] =
677 n_float_param + model_data->rxn_float_indices[model_data->n_added_rxns];
678 model_data->rxn_env_idx[model_data->n_added_rxns + 1] =
679 model_data->rxn_env_idx[model_data->n_added_rxns] + n_env_param;
680 ++(model_data->n_added_rxns);
681
682 // Add the reaction type
683 *(rxn_int_data++) = rxn_type;
684
685 // Add integer parameters
686 for (; n_int_param > 0; --n_int_param) *(rxn_int_data++) = *(int_param++);
687
688 // Add floating-point parameters
689 for (; n_float_param > 0; --n_float_param)
690 *(rxn_float_data++) = (double)*(float_param++);
691
692 model_data->n_rxn_env_data += n_env_param;
693}
694
695/** \brief Update reaction data
696 *
697 * Update data for one or more reactions. Reactions of a certain type are
698 * passed a void pointer to updated data that must be in the format specified
699 * by the reaction type. This data could be used to find specific reactions of
700 * the specified type and, for example, update rate constants.
701 *
702 * \param cell_id Id of the grid cell to update
703 * \param rxn_id Id of the reaction (or 0 if unknown)
704 * \param update_rxn_type Type of the reaction
705 * \param update_data Pointer to updated data to pass to the reaction
706 * \param solver_data Pointer to solver data
707 */
708void rxn_update_data(int cell_id, int *rxn_id, int update_rxn_type,
709 void *update_data, void *solver_data) {
710 ModelData *model_data =
711 (ModelData *)&(((SolverData *)solver_data)->model_data);
712
713 // Point to the environment-dependent data for the grid cell
714 model_data->grid_cell_rxn_env_data =
715 &(model_data->rxn_env_data[cell_id * model_data->n_rxn_env_data]);
716
717 // Get the number of reactions
718 int n_rxn = model_data->n_rxn;
719
720 // Loop through the reactions advancing the rxn_data pointer each time
721 for (; (*rxn_id) < n_rxn; (*rxn_id)++) {
722 // Get pointers to the reaction data
723 int *rxn_int_data =
724 &(model_data->rxn_int_data[model_data->rxn_int_indices[*rxn_id]]);
725 double *rxn_float_data =
726 &(model_data->rxn_float_data[model_data->rxn_float_indices[*rxn_id]]);
727
728 double *rxn_env_data =
729 &(model_data->grid_cell_rxn_env_data[model_data->rxn_env_idx[*rxn_id]]);
730
731 // Get the reaction type
732 int rxn_type = *(rxn_int_data++);
733
734 bool found = false;
735
736 // Try the update data function for reactions of the correct type
737 if (rxn_type == update_rxn_type) {
738 switch (rxn_type) {
739 case RXN_EMISSION:
740 found = rxn_emission_update_data((void *)update_data, rxn_int_data,
741 rxn_float_data, rxn_env_data);
742 break;
745 (void *)update_data, rxn_int_data, rxn_float_data, rxn_env_data);
746 break;
747 case RXN_PHOTOLYSIS:
748 found = rxn_photolysis_update_data((void *)update_data, rxn_int_data,
749 rxn_float_data, rxn_env_data);
750 break;
752 found = rxn_condensed_phase_photolysis_update_data((void *)update_data, rxn_int_data,
753 rxn_float_data, rxn_env_data);
754 break;
757 (void *)update_data, rxn_int_data, rxn_float_data, rxn_env_data);
758 break;
759 }
760 if (found) return;
761 }
762 }
763}
764
765/** \brief Print the reaction data
766 *
767 * \param solver_data Pointer to the solver data
768 */
769void rxn_print_data(void *solver_data) {
770 ModelData *model_data =
771 (ModelData *)&(((SolverData *)solver_data)->model_data);
772
773 // Get the number of reactions
774 int n_rxn = model_data->n_rxn;
775
776 printf("\n\nReaction data\n\nnumber of reactions: %d\n\n", n_rxn);
777
778 // Loop through the reactions advancing the rxn_data pointer each time
779 for (int i_rxn = 0; i_rxn < n_rxn; i_rxn++) {
780 // Get pointers to the reaction data
781 int *rxn_int_data =
782 &(model_data->rxn_int_data[model_data->rxn_int_indices[i_rxn]]);
783 double *rxn_float_data =
784 &(model_data->rxn_float_data[model_data->rxn_float_indices[i_rxn]]);
785
786 // Get the reaction type
787 int rxn_type = *(rxn_int_data++);
788
789 // Call the appropriate function
790 switch (rxn_type) {
792 rxn_aqueous_equilibrium_print(rxn_int_data, rxn_float_data);
793 break;
794 case RXN_ARRHENIUS:
795 rxn_arrhenius_print(rxn_int_data, rxn_float_data);
796 break;
797 case RXN_CMAQ_H2O2:
798 rxn_CMAQ_H2O2_print(rxn_int_data, rxn_float_data);
799 break;
800 case RXN_CMAQ_OH_HNO3:
801 rxn_CMAQ_OH_HNO3_print(rxn_int_data, rxn_float_data);
802 break;
804 rxn_condensed_phase_arrhenius_print(rxn_int_data, rxn_float_data);
805 break;
807 rxn_condensed_phase_photolysis_print(rxn_int_data, rxn_float_data);
808 break;
809 case RXN_EMISSION:
810 rxn_emission_print(rxn_int_data, rxn_float_data);
811 break;
813 rxn_first_order_loss_print(rxn_int_data, rxn_float_data);
814 break;
816 rxn_HL_phase_transfer_print(rxn_int_data, rxn_float_data);
817 break;
818 case RXN_PHOTOLYSIS:
819 rxn_photolysis_print(rxn_int_data, rxn_float_data);
820 break;
822 rxn_SIMPOL_phase_transfer_print(rxn_int_data, rxn_float_data);
823 break;
824 case RXN_SURFACE:
825 rxn_surface_print(rxn_int_data, rxn_float_data);
826 break;
828 rxn_ternary_chemical_activation_print(rxn_int_data, rxn_float_data);
829 break;
830 case RXN_TROE:
831 rxn_troe_print(rxn_int_data, rxn_float_data);
832 break;
834 rxn_wennberg_no_ro2_print(rxn_int_data, rxn_float_data);
835 break;
837 rxn_wennberg_tunneling_print(rxn_int_data, rxn_float_data);
838 break;
840 rxn_wet_deposition_print(rxn_int_data, rxn_float_data);
841 break;
842 }
843 }
844 fflush(stdout);
845}
846
847/** \brief Free an update data object
848 *
849 * \param update_data Object to free
850 */
851void rxn_free_update_data(void *update_data) { free(update_data); }
#define RXN_PHOTOLYSIS
Definition rxn_solver.c:23
void rxn_update_ids(ModelData *model_data, int *deriv_ids, Jacobian jac)
Update the time derivative and Jacobian array ids.
Definition rxn_solver.c:131
void rxn_calc_deriv_specific_types(ModelData *model_data, TimeDerivative time_deriv, realtype time_step)
Calculate the time derivative for only some specific types.
Definition rxn_solver.c:439
#define RXN_CONDENSED_PHASE_PHOTOLYSIS
Definition rxn_solver.c:34
#define RXN_WENNBERG_TUNNELING
Definition rxn_solver.c:32
#define RXN_AQUEOUS_EQUILIBRIUM
Definition rxn_solver.c:25
#define RXN_CMAQ_H2O2
Definition rxn_solver.c:21
#define RXN_ARRHENIUS
Definition rxn_solver.c:19
void rxn_calc_jac_specific_types(ModelData *model_data, Jacobian jac, realtype time_step)
Calculate the Jacobian for only some specific types.
Definition rxn_solver.c:595
void rxn_add_condensed_data(int rxn_type, int n_int_param, int n_float_param, int n_env_param, int *int_param, double *float_param, void *solver_data)
Add condensed data to the condensed data block of memory.
Definition rxn_solver.c:658
void rxn_print_data(void *solver_data)
Print the reaction data.
Definition rxn_solver.c:769
void rxn_free_update_data(void *update_data)
Free an update data object.
Definition rxn_solver.c:851
void rxn_get_used_jac_elem(ModelData *model_data, Jacobian *jac)
Get the Jacobian elements used by a particular reaction.
Definition rxn_solver.c:42
#define RXN_FIRST_ORDER_LOSS
Definition rxn_solver.c:28
#define RXN_WENNBERG_NO_RO2
Definition rxn_solver.c:33
#define RXN_CMAQ_OH_HNO3
Definition rxn_solver.c:22
#define RXN_TERNARY_CHEMICAL_ACTIVATION
Definition rxn_solver.c:31
#define RXN_TROE
Definition rxn_solver.c:20
void rxn_update_env_state(ModelData *model_data)
Update reaction data for new environmental state.
Definition rxn_solver.c:224
#define RXN_CONDENSED_PHASE_ARRHENIUS
Definition rxn_solver.c:27
#define RXN_SURFACE
Definition rxn_solver.c:35
void rxn_calc_jac(ModelData *model_data, Jacobian jac, realtype time_step)
Calculate the Jacobian.
Definition rxn_solver.c:482
#define RXN_EMISSION
Definition rxn_solver.c:29
void rxn_update_data(int cell_id, int *rxn_id, int update_rxn_type, void *update_data, void *solver_data)
Update reaction data.
Definition rxn_solver.c:708
#define RXN_SIMPOL_PHASE_TRANSFER
Definition rxn_solver.c:26
#define RXN_HL_PHASE_TRANSFER
Definition rxn_solver.c:24
void rxn_calc_deriv(ModelData *model_data, TimeDerivative time_deriv, realtype time_step)
Calculate the time derivative .
Definition rxn_solver.c:322
#define RXN_WET_DEPOSITION
Definition rxn_solver.c:30
Header file for abstract reaction functions.
Header file for reaction solver functions.
void rxn_CMAQ_H2O2_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_aqueous_equilibrium_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_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_wet_deposition_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_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_emission_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_print(int *rxn_int_data, double *rxn_float_data)
Print the Ternary Chemical Activation reaction parameters.
void rxn_emission_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_photolysis_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_emission_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_SIMPOL_phase_transfer_get_used_jac_elem(ModelData *model_data, int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_SIMPOL_phase_transfer_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_surface_get_used_jac_elem(ModelData *model_data, int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
Definition rxn_surface.c:56
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_emission_print(int *rxn_int_data, double *rxn_float_data)
Print the reaction parameters.
void rxn_surface_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_condensed_phase_arrhenius_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_CMAQ_H2O2_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_HL_phase_transfer_print(int *rxn_int_data, double *rxn_float_data)
Print the Phase Transfer reaction parameters.
bool rxn_emission_update_data(void *update_data, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data)
Update reaction data.
void rxn_CMAQ_OH_HNO3_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_SIMPOL_phase_transfer_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_CMAQ_OH_HNO3_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_aqueous_equilibrium_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_CMAQ_H2O2_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_CMAQ_H2O2_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_condensed_phase_photolysis_print(int *rxn_int_data, double *rxn_float_data)
Print the Condensed Phase photolysis reaction parameters.
void rxn_CMAQ_OH_HNO3_print(int *rxn_int_data, double *rxn_float_data)
Print the CMAQ_OH_HNO3 reaction parameters.
void rxn_HL_phase_transfer_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_troe_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.
Definition rxn_troe.c:189
void rxn_condensed_phase_arrhenius_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_HL_phase_transfer_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_wet_deposition_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_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_surface_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_wennberg_tunneling_print(int *rxn_int_data, double *rxn_float_data)
Print the Wennberg tunneling reaction parameters.
void rxn_first_order_loss_print(int *rxn_int_data, double *rxn_float_data)
Print the reaction parameters.
void rxn_surface_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_SIMPOL_phase_transfer_print(int *rxn_int_data, double *rxn_float_data)
Print the Phase Transfer reaction parameters.
void rxn_HL_phase_transfer_get_used_jac_elem(ModelData *model_data, int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_wet_deposition_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_arrhenius_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
bool rxn_photolysis_update_data(void *update_data, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data)
Update reaction data.
void rxn_wet_deposition_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_photolysis_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_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_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_arrhenius_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_wet_deposition_print(int *rxn_int_data, double *rxn_float_data)
Print the reaction parameters.
void rxn_condensed_phase_photolysis_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_aqueous_equilibrium_print(int *rxn_int_data, double *rxn_float_data)
Print the Aqueous Equilibrium reaction parameters.
void rxn_condensed_phase_arrhenius_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_troe_print(int *rxn_int_data, double *rxn_float_data)
Print the Troe reaction parameters.
Definition rxn_troe.c:231
void rxn_arrhenius_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_arrhenius_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_photolysis_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_SIMPOL_phase_transfer_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_condensed_phase_arrhenius_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_condensed_phase_photolysis_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
bool rxn_wet_deposition_update_data(void *update_data, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data)
Update reaction data.
void rxn_HL_phase_transfer_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_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_troe_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
Definition rxn_troe.c:47
void rxn_surface_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_aqueous_equilibrium_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
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_wennberg_no_ro2_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_condensed_phase_photolysis_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_condensed_phase_photolysis_calc_deriv_contrib(ModelData *model_data, TimeDerivative time_deriv, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_arrhenius_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_HL_phase_transfer_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_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 rxn_condensed_phase_photolysis_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_condensed_phase_arrhenius_print(int *rxn_int_data, double *rxn_float_data)
Print the Condensed Phase Arrhenius reaction parameters.
void rxn_CMAQ_H2O2_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
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, realtype time_step)
void rxn_troe_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.
Definition rxn_troe.c:72
void rxn_CMAQ_OH_HNO3_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_photolysis_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_emission_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_condensed_phase_arrhenius_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_CMAQ_H2O2_print(int *rxn_int_data, double *rxn_float_data)
Print the CMAQ_H2O2 reaction parameters.
void rxn_aqueous_equilibrium_get_used_jac_elem(int *rxn_int_data, double *rxn_float_data, Jacobian *jac)
Flag Jacobian elements used by this reaction.
void rxn_SIMPOL_phase_transfer_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_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_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_wennberg_tunneling_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
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_CMAQ_OH_HNO3_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
void rxn_troe_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.
Definition rxn_troe.c:107
void rxn_wet_deposition_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_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_emission_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_calc_jac_contrib(ModelData *model_data, Jacobian jac, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, realtype time_step)
bool rxn_condensed_phase_photolysis_update_data(void *update_data, int *rxn_int_data, double *rxn_float_data, double *rxn_env_data)
Update reaction data.
void rxn_troe_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.
Definition rxn_troe.c:143
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.
void rxn_CMAQ_OH_HNO3_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 rxn_photolysis_print(int *rxn_int_data, double *rxn_float_data)
Print the Photolysis reaction parameters.
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 rxn_wennberg_no_ro2_print(int *rxn_int_data, double *rxn_float_data)
Print the Wennberg NO + RO2 reaction parameters.
void rxn_surface_print(int *rxn_int_data, double *rxn_float_data)
Print the surface reaction parameters.
void rxn_aqueous_equilibrium_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_photolysis_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_arrhenius_print(int *rxn_int_data, double *rxn_float_data)
Print the Arrhenius 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, realtype time_step)
int * rxn_int_indices
double * rxn_env_data
int * rxn_float_indices
int * rxn_env_idx
double * grid_cell_rxn_env_data
int n_rxn_env_data
int * rxn_int_data
int n_added_rxns
double * rxn_float_data