Generated Code

The following is c code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

/*
   There are a total of 4 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 15 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (hour).
 * ALGEBRAIC[0] is Qv in component v (per_second).
 * STATES[0] is Vv in component v (mV).
 * CONSTANTS[0] is tau_v in component v (second).
 * CONSTANTS[1] is v_vm in component v (mV_second).
 * ALGEBRAIC[1] is Qm in component m (per_second).
 * CONSTANTS[2] is Qmax in component model_parameters (per_second).
 * ALGEBRAIC[3] is D in component D (mV).
 * CONSTANTS[3] is theta in component model_parameters (mV).
 * CONSTANTS[4] is sigma in component model_parameters (mV).
 * STATES[1] is Vm in component m (mV).
 * CONSTANTS[5] is tau_m in component m (second).
 * CONSTANTS[6] is v_mv in component m (mV_second).
 * CONSTANTS[7] is A in component m (mV).
 * STATES[2] is H in component H (nM).
 * CONSTANTS[8] is chi in component H (hour).
 * CONSTANTS[9] is mu in component H (nM_second).
 * ALGEBRAIC[2] is C in component D (dimensionless).
 * CONSTANTS[10] is c0 in component D (dimensionless).
 * CONSTANTS[14] is omega in component D (per_hour).
 * CONSTANTS[11] is alpha in component D (hour).
 * CONSTANTS[12] is v_vc in component D (mV).
 * CONSTANTS[13] is v_vh in component D (mV_per_nM).
 * RATES[0] is d/dt Vv in component v (mV).
 * RATES[1] is d/dt Vm in component m (mV).
 * RATES[2] is d/dt H in component H (nM).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = -6.0;
CONSTANTS[0] = 10.0;
CONSTANTS[1] = -1.9;
CONSTANTS[2] = 100.0;
CONSTANTS[3] = 10.0;
CONSTANTS[4] = 3.0;
STATES[1] = 0.0;
CONSTANTS[5] = 10.0;
CONSTANTS[6] = -1.9;
CONSTANTS[7] = 1.0;
STATES[2] = 15.0;
CONSTANTS[8] = 11.0;
CONSTANTS[9] = 3.6;
CONSTANTS[10] = 1.0;
CONSTANTS[11] = 16.0;
CONSTANTS[12] = -3.2;
CONSTANTS[13] = 0.19;
CONSTANTS[14] = ( 2.00000* 3.14159265358979)/24.0000;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = CONSTANTS[2]/(1.00000+exp(- (STATES[0] - CONSTANTS[3])/CONSTANTS[4]));
RATES[1] = ((CONSTANTS[7]+ CONSTANTS[6]*ALGEBRAIC[0]) - STATES[1])/(CONSTANTS[5]/3600.00);
ALGEBRAIC[1] = CONSTANTS[2]/(1.00000+exp(- (STATES[1] - CONSTANTS[3])/CONSTANTS[4]));
RATES[2] = ( CONSTANTS[9]*ALGEBRAIC[1] - STATES[2])/CONSTANTS[8];
ALGEBRAIC[2] = CONSTANTS[10]+cos( CONSTANTS[14]*(VOI - CONSTANTS[11]));
ALGEBRAIC[3] =  CONSTANTS[12]*ALGEBRAIC[2]+ CONSTANTS[13]*STATES[2];
RATES[0] = (( CONSTANTS[1]*ALGEBRAIC[1]+ALGEBRAIC[3]) - STATES[0])/(CONSTANTS[0]/3600.00);
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = CONSTANTS[2]/(1.00000+exp(- (STATES[0] - CONSTANTS[3])/CONSTANTS[4]));
ALGEBRAIC[1] = CONSTANTS[2]/(1.00000+exp(- (STATES[1] - CONSTANTS[3])/CONSTANTS[4]));
ALGEBRAIC[2] = CONSTANTS[10]+cos( CONSTANTS[14]*(VOI - CONSTANTS[11]));
ALGEBRAIC[3] =  CONSTANTS[12]*ALGEBRAIC[2]+ CONSTANTS[13]*STATES[2];
}