CAMP 1.0.0
Chemistry Across Multiple Phases
Macros | Functions
rxn_aqueous_equilibrium.c File Reference

Aqueous Equilibrium reaction solver functions. More...

Include dependency graph for rxn_aqueous_equilibrium.c:

Go to the source code of this file.

Macros

#define TEMPERATURE_K_   env_data[0]
 
#define PRESSURE_PA_   env_data[1]
 
#define SMALL_NUMBER_   1.0e-30
 
#define MIN_WATER_   1.0e-4
 
#define NUM_REACT_   (int_data[0])
 
#define NUM_PROD_   (int_data[1])
 
#define NUM_AERO_PHASE_   (int_data[2])
 
#define A_   (float_data[0])
 
#define C_   (float_data[1])
 
#define RATE_CONST_REVERSE_   (float_data[2])
 
#define WATER_CONC_   (float_data[3])
 
#define ACTIVITY_COEFF_VALUE_   (float_data[4])
 
#define RATE_CONST_FORWARD_   (rxn_env_data[0])
 
#define NUM_INT_PROP_   3
 
#define NUM_FLOAT_PROP_   5
 
#define NUM_ENV_PARAM_   1
 
#define REACT_(x)   (int_data[NUM_INT_PROP_ + x] - 1)
 
#define PROD_(x)    (int_data[NUM_INT_PROP_ + NUM_REACT_ * NUM_AERO_PHASE_ + x] - 1)
 
#define WATER_(x)    (int_data[NUM_INT_PROP_ + (NUM_REACT_ + NUM_PROD_) * NUM_AERO_PHASE_ + x] - 1)
 
#define ACTIVITY_COEFF_(x)
 
#define DERIV_ID_(x)    (int_data[NUM_INT_PROP_ + (NUM_REACT_ + NUM_PROD_ + 2) * NUM_AERO_PHASE_ + x])
 
#define JAC_ID_(x)
 
#define MASS_FRAC_TO_M_(x)   (float_data[NUM_FLOAT_PROP_ + x])
 
#define REACT_CONC_(x)    (float_data[NUM_FLOAT_PROP_ + NUM_REACT_ + NUM_PROD_ + x])
 
#define PROD_CONC_(x)    (float_data[NUM_FLOAT_PROP_ + 2 * NUM_REACT_ + NUM_PROD_ + x])
 
#define SMALL_WATER_CONC_(x)    (float_data[NUM_FLOAT_PROP_ + 2 * NUM_REACT_ + 2 * NUM_PROD_ + x])
 
#define SMALL_CONC_(x)
 

Functions

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_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_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.
 
long double calc_standard_rate (int *rxn_int_data, double *rxn_float_data, double *rxn_env_data, bool is_water_partial, long double *rate_forward, long double *rate_reverse)
 Calculate the reaction rate for a set of conditions using the standard equation per mixing ratio of water [M_X/s*kg_H2O/m^3].
 
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, double time_step)
 Calculate contributions to the time derivative \(f(t,y)\) from this reaction.
 
void rxn_aqueous_equilibrium_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_aqueous_equilibrium_print (int *rxn_int_data, double *rxn_float_data)
 Print the Aqueous Equilibrium reaction parameters.
 

Detailed Description

Aqueous Equilibrium reaction solver functions.

Definition in file rxn_aqueous_equilibrium.c.

Macro Definition Documentation

◆ A_

#define A_   (float_data[0])

Definition at line 30 of file rxn_aqueous_equilibrium.c.

◆ ACTIVITY_COEFF_

#define ACTIVITY_COEFF_ (   x)
Value:
x] - \
1)
#define NUM_REACT_
#define NUM_INT_PROP_
#define NUM_PROD_
#define NUM_AERO_PHASE_

Definition at line 44 of file rxn_aqueous_equilibrium.c.

◆ ACTIVITY_COEFF_VALUE_

#define ACTIVITY_COEFF_VALUE_   (float_data[4])

Definition at line 34 of file rxn_aqueous_equilibrium.c.

