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 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[18] is i_Na in component sodium_current (uA_per_cm2). * ALGEBRAIC[3] is i_K in component potassium_current (uA_per_cm2). * ALGEBRAIC[6] 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[16] is x_infinity in component sodium_current (dimensionless). * ALGEBRAIC[1] is alpha_x in component sodium_current (dimensionless). * ALGEBRAIC[2] is beta_x in component sodium_current (dimensionless). * STATES[1] is n in component potassium_current_n_gate (dimensionless). * ALGEBRAIC[4] is alpha_n in component potassium_current_n_gate (per_ms). * ALGEBRAIC[5] is beta_n in component potassium_current_n_gate (per_ms). * ALGEBRAIC[7] 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[20] is Ca in component calcium_concentration (uM). * CONSTANTS[12] is Ca_ex in component calcium_concentration (uM). * ALGEBRAIC[19] 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[17] is sigma in component calcium_concentration (uM_per_ms). * ALGEBRAIC[8] 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[14] is O in component O (dimensionless). * ALGEBRAIC[9] is alpha in component rate_constants (per_ms). * ALGEBRAIC[10] is alpha_ in component rate_constants (per_ms). * ALGEBRAIC[11] is beta in component rate_constants (per_ms). * ALGEBRAIC[12] is beta_ in component rate_constants (per_ms). * ALGEBRAIC[13] 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[15] 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). * There are a total of 3 condition variables. */ 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; RATES[0] = 0.1001; RATES[1] = 0.1001; RATES[2] = 0.1001; RATES[3] = 0.1001; RATES[4] = 0.1001; RATES[5] = 0.1001; RATES[7] = 0.1001; RATES[9] = 0.1001; RATES[6] = 0.1001; RATES[8] = 0.1001; RATES[10] = 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[18]+ALGEBRAIC[3]+ALGEBRAIC[6]) - ALGEBRAIC[0])/CONSTANTS[3]; resid[1] = RATES[1] - ALGEBRAIC[4]*(1.00000 - STATES[1]) - ALGEBRAIC[5]*STATES[1]; resid[2] = RATES[2] - CONSTANTS[10]*ALGEBRAIC[20]*(1.00000 - STATES[2]) - CONSTANTS[11]*STATES[2]; resid[3] = RATES[3] - CONSTANTS[20]*ALGEBRAIC[7]*(1.00000 - STATES[3]) - CONSTANTS[21]*STATES[3]; resid[4] = RATES[4] - ( ALGEBRAIC[11]*STATES[5]+ CONSTANTS[17]*STATES[6]) - STATES[4]*( 4.00000*ALGEBRAIC[9]+ALGEBRAIC[13]); resid[5] = RATES[5] - ( 4.00000*ALGEBRAIC[9]*STATES[4]+ 2.00000*ALGEBRAIC[11]*STATES[7]+ CONSTANTS[18]*STATES[8]) - STATES[5]*(ALGEBRAIC[11]+ 3.00000*ALGEBRAIC[9]+ALGEBRAIC[13]); resid[6] = RATES[7] - ( 3.00000*ALGEBRAIC[9]*STATES[5]+ 3.00000*ALGEBRAIC[11]*STATES[9]+ CONSTANTS[19]*STATES[10]) - STATES[7]*( 2.00000*ALGEBRAIC[11]+ 2.00000*ALGEBRAIC[9]+ALGEBRAIC[13]); resid[7] = RATES[9] - ( 2.00000*ALGEBRAIC[9]*STATES[7]+ 4.00000*ALGEBRAIC[11]*ALGEBRAIC[14]) - STATES[9]*( 3.00000*ALGEBRAIC[11]+ALGEBRAIC[9]); resid[8] = RATES[6] - ( ALGEBRAIC[12]*STATES[8]+ ALGEBRAIC[13]*STATES[4]) - STATES[6]*( 4.00000*ALGEBRAIC[10]+CONSTANTS[17]); resid[9] = RATES[8] - ( 4.00000*ALGEBRAIC[10]*STATES[6]+ 2.00000*ALGEBRAIC[12]*STATES[10]+ ALGEBRAIC[13]*STATES[5]) - STATES[8]*(ALGEBRAIC[12]+ 3.00000*ALGEBRAIC[10]+CONSTANTS[18]); resid[10] = RATES[10] - ( 3.00000*ALGEBRAIC[10]*STATES[8]+ ALGEBRAIC[13]*STATES[7]) - STATES[10]*( 2.00000*ALGEBRAIC[12]+CONSTANTS[19]); } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[15] = STATES[6]+STATES[8]+STATES[10]; } void computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = (CONDVAR[0]>=0.00000&&CONDVAR[1]<=0.00000&&CONDVAR[2]<=0.00000 ? CONSTANTS[6] : 0.00000); ALGEBRAIC[3] = ( 36.0000*pow(STATES[1], 4.00000)*(STATES[0]+77.0000))/1.00000; ALGEBRAIC[4] = ( 0.0200000*(STATES[0]+55.0000))/(1.00000 - exp(- (STATES[0]+55.0000)/10.0000)); ALGEBRAIC[5] = 0.250000*exp(- (STATES[0]+65.0000)/80.0000); ALGEBRAIC[6] = 0.300000*(STATES[0]+54.0000); ALGEBRAIC[7] = CONSTANTS[9]*STATES[2]; ALGEBRAIC[9] = 0.450000*exp(STATES[0]/22.0000); ALGEBRAIC[10] = ALGEBRAIC[9]/8.00000; ALGEBRAIC[11] = 0.0150000*exp(- STATES[0]/14.0000); ALGEBRAIC[12] = ALGEBRAIC[11]*8.00000; ALGEBRAIC[13] = ( 3.00000*STATES[3])/(680.000+ 320.000*STATES[3]); ALGEBRAIC[14] = ((((((1.00000 - STATES[4]) - STATES[5]) - STATES[7]) - STATES[9]) - STATES[6]) - STATES[8]) - STATES[10]; ALGEBRAIC[1] = ( 0.200000*(STATES[0]+40.0000))/(1.00000 - 1.00000*exp(- (STATES[0]+40.0000)/10.0000)); ALGEBRAIC[2] = 8.00000*exp(1.00000/- (STATES[0]+65.0000/18.0000)); ALGEBRAIC[16] = ALGEBRAIC[1]/(ALGEBRAIC[1]+ALGEBRAIC[2]); ALGEBRAIC[18] = 120.000*pow(ALGEBRAIC[16], 3.00000)*(1.00000 - STATES[1])*(STATES[0] - 120.000); ALGEBRAIC[8] = ( (( 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[17] = - 5.18200*ALGEBRAIC[8]; ALGEBRAIC[19] = ALGEBRAIC[17]/( 2.00000*CONSTANTS[13]*CONSTANTS[14]* 3.14159265358979); ALGEBRAIC[20] = ALGEBRAIC[14]*ALGEBRAIC[19]+0.100000; } void getStateInformation(double* SI) { SI[0] = 1.0; SI[1] = 1.0; SI[2] = 1.0; SI[3] = 1.0; SI[4] = 1.0; SI[5] = 1.0; SI[6] = 1.0; SI[7] = 1.0; SI[8] = 1.0; SI[9] = 1.0; SI[10] = 1.0; } void computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES, double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS) { CONDVAR[0] = VOI - CONSTANTS[4]; CONDVAR[1] = VOI - CONSTANTS[5]; CONDVAR[2] = ((VOI - CONSTANTS[4]) - floor((VOI - CONSTANTS[4])/CONSTANTS[7])*CONSTANTS[7]) - CONSTANTS[8]; }