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 5 entries in the algebraic variable array.
   There are a total of 1 entries in each of the rate and state variable arrays.
   There are a total of 5 entries in the constant variable array.
 */
/*
 * ALGEBRAIC[0] is V in component environment (millivolt).
 * VOI is t in component environment (millisec).
 * STATES[0] is n in component potassium_channel_n_gate (dimensionless).
 * ALGEBRAIC[2] is i_K in component potassium_channel (microA_per_cm2).
 * CONSTANTS[0] is g_K in component potassium_channel (milliS_per_cm2).
 * CONSTANTS[1] is Ki in component potassium_channel (mM).
 * CONSTANTS[2] is Ko in component potassium_channel (mM).
 * CONSTANTS[3] is RTF in component potassium_channel (millivolt).
 * CONSTANTS[4] is E_K in component potassium_channel (millivolt).
 * ALGEBRAIC[1] is K_conductance in component potassium_channel (milliS_per_cm2).
 * ALGEBRAIC[3] is alpha_n in component potassium_channel_n_gate (per_millisec).
 * ALGEBRAIC[4] is beta_n in component potassium_channel_n_gate (per_millisec).
 * RATES[0] is d/dt n in component potassium_channel_n_gate (dimensionless).
 * There are a total of 2 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 0.325;
CONSTANTS[0] = 36;
CONSTANTS[1] = 90;
CONSTANTS[2] = 3;
CONSTANTS[3] = 25;
CONSTANTS[4] =  CONSTANTS[3]*log(CONSTANTS[2]/CONSTANTS[1]);
RATES[0] = 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[3]*(1.00000 - STATES[0]) -  ALGEBRAIC[4]*STATES[0];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] =  CONSTANTS[0]*pow(STATES[0], 4.00000);
ALGEBRAIC[2] =  ALGEBRAIC[1]*(ALGEBRAIC[0] - CONSTANTS[4]);
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (CONDVAR[0]>0.00000&&CONDVAR[1]<0.00000 ? - 85.0000 : 0.00000);
ALGEBRAIC[3] = ( 0.0100000*(ALGEBRAIC[0]+10.0000))/(exp((ALGEBRAIC[0]+10.0000)/10.0000) - 1.00000);
ALGEBRAIC[4] =  0.125000*exp(ALGEBRAIC[0]/80.0000);
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - 5.00000;
CONDVAR[1] = VOI - 15.0000;
}