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 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[0] 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[1] 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[4] is J_fi in component fast_inward_current (per_ms). * ALGEBRAIC[6] 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[3] 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[5] 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). * There are a total of 5 condition variables. */ 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]; RATES[0] = 0.1001; RATES[1] = 0.1001; RATES[2] = 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[4]+ALGEBRAIC[6]+ALGEBRAIC[7]+ALGEBRAIC[0]); resid[1] = RATES[1] - ( (1.00000 - ALGEBRAIC[2])*(1.00000 - STATES[1]))/ALGEBRAIC[5] - ( ALGEBRAIC[2]*STATES[1])/CONSTANTS[13]; resid[2] = RATES[2] - ( (1.00000 - ALGEBRAIC[2])*(1.00000 - STATES[2]))/CONSTANTS[19] - ( ALGEBRAIC[2]*STATES[2])/CONSTANTS[20]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[1] = CONSTANTS[6]+ STATES[0]*(CONSTANTS[7] - CONSTANTS[6]); } 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[2] : 0.00000); ALGEBRAIC[2] = (CONDVAR[3]<0.00000 ? 0.00000 : 1.00000); ALGEBRAIC[4] = ( - STATES[1]*ALGEBRAIC[2]*(1.00000 - STATES[0])*(STATES[0] - CONSTANTS[8]))/CONSTANTS[21]; ALGEBRAIC[3] = (CONDVAR[4]<0.00000 ? 0.00000 : 1.00000); ALGEBRAIC[5] = ALGEBRAIC[3]*CONSTANTS[11]+ (1.00000 - ALGEBRAIC[3])*CONSTANTS[12]; ALGEBRAIC[6] = ( 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]); } void getStateInformation(double* SI) { SI[0] = 1.0; SI[1] = 1.0; SI[2] = 1.0; } void computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES, double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS) { CONDVAR[0] = VOI - CONSTANTS[0]; CONDVAR[1] = VOI - CONSTANTS[1]; CONDVAR[2] = ((VOI - CONSTANTS[0]) - floor((VOI - CONSTANTS[0])/CONSTANTS[3])*CONSTANTS[3]) - CONSTANTS[4]; CONDVAR[3] = STATES[0] - CONSTANTS[8]; CONDVAR[4] = STATES[0] - CONSTANTS[9]; }