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 12 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 32 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (millisecond).
 * STATES[0] is V in component membrane (millivolt).
 * CONSTANTS[0] is Cm in component membrane (femtofarad).
 * ALGEBRAIC[5] is Ica in component Ica (femtoampere).
 * ALGEBRAIC[7] is Is1 in component Is1 (femtoampere).
 * ALGEBRAIC[11] is Is2 in component Is2 (femtoampere).
 * ALGEBRAIC[10] is Il in component Il (femtoampere).
 * ALGEBRAIC[8] is Ik in component Ik (femtoampere).
 * CONSTANTS[1] is gCa in component Ica (picosiemens).
 * CONSTANTS[2] is VCa in component Ica (millivolt).
 * ALGEBRAIC[0] is m_infinity in component m (dimensionless).
 * CONSTANTS[3] is vm in component m (millivolt).
 * CONSTANTS[4] is sm in component m (millivolt).
 * CONSTANTS[5] is gs1 in component Is1 (picosiemens).
 * CONSTANTS[6] is VK in component Ik (millivolt).
 * STATES[1] is s1 in component s1 (dimensionless).
 * ALGEBRAIC[1] is s1_infinity in component s1 (dimensionless).
 * CONSTANTS[7] is autos1 in component s1 (dimensionless).
 * CONSTANTS[8] is s1knot in component s1 (dimensionless).
 * CONSTANTS[9] is tau_s1 in component s1 (millisecond).
 * CONSTANTS[10] is vs1 in component s1 (millivolt).
 * CONSTANTS[11] is ss1 in component s1 (millivolt).
 * CONSTANTS[12] is gK in component Ik (picosiemens).
 * STATES[2] is n in component n (dimensionless).
 * ALGEBRAIC[2] is n_infinity in component n (dimensionless).
 * CONSTANTS[13] is tau_n_bar in component n (millisecond).
 * ALGEBRAIC[6] is tau_n in component n (millisecond).
 * CONSTANTS[14] is vn in component n (millivolt).
 * CONSTANTS[15] is sn in component n (millivolt).
 * CONSTANTS[16] is gl in component Il (picosiemens).
 * CONSTANTS[17] is Vl in component Il (millivolt).
 * ALGEBRAIC[9] is q in component Il (dimensionless).
 * STATES[3] is p in component Il (dimensionless).
 * CONSTANTS[18] is alpha_p in component Il (dimensionless).
 * CONSTANTS[19] is tau_p in component Il (millisecond).
 * CONSTANTS[30] is beta_p in component Il (dimensionless).
 * CONSTANTS[20] is p0 in component Il (dimensionless).
 * CONSTANTS[21] is noise in component Il (dimensionless).
 * ALGEBRAIC[3] is sigma in component Il (dimensionless).
 * CONSTANTS[22] is w in component Il (dimensionless).
 * CONSTANTS[31] is nstoc in component Il (dimensionless).
 * CONSTANTS[23] is delNoise in component Il (dimensionless).
 * CONSTANTS[24] is gs2 in component Is2 (picosiemens).
 * STATES[4] is s2 in component s2 (dimensionless).
 * ALGEBRAIC[4] is s2_infinity in component s2 (dimensionless).
 * CONSTANTS[25] is autos2 in component s2 (dimensionless).
 * CONSTANTS[26] is s2knot in component s2 (dimensionless).
 * CONSTANTS[27] is tau_s2 in component s2 (millisecond).
 * CONSTANTS[28] is vs2 in component s2 (millivolt).
 * CONSTANTS[29] is ss2 in component s2 (millivolt).
 * RATES[0] is d/dt V in component membrane (millivolt).
 * RATES[1] is d/dt s1 in component s1 (dimensionless).
 * RATES[2] is d/dt n in component n (dimensionless).
 * RATES[3] is d/dt p in component Il (dimensionless).
 * RATES[4] is d/dt s2 in component s2 (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -40.0;
CONSTANTS[0] = 4525.0;
CONSTANTS[1] = 280.0;
CONSTANTS[2] = 100.0;
CONSTANTS[3] = -22.0;
CONSTANTS[4] = 7.5;
CONSTANTS[5] = 22.0;
CONSTANTS[6] = -80.0;
STATES[1] = 0.9;
CONSTANTS[7] = 1;
CONSTANTS[8] = 1;
CONSTANTS[9] = 1000.0;
CONSTANTS[10] = -50.0;
CONSTANTS[11] = 5;
CONSTANTS[12] = 1300.0;
STATES[2] = 0.0;
CONSTANTS[13] = 8.25;
CONSTANTS[14] = -9.0;
CONSTANTS[15] = 10.0;
CONSTANTS[16] = 41.0;
CONSTANTS[17] = -40.0;
STATES[3] = 0.14;
CONSTANTS[18] = 1.0;
CONSTANTS[19] = 100.0;
CONSTANTS[20] = 0.2;
CONSTANTS[21] = 1;
CONSTANTS[22] = 1;
CONSTANTS[23] = 3;
CONSTANTS[24] = 16;
STATES[4] = 0.5;
CONSTANTS[25] = 1;
CONSTANTS[26] = 0.47;
CONSTANTS[27] = 30000.0;
CONSTANTS[28] = -40.0;
CONSTANTS[29] = 15;
CONSTANTS[30] =  CONSTANTS[18]*(1.00000/CONSTANTS[20] - 1.00000);
CONSTANTS[31] = 1000.00/pow(CONSTANTS[23], 2.00000);
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = 1.00000/(1.00000+exp((CONSTANTS[10] - STATES[0])/CONSTANTS[11]));
RATES[1] =  CONSTANTS[7]*((ALGEBRAIC[1] - STATES[1])/CONSTANTS[9])+ (1.00000 - CONSTANTS[7])*(CONSTANTS[8] - STATES[1]);
ALGEBRAIC[3] =  pow((( CONSTANTS[18]*(1.00000 - STATES[3])+ CONSTANTS[30]*STATES[3])/( CONSTANTS[19]*CONSTANTS[31])), 1.0 / 2);
RATES[3] = ( CONSTANTS[18]*(1.00000 - STATES[3]) -  CONSTANTS[30]*STATES[3])/CONSTANTS[19]+ CONSTANTS[21]*CONSTANTS[22]*ALGEBRAIC[3];
ALGEBRAIC[4] = 1.00000/(1.00000+exp((CONSTANTS[28] - STATES[0])/CONSTANTS[29]));
RATES[4] =  CONSTANTS[25]*((ALGEBRAIC[4] - STATES[4])/CONSTANTS[27])+ (1.00000 - CONSTANTS[25])*(CONSTANTS[26] - STATES[4]);
ALGEBRAIC[2] = 1.00000/(1.00000+exp((CONSTANTS[14] - STATES[0])/CONSTANTS[15]));
ALGEBRAIC[6] = CONSTANTS[13]/(1.00000+exp((STATES[0] - CONSTANTS[14])/CONSTANTS[15]));
RATES[2] = (ALGEBRAIC[2] - STATES[2])/ALGEBRAIC[6];
ALGEBRAIC[0] = 1.00000/(1.00000+exp((CONSTANTS[3] - STATES[0])/CONSTANTS[4]));
ALGEBRAIC[5] =  CONSTANTS[1]*ALGEBRAIC[0]*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[7] =  CONSTANTS[5]*STATES[1]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[11] =  CONSTANTS[24]*STATES[4]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[9] = (1.00000+STATES[3])/2.00000;
ALGEBRAIC[10] =  CONSTANTS[16]*ALGEBRAIC[9]*(STATES[0] - CONSTANTS[17]);
ALGEBRAIC[8] =  CONSTANTS[12]*STATES[2]*(STATES[0] - CONSTANTS[6]);
RATES[0] = - (ALGEBRAIC[5]+ALGEBRAIC[7]+ALGEBRAIC[11]+ALGEBRAIC[10]+ALGEBRAIC[8])/CONSTANTS[0];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = 1.00000/(1.00000+exp((CONSTANTS[10] - STATES[0])/CONSTANTS[11]));
ALGEBRAIC[3] =  pow((( CONSTANTS[18]*(1.00000 - STATES[3])+ CONSTANTS[30]*STATES[3])/( CONSTANTS[19]*CONSTANTS[31])), 1.0 / 2);
ALGEBRAIC[4] = 1.00000/(1.00000+exp((CONSTANTS[28] - STATES[0])/CONSTANTS[29]));
ALGEBRAIC[2] = 1.00000/(1.00000+exp((CONSTANTS[14] - STATES[0])/CONSTANTS[15]));
ALGEBRAIC[6] = CONSTANTS[13]/(1.00000+exp((STATES[0] - CONSTANTS[14])/CONSTANTS[15]));
ALGEBRAIC[0] = 1.00000/(1.00000+exp((CONSTANTS[3] - STATES[0])/CONSTANTS[4]));
ALGEBRAIC[5] =  CONSTANTS[1]*ALGEBRAIC[0]*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[7] =  CONSTANTS[5]*STATES[1]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[11] =  CONSTANTS[24]*STATES[4]*(STATES[0] - CONSTANTS[6]);
ALGEBRAIC[9] = (1.00000+STATES[3])/2.00000;
ALGEBRAIC[10] =  CONSTANTS[16]*ALGEBRAIC[9]*(STATES[0] - CONSTANTS[17]);
ALGEBRAIC[8] =  CONSTANTS[12]*STATES[2]*(STATES[0] - CONSTANTS[6]);
}