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 21 entries in the algebraic variable array.
   There are a total of 11 entries in each of the rate and state variable arrays.
   There are a total of 22 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (ms).
 * CONSTANTS[0] is R_gas_const in component parameters (millijoule_per_mole_kelvin).
 * CONSTANTS[1] is Temp in component parameters (kelvin).
 * CONSTANTS[2] is F in component parameters (coulomb_per_mole).
 * STATES[0] is V in component membrane (mV).
 * CONSTANTS[3] is Cm in component membrane (uF_per_cm2).
 * ALGEBRAIC[0] is i_app in component stimulus_protocol (uA_per_cm2).
 * ALGEBRAIC[12] is i_Na in component sodium_current (uA_per_cm2).
 * ALGEBRAIC[14] is i_K in component potassium_current (uA_per_cm2).
 * ALGEBRAIC[16] is i_leak in component leak_current (uA_per_cm2).
 * CONSTANTS[4] is IstimStart in component stimulus_protocol (ms).
 * CONSTANTS[5] is IstimEnd in component stimulus_protocol (ms).
 * CONSTANTS[6] is IstimAmplitude in component stimulus_protocol (uA_per_cm2).
 * CONSTANTS[7] is IstimPeriod in component stimulus_protocol (ms).
 * CONSTANTS[8] is IstimPulseDuration in component stimulus_protocol (ms).
 * ALGEBRAIC[10] is x_infinity in component sodium_current (dimensionless).
 * ALGEBRAIC[5] is alpha_x in component sodium_current (dimensionless).
 * ALGEBRAIC[8] is beta_x in component sodium_current (dimensionless).
 * STATES[1] is n in component potassium_current_n_gate (dimensionless).
 * ALGEBRAIC[1] is alpha_n in component potassium_current_n_gate (per_ms).
 * ALGEBRAIC[6] is beta_n in component potassium_current_n_gate (per_ms).
 * ALGEBRAIC[2] is T in component transmitter_release (uM).
 * CONSTANTS[9] is T_bar in component transmitter_release (uM).
 * STATES[2] is R in component transmitter_release (dimensionless).
 * CONSTANTS[10] is kr_plus in component transmitter_release (per_uM_per_ms).
 * CONSTANTS[11] is kr_minus in component transmitter_release (per_ms).
 * ALGEBRAIC[19] is Ca in component calcium_concentration (uM).
 * CONSTANTS[12] is Ca_ex in component calcium_concentration (uM).
 * ALGEBRAIC[9] is Ca_open in component calcium_concentration (uM).
 * CONSTANTS[13] is Dc in component calcium_concentration (um2_per_second).
 * CONSTANTS[14] is r in component calcium_concentration (nm).
 * ALGEBRAIC[7] is sigma in component calcium_concentration (uM_per_ms).
 * ALGEBRAIC[3] is i_V in component calcium_concentration (uA).
 * CONSTANTS[15] is g_Ca in component calcium_concentration (pS).
 * CONSTANTS[16] is P in component calcium_concentration (mV_per_uM).
 * ALGEBRAIC[17] is O in component O (dimensionless).
 * ALGEBRAIC[11] is alpha in component rate_constants (per_ms).
 * ALGEBRAIC[13] is alpha_ in component rate_constants (per_ms).
 * ALGEBRAIC[15] is beta in component rate_constants (per_ms).
 * ALGEBRAIC[18] is beta_ in component rate_constants (per_ms).
 * ALGEBRAIC[20] is kG_plus in component rate_constants (per_ms).
 * CONSTANTS[17] is kG_minus in component rate_constants (per_ms).
 * CONSTANTS[18] is kG2_minus in component rate_constants (per_ms).
 * CONSTANTS[19] is kG3_minus in component rate_constants (per_ms).
 * STATES[3] is a in component rate_constants (dimensionless).
 * CONSTANTS[20] is ka_plus in component rate_constants (per_uM_per_ms).
 * CONSTANTS[21] is ka_minus in component rate_constants (per_ms).
 * STATES[4] is C1 in component C1 (dimensionless).
 * STATES[5] is C2 in component C2 (dimensionless).
 * STATES[6] is C_G1 in component C_G1 (dimensionless).
 * STATES[7] is C3 in component C3 (dimensionless).
 * STATES[8] is C_G2 in component C_G2 (dimensionless).
 * STATES[9] is C4 in component C4 (dimensionless).
 * STATES[10] is C_G3 in component C_G3 (dimensionless).
 * ALGEBRAIC[4] is C_G in component O (dimensionless).
 * RATES[0] is d/dt V in component membrane (mV).
 * RATES[1] is d/dt n in component potassium_current_n_gate (dimensionless).
 * RATES[2] is d/dt R in component transmitter_release (dimensionless).
 * RATES[3] is d/dt a in component rate_constants (dimensionless).
 * RATES[4] is d/dt C1 in component C1 (dimensionless).
 * RATES[5] is d/dt C2 in component C2 (dimensionless).
 * RATES[7] is d/dt C3 in component C3 (dimensionless).
 * RATES[9] is d/dt C4 in component C4 (dimensionless).
 * RATES[6] is d/dt C_G1 in component C_G1 (dimensionless).
 * RATES[8] is d/dt C_G2 in component C_G2 (dimensionless).
 * RATES[10] is d/dt C_G3 in component C_G3 (dimensionless).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 8314.41;
