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 18 entries in the algebraic variable array.
   There are a total of 8 entries in each of the rate and state variable arrays.
   There are a total of 12 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (ms).
 * STATES[0] is V in component membrane (mV).
 * CONSTANTS[0] is C in component membrane (uF_per_mm2).
 * ALGEBRAIC[0] is i_Na in component sodium_current (uA_per_mm2).
 * ALGEBRAIC[8] is i_s in component slow_inward_current (uA_per_mm2).
 * ALGEBRAIC[13] is i_x1 in component time_dependent_outward_current (uA_per_mm2).
 * ALGEBRAIC[16] is i_K1 in component time_independent_outward_current (uA_per_mm2).
 * ALGEBRAIC[17] is Istim in component stimulus_protocol (uA_per_mm2).
 * CONSTANTS[1] is g_Na in component sodium_current (mS_per_mm2).
 * CONSTANTS[2] is E_Na in component sodium_current (mV).
 * CONSTANTS[3] is g_Nac in component sodium_current (mS_per_mm2).
 * STATES[1] is m in component sodium_current_m_gate (dimensionless).
 * STATES[2] is h in component sodium_current_h_gate (dimensionless).
 * STATES[3] is j in component sodium_current_j_gate (dimensionless).
 * ALGEBRAIC[1] is alpha_m in component sodium_current_m_gate (per_ms).
 * ALGEBRAIC[2] is beta_m in component sodium_current_m_gate (per_ms).
 * ALGEBRAIC[3] is alpha_h in component sodium_current_h_gate (per_ms).
 * ALGEBRAIC[4] is beta_h in component sodium_current_h_gate (per_ms).
 * ALGEBRAIC[5] is alpha_j in component sodium_current_j_gate (per_ms).
 * ALGEBRAIC[6] is beta_j in component sodium_current_j_gate (per_ms).
 * CONSTANTS[4] is g_s in component slow_inward_current (mS_per_mm2).
 * ALGEBRAIC[7] is E_s in component slow_inward_current (mV).
 * STATES[4] is Cai in component slow_inward_current (concentration_units).
 * STATES[5] is d in component slow_inward_current_d_gate (dimensionless).
 * STATES[6] is f in component slow_inward_current_f_gate (dimensionless).
 * ALGEBRAIC[9] is alpha_d in component slow_inward_current_d_gate (per_ms).
 * ALGEBRAIC[10] is beta_d in component slow_inward_current_d_gate (per_ms).
 * ALGEBRAIC[11] is alpha_f in component slow_inward_current_f_gate (per_ms).
 * ALGEBRAIC[12] is beta_f in component slow_inward_current_f_gate (per_ms).
 * STATES[7] is x1 in component time_dependent_outward_current_x1_gate (dimensionless).
 * CONSTANTS[11] is x1_open in component time_dependent_outward_current (uA_per_mm2).
 * CONSTANTS[5] is x in component time_dependent_outward_current (dimensionless).
 * ALGEBRAIC[14] is alpha_x1 in component time_dependent_outward_current_x1_gate (per_ms).
 * ALGEBRAIC[15] is beta_x1 in component time_dependent_outward_current_x1_gate (per_ms).
 * CONSTANTS[6] is IstimStart in component stimulus_protocol (ms).
 * CONSTANTS[7] is IstimEnd in component stimulus_protocol (ms).
 * CONSTANTS[8] is IstimAmplitude in component stimulus_protocol (uA_per_mm2).
 * CONSTANTS[9] is IstimPeriod in component stimulus_protocol (ms).
 * CONSTANTS[10] is IstimPulseDuration in component stimulus_protocol (ms).
 * RATES[0] is d/dt V in component membrane (mV).
 * RATES[1] is d/dt m in component sodium_current_m_gate (dimensionless).
 * RATES[2] is d/dt h in component sodium_current_h_gate (dimensionless).
 * RATES[3] is d/dt j in component sodium_current_j_gate (dimensionless).
 * RATES[4] is d/dt Cai in component slow_inward_current (concentration_units).
 * RATES[5] is d/dt d in component slow_inward_current_d_gate (dimensionless).
 * RATES[6] is d/dt f in component slow_inward_current_f_gate (dimensionless).
 * RATES[7] is d/dt x1 in component time_dependent_outward_current_x1_gate (dimensionless).
 * There are a total of 3 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -84.624;
