/* There are a total of 14 entries in the algebraic variable array. There are a total of 7 entries in each of the rate and state variable arrays. There are a total of 24 entries in the constant variable array. */ /* * VOI is time in component environment (second). * ALGEBRAIC[0] is Vm in component membrane (millivolt). * CONSTANTS[0] is Cm in component membrane (microfarad). * ALGEBRAIC[11] is I_b in component I_b (nanoampere). * ALGEBRAIC[2] is I_Kir in component I_Kir (nanoampere). * ALGEBRAIC[9] is I_Shkr in component I_Shkr (nanoampere). * ALGEBRAIC[13] is I_stim in component I_stim (nanoampere). * STATES[0] is VmReal in component membrane (millivolt). * CONSTANTS[1] is GKir in component I_Kir (microsiemens). * CONSTANTS[2] is aKir in component I_Kir (dimensionless). * CONSTANTS[3] is bKir in component I_Kir (dimensionless). * CONSTANTS[23] is EK in component I_Kir (millivolt). * ALGEBRAIC[1] is OKir in component I_Kir (dimensionless). * CONSTANTS[4] is R in component model_parameters (millijoule_per_kelvin_mole). * CONSTANTS[5] is T in component model_parameters (kelvin). * CONSTANTS[6] is F in component model_parameters (coulomb_per_mole). * CONSTANTS[7] is Ko in component model_parameters (millimolar). * CONSTANTS[8] is Ki in component model_parameters (millimolar). * CONSTANTS[9] is PShkr in component I_Shkr (microlitre_per_second). * STATES[1] is C0ShkrReal in component I_Shkr (dimensionless). * STATES[2] is C1ShkrReal in component I_Shkr (dimensionless). * STATES[3] is C2ShkrReal in component I_Shkr (dimensionless). * STATES[4] is C3ShkrReal in component I_Shkr (dimensionless). * STATES[5] is C4ShkrReal in component I_Shkr (dimensionless). * STATES[6] is OShkrReal in component I_Shkr (dimensionless). * ALGEBRAIC[3] is C0Shkr in component I_Shkr (dimensionless). * ALGEBRAIC[4] is C1Shkr in component I_Shkr (dimensionless). * ALGEBRAIC[5] is C2Shkr in component I_Shkr (dimensionless). * ALGEBRAIC[6] is C3Shkr in component I_Shkr (dimensionless). * ALGEBRAIC[7] is C4Shkr in component I_Shkr (dimensionless). * ALGEBRAIC[8] is OShkr in component I_Shkr (dimensionless). * ALGEBRAIC[10] is kv in component I_Shkr (first_order_rate_constant). * ALGEBRAIC[12] is k_v in component I_Shkr (first_order_rate_constant). * CONSTANTS[10] is kv0 in component I_Shkr (first_order_rate_constant). * CONSTANTS[11] is zv in component I_Shkr (dimensionless). * CONSTANTS[12] is k_v0 in component I_Shkr (first_order_rate_constant). * CONSTANTS[13] is z_v in component I_Shkr (dimensionless). * CONSTANTS[14] is ko in component I_Shkr (first_order_rate_constant). * CONSTANTS[15] is k_o in component I_Shkr (first_order_rate_constant). * CONSTANTS[16] is Gb in component I_b (microsiemens). * CONSTANTS[17] is Eb in component I_b (millivolt). * CONSTANTS[18] is stim_start in component I_stim (second). * CONSTANTS[19] is stim_end in component I_stim (second). * CONSTANTS[20] is stim_period in component I_stim (second). * CONSTANTS[21] is stim_duration in component I_stim (second). * CONSTANTS[22] is stim_amplitude in component I_stim (nanoampere). * RATES[0] is d/dt VmReal in component membrane (millivolt). * RATES[1] is d/dt C0ShkrReal in component I_Shkr (dimensionless). * RATES[2] is d/dt C1ShkrReal in component I_Shkr (dimensionless). * RATES[3] is d/dt C2ShkrReal in component I_Shkr (dimensionless). * RATES[4] is d/dt C3ShkrReal in component I_Shkr (dimensionless). * RATES[5] is d/dt C4ShkrReal in component I_Shkr (dimensionless). * RATES[6] is d/dt OShkrReal in component I_Shkr (dimensionless). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 4.5e-6; STATES[0] = -58.00; CONSTANTS[1] = 1e-3; CONSTANTS[2] = 0.94; CONSTANTS[3] = 1.26; CONSTANTS[4] = 8310; CONSTANTS[5] = 295; CONSTANTS[6] = 9.65e4; CONSTANTS[7] = 5; CONSTANTS[8] = 140; CONSTANTS[9] = 5.4e-9; STATES[1] = 9.11e-1; STATES[2] = 8.57e-2; STATES[3] = 3.02e-3; STATES[4] = 4.74e-5; STATES[5] = 2.79e-7; STATES[6] = 0; CONSTANTS[10] = 30; CONSTANTS[11] = 1.28; CONSTANTS[12] = 2; CONSTANTS[13] = -1.53; CONSTANTS[14] = 77; CONSTANTS[15] = 18; CONSTANTS[16] = 6.9e-6; CONSTANTS[17] = 0; CONSTANTS[18] = 0.1; CONSTANTS[19] = 10; CONSTANTS[20] = 1; CONSTANTS[21] = 0.001; CONSTANTS[22] = 0.1; CONSTANTS[23] = (( CONSTANTS[4]*CONSTANTS[5])/CONSTANTS[6])*log(CONSTANTS[7]/CONSTANTS[8]); } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[7] = (STATES[5]<0.00000 ? 0.00000 : STATES[5]>1.00000 ? 1.00000 : STATES[5]); ALGEBRAIC[8] = (STATES[6]<0.00000 ? 0.00000 : STATES[6]>1.00000 ? 1.00000 : STATES[6]); RATES[6] = CONSTANTS[14]*ALGEBRAIC[7] - CONSTANTS[15]*ALGEBRAIC[8]; ALGEBRAIC[3] = (STATES[1]<0.00000 ? 0.00000 : STATES[1]>1.00000 ? 1.00000 : STATES[1]); ALGEBRAIC[4] = (STATES[2]<0.00000 ? 0.00000 : STATES[2]>1.00000 ? 1.00000 : STATES[2]); ALGEBRAIC[0] = (fabs(STATES[0])<1.00000e-07 ? 1.00000e-07 : STATES[0]); ALGEBRAIC[10] = CONSTANTS[10]*exp(( ALGEBRAIC[0]*CONSTANTS[11]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5])); ALGEBRAIC[12] = CONSTANTS[12]*exp(( ALGEBRAIC[0]*CONSTANTS[13]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5])); RATES[1] = ALGEBRAIC[12]*ALGEBRAIC[4] - 4.00000*ALGEBRAIC[10]*ALGEBRAIC[3]; ALGEBRAIC[5] = (STATES[3]<0.00000 ? 0.00000 : STATES[3]>1.00000 ? 1.00000 : STATES[3]); RATES[2] = ( 2.00000*ALGEBRAIC[12]*ALGEBRAIC[5]+ 4.00000*ALGEBRAIC[10]*ALGEBRAIC[3]) - ( 3.00000*ALGEBRAIC[10]+ALGEBRAIC[12])*ALGEBRAIC[4]; ALGEBRAIC[6] = (STATES[4]<0.00000 ? 0.00000 : STATES[4]>1.00000 ? 1.00000 : STATES[4]); RATES[3] = ( 3.00000*ALGEBRAIC[12]*ALGEBRAIC[6]+ 3.00000*ALGEBRAIC[10]*ALGEBRAIC[4]) - ( 2.00000*ALGEBRAIC[10]+ 2.00000*ALGEBRAIC[12])*ALGEBRAIC[5]; RATES[4] = ( 4.00000*ALGEBRAIC[12]*ALGEBRAIC[7]+ 2.00000*ALGEBRAIC[10]*ALGEBRAIC[5]) - (ALGEBRAIC[10]+ 3.00000*ALGEBRAIC[12])*ALGEBRAIC[6]; RATES[5] = ( CONSTANTS[15]*ALGEBRAIC[8]+ ALGEBRAIC[10]*ALGEBRAIC[6]) - (CONSTANTS[14]+ 4.00000*ALGEBRAIC[12])*ALGEBRAIC[7]; ALGEBRAIC[11] = CONSTANTS[16]*(ALGEBRAIC[0] - CONSTANTS[17]); ALGEBRAIC[1] = 1.00000/(CONSTANTS[2]+exp(( CONSTANTS[3]*(ALGEBRAIC[0] - CONSTANTS[23])*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]))); ALGEBRAIC[2] = CONSTANTS[1]*ALGEBRAIC[1]* pow(( CONSTANTS[7]*0.00100000), 1.0 / 2)*(ALGEBRAIC[0] - CONSTANTS[23]); ALGEBRAIC[9] = ( (( CONSTANTS[9]*ALGEBRAIC[8]*ALGEBRAIC[0]*pow(CONSTANTS[6], 2.00000))/( CONSTANTS[4]*CONSTANTS[5]))*(CONSTANTS[8] - CONSTANTS[7]*exp(( - ALGEBRAIC[0]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]))))/(1.00000 - exp(( - ALGEBRAIC[0]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]))); ALGEBRAIC[13] = (VOI>=CONSTANTS[18]&&(VOI<=CONSTANTS[19]&&(VOI - CONSTANTS[18]) - floor((VOI - CONSTANTS[18])/CONSTANTS[20])*CONSTANTS[20]<=CONSTANTS[21]) ? CONSTANTS[22] : 0.00000); RATES[0] = - ((ALGEBRAIC[2]+ALGEBRAIC[9]+ALGEBRAIC[11]) - ALGEBRAIC[13])/CONSTANTS[0]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[7] = (STATES[5]<0.00000 ? 0.00000 : STATES[5]>1.00000 ? 1.00000 : STATES[5]); ALGEBRAIC[8] = (STATES[6]<0.00000 ? 0.00000 : STATES[6]>1.00000 ? 1.00000 : STATES[6]); ALGEBRAIC[3] = (STATES[1]<0.00000 ? 0.00000 : STATES[1]>1.00000 ? 1.00000 : STATES[1]); ALGEBRAIC[4] = (STATES[2]<0.00000 ? 0.00000 : STATES[2]>1.00000 ? 1.00000 : STATES[2]); ALGEBRAIC[0] = (fabs(STATES[0])<1.00000e-07 ? 1.00000e-07 : STATES[0]); ALGEBRAIC[10] = CONSTANTS[10]*exp(( ALGEBRAIC[0]*CONSTANTS[11]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5])); ALGEBRAIC[12] = CONSTANTS[12]*exp(( ALGEBRAIC[0]*CONSTANTS[13]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5])); ALGEBRAIC[5] = (STATES[3]<0.00000 ? 0.00000 : STATES[3]>1.00000 ? 1.00000 : STATES[3]); ALGEBRAIC[6] = (STATES[4]<0.00000 ? 0.00000 : STATES[4]>1.00000 ? 1.00000 : STATES[4]); ALGEBRAIC[11] = CONSTANTS[16]*(ALGEBRAIC[0] - CONSTANTS[17]); ALGEBRAIC[1] = 1.00000/(CONSTANTS[2]+exp(( CONSTANTS[3]*(ALGEBRAIC[0] - CONSTANTS[23])*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]))); ALGEBRAIC[2] = CONSTANTS[1]*ALGEBRAIC[1]* pow(( CONSTANTS[7]*0.00100000), 1.0 / 2)*(ALGEBRAIC[0] - CONSTANTS[23]); ALGEBRAIC[9] = ( (( CONSTANTS[9]*ALGEBRAIC[8]*ALGEBRAIC[0]*pow(CONSTANTS[6], 2.00000))/( CONSTANTS[4]*CONSTANTS[5]))*(CONSTANTS[8] - CONSTANTS[7]*exp(( - ALGEBRAIC[0]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]))))/(1.00000 - exp(( - ALGEBRAIC[0]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]))); ALGEBRAIC[13] = (VOI>=CONSTANTS[18]&&(VOI<=CONSTANTS[19]&&(VOI - CONSTANTS[18]) - floor((VOI - CONSTANTS[18])/CONSTANTS[20])*CONSTANTS[20]<=CONSTANTS[21]) ? CONSTANTS[22] : 0.00000); }