CONSTANTS[1] = 310;
CONSTANTS[2] = 96485;
STATES[0] = -65;
CONSTANTS[3] = 1;
CONSTANTS[4] = 10;
CONSTANTS[5] = 50000;
CONSTANTS[6] = 40.0;
CONSTANTS[7] = 100;
CONSTANTS[8] = 1;
STATES[1] = 0;
CONSTANTS[9] = 4000.0;
STATES[2] = 0;
CONSTANTS[10] = 0.15;
CONSTANTS[11] = 2.5;
CONSTANTS[12] = 2000.0;
CONSTANTS[13] = 220;
CONSTANTS[14] = 10;
CONSTANTS[15] = 1.2;
CONSTANTS[16] = 0.006;
CONSTANTS[17] = 0.00025;
CONSTANTS[18] = 0.016;
CONSTANTS[19] = 1.024;
STATES[3] = 0;
CONSTANTS[20] = 200.0;
CONSTANTS[21] = 0.0015;
STATES[4] = 1;
STATES[5] = 0;
STATES[6] = 0;
STATES[7] = 0;
STATES[8] = 0;
STATES[9] = 0;
STATES[10] = 0;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[2] =  CONSTANTS[9]*STATES[2];
RATES[3] =  CONSTANTS[20]*ALGEBRAIC[2]*(1.00000 - STATES[3]) -  CONSTANTS[21]*STATES[3];
ALGEBRAIC[1] = ( 0.0200000*(STATES[0]+55.0000))/(1.00000 - exp(- (STATES[0]+55.0000)/10.0000));
ALGEBRAIC[6] =  0.250000*exp(- (STATES[0]+65.0000)/80.0000);
RATES[1] =  ALGEBRAIC[1]*(1.00000 - STATES[1]) -  ALGEBRAIC[6]*STATES[1];
ALGEBRAIC[0] = (VOI>=CONSTANTS[4]&&VOI<=CONSTANTS[5]&&(VOI - CONSTANTS[4]) -  floor((VOI - CONSTANTS[4])/CONSTANTS[7])*CONSTANTS[7]<=CONSTANTS[8] ? CONSTANTS[6] : 0.00000);
ALGEBRAIC[5] = ( 0.200000*(STATES[0]+40.0000))/(1.00000 -  1.00000*exp(- (STATES[0]+40.0000)/10.0000));
ALGEBRAIC[8] =  8.00000*exp(1.00000/- (STATES[0]+65.0000/18.0000));
ALGEBRAIC[10] = ALGEBRAIC[5]/(ALGEBRAIC[5]+ALGEBRAIC[8]);
ALGEBRAIC[12] =  120.000*pow(ALGEBRAIC[10], 3.00000)*(1.00000 - STATES[1])*(STATES[0] - 120.000);
ALGEBRAIC[14] = ( 36.0000*pow(STATES[1], 4.00000)*(STATES[0]+77.0000))/1.00000;
ALGEBRAIC[16] =  0.300000*(STATES[0]+54.0000);
RATES[0] = - ((ALGEBRAIC[12]+ALGEBRAIC[14]+ALGEBRAIC[16]) - ALGEBRAIC[0])/CONSTANTS[3];
ALGEBRAIC[17] = ((((((1.00000 - STATES[4]) - STATES[5]) - STATES[7]) - STATES[9]) - STATES[6]) - STATES[8]) - STATES[10];
ALGEBRAIC[11] =  0.450000*exp(STATES[0]/22.0000);
ALGEBRAIC[15] =  0.0150000*exp(- STATES[0]/14.0000);
RATES[9] = ( 2.00000*ALGEBRAIC[11]*STATES[7]+ 4.00000*ALGEBRAIC[15]*ALGEBRAIC[17]) -  STATES[9]*( 3.00000*ALGEBRAIC[15]+ALGEBRAIC[11]);
ALGEBRAIC[3] = ( (( CONSTANTS[15]*CONSTANTS[16]*2.00000*CONSTANTS[2]*STATES[0])/( CONSTANTS[0]*CONSTANTS[1]))*CONSTANTS[12])/(1.00000 - exp(( 2.00000*CONSTANTS[2]*STATES[0])/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[7] =  - 5.18200*ALGEBRAIC[3];
ALGEBRAIC[9] = ALGEBRAIC[7]/( 2.00000*CONSTANTS[13]*CONSTANTS[14]* 3.14159265358979);
ALGEBRAIC[19] =  ALGEBRAIC[17]*ALGEBRAIC[9]+0.100000;
RATES[2] =  CONSTANTS[10]*ALGEBRAIC[19]*(1.00000 - STATES[2]) -  CONSTANTS[11]*STATES[2];
ALGEBRAIC[20] = ( 3.00000*STATES[3])/(680.000+ 320.000*STATES[3]);
RATES[4] = ( ALGEBRAIC[15]*STATES[5]+ CONSTANTS[17]*STATES[6]) -  STATES[4]*( 4.00000*ALGEBRAIC[11]+ALGEBRAIC[20]);
RATES[5] = ( 4.00000*ALGEBRAIC[11]*STATES[4]+ 2.00000*ALGEBRAIC[15]*STATES[7]+ CONSTANTS[18]*STATES[8]) -  STATES[5]*(ALGEBRAIC[15]+ 3.00000*ALGEBRAIC[11]+ALGEBRAIC[20]);
RATES[7] = ( 3.00000*ALGEBRAIC[11]*STATES[5]+ 3.00000*ALGEBRAIC[15]*STATES[9]+ CONSTANTS[19]*STATES[10]) -  STATES[7]*( 2.00000*ALGEBRAIC[15]+ 2.00000*ALGEBRAIC[11]+ALGEBRAIC[20]);
ALGEBRAIC[13] = ALGEBRAIC[11]/8.00000;
ALGEBRAIC[18] =  ALGEBRAIC[15]*8.00000;
RATES[6] = ( ALGEBRAIC[18]*STATES[8]+ ALGEBRAIC[20]*STATES[4]) -  STATES[6]*( 4.00000*ALGEBRAIC[13]+CONSTANTS[17]);
RATES[8] = ( 4.00000*ALGEBRAIC[13]*STATES[6]+ 2.00000*ALGEBRAIC[18]*STATES[10]+ ALGEBRAIC[20]*STATES[5]) -  STATES[8]*(ALGEBRAIC[18]+ 3.00000*ALGEBRAIC[13]+CONSTANTS[18]);
RATES[10] = ( 3.00000*ALGEBRAIC[13]*STATES[8]+ ALGEBRAIC[20]*STATES[7]) -  STATES[10]*( 2.00000*ALGEBRAIC[18]+CONSTANTS[19]);
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[2] =  CONSTANTS[9]*STATES[2];
ALGEBRAIC[1] = ( 0.0200000*(STATES[0]+55.0000))/(1.00000 - exp(- (STATES[0]+55.0000)/10.0000));
ALGEBRAIC[6] =  0.250000*exp(- (STATES[0]+65.0000)/80.0000);
ALGEBRAIC[0] = (VOI>=CONSTANTS[4]&&VOI<=CONSTANTS[5]&&(VOI - CONSTANTS[4]) -  floor((VOI - CONSTANTS[4])/CONSTANTS[7])*CONSTANTS[7]<=CONSTANTS[8] ? CONSTANTS[6] : 0.00000);
ALGEBRAIC[5] = ( 0.200000*(STATES[0]+40.0000))/(1.00000 -  1.00000*exp(- (STATES[0]+40.0000)/10.0000));
ALGEBRAIC[8] =  8.00000*exp(1.00000/- (STATES[0]+65.0000/18.0000));
ALGEBRAIC[10] = ALGEBRAIC[5]/(ALGEBRAIC[5]+ALGEBRAIC[8]);
ALGEBRAIC[12] =  120.000*pow(ALGEBRAIC[10], 3.00000)*(1.00000 - STATES[1])*(STATES[0] - 120.000);
ALGEBRAIC[14] = ( 36.0000*pow(STATES[1], 4.00000)*(STATES[0]+77.0000))/1.00000;
ALGEBRAIC[16] =  0.300000*(STATES[0]+54.0000);
ALGEBRAIC[17] = ((((((1.00000 - STATES[4]) - STATES[5]) - STATES[7]) - STATES[9]) - STATES[6]) - STATES[8]) - STATES[10];
ALGEBRAIC[11] =  0.450000*exp(STATES[0]/22.0000);
ALGEBRAIC[15] =  0.0150000*exp(- STATES[0]/14.0000);
ALGEBRAIC[3] = ( (( CONSTANTS[15]*CONSTANTS[16]*2.00000*CONSTANTS[2]*STATES[0])/( CONSTANTS[0]*CONSTANTS[1]))*CONSTANTS[12])/(1.00000 - exp(( 2.00000*CONSTANTS[2]*STATES[0])/( CONSTANTS[0]*CONSTANTS[1])));
ALGEBRAIC[7] =  - 5.18200*ALGEBRAIC[3];
ALGEBRAIC[9] = ALGEBRAIC[7]/( 2.00000*CONSTANTS[13]*CONSTANTS[14]* 3.14159265358979);
ALGEBRAIC[19] =  ALGEBRAIC[17]*ALGEBRAIC[9]+0.100000;
ALGEBRAIC[20] = ( 3.00000*STATES[3])/(680.000+ 320.000*STATES[3]);
ALGEBRAIC[13] = ALGEBRAIC[11]/8.00000;
ALGEBRAIC[18] =  ALGEBRAIC[15]*8.00000;
ALGEBRAIC[4] = STATES[6]+STATES[8]+STATES[10];
}