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 29 entries in the algebraic variable array.
   There are a total of 9 entries in each of the rate and state variable arrays.
   There are a total of 45 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (millisecond).
 * CONSTANTS[0] is RT in component parameters (joule_per_mole).
 * STATES[0] is V_m in component membrane (millivolt).
 * CONSTANTS[1] is C_m in component membrane (picofarad).
 * ALGEBRAIC[3] is I_Na in component I_Na (picoampere).
 * ALGEBRAIC[8] is I_T in component I_T (picoampere).
 * ALGEBRAIC[27] is I_KCa in component I_KCa (picoampere).
 * ALGEBRAIC[18] is I_Ca in component I_Ca (picoampere).
 * ALGEBRAIC[23] is I_L in component I_L (picoampere).
 * ALGEBRAIC[24] is I_K in component I_K (picoampere).
 * ALGEBRAIC[2] is I_stim in component I_stim (picoampere).
 * CONSTANTS[2] is I_mag in component I_stim (picoampere).
 * CONSTANTS[3] is t_0 in component I_stim (millisecond).
 * CONSTANTS[4] is t_1 in component I_stim (millisecond).
 * ALGEBRAIC[0] is H_0 in component I_stim (dimensionless).
 * ALGEBRAIC[1] is H_1 in component I_stim (dimensionless).
 * CONSTANTS[5] is g_Na in component I_Na (nanosiemens).
 * CONSTANTS[6] is E_Na in component I_Na (millivolt).
 * STATES[1] is m in component m (dimensionless).
 * STATES[2] is h in component h (dimensionless).
 * CONSTANTS[7] is E_m in component m (millivolt).
 * CONSTANTS[8] is V_alpha_m in component m (millivolt).
 * CONSTANTS[9] is V_beta_m in component m (millivolt).
 * ALGEBRAIC[4] is alpha_m in component m (per_millisecond).
 * ALGEBRAIC[5] is beta_m in component m (per_millisecond).
 * CONSTANTS[10] is alpha_m_max in component m (per_millivolt_per_millisecond).
 * CONSTANTS[11] is beta_m_max in component m (per_millisecond).
 * CONSTANTS[12] is E_h in component h (millivolt).
 * CONSTANTS[13] is V_alpha_h in component h (millivolt).
 * CONSTANTS[14] is V_beta_h in component h (millivolt).
 * ALGEBRAIC[6] is alpha_h in component h (per_millisecond).
 * ALGEBRAIC[7] is beta_h in component h (per_millisecond).
 * CONSTANTS[15] is alpha_h_max in component h (per_millisecond).
 * CONSTANTS[16] is beta_h_max in component h (per_millisecond).
 * CONSTANTS[17] is R_s in component I_T (per_nanosiemens).
 * CONSTANTS[18] is C_t in component I_T (picofarad).
 * STATES[3] is V_T in component V_T (millivolt).
 * CONSTANTS[19] is g_KCa in component I_KCa (nanosiemens).
 * CONSTANTS[20] is E_K in component I_K (millivolt).
 * STATES[4] is o in component o (dimensionless).
 * ALGEBRAIC[13] is w in component w (dimensionless).
 * STATES[5] is c in component calcium_handling (dimensionless).
 * ALGEBRAIC[12] is o_oinf in component o (dimensionless).
 * ALGEBRAIC[9] is alpha_Vm in component o (per_millisecond).
 * ALGEBRAIC[10] is beta_Vm in component o (per_millisecond).
 * ALGEBRAIC[11] is tau_Vm in component o (millisecond).
 * CONSTANTS[21] is d_1 in component o (dimensionless).
 * CONSTANTS[22] is d_2 in component o (dimensionless).
 * CONSTANTS[23] is k_1 in component o (dimensionless).
 * CONSTANTS[24] is k_2 in component o (dimensionless).
 * CONSTANTS[25] is a_bar in component o (per_millisecond).
 * CONSTANTS[26] is b_bar in component o (per_millisecond).
 * CONSTANTS[27] is kd in component w (dimensionless).
 * STATES[6] is cer in component calcium_handling (dimensionless).
 * ALGEBRAIC[28] is j_mem in component calcium_handling (picoampere).
 * ALGEBRAIC[14] is j_leak in component calcium_handling (picoampere).
 * ALGEBRAIC[15] is j_serca in component calcium_handling (picoampere).
 * ALGEBRAIC[16] is j_er in component calcium_handling (picoampere).
 * CONSTANTS[28] is alpha in component calcium_handling (dimensionless).
 * CONSTANTS[29] is k_pmca in component calcium_handling (dimensionless).
 * CONSTANTS[30] is k_serca in component calcium_handling (picoampere).
 * CONSTANTS[31] is p_leak in component calcium_handling (picoampere).
 * CONSTANTS[32] is f_er in component calcium_handling (per_picoampere_per_millisecond).
 * CONSTANTS[33] is f_cyt in component calcium_handling (per_picoampere_per_millisecond).
 * CONSTANTS[34] is v_cytver in component calcium_handling (dimensionless).
 * STATES[7] is d in component d (dimensionless).
 * ALGEBRAIC[17] is g_Ca in component I_Ca (nanosiemens).
 * CONSTANTS[35] is g_Ca0 in component I_Ca (nanosiemens_per_millivolt).
 * CONSTANTS[36] is E_Ca in component I_Ca (millivolt).
 * ALGEBRAIC[21] is alpha_d in component d (per_millisecond).
 * ALGEBRAIC[22] is beta_d in component d (per_millisecond).
 * ALGEBRAIC[20] is tau_d in component d (millisecond).
 * ALGEBRAIC[19] is d_infinity in component d (dimensionless).
 * CONSTANTS[37] is E_L in component I_L (millivolt).
 * CONSTANTS[38] is g_Lmax in component I_L (nanosiemens).
 * STATES[8] is n in component n (dimensionless).
 * CONSTANTS[39] is g_K in component I_K (nanosiemens).
 * CONSTANTS[40] is E_n in component n (millivolt).
 * CONSTANTS[41] is V_alpha_n in component n (millivolt).
 * CONSTANTS[42] is V_beta_n in component n (millivolt).
 * ALGEBRAIC[25] is alpha_n in component n (per_millisecond).
 * ALGEBRAIC[26] is beta_n in component n (per_millisecond).
 * CONSTANTS[43] is alpha_n_max in component n (per_millivolt_per_millisecond).
 * CONSTANTS[44] is beta_n_max in component n (per_millisecond).
 * RATES[0] is d/dt V_m in component membrane (millivolt).
 * RATES[1] is d/dt m in component m (dimensionless).
 * RATES[2] is d/dt h in component h (dimensionless).
 * RATES[3] is d/dt V_T in component V_T (millivolt).
 * RATES[4] is d/dt o in component o (dimensionless).
 * RATES[5] is d/dt c in component calcium_handling (dimensionless).
 * RATES[6] is d/dt cer in component calcium_handling (dimensionless).
 * RATES[7] is d/dt d in component d (dimensionless).
 * RATES[8] is d/dt n in component n (dimensionless).
 * There are a total of 2 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 2577;
