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 7 entries in the algebraic variable array.
   There are a total of 4 entries in each of the rate and state variable arrays.
   There are a total of 11 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * CONSTANTS[0] is sigma in component parameters (dm).
 * CONSTANTS[1] is CNG_tot in component parameters (mole_per_dm_squared).
 * CONSTANTS[2] is CaM_tot in component parameters (mole_per_dm_cubed).
 * CONSTANTS[3] is km_CNG_0 in component parameters (per_second).
 * CONSTANTS[4] is km_CaM4 in component parameters (per_second).
 * CONSTANTS[5] is kp_CaM4 in component parameters (dm_6_per_second_per_mole_squared).
 * CONSTANTS[6] is kp_CNG_i in component parameters (dm_3_per_second_per_mole).
 * CONSTANTS[7] is km_CNG_i in component parameters (per_second).
 * CONSTANTS[8] is i_Ca in component parameters (per_second).
 * CONSTANTS[9] is k_Ca in component parameters (mole_per_dm_squared_per_second).
 * CONSTANTS[10] is K_Ca in component parameters (mole_per_dm_cubed).
 * ALGEBRAIC[0] is kp_act in component parameters (per_second).
 * STATES[0] is CNG_o in component dCNG_o_dt (mole_per_dm_squared).
 * ALGEBRAIC[1] is CNG_o_normalized in component dCNG_o_dt (dimensionless).
 * STATES[1] is CNG_i in component dCNG_i_dt (mole_per_dm_squared).
 * STATES[2] is CaM4 in component dCaM4_dt (mole_per_dm_cubed).
 * STATES[3] is Ca in component dCa_dt (mole_per_dm_cubed).
 * ALGEBRAIC[2] is Ca_normalized in component dCa_dt (dimensionless).
 * ALGEBRAIC[3] is CaM4_normalized in component dCaM4_dt (dimensionless).
 * ALGEBRAIC[4] is CNG_i_normalized in component dCNG_i_dt (dimensionless).
 * ALGEBRAIC[5] is CNG_c in component dCNG_c_dt (mole_per_dm_squared).
 * ALGEBRAIC[6] is CaM in component dCaM_dt (mole_per_dm_cubed).
 * RATES[0] is d/dt CNG_o in component dCNG_o_dt (mole_per_dm_squared).
 * RATES[3] is d/dt Ca in component dCa_dt (mole_per_dm_cubed).
 * RATES[2] is d/dt CaM4 in component dCaM4_dt (mole_per_dm_cubed).
 * RATES[1] is d/dt CNG_i in component dCNG_i_dt (mole_per_dm_squared).
 * There are a total of 4 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 5e-7;
CONSTANTS[1] = 1.3e-13;
CONSTANTS[2] = 2e-5;
CONSTANTS[3] = 1e-2;
CONSTANTS[4] = 2.5;
CONSTANTS[5] = 1.1e9;
CONSTANTS[6] = 2.1e6;
CONSTANTS[7] = 3.4e-1;
CONSTANTS[8] = 2e4;
CONSTANTS[9] = 1e-10;
CONSTANTS[10] = 1.2e-7;
STATES[0] = 0;
STATES[1] = 0;
STATES[2] = 0;
STATES[3] = 0;
RATES[0] = 0.1001;
RATES[3] = 0.1001;
RATES[2] = 0.1001;
RATES[1] = 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[0]*((CONSTANTS[1] - STATES[0]) - STATES[1]) -  CONSTANTS[3]*STATES[0]) -  CONSTANTS[6]*STATES[0]*STATES[2];
resid[1] = RATES[3] - ( (STATES[0]/CONSTANTS[0])*CONSTANTS[8] - ( (CONSTANTS[9]/CONSTANTS[0])*STATES[3])/(STATES[3]+CONSTANTS[10])) -  4.00000*( CONSTANTS[5]*pow(STATES[3], 2.00000)*((CONSTANTS[2] - STATES[2]) - STATES[1]/CONSTANTS[0]) -  CONSTANTS[4]*STATES[2]);
resid[2] = RATES[2] - (( CONSTANTS[5]*pow(STATES[3], 2.00000)*((CONSTANTS[2] - STATES[2]) - STATES[1]/CONSTANTS[0]) -  CONSTANTS[4]*STATES[2]) -  (CONSTANTS[6]/CONSTANTS[0])*STATES[2]*(CONSTANTS[1] - STATES[0]))+ (CONSTANTS[7]/CONSTANTS[0])*STATES[1];
resid[3] = RATES[1] -  - CONSTANTS[7]*STATES[1]+ CONSTANTS[6]*STATES[2]*(CONSTANTS[1] - STATES[1]);
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = STATES[0]/CONSTANTS[1];
ALGEBRAIC[2] =  STATES[3]*10000.0;
ALGEBRAIC[3] = STATES[2]/CONSTANTS[2];
ALGEBRAIC[4] = STATES[1]/CONSTANTS[1];
ALGEBRAIC[5] = (CONSTANTS[1] - STATES[0]) - STATES[1];
ALGEBRAIC[6] = (CONSTANTS[2] - STATES[2]) -  (1.00000/CONSTANTS[0])*STATES[1];
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (CONDVAR[0]>0.00000&&CONDVAR[1]<0.00000 ? 5.50000 : CONDVAR[2]>0.00000&&CONDVAR[3]<0.00000 ? 5.50000 : 1.60000e-05);
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
SI[3] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - 0.100000;
CONDVAR[1] = VOI - 0.200000;
CONDVAR[2] = VOI - 4.10000;
CONDVAR[3] = VOI - 4.20000;
}