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 6 entries in the algebraic variable array.
   There are a total of 4 entries in each of the rate and state variable arrays.
   There are a total of 29 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * STATES[1] is F_CE in component F_CE (newton).
 * ALGEBRAIC[0] is f_L_CE in component f_L_CE (newton).
 * STATES[2] is g_V_CE in component g_V_CE (dimensionless).
 * CONSTANTS[0] is a in component user_defined_constants (dimensionless).
 * CONSTANTS[1] is F_min in component f_L_CE (newton).
 * CONSTANTS[2] is F_max in component user_defined_constants (newton).
 * STATES[0] is L_CE in component L_CE (metre).
 * CONSTANTS[3] is L_CE_opt in component user_defined_constants (metre).
 * CONSTANTS[4] is W in component f_L_CE (dimensionless).
 * CONSTANTS[28] is lambda_a in component lambda_a (second_per_metre).
 * CONSTANTS[5] is V_max in component g_V_CE (metre_per_second).
 * STATES[3] is V_CE in component V_CE (dimensionless).
 * CONSTANTS[6] is A in component g_V_CE (dimensionless).
 * CONSTANTS[7] is g_max in component g_V_CE (dimensionless).
 * CONSTANTS[24] is d1 in component d1 (dimensionless).
 * CONSTANTS[26] is d2 in component d2 (dimensionless).
 * CONSTANTS[27] is d3 in component d3 (dimensionless).
 * CONSTANTS[8] is gamma in component g_V_CE (dimensionless).
 * CONSTANTS[9] is V_max in component d1 (metre_per_second).
 * CONSTANTS[10] is A in component d1 (dimensionless).
 * CONSTANTS[11] is g_max in component d1 (dimensionless).
 * CONSTANTS[12] is S in component d1 (metre_per_second).
 * CONSTANTS[13] is S in component d2 (metre_per_second).
 * CONSTANTS[14] is A in component d2 (dimensionless).
 * CONSTANTS[15] is V_max in component d2 (metre_per_second).
 * CONSTANTS[16] is gamma in component d2 (dimensionless).
 * CONSTANTS[17] is g_max in component d3 (dimensionless).
 * CONSTANTS[18] is gamma in component d3 (dimensionless).
 * ALGEBRAIC[4] is F_SEE in component F_SEE (newton).
 * CONSTANTS[19] is k_SEE in component F_SEE (newton_per_metre2).
 * ALGEBRAIC[3] is L_SEE in component L_SEE (metre).
 * CONSTANTS[20] is L_slack in component F_SEE (metre).
 * ALGEBRAIC[1] is F_PEE in component F_PEE (newton).
 * CONSTANTS[25] is k_PEE in component k_PEE (newton_per_metre2).
 * CONSTANTS[21] is L_slack in component F_PEE (metre).
 * CONSTANTS[22] is W in component k_PEE (dimensionless).
 * CONSTANTS[23] is L_CE_opt in component k_PEE (metre).
 * ALGEBRAIC[2] is L_m in component L_m (metre).
 * ALGEBRAIC[5] is F_m in component F_m (newton).
 * RATES[0] is d/dt L_CE in component L_CE (metre).
 * There are a total of 9 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 0.8;
