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 34 entries in the algebraic variable array.
   There are a total of 14 entries in each of the rate and state variable arrays.
   There are a total of 51 entries in the constant variable array.
 */
/*
 * VOI is time in component Time (time_units).
 * CONSTANTS[0] is Ach in component Neural_input (millimolar).
 * CONSTANTS[1] is Gcouple in component Gap_junction (conductance_units).
 * CONSTANTS[2] is T in component Environment (Temperature_units).
 * CONSTANTS[3] is T_exp in component Environment (Temperature_units).
 * CONSTANTS[4] is F in component Environment (F_units).
 * CONSTANTS[5] is R in component Environment (R_units).
 * CONSTANTS[6] is Q10Ca in component Environment (dimensionless).
 * CONSTANTS[7] is Q10K in component Environment (dimensionless).
 * CONSTANTS[8] is Q10Na in component Environment (dimensionless).
 * CONSTANTS[9] is Ca_o in component Environment (millimolar).
 * CONSTANTS[10] is Na_o in component Environment (millimolar).
 * CONSTANTS[11] is K_o in component Environment (millimolar).
 * CONSTANTS[12] is Cl_o in component Environment (millimolar).
 * CONSTANTS[33] is T_correction_Na in component Environment (dimensionless).
 * CONSTANTS[34] is T_correction_K in component Environment (dimensionless).
 * CONSTANTS[35] is T_correction_Ca in component Environment (dimensionless).
 * CONSTANTS[36] is T_correction_BK in component Environment (conductance_units).
 * CONSTANTS[37] is FoRT in component Environment (Inverse_Voltage_units).
 * CONSTANTS[38] is RToF in component Environment (voltage_units).
 * CONSTANTS[13] is Cm_SM in component SM_Membrane (capacitance_units).
 * CONSTANTS[14] is Vol_SM in component SM_Membrane (volume_units).
 * STATES[0] is Vm_SM in component SM_Membrane (voltage_units).
 * STATES[1] is Ca_i in component SM_Membrane (millimolar).
 * CONSTANTS[15] is Na_i in component SM_Membrane (millimolar).
 * CONSTANTS[16] is K_i in component SM_Membrane (millimolar).
 * ALGEBRAIC[25] is I_Na_SM in component I_Na_SM (current_units).
 * ALGEBRAIC[7] is I_Ltype_SM in component I_Ltype_SM (current_units).
 * ALGEBRAIC[13] is I_LVA_SM in component I_LVA_SM (current_units).
 * ALGEBRAIC[20] is I_kr_SM in component I_kr_SM (current_units).
 * ALGEBRAIC[29] is I_ka_SM in component I_ka_SM (current_units).
 * ALGEBRAIC[15] is I_BK_SM in component I_BK_SM (current_units).
 * ALGEBRAIC[33] is I_NSCC_SM in component I_NSCC_SM (current_units).
 * ALGEBRAIC[16] is I_bk_SM in component I_bk_SM (current_units).
 * ALGEBRAIC[8] is J_CaSR_SM in component J_CaSR_SM (millimolar_per_millisecond).
 * ALGEBRAIC[2] is I_stim in component I_stim (current_units).
 * ALGEBRAIC[1] is local_time in component I_stim (time_units).
 * CONSTANTS[17] is period in component I_stim (time_units).
 * ALGEBRAIC[0] is stim_start in component I_stim (time_units).
 * CONSTANTS[18] is delta_VICC in component I_stim (voltage_units).
 * CONSTANTS[19] is t_ICCpeak in component I_stim (time_units).
 * CONSTANTS[20] is t_ICCplateau in component I_stim (time_units).
 * CONSTANTS[21] is t_ICC_stimulus in component I_stim (time_units).
 * CONSTANTS[22] is V_decay in component I_stim (voltage_units).
 * ALGEBRAIC[3] is d_inf_Ltype_SM in component d_Ltype_SM (dimensionless).
 * CONSTANTS[40] is tau_d_Ltype_SM in component d_Ltype_SM (time_units).
 * STATES[2] is d_Ltype_SM in component d_Ltype_SM (dimensionless).
 * ALGEBRAIC[4] is f_inf_Ltype_SM in component f_Ltype_SM (dimensionless).
 * CONSTANTS[41] is tau_f_Ltype_SM in component f_Ltype_SM (time_units).
 * STATES[3] is f_Ltype_SM in component f_Ltype_SM (dimensionless).
 * ALGEBRAIC[5] is f_ca_inf_Ltype_SM in component f_ca_Ltype_SM (dimensionless).
 * CONSTANTS[42] is tau_f_ca_Ltype_SM in component f_ca_Ltype_SM (time_units).
 * STATES[4] is f_ca_Ltype_SM in component f_ca_Ltype_SM (dimensionless).
 * ALGEBRAIC[6] is E_Ca in component I_Ltype_SM (voltage_units).
 * CONSTANTS[23] is G_max_Ltype in component I_Ltype_SM (conductance_units).
 * CONSTANTS[24] is J_max_CaSR in component J_CaSR_SM (millimolar_per_millisecond).
 * ALGEBRAIC[9] is d_inf_LVA_SM in component d_LVA_SM (dimensionless).
 * CONSTANTS[43] is tau_d_LVA_SM in component d_LVA_SM (time_units).
 * STATES[5] is d_LVA_SM in component d_LVA_SM (dimensionless).
 * ALGEBRAIC[10] is f_inf_LVA_SM in component f_LVA_SM (dimensionless).
 * ALGEBRAIC[11] is tau_f_LVA_SM in component f_LVA_SM (time_units).
 * STATES[6] is f_LVA_SM in component f_LVA_SM (dimensionless).
 * ALGEBRAIC[12] is E_Ca in component I_LVA_SM (voltage_units).
 * CONSTANTS[25] is G_max_LVA in component I_LVA_SM (conductance_units).
 * ALGEBRAIC[14] is d_BK_SM in component d_BK_SM (dimensionless).
 * CONSTANTS[44] is E_K in component I_BK_SM (voltage_units).
 * CONSTANTS[26] is G_max_BK in component I_BK_SM (conductance_units).
 * CONSTANTS[45] is E_K in component I_bk_SM (voltage_units).
 * CONSTANTS[27] is G_max_bk in component I_bk_SM (conductance_units).
 * ALGEBRAIC[17] is xr1_inf_SM in component xr1_SM (dimensionless).
 * CONSTANTS[46] is tau_xr1_SM in component xr1_SM (time_units).
 * STATES[7] is xr1_SM in component xr1_SM (dimensionless).
 * ALGEBRAIC[18] is xr2_inf_SM in component xr2_SM (dimensionless).
 * ALGEBRAIC[19] is tau_xr2_SM in component xr2_SM (time_units).
 * STATES[8] is xr2_SM in component xr2_SM (dimensionless).
 * CONSTANTS[47] is E_K in component I_kr_SM (voltage_units).
 * CONSTANTS[28] is G_max_kr_SM in component I_kr_SM (conductance_units).
 * ALGEBRAIC[21] is m_inf_Na in component m_Na_SM (dimensionless).
 * ALGEBRAIC[22] is tau_m_Na in component m_Na_SM (time_units).
 * STATES[9] is m_Na_SM in component m_Na_SM (dimensionless).
 * ALGEBRAIC[23] is h_inf_Na in component h_Na_SM (dimensionless).
 * ALGEBRAIC[24] is tau_h_Na in component h_Na_SM (time_units).
 * STATES[10] is h_Na_SM in component h_Na_SM (dimensionless).
 * CONSTANTS[48] is E_Na in component I_Na_SM (voltage_units).
 * CONSTANTS[29] is G_max_Na_SM in component I_Na_SM (conductance_units).
 * ALGEBRAIC[26] is xa1_inf_SM in component xa1_SM (dimensionless).
 * ALGEBRAIC[27] is tau_xa1_SM in component xa1_SM (time_units).
 * STATES[11] is xa1_SM in component xa1_SM (dimensionless).
 * ALGEBRAIC[28] is xa2_inf_SM in component xa2_SM (dimensionless).
 * CONSTANTS[49] is tau_xa2_SM in component xa2_SM (time_units).
 * STATES[12] is xa2_SM in component xa2_SM (dimensionless).
 * CONSTANTS[50] is E_K in component I_ka_SM (voltage_units).
 * CONSTANTS[30] is G_max_ka_SM in component I_ka_SM (conductance_units).
 * ALGEBRAIC[30] is m_inf_NSCC_SM in component m_NSCC_SM (dimensionless).
 * ALGEBRAIC[31] is tau_m_NSCC_SM in component m_NSCC_SM (time_units).
 * STATES[13] is m_NSCC_SM in component m_NSCC_SM (dimensionless).
 * CONSTANTS[31] is E_NSCC in component I_NSCC_SM (voltage_units).
 * CONSTANTS[32] is G_max_NSCC_SM in component I_NSCC_SM (conductance_units).
 * ALGEBRAIC[32] is f_ca_NSCC_SM in component I_NSCC_SM (dimensionless).
 * CONSTANTS[39] is rach_NSCC_SM in component I_NSCC_SM (dimensionless).
 * RATES[0] is d/dt Vm_SM in component SM_Membrane (voltage_units).
 * RATES[1] is d/dt Ca_i in component SM_Membrane (millimolar).
 * RATES[2] is d/dt d_Ltype_SM in component d_Ltype_SM (dimensionless).
 * RATES[3] is d/dt f_Ltype_SM in component f_Ltype_SM (dimensionless).
 * RATES[4] is d/dt f_ca_Ltype_SM in component f_ca_Ltype_SM (dimensionless).
 * RATES[5] is d/dt d_LVA_SM in component d_LVA_SM (dimensionless).
 * RATES[6] is d/dt f_LVA_SM in component f_LVA_SM (dimensionless).
 * RATES[7] is d/dt xr1_SM in component xr1_SM (dimensionless).
 * RATES[8] is d/dt xr2_SM in component xr2_SM (dimensionless).
 * RATES[9] is d/dt m_Na_SM in component m_Na_SM (dimensionless).
 * RATES[10] is d/dt h_Na_SM in component h_Na_SM (dimensionless).
 * RATES[11] is d/dt xa1_SM in component xa1_SM (dimensionless).
 * RATES[12] is d/dt xa2_SM in component xa2_SM (dimensionless).
 * RATES[13] is d/dt m_NSCC_SM in component m_NSCC_SM (dimensionless).
 * There are a total of 13 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 0.00001;
CONSTANTS[1] = 1.3;
CONSTANTS[2] = 310;
CONSTANTS[3] = 297;
CONSTANTS[4] = 96486;
CONSTANTS[5] = 8314.4;
CONSTANTS[6] = 2.1;
CONSTANTS[7] = 1.365;
CONSTANTS[8] = 2.45;
CONSTANTS[9] = 2.5;
CONSTANTS[10] = 137;
CONSTANTS[11] = 5.9;
CONSTANTS[12] = 134;
CONSTANTS[13] = 77;
CONSTANTS[14] = 3500;
STATES[0] = -69.75;
STATES[1] = 0.00008;
CONSTANTS[15] = 10;
CONSTANTS[16] = 164;
CONSTANTS[17] = 20000;
CONSTANTS[18] = 59;
CONSTANTS[19] = 98;
CONSTANTS[20] = 7582;
CONSTANTS[21] = 10000;
CONSTANTS[22] = 37.25;
STATES[2] = 0.0;
STATES[3] = 0.95;
STATES[4] = 1.0;
CONSTANTS[23] = 65;
CONSTANTS[24] = 0.31705;
STATES[5] = 0.02;
STATES[6] = 0.99;
CONSTANTS[25] = 0.18;
CONSTANTS[26] = 45.7;
CONSTANTS[27] = 0.0144;
STATES[7] = 0.0;
STATES[8] = 0.82;
CONSTANTS[28] = 35;
STATES[9] = 0.005;
STATES[10] = 0.05787;
CONSTANTS[29] = 3;
STATES[11] = 0.00414;
STATES[12] = 0.72;
CONSTANTS[30] = 9;
STATES[13] = 0.0;
CONSTANTS[31] = -28;
CONSTANTS[32] = 50;
CONSTANTS[33] = pow(CONSTANTS[8], (CONSTANTS[2] - CONSTANTS[3])/10.0000);
CONSTANTS[34] = pow(CONSTANTS[7], (CONSTANTS[2] - CONSTANTS[3])/10.0000);
CONSTANTS[35] = pow(CONSTANTS[6], (CONSTANTS[2] - CONSTANTS[3])/10.0000);
CONSTANTS[36] =  1.10000*(CONSTANTS[2] - CONSTANTS[3]);
CONSTANTS[37] = CONSTANTS[4]/( CONSTANTS[5]*CONSTANTS[2]);
CONSTANTS[38] = ( CONSTANTS[5]*CONSTANTS[2])/CONSTANTS[4];
CONSTANTS[39] = 1.00000/(1.00000+0.0100000/CONSTANTS[0]);
CONSTANTS[40] =  CONSTANTS[35]*0.470000;
CONSTANTS[41] =  CONSTANTS[35]*86.0000;
CONSTANTS[42] =  CONSTANTS[35]*2.00000;
CONSTANTS[43] =  CONSTANTS[35]*3.00000;
CONSTANTS[44] =  CONSTANTS[38]*log(CONSTANTS[11]/CONSTANTS[16]);
CONSTANTS[45] =  CONSTANTS[38]*log(CONSTANTS[11]/CONSTANTS[16]);
CONSTANTS[46] =  CONSTANTS[34]*80.0000;
CONSTANTS[47] =  CONSTANTS[38]*log(CONSTANTS[11]/CONSTANTS[16]);
CONSTANTS[48] =  CONSTANTS[38]*log(CONSTANTS[10]/CONSTANTS[15]);
CONSTANTS[49] =  CONSTANTS[34]*90.0000;
CONSTANTS[50] =  CONSTANTS[38]*log(CONSTANTS[11]/CONSTANTS[16]);
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;
RATES[9] = 0.1001;
RATES[10] = 0.1001;
RATES[11] = 0.1001;
RATES[12] = 0.1001;
RATES[13] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] -  -1.00000*(1.00000/CONSTANTS[13])*(ALGEBRAIC[25]+ALGEBRAIC[7]+ALGEBRAIC[13]+ALGEBRAIC[20]+ALGEBRAIC[29]+ALGEBRAIC[15]+ALGEBRAIC[33]+ALGEBRAIC[16]+ -1.00000*ALGEBRAIC[2]);
resid[1] = RATES[1] - ( -1.00000*ALGEBRAIC[7]+ -1.00000*ALGEBRAIC[13])/( 2.00000*0.00100000*CONSTANTS[4]*CONSTANTS[14])+ -1.00000*ALGEBRAIC[8];
resid[2] = RATES[2] - (ALGEBRAIC[3] - STATES[2])/CONSTANTS[40];
resid[3] = RATES[3] - (ALGEBRAIC[4] - STATES[3])/CONSTANTS[41];
resid[4] = RATES[4] - (ALGEBRAIC[5] - STATES[4])/CONSTANTS[42];
resid[5] = RATES[5] - (ALGEBRAIC[9] - STATES[5])/CONSTANTS[43];
resid[6] = RATES[6] - (ALGEBRAIC[10] - STATES[6])/ALGEBRAIC[11];
resid[7] = RATES[7] - (ALGEBRAIC[17] - STATES[7])/CONSTANTS[46];
resid[8] = RATES[8] - (ALGEBRAIC[18] - STATES[8])/ALGEBRAIC[19];
resid[9] = RATES[9] - (ALGEBRAIC[21] - STATES[9])/ALGEBRAIC[22];
resid[10] = RATES[10] - (ALGEBRAIC[23] - STATES[10])/ALGEBRAIC[24];
resid[11] = RATES[11] - (ALGEBRAIC[26] - STATES[11])/ALGEBRAIC[27];
resid[12] = RATES[12] - (ALGEBRAIC[28] - STATES[12])/CONSTANTS[49];
resid[13] = RATES[13] - (ALGEBRAIC[30] - STATES[13])/ALGEBRAIC[31];
}
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&&CONDVAR[1]<=0.00000 ?  CONSTANTS[17]*1.00000 : CONDVAR[2]>0.00000&&CONDVAR[3]<=0.00000 ?  CONSTANTS[17]*2.00000 : CONDVAR[4]>0.00000&&CONDVAR[5]<=0.00000 ?  CONSTANTS[17]*3.00000 : CONDVAR[6]>0.00000&&CONDVAR[7]<=0.00000 ?  CONSTANTS[17]*4.00000 : 0.00000);
ALGEBRAIC[1] = VOI - (ALGEBRAIC[0]+CONSTANTS[19]);
ALGEBRAIC[2] = (CONDVAR[8]<0.00000 ?  CONSTANTS[1]*CONSTANTS[18] : CONDVAR[9]>=0.00000&&CONDVAR[10]<=0.00000 ?  CONSTANTS[1]*CONSTANTS[18]*(1.00000/(1.00000+exp((ALGEBRAIC[1] - 8000.00)/1000.00))) : CONDVAR[11]>0.00000&&CONDVAR[12]<0.00000 ?  CONSTANTS[1]*CONSTANTS[22]*(1.00000/(1.00000+exp((ALGEBRAIC[1] - 8000.00)/150.000))) : 0.00000);
ALGEBRAIC[3] = 1.00000/(1.00000+exp((STATES[0]+17.0000)/-4.30000));
ALGEBRAIC[4] = 1.00000/(1.00000+exp((STATES[0]+43.0000)/8.90000));
ALGEBRAIC[5] = 1.00000 - 1.00000/(1.00000+exp(((STATES[1] - 8.99900e-05) - 0.000214000)/-1.31000e-05));
ALGEBRAIC[6] =  0.500000*CONSTANTS[38]*log(CONSTANTS[9]/STATES[1]);
ALGEBRAIC[7] =  CONSTANTS[23]*( STATES[3]*STATES[2]*STATES[4])*(STATES[0] - ALGEBRAIC[6]);
ALGEBRAIC[8] =  CONSTANTS[24]*pow( STATES[1]*1.00000, 1.34000);
ALGEBRAIC[9] = 1.00000/(1.00000+exp((STATES[0]+27.5000)/-10.9000));
ALGEBRAIC[10] = 1.00000/(1.00000+exp((STATES[0]+15.8000)/7.00000));
ALGEBRAIC[11] =  CONSTANTS[35]*( 7.58000*exp( STATES[0]*0.00817000));
ALGEBRAIC[12] =  0.500000*CONSTANTS[38]*log(CONSTANTS[9]/STATES[1]);
ALGEBRAIC[13] =  CONSTANTS[25]*( STATES[6]*STATES[5])*(STATES[0] - ALGEBRAIC[12]);
ALGEBRAIC[14] = 1.00000/(1.00000+exp(STATES[0]/-17.0000 -  2.00000*log(STATES[1]/0.00100000)));
ALGEBRAIC[15] =  (CONSTANTS[26]+CONSTANTS[36])*ALGEBRAIC[14]*(STATES[0] - CONSTANTS[44]);
ALGEBRAIC[16] =  CONSTANTS[27]*(STATES[0] - CONSTANTS[45]);
ALGEBRAIC[17] = 1.00000/(1.00000+exp((STATES[0]+27.0000)/-5.00000));
ALGEBRAIC[18] = 0.200000+0.800000/(1.00000+exp((STATES[0]+58.0000)/10.0000));
ALGEBRAIC[19] =  CONSTANTS[34]*(-707.000+ 1481.00*exp((STATES[0]+36.0000)/95.0000));
ALGEBRAIC[20] =  CONSTANTS[28]*( STATES[7]*STATES[8])*(STATES[0] - CONSTANTS[47]);
ALGEBRAIC[21] = 1.00000/(1.00000+exp((STATES[0]+47.0000)/-4.80000));
ALGEBRAIC[22] =  CONSTANTS[33]*( STATES[0]*-0.0170000*1.00000+0.440000);
ALGEBRAIC[23] = 1.00000/(1.00000+exp((STATES[0]+78.0000)/3.00000));
ALGEBRAIC[24] =  CONSTANTS[33]*( STATES[0]*-0.250000*1.00000+5.50000);
ALGEBRAIC[25] =  CONSTANTS[29]*( STATES[10]*STATES[9])*(STATES[0] - CONSTANTS[48]);
ALGEBRAIC[26] = 1.00000/(1.00000+exp((STATES[0]+26.5000)/-7.90000));
ALGEBRAIC[27] =  CONSTANTS[34]*(31.8000+ 175.000*exp( -0.500000*pow((STATES[0]+44.4000)/22.3000, 2.00000)));
ALGEBRAIC[28] = 0.100000+0.900000/(1.00000+exp((STATES[0]+65.0000)/6.20000));
ALGEBRAIC[29] =  CONSTANTS[30]*( STATES[11]*STATES[12])*(STATES[0] - CONSTANTS[50]);
ALGEBRAIC[30] = 1.00000/(1.00000+exp((STATES[0]+25.0000)/-20.0000));
ALGEBRAIC[31] =  (1.00000/(1.00000+exp((STATES[0]+66.0000)/-26.0000)))*150.000;
ALGEBRAIC[32] = 1.00000/(1.00000+pow(STATES[1]/0.000200000, -4.00000));
ALGEBRAIC[33] =  CONSTANTS[32]*STATES[13]*ALGEBRAIC[32]*CONSTANTS[39]*(STATES[0] - CONSTANTS[31]);
}
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;
SI[9] = 1.0;
SI[10] = 1.0;
SI[11] = 1.0;
SI[12] = 1.0;
SI[13] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI -  CONSTANTS[17]*1.00000;
CONDVAR[1] = VOI -  CONSTANTS[17]*2.00000;
CONDVAR[2] = VOI -  CONSTANTS[17]*2.00000;
CONDVAR[3] = VOI -  CONSTANTS[17]*3.00000;
CONDVAR[4] = VOI -  CONSTANTS[17]*3.00000;
CONDVAR[5] = VOI -  CONSTANTS[17]*4.00000;
CONDVAR[6] = VOI -  CONSTANTS[17]*4.00000;
CONDVAR[7] = VOI -  CONSTANTS[17]*5.00000;
CONDVAR[8] = ALGEBRAIC[1] - CONSTANTS[19];
CONDVAR[9] = ALGEBRAIC[1] - CONSTANTS[19];
CONDVAR[10] = ALGEBRAIC[1] - CONSTANTS[20];
CONDVAR[11] = ALGEBRAIC[1] - CONSTANTS[20];
CONDVAR[12] = ALGEBRAIC[1] - CONSTANTS[21];
}