◆ C_

#define C_   (float_data[1])

Definition at line 31 of file rxn_aqueous_equilibrium.c.

◆ DERIV_ID_

#define DERIV_ID_ (   x)     (int_data[NUM_INT_PROP_ + (NUM_REACT_ + NUM_PROD_ + 2) * NUM_AERO_PHASE_ + x])

Definition at line 48 of file rxn_aqueous_equilibrium.c.

◆ JAC_ID_

#define JAC_ID_ (   x)
Value:
(int_data[NUM_INT_PROP_ + \
(2 * (NUM_REACT_ + NUM_PROD_) + 2) * NUM_AERO_PHASE_ + x])

Definition at line 50 of file rxn_aqueous_equilibrium.c.

◆ MASS_FRAC_TO_M_

#define MASS_FRAC_TO_M_ (   x)    (float_data[NUM_FLOAT_PROP_ + x])

Definition at line 53 of file rxn_aqueous_equilibrium.c.

◆ MIN_WATER_

#define MIN_WATER_   1.0e-4

Definition at line 25 of file rxn_aqueous_equilibrium.c.

◆ NUM_AERO_PHASE_

#define NUM_AERO_PHASE_   (int_data[2])

Definition at line 29 of file rxn_aqueous_equilibrium.c.

◆ NUM_ENV_PARAM_

#define NUM_ENV_PARAM_   1

Definition at line 38 of file rxn_aqueous_equilibrium.c.

◆ NUM_FLOAT_PROP_

#define NUM_FLOAT_PROP_   5

Definition at line 37 of file rxn_aqueous_equilibrium.c.

◆ NUM_INT_PROP_

#define NUM_INT_PROP_   3

Definition at line 36 of file rxn_aqueous_equilibrium.c.

◆ NUM_PROD_

#define NUM_PROD_   (int_data[1])

Definition at line 28 of file rxn_aqueous_equilibrium.c.

◆ NUM_REACT_

#define NUM_REACT_   (int_data[0])

Definition at line 27 of file rxn_aqueous_equilibrium.c.

◆ PRESSURE_PA_

#define PRESSURE_PA_   env_data[1]

Definition at line 18 of file rxn_aqueous_equilibrium.c.

◆ PROD_

#define PROD_ (   x)     (int_data[NUM_INT_PROP_ + NUM_REACT_ * NUM_AERO_PHASE_ + x] - 1)

Definition at line 40 of file rxn_aqueous_equilibrium.c.

◆ PROD_CONC_

#define PROD_CONC_ (   x)     (float_data[NUM_FLOAT_PROP_ + 2 * NUM_REACT_ + NUM_PROD_ + x])

Definition at line 56 of file rxn_aqueous_equilibrium.c.

◆ RATE_CONST_FORWARD_

#define RATE_CONST_FORWARD_   (rxn_env_data[0])

Definition at line 35 of file rxn_aqueous_equilibrium.c.

◆ RATE_CONST_REVERSE_

#define RATE_CONST_REVERSE_   (float_data[2])

Definition at line 32 of file rxn_aqueous_equilibrium.c.

◆ REACT_

#define REACT_ (   x)    (int_data[NUM_INT_PROP_ + x] - 1)

Definition at line 39 of file rxn_aqueous_equilibrium.c.

◆ REACT_CONC_

#define REACT_CONC_ (   x)     (float_data[NUM_FLOAT_PROP_ + NUM_REACT_ + NUM_PROD_ + x])

Definition at line 54 of file rxn_aqueous_equilibrium.c.

◆ SMALL_CONC_

