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 10 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 13 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (millisecond).
 * STATES[0] is V in component membrane (millivolt).
 * CONSTANTS[0] is E_R in component membrane (millivolt).
 * CONSTANTS[1] is Cm in component membrane (microF_per_cm2).
 * ALGEBRAIC[0] is i_Na in component sodium_channel (microA_per_cm2).
 * ALGEBRAIC[5] is i_K in component potassium_channel (microA_per_cm2).
 * ALGEBRAIC[8] is i_L in component leakage_current (microA_per_cm2).
 * ALGEBRAIC[9] is Istim in component stimulus_protocol (microA_per_cm2).
 * CONSTANTS[2] is g_Na in component sodium_channel (milliS_per_cm2).
 * CONSTANTS[10] is E_Na in component sodium_channel (millivolt).
 * STATES[1] is m in component sodium_channel_m_gate (dimensionless).
 * STATES[2] is h in component sodium_channel_h_gate (dimensionless).
 * ALGEBRAIC[1] is alpha_m in component sodium_channel_m_gate (per_millisecond).
 * ALGEBRAIC[2] is beta_m in component sodium_channel_m_gate (per_millisecond).
 * ALGEBRAIC[3] is alpha_h in component sodium_channel_h_gate (per_millisecond).
 * ALGEBRAIC[4] is beta_h in component sodium_channel_h_gate (per_millisecond).
 * CONSTANTS[3] is g_K in component potassium_channel (milliS_per_cm2).
 * CONSTANTS[11] is E_K in component potassium_channel (millivolt).
 * STATES[3] is n in component potassium_channel_n_gate (dimensionless).
 * ALGEBRAIC[6] is alpha_n in component potassium_channel_n_gate (per_millisecond).
 * ALGEBRAIC[7] is beta_n in component potassium_channel_n_gate (per_millisecond).
 * CONSTANTS[4] is g_L in component leakage_current (milliS_per_cm2).
 * CONSTANTS[12] is E_L in component leakage_current (millivolt).
 * CONSTANTS[5] is IstimStart in component stimulus_protocol (millisecond).
 * CONSTANTS[6] is IstimEnd in component stimulus_protocol (millisecond).
 * CONSTANTS[7] is IstimAmplitude in component stimulus_protocol (microA_per_cm2).
 * CONSTANTS[8] is IstimPeriod in component stimulus_protocol (millisecond).
 * CONSTANTS[9] is IstimPulseDuration in component stimulus_protocol (millisecond).
 * RATES[0] is d/dt V in component membrane (millivolt).
 * RATES[1] is d/dt m in component sodium_channel_m_gate (dimensionless).
 * RATES[2] is d/dt h in component sodium_channel_h_gate (dimensionless).
 * RATES[3] is d/dt n in component potassium_channel_n_gate (dimensionless).
 * There are a total of 3 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -75;
CONSTANTS[0] = -75;
CONSTANTS[1] = 1;
CONSTANTS[2] = 120;
STATES[1] = 0.05;
STATES[2] = 0.6;
CONSTANTS[3] = 36;
STATES[3] = 0.325;
CONSTANTS[4] = 0.3;
CONSTANTS[5] = 50;
CONSTANTS[6] = 50000;
CONSTANTS[7] = 20;
CONSTANTS[8] = 200;
CONSTANTS[9] = 0.5;
CONSTANTS[10] = CONSTANTS[0]+115.000;
CONSTANTS[11] = CONSTANTS[0] - 12.0000;
CONSTANTS[12] = CONSTANTS[0]+10.6130;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[3] = 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[9]+ALGEBRAIC[0]+ALGEBRAIC[5]+ALGEBRAIC[8])/CONSTANTS[1];
resid[1] = RATES[1] -  ALGEBRAIC[1]*(1.00000 - STATES[1]) -  ALGEBRAIC[2]*STATES[1];
resid[2] = RATES[2] -  ALGEBRAIC[3]*(1.00000 - STATES[2]) -  ALGEBRAIC[4]*STATES[2];
resid[3] = RATES[3] -  ALGEBRAIC[6]*(1.00000 - STATES[3]) -  ALGEBRAIC[7]*STATES[3];
}
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] =  CONSTANTS[2]*pow(STATES[1], 3.00000)*STATES[2]*(STATES[0] - CONSTANTS[10]);
ALGEBRAIC[1] = ( - 0.100000*(STATES[0]+50.0000))/(exp(- (STATES[0]+50.0000)/10.0000) - 1.00000);
ALGEBRAIC[2] =  4.00000*exp(- (STATES[0]+75.0000)/18.0000);
ALGEBRAIC[3] =  0.0700000*exp(- (STATES[0]+75.0000)/20.0000);
ALGEBRAIC[4] = 1.00000/(exp(- (STATES[0]+45.0000)/10.0000)+1.00000);
ALGEBRAIC[5] =  CONSTANTS[3]*pow(STATES[3], 4.00000)*(STATES[0] - CONSTANTS[11]);
ALGEBRAIC[6] = ( - 0.0100000*(STATES[0]+65.0000))/(exp(- (STATES[0]+65.0000)/10.0000) - 1.00000);
ALGEBRAIC[7] =  0.125000*exp((STATES[0]+75.0000)/80.0000);
ALGEBRAIC[8] =  CONSTANTS[4]*(STATES[0] - CONSTANTS[12]);
ALGEBRAIC[9] = (CONDVAR[0]>=0.00000&&CONDVAR[1]<=0.00000&&CONDVAR[2]<=0.00000 ? CONSTANTS[7] : 0.00000);
}
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 - CONSTANTS[5];
CONDVAR[1] = VOI - CONSTANTS[6];
CONDVAR[2] = ((VOI - CONSTANTS[5]) -  floor((VOI - CONSTANTS[5])/CONSTANTS[8])*CONSTANTS[8]) - CONSTANTS[9];
}