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 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[10] is I_b in component I_b (nanoampere).
 * ALGEBRAIC[12] is I_Kir in component I_Kir (nanoampere).
 * ALGEBRAIC[13] is I_Shkr in component I_Shkr (nanoampere).
 * ALGEBRAIC[11] 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[2] is C0Shkr in component I_Shkr (dimensionless).
 * ALGEBRAIC[3] is C1Shkr in component I_Shkr (dimensionless).
 * ALGEBRAIC[4] is C2Shkr in component I_Shkr (dimensionless).
 * ALGEBRAIC[5] is C3Shkr in component I_Shkr (dimensionless).
 * ALGEBRAIC[6] is C4Shkr in component I_Shkr (dimensionless).
 * ALGEBRAIC[7] is OShkr in component I_Shkr (dimensionless).
 * ALGEBRAIC[8] is kv in component I_Shkr (first_order_rate_constant).
 * ALGEBRAIC[9] 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).
 * There are a total of 16 condition variables.
 */
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]);
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[6] = 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[12]+ALGEBRAIC[13]+ALGEBRAIC[10]) - ALGEBRAIC[11])/CONSTANTS[0];
resid[1] = RATES[1] -  ALGEBRAIC[9]*ALGEBRAIC[3] -  4.00000*ALGEBRAIC[8]*ALGEBRAIC[2];
resid[2] = RATES[2] - ( 2.00000*ALGEBRAIC[9]*ALGEBRAIC[4]+ 4.00000*ALGEBRAIC[8]*ALGEBRAIC[2]) -  ( 3.00000*ALGEBRAIC[8]+ALGEBRAIC[9])*ALGEBRAIC[3];
resid[3] = RATES[3] - ( 3.00000*ALGEBRAIC[9]*ALGEBRAIC[5]+ 3.00000*ALGEBRAIC[8]*ALGEBRAIC[3]) -  ( 2.00000*ALGEBRAIC[8]+ 2.00000*ALGEBRAIC[9])*ALGEBRAIC[4];
resid[4] = RATES[4] - ( 4.00000*ALGEBRAIC[9]*ALGEBRAIC[6]+ 2.00000*ALGEBRAIC[8]*ALGEBRAIC[4]) -  (ALGEBRAIC[8]+ 3.00000*ALGEBRAIC[9])*ALGEBRAIC[5];
resid[5] = RATES[5] - ( CONSTANTS[15]*ALGEBRAIC[7]+ ALGEBRAIC[8]*ALGEBRAIC[5]) -  (CONSTANTS[14]+ 4.00000*ALGEBRAIC[9])*ALGEBRAIC[6];
resid[6] = RATES[6] -  CONSTANTS[14]*ALGEBRAIC[6] -  CONSTANTS[15]*ALGEBRAIC[7];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[2] = (CONDVAR[1]<0.00000 ? 0.00000 : CONDVAR[2]>0.00000 ? 1.00000 : STATES[1]);
ALGEBRAIC[3] = (CONDVAR[3]<0.00000 ? 0.00000 : CONDVAR[4]>0.00000 ? 1.00000 : STATES[2]);
ALGEBRAIC[4] = (CONDVAR[5]<0.00000 ? 0.00000 : CONDVAR[6]>0.00000 ? 1.00000 : STATES[3]);
ALGEBRAIC[5] = (CONDVAR[7]<0.00000 ? 0.00000 : CONDVAR[8]>0.00000 ? 1.00000 : STATES[4]);
ALGEBRAIC[6] = (CONDVAR[9]<0.00000 ? 0.00000 : CONDVAR[10]>0.00000 ? 1.00000 : STATES[5]);
ALGEBRAIC[7] = (CONDVAR[11]<0.00000 ? 0.00000 : CONDVAR[12]>0.00000 ? 1.00000 : STATES[6]);
ALGEBRAIC[0] = (CONDVAR[0]<0.00000 ? 1.00000e-07 : STATES[0]);
ALGEBRAIC[8] =  CONSTANTS[10]*exp(( ALGEBRAIC[0]*CONSTANTS[11]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]));
ALGEBRAIC[9] =  CONSTANTS[12]*exp(( ALGEBRAIC[0]*CONSTANTS[13]*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5]));
ALGEBRAIC[10] =  CONSTANTS[16]*(ALGEBRAIC[0] - CONSTANTS[17]);
ALGEBRAIC[11] = (CONDVAR[13]>=0.00000&&(CONDVAR[14]<=0.00000&&CONDVAR[15]<=0.00000) ? CONSTANTS[22] : 0.00000);
ALGEBRAIC[1] = 1.00000/(CONSTANTS[2]+exp(( CONSTANTS[3]*(ALGEBRAIC[0] - CONSTANTS[23])*CONSTANTS[6])/( CONSTANTS[4]*CONSTANTS[5])));
ALGEBRAIC[12] =  CONSTANTS[1]*ALGEBRAIC[1]* pow(( CONSTANTS[7]*0.00100000), 1.0 / 2)*(ALGEBRAIC[0] - CONSTANTS[23]);
ALGEBRAIC[13] = ( (( CONSTANTS[9]*ALGEBRAIC[7]*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])));
}
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;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = fabs(STATES[0]) - 1.00000e-07;
CONDVAR[1] = STATES[1] - 0.00000;
CONDVAR[2] = STATES[1] - 1.00000;
CONDVAR[3] = STATES[2] - 0.00000;
CONDVAR[4] = STATES[2] - 1.00000;
CONDVAR[5] = STATES[3] - 0.00000;
CONDVAR[6] = STATES[3] - 1.00000;
CONDVAR[7] = STATES[4] - 0.00000;
CONDVAR[8] = STATES[4] - 1.00000;
CONDVAR[9] = STATES[5] - 0.00000;
CONDVAR[10] = STATES[5] - 1.00000;
CONDVAR[11] = STATES[6] - 0.00000;
CONDVAR[12] = STATES[6] - 1.00000;
CONDVAR[13] = VOI - CONSTANTS[18];
CONDVAR[14] = VOI - CONSTANTS[19];
CONDVAR[15] = ((VOI - CONSTANTS[18]) -  floor((VOI - CONSTANTS[18])/CONSTANTS[20])*CONSTANTS[20]) - CONSTANTS[21];
}