CONSTANTS[1] = 10;
CONSTANTS[2] = 7000;
STATES[0] = 0.038;
CONSTANTS[3] = 0.093;
CONSTANTS[4] = 0.63;
CONSTANTS[5] = 0.93;
CONSTANTS[6] = 0.25;
CONSTANTS[7] = 1.5;
CONSTANTS[8] = 5.67;
CONSTANTS[9] = 0.93;
CONSTANTS[10] = 0.25;
CONSTANTS[11] = 1.5;
CONSTANTS[12] = 2;
CONSTANTS[13] = 2;
CONSTANTS[14] = 0.25;
CONSTANTS[15] = 0.93;
CONSTANTS[16] = 5.67;
CONSTANTS[17] = 1.5;
CONSTANTS[18] = 5.67;
CONSTANTS[19] = 1000000;
CONSTANTS[20] = 0.0025;
CONSTANTS[21] = 0.0025;
CONSTANTS[22] = 0.63;
CONSTANTS[23] = 0.01;
CONSTANTS[24] = ( CONSTANTS[9]*CONSTANTS[10]*(CONSTANTS[11] - 1.00000))/( CONSTANTS[12]*(CONSTANTS[10]+1.00000));
CONSTANTS[25] = CONSTANTS[2]/pow( CONSTANTS[22]*CONSTANTS[23], 2.00000);
CONSTANTS[26] = ( CONSTANTS[13]*(CONSTANTS[14]+1.00000))/( CONSTANTS[15]*CONSTANTS[14]*pow(CONSTANTS[16]+1.00000, 2.00000));
CONSTANTS[27] = ( (CONSTANTS[17] - 1.00000)*pow(CONSTANTS[18], 2.00000))/pow(CONSTANTS[18]+1.00000, 2.00000)+1.00000;
CONSTANTS[28] =  1.00000*((1.00000 - exp( - 3.82000*CONSTANTS[0]))+ CONSTANTS[0]*exp(- 3.82000));
STATES[1] = 0.1001;
STATES[2] = 0.1001;
STATES[3] = 0.1001;
RATES[0] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = STATES[1] -  ALGEBRAIC[0]*STATES[2]*CONSTANTS[0];
resid[1] = STATES[2] - (CONDVAR[0]<=0.00000 ? ( CONSTANTS[28]*CONSTANTS[5]+STATES[3])/( CONSTANTS[28]*CONSTANTS[5] - STATES[3]/CONSTANTS[6]) : CONDVAR[1]<0.00000&&CONDVAR[2]<=0.00000 ? ( CONSTANTS[7]*STATES[3]+CONSTANTS[24])/(STATES[3]+CONSTANTS[24]) : CONDVAR[3]>0.00000 ? CONSTANTS[27]+ CONSTANTS[26]*STATES[3] : 0.0/0.0);
resid[2] = STATES[3] -  1.00000*(( (1.00000/STATES[2])*( ALGEBRAIC[4]*(ALGEBRAIC[2] - STATES[0]) -  ALGEBRAIC[1]*STATES[0]))/( CONSTANTS[0]*ALGEBRAIC[0]));
resid[3] = RATES[0] -  1.00000*STATES[3];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[5] = ALGEBRAIC[4];
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = ( CONSTANTS[2]*( 1.00000*(1.00000 - STATES[0]) - pow(CONSTANTS[3], 2.00000)))/( pow(CONSTANTS[4], 2.00000)*pow(CONSTANTS[3], 2.00000));
ALGEBRAIC[1] = (CONDVAR[5]<=0.00000 ? 0.00000 :  CONSTANTS[25]*pow(STATES[0] - CONSTANTS[21], 2.00000));
ALGEBRAIC[2] = (CONDVAR[6]<=0.00000 ? 0.0380000 : CONDVAR[7]>0.00000&&CONDVAR[8]<0.00000 ? 0.0380000+ 0.00200000*(VOI - 1.00000) : 0.0400000);
ALGEBRAIC[3] = ALGEBRAIC[2] - STATES[0];
ALGEBRAIC[4] = (CONDVAR[4]<=0.00000 ? 0.00000 :  CONSTANTS[19]*pow(ALGEBRAIC[3] - CONSTANTS[20], 2.00000));
}
void
getStateInformation(double* SI)
{
SI[1] = 0.0;
SI[2] = 0.0;
SI[0] = 1.0;
SI[3] = 0.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = STATES[3] - 0.00000;
CONDVAR[1] = 0.00000 - STATES[3];
CONDVAR[2] = STATES[3] -  CONSTANTS[8]*CONSTANTS[24];
CONDVAR[3] = STATES[3] -  CONSTANTS[8]*CONSTANTS[24];
CONDVAR[4] = ALGEBRAIC[3] - CONSTANTS[20];
CONDVAR[5] = STATES[0] - CONSTANTS[21];
CONDVAR[6] = VOI - 1.00000;
CONDVAR[7] = VOI - 1.00000;
CONDVAR[8] = VOI - 2.00000;
}