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). * STATES[0] is u in component membrane (dimensionless). * CONSTANTS[0] is Cm in component membrane (uF_per_cm2). * ALGEBRAIC[0] is Vm in component membrane (mV). * CONSTANTS[1] is V_0 in component membrane (mV). * CONSTANTS[2] 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[6] is J_si in component slow_inward_current (per_ms). * ALGEBRAIC[7] is Istim in component stimulus_protocol (per_ms). * ALGEBRAIC[1] is p in component p (dimensionless). * CONSTANTS[3] is u_c in component p (dimensionless). * ALGEBRAIC[2] is q in component q (dimensionless). * CONSTANTS[4] is u_v in component q (dimensionless). * CONSTANTS[21] is tau_d in component fast_inward_current (ms). * CONSTANTS[5] 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[4] is tau_v_minus in component fast_inward_current_v_gate (ms). * CONSTANTS[6] is tau_v1_minus in component fast_inward_current_v_gate (ms). * CONSTANTS[7] is tau_v2_minus in component fast_inward_current_v_gate (ms). * CONSTANTS[8] is tau_v_plus in component fast_inward_current_v_gate (ms). * CONSTANTS[9] is tau_0 in component slow_outward_current (ms). * CONSTANTS[10] is tau_r in component slow_outward_current (ms). * CONSTANTS[11] is tau_si in component slow_inward_current (ms). * CONSTANTS[12] is u_csi in component slow_inward_current (dimensionless). * CONSTANTS[13] is k in component slow_inward_current (dimensionless). * STATES[2] is w in component slow_inward_current_w_gate (dimensionless). * CONSTANTS[14] is tau_w_minus in component slow_inward_current_w_gate (ms). * CONSTANTS[15] is tau_w_plus in component slow_inward_current_w_gate (ms). * CONSTANTS[16] is IstimStart in component stimulus_protocol (ms). * CONSTANTS[17] is IstimEnd in component stimulus_protocol (ms). * CONSTANTS[18] is IstimAmplitude in component stimulus_protocol (per_ms). * CONSTANTS[19] is IstimPeriod in component stimulus_protocol (ms). * CONSTANTS[20] is IstimPulseDuration in component stimulus_protocol (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) { STATES[0] = 0; CONSTANTS[0] = 1; CONSTANTS[1] = -85; CONSTANTS[2] = 15; CONSTANTS[3] = 0.13; CONSTANTS[4] = 0.025; CONSTANTS[5] = 8.7; STATES[1] = 1; CONSTANTS[6] = 333; CONSTANTS[7] = 40; CONSTANTS[8] = 10; CONSTANTS[9] = 12.5; CONSTANTS[10] = 25; CONSTANTS[11] = 22.22; CONSTANTS[12] = 0.85; CONSTANTS[13] = 10; STATES[2] = 1; CONSTANTS[14] = 65; CONSTANTS[15] = 1000; CONSTANTS[16] = 10; CONSTANTS[17] = 50000; CONSTANTS[18] = -0.2; CONSTANTS[19] = 1000; CONSTANTS[20] = 1; CONSTANTS[21] = CONSTANTS[0]/CONSTANTS[5]; 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[3]+ALGEBRAIC[5]+ALGEBRAIC[6]+ALGEBRAIC[7]); resid[1] = RATES[1] - ( (1.00000 - ALGEBRAIC[1])*(1.00000 - STATES[1]))/ALGEBRAIC[4] - ( ALGEBRAIC[1]*STATES[1])/CONSTANTS[8]; resid[2] = RATES[2] - ( (1.00000 - ALGEBRAIC[1])*(1.00000 - STATES[2]))/CONSTANTS[14] - ( ALGEBRAIC[1]*STATES[2])/CONSTANTS[15]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = CONSTANTS[1]+ STATES[0]*(CONSTANTS[2] - CONSTANTS[1]); } void computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[1] = (CONDVAR[0]<0.00000 ? 0.00000 : 1.00000); ALGEBRAIC[3] = ( - STATES[1]*ALGEBRAIC[1]*(1.00000 - STATES[0])*(STATES[0] - CONSTANTS[3]))/CONSTANTS[21]; ALGEBRAIC[2] = (CONDVAR[1]<0.00000 ? 0.00000 : 1.00000); ALGEBRAIC[4] = ALGEBRAIC[2]*CONSTANTS[6]+ (1.00000 - ALGEBRAIC[2])*CONSTANTS[7]; ALGEBRAIC[5] = ( STATES[0]*(1.00000 - ALGEBRAIC[1]))/CONSTANTS[9]+ALGEBRAIC[1]/CONSTANTS[10]; ALGEBRAIC[6] = ( - STATES[2]*(1.00000+ tanh( CONSTANTS[13]*(STATES[0] - CONSTANTS[12]))))/( 2.00000*CONSTANTS[11]); ALGEBRAIC[7] = (CONDVAR[2]>=0.00000&&CONDVAR[3]<=0.00000&&CONDVAR[4]<=0.00000 ? CONSTANTS[18] : 0.00000); } 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] = STATES[0] - CONSTANTS[3]; CONDVAR[1] = STATES[0] - CONSTANTS[4]; CONDVAR[2] = VOI - CONSTANTS[16]; CONDVAR[3] = VOI - CONSTANTS[17]; CONDVAR[4] = ((VOI - CONSTANTS[16]) - floor((VOI - CONSTANTS[16])/CONSTANTS[19])*CONSTANTS[19]) - CONSTANTS[20]; }