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 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 14 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (millisecond).
 * STATES[0] is V in component V (millivolt).
 * CONSTANTS[0] is C in component V (microF_per_cm2).
 * CONSTANTS[1] is i_app in component V (microA_per_cm2).
 * ALGEBRAIC[0] is i_L in component i_L (microA_per_cm2).
 * ALGEBRAIC[1] is i_Ca in component i_Ca (microA_per_cm2).
 * ALGEBRAIC[4] is i_K in component i_K (microA_per_cm2).
 * CONSTANTS[2] is g_L in component i_L (milliS_per_cm2).
 * CONSTANTS[3] is E_L in component i_L (millivolt).
 * CONSTANTS[4] is E_Ca in component i_Ca (millivolt).
 * CONSTANTS[5] is g_Ca in component i_Ca (milliS_per_cm2).
 * STATES[1] is m in component i_Ca_m_gate (dimensionless).
 * ALGEBRAIC[2] is m_infinity in component i_Ca_m_gate (dimensionless).
 * ALGEBRAIC[3] is lambda_m in component i_Ca_m_gate (per_millisecond).
 * CONSTANTS[6] is lambda_m_bar in component i_Ca_m_gate (per_millisecond).
 * CONSTANTS[7] is V1 in component i_Ca_m_gate (millivolt).
 * CONSTANTS[8] is V2 in component i_Ca_m_gate (millivolt).
 * CONSTANTS[9] is E_K in component i_K (millivolt).
 * CONSTANTS[10] is g_K in component i_K (milliS_per_cm2).
 * STATES[2] is n in component i_K_n_gate (dimensionless).
 * ALGEBRAIC[5] is n_infinity in component i_K_n_gate (dimensionless).
 * ALGEBRAIC[6] is lambda_n in component i_K_n_gate (per_millisecond).
 * CONSTANTS[11] is lambda_n_bar in component i_K_n_gate (per_millisecond).
 * CONSTANTS[12] is V3 in component i_K_n_gate (millivolt).
 * CONSTANTS[13] is V4 in component i_K_n_gate (millivolt).
 * RATES[0] is d/dt V in component V (millivolt).
 * RATES[1] is d/dt m in component i_Ca_m_gate (dimensionless).
 * RATES[2] is d/dt n in component i_K_n_gate (dimensionless).
 * There are a total of 0 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -50;
CONSTANTS[0] = 20.0;
CONSTANTS[1] = 540.0;
CONSTANTS[2] = 2.0;
CONSTANTS[3] = -50.00;
CONSTANTS[4] = 100.0;
CONSTANTS[5] = 4.0;
STATES[1] = 0.1;
CONSTANTS[6] = 1.0;
CONSTANTS[7] = 0.0;
CONSTANTS[8] = 15.0;
CONSTANTS[9] = -70.0;
CONSTANTS[10] = 8.0;
STATES[2] = 0.1;
CONSTANTS[11] = 0.1;
CONSTANTS[12] = 10.0;
CONSTANTS[13] = 10.0;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
RATES[2] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] - (CONSTANTS[1] - (ALGEBRAIC[0]+ALGEBRAIC[1]+ALGEBRAIC[4]))/CONSTANTS[0];
resid[1] = RATES[1] -  ALGEBRAIC[3]*(ALGEBRAIC[2] - STATES[1]);
resid[2] = RATES[2] -  ALGEBRAIC[6]*(ALGEBRAIC[5] - STATES[2]);
}
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]*(STATES[0] - CONSTANTS[3]);
ALGEBRAIC[1] =  CONSTANTS[5]*STATES[1]*(STATES[0] - CONSTANTS[4]);
ALGEBRAIC[2] =  0.500000*(1.00000+ tanh((STATES[0] - CONSTANTS[7])/CONSTANTS[8]));
ALGEBRAIC[3] =  CONSTANTS[6]*cosh((STATES[0] - CONSTANTS[7])/( 2.00000*CONSTANTS[8]));
ALGEBRAIC[4] =  CONSTANTS[10]*STATES[2]*(STATES[0] - CONSTANTS[9]);
ALGEBRAIC[5] =  0.500000*(1.00000+ tanh((STATES[0] - CONSTANTS[12])/CONSTANTS[13]));
ALGEBRAIC[6] =  CONSTANTS[11]*cosh((STATES[0] - CONSTANTS[12])/( 2.00000*CONSTANTS[13]));
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
}