#define SMALL_CONC_ (   x)
Value:
(float_data[NUM_FLOAT_PROP_ + 2 * NUM_REACT_ + 2 * NUM_PROD_ + \
#define NUM_FLOAT_PROP_

Definition at line 60 of file rxn_aqueous_equilibrium.c.

◆ SMALL_NUMBER_

#define SMALL_NUMBER_   1.0e-30

Definition at line 21 of file rxn_aqueous_equilibrium.c.

◆ SMALL_WATER_CONC_

#define SMALL_WATER_CONC_ (   x)     (float_data[NUM_FLOAT_PROP_ + 2 * NUM_REACT_ + 2 * NUM_PROD_ + x])

Definition at line 58 of file rxn_aqueous_equilibrium.c.

◆ TEMPERATURE_K_

#define TEMPERATURE_K_   env_data[0]

Definition at line 17 of file rxn_aqueous_equilibrium.c.

◆ WATER_

#define WATER_ (   x)     (int_data[NUM_INT_PROP_ + (NUM_REACT_ + NUM_PROD_) * NUM_AERO_PHASE_ + x] - 1)

Definition at line 42 of file rxn_aqueous_equilibrium.c.

◆ WATER_CONC_

#define WATER_CONC_   (float_data[3])

Definition at line 33 of file rxn_aqueous_equilibrium.c.

Function Documentation

◆ calc_standard_rate()

long double calc_standard_rate ( int *  rxn_int_data,
double *  rxn_float_data,
double *  rxn_env_data,
bool  is_water_partial,
long double *  rate_forward,
long double *  rate_reverse 
)

Calculate the reaction rate for a set of conditions using the standard equation per mixing ratio of water [M_X/s*kg_H2O/m^3].

Parameters
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating point data
rxn_env_dataPointer to the environment-dependent parameters
is_water_partialFlag indicating whether the calculation should return the partial derivative d_rate/d_H2O
rate_forward[output] calculated forward rate
rate_reverse[output] calculated reverse rate
Returns
reaction rate per mixing ratio of water [M_X/s*kg_H2O/m^3]

Definition at line 278 of file rxn_aqueous_equilibrium.c.

Here is the caller graph for this function:

◆ rxn_aqueous_equilibrium_calc_deriv_contrib()

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,
double  time_step 
)

Calculate contributions to the time derivative \(f(t,y)\) from this reaction.

Parameters
model_dataPointer to the model data, including the state array
time_derivTimeDerivative object
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating-point data
rxn_env_dataPointer to the environment-dependent parameters
time_stepCurrent time step of the itegrator (s)

Definition at line 323 of file rxn_aqueous_equilibrium.c.

Here is the call graph for this function:

◆ rxn_aqueous_equilibrium_calc_jac_contrib()

void rxn_aqueous_equilibrium_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.

Parameters
model_dataPointer to the model data
jacReaction Jacobian
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating-point data
rxn_env_dataPointer to the environment-dependent parameters
time_stepCurrent time step of the itegrator (s)

Definition at line 403 of file rxn_aqueous_equilibrium.c.

Here is the call graph for this function:

◆ rxn_aqueous_equilibrium_get_used_jac_elem()

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.

Parameters
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating-point data
jacJacobian

Definition at line 70 of file rxn_aqueous_equilibrium.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rxn_aqueous_equilibrium_print()

void rxn_aqueous_equilibrium_print ( int *  rxn_int_data,
double *  rxn_float_data 
)

Print the Aqueous Equilibrium reaction parameters.

Parameters
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating-point data

Definition at line 549 of file rxn_aqueous_equilibrium.c.

Here is the caller graph for this function:

◆ rxn_aqueous_equilibrium_update_env_state()

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.

For Aqueous Equilibrium reaction this only involves recalculating the forward rate constant.

Parameters
model_dataPointer to the model data
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating-point data
rxn_env_dataPointer to the environment-dependent parameters

Definition at line 244 of file rxn_aqueous_equilibrium.c.

Here is the caller graph for this function:

◆ rxn_aqueous_equilibrium_update_ids()

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.

Parameters
model_dataPointer to the model data
deriv_idsId of each state variable in the derivative array
jacJacobian
rxn_int_dataPointer to the reaction integer data
rxn_float_dataPointer to the reaction floating-point data

Definition at line 132 of file rxn_aqueous_equilibrium.c.

Here is the call graph for this function:
Here is the caller graph for this function: