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 14 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 25 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (millisecond).
 * STATES[0] is V in component membrane (millivolt).
 * CONSTANTS[0] is C in component membrane (picoF).
 * CONSTANTS[1] is i_app in component membrane (picoA).
 * ALGEBRAIC[11] is i_NaP in component persistent_sodium_current (picoA).
 * ALGEBRAIC[4] is i_Na in component fast_sodium_current (picoA).
 * ALGEBRAIC[8] is i_K in component potassium_current (picoA).
 * ALGEBRAIC[9] is i_KS in component slow_potassium_current (picoA).
 * ALGEBRAIC[12] is i_L in component leakage_current (picoA).
 * ALGEBRAIC[13] is i_tonic_e in component tonic_current (picoA).
 * CONSTANTS[2] is E_Na in component fast_sodium_current (millivolt).
 * CONSTANTS[3] is g_Na in component fast_sodium_current (nanoS).
 * ALGEBRAIC[0] is m_infinity in component fast_sodium_current_m_gate (dimensionless).
 * STATES[1] is n in component fast_sodium_current_n_gate (dimensionless).
 * CONSTANTS[4] is theta_m in component fast_sodium_current_m_gate (millivolt).
 * CONSTANTS[5] is sigma_m in component fast_sodium_current_m_gate (millivolt).
 * ALGEBRAIC[1] is n_infinity in component fast_sodium_current_n_gate (dimensionless).
 * ALGEBRAIC[5] is tau_n in component fast_sodium_current_n_gate (millisecond).
 * CONSTANTS[6] is tau_n_max in component fast_sodium_current_n_gate (millisecond).
 * CONSTANTS[7] is theta_n in component fast_sodium_current_n_gate (millivolt).
 * CONSTANTS[8] is sigma_n in component fast_sodium_current_n_gate (millivolt).
 * CONSTANTS[9] is E_K in component potassium_current (millivolt).
 * CONSTANTS[10] is g_K in component potassium_current (nanoS).
 * STATES[2] is n in component potassium_current_n_gate (dimensionless).
 * ALGEBRAIC[2] is n_infinity in component potassium_current_n_gate (dimensionless).
 * ALGEBRAIC[6] is tau_n in component potassium_current_n_gate (millisecond).
 * CONSTANTS[11] is tau_n_max in component potassium_current_n_gate (millisecond).
 * CONSTANTS[12] is theta_n in component potassium_current_n_gate (millivolt).
 * CONSTANTS[13] is sigma_n in component potassium_current_n_gate (millivolt).
 * CONSTANTS[14] is g_KS in component slow_potassium_current (nanoS).
 * STATES[3] is k in component slow_potassium_current_k_gate (dimensionless).
 * ALGEBRAIC[3] is k_infinity in component slow_potassium_current_k_gate (dimensionless).
 * ALGEBRAIC[7] is tau_k in component slow_potassium_current_k_gate (millisecond).
 * CONSTANTS[15] is tau_k_max in component slow_potassium_current_k_gate (millisecond).
 * CONSTANTS[16] is theta_k in component slow_potassium_current_k_gate (millivolt).
 * CONSTANTS[17] is sigma_k in component slow_potassium_current_k_gate (millivolt).
 * CONSTANTS[18] is g_NaP in component persistent_sodium_current (nanoS).
 * ALGEBRAIC[10] is m_infinity in component persistent_sodium_current_m_gate (dimensionless).
 * CONSTANTS[19] is theta_m in component persistent_sodium_current_m_gate (millivolt).
 * CONSTANTS[20] is sigma_m in component persistent_sodium_current_m_gate (millivolt).
 * CONSTANTS[21] is g_L in component leakage_current (nanoS).
 * CONSTANTS[22] is E_L in component leakage_current (millivolt).
 * CONSTANTS[23] is g_tonic_e in component tonic_current (nanoS).
 * CONSTANTS[24] is E_syn_e in component tonic_current (millivolt).
 * RATES[0] is d/dt V in component membrane (millivolt).
 * RATES[1] is d/dt n in component fast_sodium_current_n_gate (dimensionless).
 * RATES[2] is d/dt n in component potassium_current_n_gate (dimensionless).
 * RATES[3] is d/dt k in component slow_potassium_current_k_gate (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -55.0;
CONSTANTS[0] = 21.0;
CONSTANTS[1] = 0.0;
CONSTANTS[2] = 50.0;
CONSTANTS[3] = 28.0;
STATES[1] = 0.01;
CONSTANTS[4] = -34.0;
CONSTANTS[5] = -5.0;
CONSTANTS[6] = 10.0;
CONSTANTS[7] = -29.0;
CONSTANTS[8] = -4.0;
CONSTANTS[9] = -85.0;
CONSTANTS[10] = 11.2;
STATES[2] = 0.01;
CONSTANTS[11] = 10.0;
CONSTANTS[12] = -29.0;
CONSTANTS[13] = -4.0;
CONSTANTS[14] = 5.6;
STATES[3] = 0.22;
CONSTANTS[15] = 10000.0;
CONSTANTS[16] = -38.0;
CONSTANTS[17] = -6.0;
CONSTANTS[18] = 2.8;
CONSTANTS[19] = -40.0;
CONSTANTS[20] = -6.0;
CONSTANTS[21] = 2.8;
CONSTANTS[22] = -50.0;
CONSTANTS[23] = 0.0;
CONSTANTS[24] = 0.0;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[7])/CONSTANTS[8]));
ALGEBRAIC[5] = CONSTANTS[6]/cosh((STATES[0] - CONSTANTS[7])/( 2.00000*CONSTANTS[8]));
RATES[1] = (ALGEBRAIC[1] - STATES[1])/ALGEBRAIC[5];
ALGEBRAIC[2] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[12])/CONSTANTS[13]));
ALGEBRAIC[6] = CONSTANTS[11]/cosh((STATES[0] - CONSTANTS[12])/( 2.00000*CONSTANTS[13]));
RATES[2] = (ALGEBRAIC[2] - STATES[2])/ALGEBRAIC[6];
ALGEBRAIC[3] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[16])/CONSTANTS[17]));
ALGEBRAIC[7] = CONSTANTS[15]/cosh((STATES[0] - CONSTANTS[16])/( 2.00000*CONSTANTS[17]));
RATES[3] = (ALGEBRAIC[3] - STATES[3])/ALGEBRAIC[7];
ALGEBRAIC[10] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[19])/CONSTANTS[20]));
ALGEBRAIC[11] =  CONSTANTS[18]*ALGEBRAIC[10]*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[0] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[4])/CONSTANTS[5]));
ALGEBRAIC[4] =  CONSTANTS[3]*pow(ALGEBRAIC[0], 3.00000)*(1.00000 - STATES[1])*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[8] =  CONSTANTS[10]*pow(STATES[2], 4.00000)*(STATES[0] - CONSTANTS[9]);
ALGEBRAIC[9] =  CONSTANTS[14]*STATES[3]*(STATES[0] - CONSTANTS[9]);
ALGEBRAIC[12] =  CONSTANTS[21]*(STATES[0] - CONSTANTS[22]);
ALGEBRAIC[13] =  CONSTANTS[23]*(STATES[0] - CONSTANTS[24]);
RATES[0] = (- (ALGEBRAIC[11]+ALGEBRAIC[9]+ALGEBRAIC[4]+ALGEBRAIC[8]+ALGEBRAIC[12]+ALGEBRAIC[13])+CONSTANTS[1])/CONSTANTS[0];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[7])/CONSTANTS[8]));
ALGEBRAIC[5] = CONSTANTS[6]/cosh((STATES[0] - CONSTANTS[7])/( 2.00000*CONSTANTS[8]));
ALGEBRAIC[2] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[12])/CONSTANTS[13]));
ALGEBRAIC[6] = CONSTANTS[11]/cosh((STATES[0] - CONSTANTS[12])/( 2.00000*CONSTANTS[13]));
ALGEBRAIC[3] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[16])/CONSTANTS[17]));
ALGEBRAIC[7] = CONSTANTS[15]/cosh((STATES[0] - CONSTANTS[16])/( 2.00000*CONSTANTS[17]));
ALGEBRAIC[10] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[19])/CONSTANTS[20]));
ALGEBRAIC[11] =  CONSTANTS[18]*ALGEBRAIC[10]*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[0] = 1.00000/(1.00000+exp((STATES[0] - CONSTANTS[4])/CONSTANTS[5]));
ALGEBRAIC[4] =  CONSTANTS[3]*pow(ALGEBRAIC[0], 3.00000)*(1.00000 - STATES[1])*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[8] =  CONSTANTS[10]*pow(STATES[2], 4.00000)*(STATES[0] - CONSTANTS[9]);
ALGEBRAIC[9] =  CONSTANTS[14]*STATES[3]*(STATES[0] - CONSTANTS[9]);
ALGEBRAIC[12] =  CONSTANTS[21]*(STATES[0] - CONSTANTS[22]);
ALGEBRAIC[13] =  CONSTANTS[23]*(STATES[0] - CONSTANTS[24]);
}