CONSTANTS[0] = 0.01;
CONSTANTS[1] = 4e-2;
CONSTANTS[2] = 50;
CONSTANTS[3] = 3e-5;
STATES[1] = 0.011;
STATES[2] = 0.988;
STATES[3] = 0.975;
CONSTANTS[4] = 9e-4;
STATES[4] = 1e-4;
STATES[5] = 0.003;
STATES[6] = 0.994;
STATES[7] = 0.0001;
CONSTANTS[5] = 0;
CONSTANTS[6] = 10;
CONSTANTS[7] = 50000;
CONSTANTS[8] = 0.5;
CONSTANTS[9] = 1000;
CONSTANTS[10] = 1;
CONSTANTS[11] = SampleUsingPDF(&pdf_0, 0, pdf_roots_0, CONSTANTS, ALGEBRAIC);
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;
RATES[7] = 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[17] - (ALGEBRAIC[0]+ALGEBRAIC[8]+ALGEBRAIC[13]+ALGEBRAIC[16]))/CONSTANTS[0];
resid[1] = RATES[1] -  ALGEBRAIC[1]*(1.00000 - STATES[1]) -  ALGEBRAIC[2]*STATES[1];
resid[2] = RATES[2] -  ALGEBRAIC[3]*(1.00000 - STATES[2]) -  ALGEBRAIC[4]*STATES[2];
resid[3] = RATES[3] -  ALGEBRAIC[5]*(1.00000 - STATES[3]) -  ALGEBRAIC[6]*STATES[3];
resid[4] = RATES[4] - ( - 0.0100000*ALGEBRAIC[8])/1.00000+ 0.0700000*(0.000100000 - STATES[4]);
resid[5] = RATES[5] -  ALGEBRAIC[9]*(1.00000 - STATES[5]) -  ALGEBRAIC[10]*STATES[5];
resid[6] = RATES[6] -  ALGEBRAIC[11]*(1.00000 - STATES[6]) -  ALGEBRAIC[12]*STATES[6];
resid[7] = RATES[7] -  ALGEBRAIC[14]*(1.00000 - STATES[7]) -  ALGEBRAIC[15]*STATES[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[0] =  ( CONSTANTS[1]*pow(STATES[1], 3.00000)*STATES[2]*STATES[3]+CONSTANTS[3])*(STATES[0] - CONSTANTS[2]);
ALGEBRAIC[1] = ( - 1.00000*(STATES[0]+47.0000))/(exp( - 0.100000*(STATES[0]+47.0000)) - 1.00000);
ALGEBRAIC[2] =  40.0000*exp( - 0.0560000*(STATES[0]+72.0000));
ALGEBRAIC[3] =  0.126000*exp( - 0.250000*(STATES[0]+77.0000));
ALGEBRAIC[4] = 1.70000/(exp( - 0.0820000*(STATES[0]+22.5000))+1.00000);
ALGEBRAIC[5] = ( 0.0550000*exp( - 0.250000*(STATES[0]+78.0000)))/(exp( - 0.200000*(STATES[0]+78.0000))+1.00000);
ALGEBRAIC[6] = 0.300000/(exp( - 0.100000*(STATES[0]+32.0000))+1.00000);
ALGEBRAIC[7] = - 82.3000 -  13.0287*log( STATES[4]*0.00100000);
ALGEBRAIC[8] =  CONSTANTS[4]*STATES[5]*STATES[6]*(STATES[0] - ALGEBRAIC[7]);
ALGEBRAIC[9] = ( 0.0950000*exp(- (STATES[0] - 5.00000)/100.000))/(1.00000+exp(- (STATES[0] - 5.00000)/13.8900));
ALGEBRAIC[10] = ( 0.0700000*exp(- (STATES[0]+44.0000)/59.0000))/(1.00000+exp((STATES[0]+44.0000)/20.0000));
ALGEBRAIC[11] = ( 0.0120000*exp(- (STATES[0]+28.0000)/125.000))/(1.00000+exp((STATES[0]+28.0000)/6.67000));
ALGEBRAIC[12] = ( 0.00650000*exp(- (STATES[0]+30.0000)/50.0000))/(1.00000+exp(- (STATES[0]+30.0000)/5.00000));
ALGEBRAIC[13] = ( STATES[7]*CONSTANTS[11]*(exp( 0.0400000*(STATES[0]+77.0000)) - 1.00000))/exp( 0.0400000*(STATES[0]+35.0000));
ALGEBRAIC[14] = ( 0.000500000*exp((STATES[0]+50.0000)/12.1000))/(1.00000+exp((STATES[0]+50.0000)/17.5000));
ALGEBRAIC[15] = ( 0.00130000*exp(- (STATES[0]+20.0000)/16.6700))/(1.00000+exp(- (STATES[0]+20.0000)/25.0000));
ALGEBRAIC[16] =  0.00350000*(( 4.00000*(exp( 0.0400000*(STATES[0]+85.0000)) - 1.00000))/(exp( 0.0800000*(STATES[0]+53.0000))+exp( 0.0400000*(STATES[0]+53.0000)))+( 0.200000*(STATES[0]+23.0000))/(1.00000 - exp( - 0.0400000*(STATES[0]+23.0000))));
ALGEBRAIC[17] = (CONDVAR[0]>=0.00000&&CONDVAR[1]<=0.00000&&CONDVAR[2]<=0.00000 ? CONSTANTS[8] : 0.00000);
}
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;
SI[7] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - CONSTANTS[6];
CONDVAR[1] = VOI - CONSTANTS[7];
CONDVAR[2] = ((VOI - CONSTANTS[6]) -  floor((VOI - CONSTANTS[6])/CONSTANTS[9])*CONSTANTS[9]) - CONSTANTS[10];
}
double pdf_0(double bvar, double* CONSTANTS, double* ALGEBRAIC)
{
  return ( (1.00000/ pow(( 2.00000* 3.14159265358979*1.00000e-06), 1.0 / 2))*exp(- pow(bvar - 0.00800000, 2.00000)/( 2.00000*1.00000e-06)));
}
double (*pdf_roots_0[])(double bvar, double*, double*) = {};