16#define SUB_MODEL_UNIFAC 1
17#define SUB_MODEL_ZSR_AEROSOL_WATER 2
18#define SUB_MODEL_PDFITE 3
31 "\n\nERROR allocating sub-model Jacobian structure for sub-model "
32 "interdepenedence\n\n");
40 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
41 int *sub_model_int_data =
44 double *sub_model_float_data =
49 int sub_model_type = *(sub_model_int_data++);
51 switch (sub_model_type) {
54 sub_model_float_data, &local_jac);
58 sub_model_float_data, &local_jac);
62 sub_model_int_data, sub_model_float_data, &local_jac);
69 printf(
"\n\nERROR building sparse Jacobian for sub models\n\n");
126 printf(
"\n\nError allocating sub model Jacobian map\n\n");
137 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
143 "\n\nERROR allocating sub-model Jacobian structure for sub-model "
144 "interdepenedence\n\n");
148 int *sub_model_int_data =
151 double *sub_model_float_data =
156 int sub_model_type = *(sub_model_int_data++);
158 switch (sub_model_type) {
161 sub_model_float_data, &local_jac);
165 sub_model_float_data, &local_jac);
169 sub_model_int_data, sub_model_float_data, &local_jac);
176 "\n\nERROR building sub-model Jacobian structure for sub-model "
177 "interdependence\n\n");
185 for (
unsigned int i_elem =
190 if (i_dep != i_ind &&
213 printf(
"\n\nError mapping sub-model Jacobian elements %d %d\n\n", i_map,
230 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
231 int *sub_model_int_data =
234 double *sub_model_float_data =
239 int sub_model_type = *(sub_model_int_data++);
241 switch (sub_model_type) {
252 sub_model_int_data, sub_model_float_data, deriv_ids, jac);
270 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
271 int *sub_model_int_data =
274 double *sub_model_float_data =
277 double *sub_model_env_data =
282 int sub_model_type = *(sub_model_int_data++);
285 switch (sub_model_type) {
288 sub_model_float_data,
289 sub_model_env_data, model_data);
293 sub_model_float_data,
294 sub_model_env_data, model_data);
298 sub_model_int_data, sub_model_float_data, sub_model_env_data,
314 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
315 int *sub_model_int_data =
318 double *sub_model_float_data =
321 double *sub_model_env_data =
326 int sub_model_type = *(sub_model_int_data++);
329 switch (sub_model_type) {
332 sub_model_env_data, model_data);
336 sub_model_env_data, model_data);
340 sub_model_float_data,
341 sub_model_env_data, model_data);
353#ifdef CAMP_USE_SUNDIALS
355 realtype time_step) {
361 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
362 int *sub_model_int_data =
365 double *sub_model_float_data =
368 double *sub_model_env_data =
373 int sub_model_type = *(sub_model_int_data++);
376 switch (sub_model_type) {
379 sub_model_int_data, sub_model_float_data, sub_model_env_data,
380 model_data, J_data, (
double)time_step);
384 sub_model_int_data, sub_model_float_data, sub_model_env_data,
385 model_data, J_data, (
double)time_step);
389 sub_model_int_data, sub_model_float_data, sub_model_env_data,
390 model_data, J_data, (
double)time_step);
414 int n_float_param,
int n_env_param,
415 int *int_param,
double *float_param,
421 int *sub_model_int_data = &(
424 double *sub_model_float_data =
442 *(sub_model_int_data++) = sub_model_type;
445 for (; n_int_param > 0; --n_int_param)
446 *(sub_model_int_data++) = *(int_param++);
449 for (; n_float_param > 0; --n_float_param)
450 *(sub_model_float_data++) = (double)*(float_param++);
469 int update_sub_model_type,
void *update_data,
483 for (; (*sub_model_id) < n_sub_model; (*sub_model_id)++) {
484 int *sub_model_int_data =
487 double *sub_model_float_data =
490 double *sub_model_env_data = &(
495 int sub_model_type = *(sub_model_int_data++);
500 if (sub_model_type != update_sub_model_type)
continue;
518 for (
int i_sub_model = 0; i_sub_model < n_sub_model; i_sub_model++) {
519 int *sub_model_int_data =
522 double *sub_model_float_data =
527 int sub_model_type = *(sub_model_int_data++);
530 switch (sub_model_type) {
539 sub_model_float_data);
unsigned int jacobian_column_pointer_value(Jacobian jac, unsigned int col_id)
Returns the value of a column pointer.
void jacobian_free(Jacobian *jac)
Free memory associated with a Jacobian.
unsigned int jacobian_build_matrix(Jacobian *jac)
Builds the sparse matrix with the registered elements.
int jacobian_initialize_empty(Jacobian *jac, unsigned int num_spec)
Initialize the Jacobian.
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_register_element(Jacobian *jac, unsigned int dep_id, unsigned int ind_id)
Adds an element to the sparse matrix.
unsigned int jacobian_row_index(Jacobian jac, unsigned int elem_id)
Returns the row for a given Jacobian element.
#define CHEM_SPEC_VARIABLE
int * sub_model_int_indices
double * sub_model_float_data
double * grid_cell_sub_model_env_data
double * sub_model_env_data
int * sub_model_float_indices
void sub_model_print_data(void *solver_data)
Print the sub model data.
void sub_model_update_ids(ModelData *model_data, int *deriv_ids, Jacobian jac)
Update the time derivative and Jacobian array ids.
void sub_model_add_condensed_data(int sub_model_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 for sub models.
#define SUB_MODEL_ZSR_AEROSOL_WATER
void sub_model_get_used_jac_elem(ModelData *model_data, Jacobian *jac)
Get the Jacobian elements used by a particular sub model.
void sub_model_set_jac_map(ModelData *model_data, Jacobian jac)
Set the map for sub-model interdependence.
void sub_model_update_env_state(ModelData *model_data)
Update sub model data for a new environmental state.
void sub_model_calculate(ModelData *model_data)
Perform the sub model calculations for the current model state.
void sub_model_get_jac_contrib(ModelData *model_data, double *J_data, realtype time_step)
Calculate the Jacobian constributions from sub model calculations.
void sub_model_update_data(int cell_id, int *sub_model_id, int update_sub_model_type, void *update_data, void *solver_data)
Update sub-model data.
Header file for abstract sub model functions.
Header file for sub model functions.
void sub_model_UNIFAC_get_jac_contrib(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data, realtype *J, double time_step)
Add contributions to the Jacobian from derivates calculated using the output of this sub model.
void sub_model_ZSR_aerosol_water_get_used_jac_elem(int *sub_model_int_data, double *sub_model_float_data, Jacobian *jac)
Flag Jacobian elements used by this sub model.
void sub_model_PDFiTE_get_used_jac_elem(int *sub_model_int_data, double *sub_model_float_data, Jacobian *jac)
Flag Jacobian elements used by this sub model.
void sub_model_UNIFAC_update_ids(int *sub_model_int_data, double *sub_model_float_data, int *deriv_ids, Jacobian jac)
Update stored ids for elements used within a row of the Jacobian matrix.
void sub_model_PDFiTE_calculate(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data)
Perform the sub-model calculations for the current model state.
void sub_model_UNIFAC_update_env_state(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data)
Update sub-model data for new environmental conditions.
void sub_model_PDFiTE_get_jac_contrib(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data, realtype *J, double time_step)
Add contributions to the Jacobian from derivates calculated using the output of this sub model.
void sub_model_PDFiTE_print(int *sub_model_int_data, double *sub_model_float_data)
Print the PDFiTE Activity sub model parameters.
void sub_model_ZSR_aerosol_water_calculate(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data)
Do pre-derivative calculations.
void sub_model_UNIFAC_get_used_jac_elem(int *sub_model_int_data, double *sub_model_float_data, Jacobian *jac)
Get the Jacobian elements used for a particular row of the matrix.
void sub_model_ZSR_aerosol_water_print(int *sub_model_int_data, double *sub_model_float_data)
Print the ZSR Aerosol Water sub model parameters.
void sub_model_ZSR_aerosol_water_update_env_state(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data)
Update sub model data for new environmental conditions.
void sub_model_UNIFAC_calculate(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data)
Perform the sub-model calculations for the current model state.
void sub_model_ZSR_aerosol_water_get_jac_contrib(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data, realtype *J, double time_step)
Add contributions to the Jacobian from derivates calculated using the output of this sub model.
void sub_model_UNIFAC_print(int *sub_model_int_data, double *sub_model_float_data)
Print the sub model data.
void sub_model_PDFiTE_update_ids(int *sub_model_int_data, double *sub_model_float_data, int *deriv_ids, Jacobian jac)
Update the time derivative and Jacbobian array indices.
void sub_model_PDFiTE_update_env_state(int *sub_model_int_data, double *sub_model_float_data, double *sub_model_env_data, ModelData *model_data)
Update sub model data for new environmental conditions.
void sub_model_ZSR_aerosol_water_update_ids(int *sub_model_int_data, double *sub_model_float_data, int *deriv_ids, Jacobian jac)
Update the time derivative and Jacbobian array indices.