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 7 entries in the algebraic variable array.
   There are a total of 3 entries in each of the rate and state variable arrays.
   There are a total of 16 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (millisecond).
 * STATES[0] is V in component membrane (millivolt).
 * CONSTANTS[0] is tau in component membrane (millisecond).
 * ALGEBRAIC[4] is i_K in component potassium_current (picoA).
 * ALGEBRAIC[6] is i_K_ATP in component ATP_sensitive_potassium_current (picoA).
 * ALGEBRAIC[3] is i_Ca in component calcium_current (picoA).
 * ALGEBRAIC[5] is i_s in component slow_current (picoA).
 * CONSTANTS[1] is g_Ca in component calcium_current (nanoS).
 * CONSTANTS[2] is V_Ca in component calcium_current (millivolt).
 * ALGEBRAIC[0] is m_infinity in component calcium_current_m_gate (dimensionless).
 * CONSTANTS[3] is V_m in component calcium_current_m_gate (millivolt).
 * CONSTANTS[4] is theta_m in component calcium_current_m_gate (millivolt).
 * CONSTANTS[5] is V_K in component potassium_current (millivolt).
 * CONSTANTS[6] is g_K in component potassium_current (nanoS).
 * STATES[1] is n in component potassium_current_n_gate (dimensionless).
 * ALGEBRAIC[1] is n_infinity in component potassium_current_n_gate (dimensionless).
 * CONSTANTS[7] is V_n in component potassium_current_n_gate (millivolt).
 * CONSTANTS[8] is theta_n in component potassium_current_n_gate (millivolt).
 * CONSTANTS[9] is lambda in component potassium_current_n_gate (dimensionless).
 * CONSTANTS[10] is g_s in component slow_current (nanoS).
 * STATES[2] is s in component slow_current_s_gate (dimensionless).
 * ALGEBRAIC[2] is s_infinity in component slow_current_s_gate (dimensionless).
 * CONSTANTS[11] is V_s in component slow_current_s_gate (millivolt).
 * CONSTANTS[12] is theta_s in component slow_current_s_gate (millivolt).
 * CONSTANTS[13] is tau_s in component slow_current_s_gate (millisecond).
 * CONSTANTS[14] is g_K_ATP in component ATP_sensitive_potassium_current (nanoS).
 * CONSTANTS[15] is p in component ATP_sensitive_potassium_current (dimensionless).
 * RATES[0] is d/dt V in component membrane (millivolt).
 * RATES[1] is d/dt n in component potassium_current_n_gate (dimensionless).
 * RATES[2] is d/dt s in component slow_current_s_gate (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -64.0;
CONSTANTS[0] = 20.0;
CONSTANTS[1] = 3.6;
CONSTANTS[2] = 25.0;
CONSTANTS[3] = -20.0;
CONSTANTS[4] = 12.0;
CONSTANTS[5] = -75.0;
CONSTANTS[6] = 10.0;
STATES[1] = 0.01;
CONSTANTS[7] = -17.0;
CONSTANTS[8] = 5.6;
CONSTANTS[9] = 0.9;
CONSTANTS[10] = 4.0;
STATES[2] = 0.01;
CONSTANTS[11] = -22.0;
CONSTANTS[12] = 8.0;
CONSTANTS[13] = 20000.0;
CONSTANTS[14] = 1.2;
CONSTANTS[15] = 0.5;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = 1.00000/(1.00000+exp((CONSTANTS[7] - STATES[0])/CONSTANTS[8]));
RATES[1] = ( CONSTANTS[9]*(ALGEBRAIC[1] - STATES[1]))/CONSTANTS[0];
ALGEBRAIC[2] = 1.00000/(1.00000+exp((CONSTANTS[11] - STATES[0])/CONSTANTS[12]));
RATES[2] = (ALGEBRAIC[2] - STATES[2])/CONSTANTS[13];
ALGEBRAIC[4] =  CONSTANTS[6]*STATES[1]*(STATES[0] - CONSTANTS[5]);
ALGEBRAIC[6] =  CONSTANTS[14]*CONSTANTS[15]*(STATES[0] - CONSTANTS[5]);
ALGEBRAIC[0] = 1.00000/(1.00000+exp((CONSTANTS[3] - STATES[0])/CONSTANTS[4]));
ALGEBRAIC[3] =  CONSTANTS[1]*ALGEBRAIC[0]*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[5] =  CONSTANTS[10]*STATES[2]*(STATES[0] - CONSTANTS[5]);
RATES[0] = - (ALGEBRAIC[3]+ALGEBRAIC[4]+ALGEBRAIC[6]+ALGEBRAIC[5])/CONSTANTS[0];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = 1.00000/(1.00000+exp((CONSTANTS[7] - STATES[0])/CONSTANTS[8]));
ALGEBRAIC[2] = 1.00000/(1.00000+exp((CONSTANTS[11] - STATES[0])/CONSTANTS[12]));
ALGEBRAIC[4] =  CONSTANTS[6]*STATES[1]*(STATES[0] - CONSTANTS[5]);
ALGEBRAIC[6] =  CONSTANTS[14]*CONSTANTS[15]*(STATES[0] - CONSTANTS[5]);
ALGEBRAIC[0] = 1.00000/(1.00000+exp((CONSTANTS[3] - STATES[0])/CONSTANTS[4]));
ALGEBRAIC[3] =  CONSTANTS[1]*ALGEBRAIC[0]*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[5] =  CONSTANTS[10]*STATES[2]*(STATES[0] - CONSTANTS[5]);
}