STATES[0] = -75;
CONSTANTS[1] = 0.009;
CONSTANTS[2] = 2;
CONSTANTS[3] = 5;
CONSTANTS[4] = 6;
CONSTANTS[5] = 0.45;
CONSTANTS[6] = 50;
STATES[1] = 0;
STATES[2] = 1;
CONSTANTS[7] = -42;
CONSTANTS[8] = 10;
CONSTANTS[9] = 18;
CONSTANTS[10] = 0.208;
CONSTANTS[11] = 2.081;
CONSTANTS[12] = -41;
CONSTANTS[13] = 14.7;
CONSTANTS[14] = 7.6;
CONSTANTS[15] = 0.0156;
CONSTANTS[16] = 3.382;
CONSTANTS[17] = 15;
CONSTANTS[18] = 0.04;
STATES[3] = -70;
CONSTANTS[19] = 0.5;
CONSTANTS[20] = -70;
STATES[4] = 0.15;
STATES[5] = 0.15;
CONSTANTS[21] = 0.84;
CONSTANTS[22] = 1;
CONSTANTS[23] = 0.18;
CONSTANTS[24] = 0.011;
CONSTANTS[25] = 0.48;
CONSTANTS[26] = 0.28;
CONSTANTS[27] = 0.18;
STATES[6] = 200;
CONSTANTS[28] = 4.5e-6;
CONSTANTS[29] = 0.2;
CONSTANTS[30] = 0.4;
CONSTANTS[31] = 0.0005;
CONSTANTS[32] = 0.01;
CONSTANTS[33] = 0.01;
CONSTANTS[34] = 5;
STATES[7] = 0;
CONSTANTS[35] = 0.05;
CONSTANTS[36] = 50;
CONSTANTS[37] = -75;
CONSTANTS[38] = 0.0024;
STATES[8] = 0;
CONSTANTS[39] = 0.415;
CONSTANTS[40] = -40;
CONSTANTS[41] = 7;
CONSTANTS[42] = 40;
CONSTANTS[43] = 0.0229;
CONSTANTS[44] = 0.09616;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[3] = 0.1001;
RATES[4] = 0.1001;
RATES[5] = 0.1001;
RATES[6] = 0.1001;
RATES[7] = 0.1001;
RATES[8] = 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[2] - (ALGEBRAIC[3]+ALGEBRAIC[18]+ALGEBRAIC[24]+ALGEBRAIC[23]+ALGEBRAIC[8]+ALGEBRAIC[27]))/CONSTANTS[1];
resid[1] = RATES[1] -  ALGEBRAIC[4]*(1.00000 - STATES[1]) -  ALGEBRAIC[5]*STATES[1];
resid[2] = RATES[2] -  ALGEBRAIC[6]*(1.00000 - STATES[2]) -  ALGEBRAIC[7]*STATES[2];
resid[3] = RATES[3] - (STATES[0] - STATES[3])/( CONSTANTS[17]*CONSTANTS[18]);
resid[4] = RATES[4] - (ALGEBRAIC[12] - STATES[4])/ALGEBRAIC[11];
resid[5] = RATES[5] -  CONSTANTS[33]*(ALGEBRAIC[28]+ALGEBRAIC[16]);
resid[6] = RATES[6] -  - CONSTANTS[32]*CONSTANTS[34]*ALGEBRAIC[16];
resid[7] = RATES[7] -  ALGEBRAIC[21]*(1.00000 - STATES[7]) -  ALGEBRAIC[22]*STATES[7];
resid[8] = RATES[8] -  ALGEBRAIC[25]*(1.00000 - STATES[8]) -  ALGEBRAIC[26]*STATES[8];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (CONDVAR[0]<0.00000 ? 0.00000 : 1.00000);
ALGEBRAIC[1] = (CONDVAR[1]<0.00000 ? 0.00000 : 1.00000);
ALGEBRAIC[2] =  CONSTANTS[2]*(ALGEBRAIC[0] - ALGEBRAIC[1]);
ALGEBRAIC[3] =  CONSTANTS[5]*pow(STATES[1], 3.00000)*STATES[2]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[4] = ( CONSTANTS[10]*(STATES[0] - CONSTANTS[7]))/(1.00000 - exp((CONSTANTS[7] - STATES[0])/CONSTANTS[8]));
ALGEBRAIC[5] =  CONSTANTS[11]*exp((CONSTANTS[7] - STATES[0])/CONSTANTS[9]);
ALGEBRAIC[6] =  CONSTANTS[15]*exp((STATES[0] - CONSTANTS[12])/CONSTANTS[13]);
ALGEBRAIC[7] = CONSTANTS[16]/(1.00000+exp((CONSTANTS[12] - STATES[0])/CONSTANTS[14]));
ALGEBRAIC[8] = (STATES[0] - STATES[3])/CONSTANTS[17];
ALGEBRAIC[9] = CONSTANTS[25]/(1.00000+ CONSTANTS[23]*exp(( - 2.00000*CONSTANTS[21]*96.4850*STATES[0])/( CONSTANTS[0]*STATES[5])));
ALGEBRAIC[10] = CONSTANTS[26]/(1.00000+STATES[5]/( CONSTANTS[24]*exp(( - 2.00000*CONSTANTS[22]*96.4850*STATES[0])/CONSTANTS[0])));
ALGEBRAIC[11] = 1.00000/(ALGEBRAIC[9]+ALGEBRAIC[10]);
ALGEBRAIC[12] =  ALGEBRAIC[9]*ALGEBRAIC[11];
ALGEBRAIC[14] =  CONSTANTS[31]*(STATES[6] - STATES[5]);
ALGEBRAIC[15] =  CONSTANTS[30]*STATES[5];
ALGEBRAIC[16] = ALGEBRAIC[14] - ALGEBRAIC[15];
ALGEBRAIC[17] = ( - CONSTANTS[35]*STATES[0])/(exp( 0.117000*STATES[0]) - 1.00000);
ALGEBRAIC[18] =  ALGEBRAIC[17]*pow(STATES[7], 2.00000)*(STATES[0] - CONSTANTS[36]);
ALGEBRAIC[20] = ( 80.0000*1.00000)/cosh( - 0.0310000*(STATES[0]+37.1000));
ALGEBRAIC[19] = 1.00000/(1.00000+exp((- 24.6000 - STATES[0])/11.3000));
ALGEBRAIC[21] = ALGEBRAIC[19]/ALGEBRAIC[20];
ALGEBRAIC[22] = (1.00000 - ALGEBRAIC[19])/ALGEBRAIC[20];
ALGEBRAIC[23] =  CONSTANTS[38]*(STATES[0] - CONSTANTS[37]);
ALGEBRAIC[24] =  CONSTANTS[39]*pow(STATES[8], 4.00000)*(STATES[0] - CONSTANTS[20]);
ALGEBRAIC[25] = ( CONSTANTS[43]*(STATES[0] - CONSTANTS[40]))/(1.00000 - exp((CONSTANTS[40] - STATES[0])/CONSTANTS[41]));
ALGEBRAIC[26] =  CONSTANTS[44]*exp((CONSTANTS[40] - STATES[0])/CONSTANTS[42]);
ALGEBRAIC[13] = pow(STATES[5], 5.00000)/(pow(STATES[5], 5.00000)+pow(CONSTANTS[27], 5.00000));
ALGEBRAIC[27] =  CONSTANTS[19]*STATES[4]*ALGEBRAIC[13]*(STATES[0] - CONSTANTS[20]);
ALGEBRAIC[28] =  - CONSTANTS[28]*ALGEBRAIC[18]*CONSTANTS[29]*STATES[5];
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
SI[3] = 1.0;
SI[4] = 1.0;
SI[5] = 1.0;
SI[6] = 1.0;
SI[7] = 1.0;
SI[8] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - CONSTANTS[3];
CONDVAR[1] = VOI - CONSTANTS[4];
}