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 16 entries in the algebraic variable array.
   There are a total of 5 entries in each of the rate and state variable arrays.
   There are a total of 16 entries in the constant variable array.
 */
/*
 * CONSTANTS[0] is T in component parameters (kelvin).
 * CONSTANTS[1] is K in component parameters_propagation (per_ms).
 * CONSTANTS[2] is V_initial in component initial_conditions (mV).
 * VOI is time in component time (ms).
 * ALGEBRAIC[6] is INa in component INa (uA_per_cmsq).
 * ALGEBRAIC[11] is IK in component IK (uA_per_cmsq).
 * ALGEBRAIC[13] is Ileak in component Ileak (uA_per_cmsq).
 * ALGEBRAIC[14] is Ii in component propagated_AP (uA_per_cmsq).
 * ALGEBRAIC[0] is Im in component propagated_AP (uA_per_cmsq).
 * ALGEBRAIC[15] is I in component propagated_AP (uA_per_cmsq).
 * ALGEBRAIC[12] is g in component propagated_AP (mS_per_cmsq).
 * ALGEBRAIC[10] is gK in component IK (mS_per_cmsq).
 * ALGEBRAIC[1] is gNa in component INa (mS_per_cmsq).
 * STATES[0] is V in component propagated_AP (mV).
 * ALGEBRAIC[2] is minus_V in component propagated_AP (mV).
 * STATES[2] is X in component hh_gating_variable (dimensionless).
 * STATES[3] is X in component hh_gating_variable (dimensionless).
 * STATES[4] is X in component hh_gating_variable (dimensionless).
 * CONSTANTS[3] is n_initial in component initial_conditions (dimensionless).
 * CONSTANTS[4] is m_initial in component initial_conditions (dimensionless).
 * CONSTANTS[5] is h_initial in component initial_conditions (dimensionless).
 * CONSTANTS[6] is VNa in component parameters (mV).
 * CONSTANTS[7] is VK in component parameters (mV).
 * CONSTANTS[8] is Vleak in component parameters (mV).
 * CONSTANTS[9] is gNa_max in component parameters (mS_per_cmsq).
 * CONSTANTS[10] is gK_max in component parameters (mS_per_cmsq).
 * CONSTANTS[11] is gleak_max in component parameters (mS_per_cmsq).
 * CONSTANTS[12] is Cm in component parameters (uF_per_cmsq).
 * CONSTANTS[13] is V_initial in component initial_conditions (mV).
 * ALGEBRAIC[3] is alpha in component alpha_m (per_ms).
 * CONSTANTS[14] is phi in component temperature_factor (dimensionless).
 * ALGEBRAIC[7] is beta in component beta_m (per_ms).
 * ALGEBRAIC[4] is alpha in component alpha_h (per_ms).
 * ALGEBRAIC[8] is beta in component beta_h (per_ms).
 * ALGEBRAIC[5] is alpha in component alpha_n (per_ms).
 * CONSTANTS[15] is phi in component temperature_factor (dimensionless).
 * ALGEBRAIC[9] is beta in component beta_n (per_ms).
 * STATES[1] is d/dt V in component propagated_AP (mV).
 * RATES[1] is d^2/dtV in component propagated_AP (mV).
 * RATES[3] is d/dt X in component hh_gating_variable (dimensionless).
 * RATES[2] is d/dt X in component hh_gating_variable (dimensionless).
 * RATES[4] is d/dt X in component hh_gating_variable (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 18.5;
CONSTANTS[1] = 10.47;
CONSTANTS[2] = 0;
STATES[1] = 0.0;
CONSTANTS[3] = 0.315;
CONSTANTS[4] = 0.042;
CONSTANTS[5] = 0.608;
CONSTANTS[6] = -115.0;
CONSTANTS[7] = 12.0;
CONSTANTS[8] = -10.613;
CONSTANTS[9] = 120.0;
CONSTANTS[10] = 36.0;
CONSTANTS[11] = 0.3;
CONSTANTS[12] = 1.0;
CONSTANTS[13] = 0.0;
CONSTANTS[14] = pow(3.00000, (CONSTANTS[0] - 6.30000)/10.0000);
CONSTANTS[15] = pow(3.00000, (CONSTANTS[0] - 6.30000)/10.0000);
STATES[0] = CONSTANTS[2];
STATES[2] = CONSTANTS[5];
STATES[3] = CONSTANTS[4];
STATES[4] = CONSTANTS[3];
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[3] =  (( 0.100000*(STATES[0]+25.0000))/(exp((STATES[0]+25.0000)/10.0000) - 1.00000))*CONSTANTS[14];
ALGEBRAIC[7] =  4.00000*exp(STATES[0]/18.0000)*CONSTANTS[14];
RATES[3] =  ALGEBRAIC[3]*(1.00000 - STATES[3]) -  ALGEBRAIC[7]*STATES[3];
ALGEBRAIC[4] =  0.0700000*exp(STATES[0]/20.0000)*CONSTANTS[14];
ALGEBRAIC[8] =  (1.00000/(exp((STATES[0]+30.0000)/10.0000)+1.00000))*CONSTANTS[14];
RATES[2] =  ALGEBRAIC[4]*(1.00000 - STATES[2]) -  ALGEBRAIC[8]*STATES[2];
ALGEBRAIC[5] =  (( 0.0100000*(STATES[0]+10.0000))/(exp((STATES[0]+10.0000)/10.0000) - 1.00000))*CONSTANTS[15];
ALGEBRAIC[9] =  0.125000*exp(STATES[0]/80.0000)*CONSTANTS[15];
RATES[4] =  ALGEBRAIC[5]*(1.00000 - STATES[4]) -  ALGEBRAIC[9]*STATES[4];
ALGEBRAIC[1] =  CONSTANTS[9]*pow(STATES[3], 3.00000)*STATES[2];
ALGEBRAIC[6] =  ALGEBRAIC[1]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[10] =  CONSTANTS[10]*pow(STATES[4], 4.00000);
ALGEBRAIC[11] =  ALGEBRAIC[10]*(STATES[0] - CONSTANTS[7]);
ALGEBRAIC[13] =  CONSTANTS[11]*(STATES[0] - CONSTANTS[8]);
ALGEBRAIC[14] = ALGEBRAIC[6]+ALGEBRAIC[11]+ALGEBRAIC[13];
RATES[1] =  CONSTANTS[1]*(STATES[1]+ (1.00000/CONSTANTS[12])*ALGEBRAIC[14]);
RATES[0] = STATES[1];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[3] =  (( 0.100000*(STATES[0]+25.0000))/(exp((STATES[0]+25.0000)/10.0000) - 1.00000))*CONSTANTS[14];
ALGEBRAIC[7] =  4.00000*exp(STATES[0]/18.0000)*CONSTANTS[14];
ALGEBRAIC[4] =  0.0700000*exp(STATES[0]/20.0000)*CONSTANTS[14];
ALGEBRAIC[8] =  (1.00000/(exp((STATES[0]+30.0000)/10.0000)+1.00000))*CONSTANTS[14];
ALGEBRAIC[5] =  (( 0.0100000*(STATES[0]+10.0000))/(exp((STATES[0]+10.0000)/10.0000) - 1.00000))*CONSTANTS[15];
ALGEBRAIC[9] =  0.125000*exp(STATES[0]/80.0000)*CONSTANTS[15];
ALGEBRAIC[1] =  CONSTANTS[9]*pow(STATES[3], 3.00000)*STATES[2];
ALGEBRAIC[6] =  ALGEBRAIC[1]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[10] =  CONSTANTS[10]*pow(STATES[4], 4.00000);
ALGEBRAIC[11] =  ALGEBRAIC[10]*(STATES[0] - CONSTANTS[7]);
ALGEBRAIC[13] =  CONSTANTS[11]*(STATES[0] - CONSTANTS[8]);
ALGEBRAIC[14] = ALGEBRAIC[6]+ALGEBRAIC[11]+ALGEBRAIC[13];
ALGEBRAIC[0] =  - CONSTANTS[12]*STATES[1];
ALGEBRAIC[2] = - STATES[0];
ALGEBRAIC[12] = ALGEBRAIC[10]+ALGEBRAIC[1]+CONSTANTS[11];
ALGEBRAIC[15] =  (CONSTANTS[12]/CONSTANTS[1])*RATES[1];
}