Generated Code

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

The raw code is available.

/*
   There are a total of 30 entries in the algebraic variable array.
   There are a total of 7 entries in each of the rate and state variable arrays.
   There are a total of 22 entries in the constant variable array.
 */
/*
 * VOI is t in component environment (second).
 * CONSTANTS[0] is C_m in component environment (fF).
 * STATES[0] is q_K_o in component environment (fmol).
 * STATES[1] is q_K_i in component environment (fmol).
 * STATES[2] is q_Sa in component environment (fmol).
 * STATES[3] is q_Sb in component environment (fmol).
 * STATES[4] is q_Sc in component environment (fmol).
 * STATES[5] is q_Sd in component environment (fmol).
 * STATES[6] is q_mem in component environment (fC).
 * CONSTANTS[1] is R in component environment (J_per_K_per_mol).
 * CONSTANTS[2] is T in component environment (kelvin).
 * CONSTANTS[3] is F in component environment (C_per_mol).
 * ALGEBRAIC[21] is v_Kr in component Kr (fmol_per_sec).
 * ALGEBRAIC[27] is I_mem_Kr in component Kr (fA).
 * ALGEBRAIC[1] is I_stim in component environment (fA).
 * CONSTANTS[4] is stimPeriod in component environment (second).
 * CONSTANTS[5] is stimDuration in component environment (second).
 * ALGEBRAIC[0] is tPeriod in component environment (second).
 * CONSTANTS[6] is kappa_Kr in component Kr_parameters (fmol_per_sec).
 * CONSTANTS[7] is kappa_xr10 in component Kr_parameters (fmol_per_sec).
 * CONSTANTS[8] is kappa_xr11 in component Kr_parameters (fmol_per_sec).
 * CONSTANTS[9] is kappa_xr20 in component Kr_parameters (fmol_per_sec).
 * CONSTANTS[10] is kappa_xr21 in component Kr_parameters (fmol_per_sec).
 * CONSTANTS[11] is K_K_i in component Kr_parameters (per_fmol).
 * CONSTANTS[12] is K_K_o in component Kr_parameters (per_fmol).
 * CONSTANTS[13] is K_Sa_Kr in component Kr_parameters (per_fmol).
 * CONSTANTS[14] is K_Sb_Kr in component Kr_parameters (per_fmol).
 * CONSTANTS[15] is K_Sc_Kr in component Kr_parameters (per_fmol).
 * CONSTANTS[16] is K_Sd_Kr in component Kr_parameters (per_fmol).
 * CONSTANTS[17] is zK in component Kr_parameters (dimensionless).
 * CONSTANTS[18] is z_xr1_f in component Kr_parameters (dimensionless).
 * CONSTANTS[19] is z_xr1_r in component Kr_parameters (dimensionless).
 * CONSTANTS[20] is z_xr2_f in component Kr_parameters (dimensionless).
 * CONSTANTS[21] is z_xr2_r in component Kr_parameters (dimensionless).
 * ALGEBRAIC[2] is u_K_i in component Kr (J_per_mol).
 * ALGEBRAIC[3] is u_K_o in component Kr (J_per_mol).
 * ALGEBRAIC[4] is V_mem in component Kr (J_per_C).
 * ALGEBRAIC[5] is Am_Kr in component Kr (J_per_mol).
 * ALGEBRAIC[19] is Af_Kr in component Kr (J_per_mol).
 * ALGEBRAIC[20] is Ar_Kr in component Kr (J_per_mol).
 * ALGEBRAIC[17] is v_Sa in component Kr (fmol_per_sec).
 * ALGEBRAIC[28] is v_Sb in component Kr (fmol_per_sec).
 * ALGEBRAIC[26] is v_Sc in component Kr (fmol_per_sec).
 * ALGEBRAIC[29] is v_Sd in component Kr (fmol_per_sec).
 * ALGEBRAIC[12] is v_x10 in component Kr (fmol_per_sec).
 * ALGEBRAIC[24] is v_x11 in component Kr (fmol_per_sec).
 * ALGEBRAIC[16] is v_x20 in component Kr (fmol_per_sec).
 * ALGEBRAIC[25] is v_x21 in component Kr (fmol_per_sec).
 * ALGEBRAIC[6] is mu_Sa in component Kr (J_per_mol).
 * ALGEBRAIC[9] is mu_Sb in component Kr (J_per_mol).
 * ALGEBRAIC[13] is mu_Sc in component Kr (J_per_mol).
 * ALGEBRAIC[18] is mu_Sd in component Kr (J_per_mol).
 * ALGEBRAIC[7] is Af_x10 in component Kr (J_per_mol).
 * ALGEBRAIC[10] is Ar_x10 in component Kr (J_per_mol).
 * ALGEBRAIC[14] is Af_x11 in component Kr (J_per_mol).
 * ALGEBRAIC[22] is Ar_x11 in component Kr (J_per_mol).
 * ALGEBRAIC[8] is Af_x20 in component Kr (J_per_mol).
 * ALGEBRAIC[15] is Ar_x20 in component Kr (J_per_mol).
 * ALGEBRAIC[11] is Af_x21 in component Kr (J_per_mol).
 * ALGEBRAIC[23] is Ar_x21 in component Kr (J_per_mol).
 * RATES[1] is d/dt q_K_i in component environment (fmol).
 * RATES[0] is d/dt q_K_o in component environment (fmol).
 * RATES[6] is d/dt q_mem in component environment (fC).
 * RATES[2] is d/dt q_Sa in component environment (fmol).
 * RATES[3] is d/dt q_Sb in component environment (fmol).
 * RATES[4] is d/dt q_Sc in component environment (fmol).
 * RATES[5] is d/dt q_Sd in component environment (fmol).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 60000;
STATES[0] = 20.0448;
STATES[1] = 388.832;
STATES[2] = 1.598306E-07;
STATES[3] = 1.598306E-07;
STATES[4] = 1.598306E-07;
STATES[5] = 1.598306E-07;
STATES[6] = -13039;
CONSTANTS[1] = 8.31;
CONSTANTS[2] = 310;
CONSTANTS[3] = 96500;
CONSTANTS[4] = 1;
CONSTANTS[5] = 0.0001;
CONSTANTS[6] = 175.029;
CONSTANTS[7] = 0.0794844;
CONSTANTS[8] = 0.00212813;
CONSTANTS[9] = 0.267259;
CONSTANTS[10] = 2.18134;
CONSTANTS[11] = 12.9706;
CONSTANTS[12] = 95.1175;
CONSTANTS[13] = 0.0465841;
CONSTANTS[14] = 0.00570751;
CONSTANTS[15] = 1.73989;
CONSTANTS[16] = 0.213172;
CONSTANTS[17] = 1;
CONSTANTS[18] = 1.6149028778859738;
CONSTANTS[19] = -1.3218634652232777;
CONSTANTS[20] = -1.0273976425216251;
CONSTANTS[21] = -0.18153135376657775;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[4] = STATES[6]/CONSTANTS[0];
ALGEBRAIC[6] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[13]*STATES[2]);
ALGEBRAIC[7] = ALGEBRAIC[6]+ CONSTANTS[18]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[9] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[14]*STATES[3]);
ALGEBRAIC[10] = ALGEBRAIC[9]+ CONSTANTS[19]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[12] =  CONSTANTS[7]*(exp(ALGEBRAIC[7]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[10]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[8] = ALGEBRAIC[6]+ CONSTANTS[20]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[13] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[15]*STATES[4]);
ALGEBRAIC[15] = ALGEBRAIC[13]+ CONSTANTS[21]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[16] =  CONSTANTS[9]*(exp(ALGEBRAIC[8]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[15]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[17] = - ALGEBRAIC[12] - ALGEBRAIC[16];
RATES[2] = ALGEBRAIC[17];
ALGEBRAIC[5] =  CONSTANTS[17]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[2] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[11]*STATES[1]);
ALGEBRAIC[18] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[16]*STATES[5]);
ALGEBRAIC[19] = ALGEBRAIC[18]+ALGEBRAIC[2]+ALGEBRAIC[5];
ALGEBRAIC[3] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[12]*STATES[0]);
ALGEBRAIC[20] = ALGEBRAIC[18]+ALGEBRAIC[3];
ALGEBRAIC[21] = (ALGEBRAIC[5]==0.00000 ?  1.00000*CONSTANTS[6]*(exp(ALGEBRAIC[19]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[20]/( CONSTANTS[1]*CONSTANTS[2]))) :  ((( 1.00000*CONSTANTS[6]*ALGEBRAIC[5])/( CONSTANTS[1]*CONSTANTS[2]))/(exp(ALGEBRAIC[5]/( CONSTANTS[1]*CONSTANTS[2])) - 1.00000))*(exp(ALGEBRAIC[19]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[20]/( CONSTANTS[1]*CONSTANTS[2]))));
RATES[1] = - ALGEBRAIC[21];
RATES[0] = ALGEBRAIC[21];
ALGEBRAIC[14] = ALGEBRAIC[13]+ CONSTANTS[18]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[22] = ALGEBRAIC[18]+ CONSTANTS[19]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[24] =  CONSTANTS[8]*(exp(ALGEBRAIC[14]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[22]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[26] = ALGEBRAIC[16] - ALGEBRAIC[24];
RATES[4] = ALGEBRAIC[26];
ALGEBRAIC[11] = ALGEBRAIC[9]+ CONSTANTS[20]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[23] = ALGEBRAIC[18]+ CONSTANTS[21]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[25] =  CONSTANTS[10]*(exp(ALGEBRAIC[11]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[23]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[27] =  CONSTANTS[3]*( - CONSTANTS[17]*ALGEBRAIC[21]+ ALGEBRAIC[12]*(CONSTANTS[19] - CONSTANTS[18])+ ALGEBRAIC[24]*(CONSTANTS[19] - CONSTANTS[19])+ ALGEBRAIC[16]*(CONSTANTS[21] - CONSTANTS[20])+ ALGEBRAIC[25]*(CONSTANTS[21] - CONSTANTS[20]));
ALGEBRAIC[0] = VOI -  floor(VOI/CONSTANTS[4])*CONSTANTS[4];
ALGEBRAIC[1] = (ALGEBRAIC[0]>=0.300000&&ALGEBRAIC[0]<=0.300000+CONSTANTS[5] ? ( 0.0750000*CONSTANTS[0])/CONSTANTS[5] : 0.00000);
RATES[6] = ALGEBRAIC[27]+ALGEBRAIC[1];
ALGEBRAIC[28] = ALGEBRAIC[12] - ALGEBRAIC[25];
RATES[3] = ALGEBRAIC[28];
ALGEBRAIC[29] = ALGEBRAIC[24]+ALGEBRAIC[25];
RATES[5] = ALGEBRAIC[29];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[4] = STATES[6]/CONSTANTS[0];
ALGEBRAIC[6] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[13]*STATES[2]);
ALGEBRAIC[7] = ALGEBRAIC[6]+ CONSTANTS[18]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[9] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[14]*STATES[3]);
ALGEBRAIC[10] = ALGEBRAIC[9]+ CONSTANTS[19]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[12] =  CONSTANTS[7]*(exp(ALGEBRAIC[7]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[10]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[8] = ALGEBRAIC[6]+ CONSTANTS[20]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[13] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[15]*STATES[4]);
ALGEBRAIC[15] = ALGEBRAIC[13]+ CONSTANTS[21]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[16] =  CONSTANTS[9]*(exp(ALGEBRAIC[8]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[15]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[17] = - ALGEBRAIC[12] - ALGEBRAIC[16];
ALGEBRAIC[5] =  CONSTANTS[17]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[2] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[11]*STATES[1]);
ALGEBRAIC[18] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[16]*STATES[5]);
ALGEBRAIC[19] = ALGEBRAIC[18]+ALGEBRAIC[2]+ALGEBRAIC[5];
ALGEBRAIC[3] =  CONSTANTS[1]*CONSTANTS[2]*log( CONSTANTS[12]*STATES[0]);
ALGEBRAIC[20] = ALGEBRAIC[18]+ALGEBRAIC[3];
ALGEBRAIC[21] = (ALGEBRAIC[5]==0.00000 ?  1.00000*CONSTANTS[6]*(exp(ALGEBRAIC[19]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[20]/( CONSTANTS[1]*CONSTANTS[2]))) :  ((( 1.00000*CONSTANTS[6]*ALGEBRAIC[5])/( CONSTANTS[1]*CONSTANTS[2]))/(exp(ALGEBRAIC[5]/( CONSTANTS[1]*CONSTANTS[2])) - 1.00000))*(exp(ALGEBRAIC[19]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[20]/( CONSTANTS[1]*CONSTANTS[2]))));
ALGEBRAIC[14] = ALGEBRAIC[13]+ CONSTANTS[18]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[22] = ALGEBRAIC[18]+ CONSTANTS[19]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[24] =  CONSTANTS[8]*(exp(ALGEBRAIC[14]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[22]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[26] = ALGEBRAIC[16] - ALGEBRAIC[24];
ALGEBRAIC[11] = ALGEBRAIC[9]+ CONSTANTS[20]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[23] = ALGEBRAIC[18]+ CONSTANTS[21]*CONSTANTS[3]*ALGEBRAIC[4];
ALGEBRAIC[25] =  CONSTANTS[10]*(exp(ALGEBRAIC[11]/( CONSTANTS[1]*CONSTANTS[2])) - exp(ALGEBRAIC[23]/( CONSTANTS[1]*CONSTANTS[2])));
ALGEBRAIC[27] =  CONSTANTS[3]*( - CONSTANTS[17]*ALGEBRAIC[21]+ ALGEBRAIC[12]*(CONSTANTS[19] - CONSTANTS[18])+ ALGEBRAIC[24]*(CONSTANTS[19] - CONSTANTS[19])+ ALGEBRAIC[16]*(CONSTANTS[21] - CONSTANTS[20])+ ALGEBRAIC[25]*(CONSTANTS[21] - CONSTANTS[20]));
ALGEBRAIC[0] = VOI -  floor(VOI/CONSTANTS[4])*CONSTANTS[4];
ALGEBRAIC[1] = (ALGEBRAIC[0]>=0.300000&&ALGEBRAIC[0]<=0.300000+CONSTANTS[5] ? ( 0.0750000*CONSTANTS[0])/CONSTANTS[5] : 0.00000);
ALGEBRAIC[28] = ALGEBRAIC[12] - ALGEBRAIC[25];
ALGEBRAIC[29] = ALGEBRAIC[24]+ALGEBRAIC[25];
}