Generated Code

The following is c_ida code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

/*
   There are a total of 6 entries in the algebraic variable array.
   There are a total of 3 entries in each of the rate and state variable arrays.
   There are a total of 8 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * STATES[0] is q_CO2_i in component environment (fmol).
 * STATES[1] is q_HCO3_i in component environment (fmol).
 * STATES[2] is q_H_i in component environment (fmol).
 * ALGEBRAIC[5] is v_Re_CO2hyd in component CO2_hyd (fmol_per_sec).
 * ALGEBRAIC[1] is pH_i in component environment (dimensionless).
 * ALGEBRAIC[0] is cH_i in component environment (mM).
 * CONSTANTS[0] is w_i in component environment (pL).
 * CONSTANTS[1] is kappa_Re_CO2hyd in component CO2_hyd_parameters (fmol_per_sec).
 * CONSTANTS[2] is K_CO2_i in component CO2_hyd_parameters (per_fmol).
 * CONSTANTS[3] is K_HCO3_i in component CO2_hyd_parameters (per_fmol).
 * CONSTANTS[4] is K_H_i in component CO2_hyd_parameters (per_fmol).
 * CONSTANTS[5] is R in component constants (J_per_K_per_mol).
 * CONSTANTS[6] is T in component constants (kelvin).
 * ALGEBRAIC[2] is mu_CO2_i in component CO2_hyd (J_per_mol).
 * ALGEBRAIC[3] is mu_HCO3_i in component CO2_hyd (J_per_mol).
 * ALGEBRAIC[4] is mu_H_i in component CO2_hyd (J_per_mol).
 * CONSTANTS[7] is F in component constants (C_per_mol).
 * RATES[0] is d/dt q_CO2_i in component environment (fmol).
 * RATES[1] is d/dt q_HCO3_i in component environment (fmol).
 * RATES[2] is d/dt q_H_i in component environment (fmol).
 * There are a total of 0 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 46.968;
STATES[1] = 509.2;
STATES[2] = 2.69019E-06;
CONSTANTS[0] = 38;
CONSTANTS[1] = 153.093;
CONSTANTS[2] = 82.5092;
CONSTANTS[3] = 0.00128495;
CONSTANTS[4] = 0.00128495;
CONSTANTS[5] = 8.31;
CONSTANTS[6] = 310;
CONSTANTS[7] = 96485;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] - - ALGEBRAIC[5];
resid[1] = RATES[1] - ALGEBRAIC[5];
resid[2] = RATES[2] - ALGEBRAIC[5];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = STATES[2]/CONSTANTS[0];
ALGEBRAIC[1] = - arbitrary_log(ALGEBRAIC[0], 10);
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[2] =  CONSTANTS[5]*CONSTANTS[6]*log( CONSTANTS[2]*STATES[0]);
ALGEBRAIC[3] =  CONSTANTS[5]*CONSTANTS[6]*log( CONSTANTS[3]*STATES[1]);
ALGEBRAIC[4] =  CONSTANTS[5]*CONSTANTS[6]*log( CONSTANTS[4]*STATES[2]);
ALGEBRAIC[5] =  CONSTANTS[1]*(exp(ALGEBRAIC[2]/( CONSTANTS[5]*CONSTANTS[6])) - exp((ALGEBRAIC[3]+ALGEBRAIC[4])/( CONSTANTS[5]*CONSTANTS[6])));
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
}
Source
Derived from workspace BG_CO2_hydration at changeset 13ec7e6d78f3.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
License
The terms of use/license for this work is unspecified.