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 8 entries in the algebraic variable array. There are a total of 3 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). * ALGEBRAIC[1] is Istim in component stimulus_protocol (per_ms). * CONSTANTS[0] is IstimStart in component stimulus_protocol (ms). * CONSTANTS[1] is IstimEnd in component stimulus_protocol (ms). * CONSTANTS[2] is IstimAmplitude in component stimulus_protocol (per_ms). * CONSTANTS[3] is IstimPeriod in component stimulus_protocol (ms). * CONSTANTS[4] is IstimPulseDuration in component stimulus_protocol (ms). * STATES[0] is u in component membrane (dimensionless). * CONSTANTS[5] is Cm in component membrane (uF_per_cm2). * ALGEBRAIC[0] is Vm in component membrane (mV). * CONSTANTS[6] is V_0 in component membrane (mV). * CONSTANTS[7] is V_fi in component membrane (mV). * ALGEBRAIC[3] is J_fi in component fast_inward_current (per_ms). * ALGEBRAIC[5] is J_so in component slow_outward_current (per_ms). * ALGEBRAIC[7] is J_si in component slow_inward_current (per_ms). * ALGEBRAIC[2] is p in component p (dimensionless). * CONSTANTS[8] is u_c in component p (dimensionless). * ALGEBRAIC[4] is q in component q (dimensionless). * CONSTANTS[9] is u_v in component q (dimensionless). * CONSTANTS[21] is tau_d in component fast_inward_current (ms). * CONSTANTS[10] is g_fi_max in component fast_inward_current (mS_per_cm2). * STATES[1] is v in component fast_inward_current_v_gate (dimensionless). * ALGEBRAIC[6] is tau_v_minus in component fast_inward_current_v_gate (ms). * CONSTANTS[11] is tau_v1_minus in component fast_inward_current_v_gate (ms). * CONSTANTS[12] is tau_v2_minus in component fast_inward_current_v_gate (ms). * CONSTANTS[13] is tau_v_plus in component fast_inward_current_v_gate (ms). * CONSTANTS[14] is tau_0 in component slow_outward_current (ms). * CONSTANTS[15] is tau_r in component slow_outward_current (ms). * CONSTANTS[16] is tau_si in component slow_inward_current (ms). * CONSTANTS[17] is u_csi in component slow_inward_current (dimensionless). * CONSTANTS[18] is k in component slow_inward_current (dimensionless). * STATES[2] is w in component slow_inward_current_w_gate (dimensionless). * CONSTANTS[19] is tau_w_minus in component slow_inward_current_w_gate (ms). * CONSTANTS[20] is tau_w_plus in component slow_inward_current_w_gate (ms). * RATES[0] is d/dt u in component membrane (dimensionless). * RATES[1] is d/dt v in component fast_inward_current_v_gate (dimensionless). * RATES[2] is d/dt w in component slow_inward_current_w_gate (dimensionless). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 100; CONSTANTS[1] = 50000; CONSTANTS[2] = -0.2; CONSTANTS[3] = 1000; CONSTANTS[4] = 1; STATES[0] = 0; CONSTANTS[5] = 1; CONSTANTS[6] = -85; CONSTANTS[7] = 15; CONSTANTS[8] = 0.13; CONSTANTS[9] = 0; CONSTANTS[10] = 5.8; STATES[1] = 1; CONSTANTS[11] = 18.2; CONSTANTS[12] = 18.2; CONSTANTS[13] = 10; CONSTANTS[14] = 12.5; CONSTANTS[15] = 130; CONSTANTS[16] = 127; CONSTANTS[17] = 0.85; CONSTANTS[18] = 10; STATES[2] = 1; CONSTANTS[19] = 80; CONSTANTS[20] = 1020; CONSTANTS[21] = CONSTANTS[5]/CONSTANTS[10]; } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[2] = (STATES[0]<CONSTANTS[8] ? 0.00000 : 1.00000); RATES[2] = ( (1.00000 - ALGEBRAIC[2])*(1.00000 - STATES[2]))/CONSTANTS[19] - ( ALGEBRAIC[2]*STATES[2])/CONSTANTS[20]; ALGEBRAIC[4] = (STATES[0]<CONSTANTS[9] ? 0.00000 : 1.00000); ALGEBRAIC[6] = ALGEBRAIC[4]*CONSTANTS[11]+ (1.00000 - ALGEBRAIC[4])*CONSTANTS[12]; RATES[1] = ( (1.00000 - ALGEBRAIC[2])*(1.00000 - STATES[1]))/ALGEBRAIC[6] - ( ALGEBRAIC[2]*STATES[1])/CONSTANTS[13]; ALGEBRAIC[1] = (VOI>=CONSTANTS[0]&&VOI<=CONSTANTS[1]&&(VOI - CONSTANTS[0]) - floor((VOI - CONSTANTS[0])/CONSTANTS[3])*CONSTANTS[3]<=CONSTANTS[4] ? CONSTANTS[2] : 0.00000); ALGEBRAIC[3] = ( - STATES[1]*ALGEBRAIC[2]*(1.00000 - STATES[0])*(STATES[0] - CONSTANTS[8]))/CONSTANTS[21]; ALGEBRAIC[5] = ( STATES[0]*(1.00000 - ALGEBRAIC[2]))/CONSTANTS[14]+ALGEBRAIC[2]/CONSTANTS[15]; ALGEBRAIC[7] = ( - STATES[2]*(1.00000+ tanh( CONSTANTS[18]*(STATES[0] - CONSTANTS[17]))))/( 2.00000*CONSTANTS[16]); RATES[0] = - (ALGEBRAIC[3]+ALGEBRAIC[5]+ALGEBRAIC[7]+ALGEBRAIC[1]); } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[2] = (STATES[0]<CONSTANTS[8] ? 0.00000 : 1.00000); ALGEBRAIC[4] = (STATES[0]<CONSTANTS[9] ? 0.00000 : 1.00000); ALGEBRAIC[6] = ALGEBRAIC[4]*CONSTANTS[11]+ (1.00000 - ALGEBRAIC[4])*CONSTANTS[12]; ALGEBRAIC[1] = (VOI>=CONSTANTS[0]&&VOI<=CONSTANTS[1]&&(VOI - CONSTANTS[0]) - floor((VOI - CONSTANTS[0])/CONSTANTS[3])*CONSTANTS[3]<=CONSTANTS[4] ? CONSTANTS[2] : 0.00000); ALGEBRAIC[3] = ( - STATES[1]*ALGEBRAIC[2]*(1.00000 - STATES[0])*(STATES[0] - CONSTANTS[8]))/CONSTANTS[21]; ALGEBRAIC[5] = ( STATES[0]*(1.00000 - ALGEBRAIC[2]))/CONSTANTS[14]+ALGEBRAIC[2]/CONSTANTS[15]; ALGEBRAIC[7] = ( - STATES[2]*(1.00000+ tanh( CONSTANTS[18]*(STATES[0] - CONSTANTS[17]))))/( 2.00000*CONSTANTS[16]); ALGEBRAIC[0] = CONSTANTS[6]+ STATES[0]*(CONSTANTS[7] - CONSTANTS[6]); }