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 24 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 58 entries in the constant variable array.
 */
/*
 * VOI is t in component environment (second).
 * ALGEBRAIC[11] is Pi in component TempCDa (UnitP).
 * STATES[0] is Pi in component TempRLC (UnitP).
 * ALGEBRAIC[14] is Qo in component TempRC (UnitQ).
 * ALGEBRAIC[21] is Qvi in component TempIPump (UnitQ).
 * ALGEBRAIC[17] is Qo in component TempCDv (UnitQ).
 * ALGEBRAIC[12] is Pi in component TJoint (UnitP).
 * ALGEBRAIC[20] is Qvo in component TempIPump (UnitQ).
 * ALGEBRAIC[6] is Pi in component TJoint (UnitP).
 * ALGEBRAIC[10] is Pi in component TempCDv (UnitP).
 * ALGEBRAIC[22] is Qo in component TJoint (UnitQ).
 * CONSTANTS[0] is CVao in component ParaHeartP (UnitCV).
 * ALGEBRAIC[2] is E in component EVentricle (UnitE).
 * STATES[1] is V in component TempCDv (UnitV).
 * CONSTANTS[1] is PlvIni in component ParaHeartP (UnitP).
 * CONSTANTS[2] is VlvIni in component ParaHeartP (UnitV).
 * ALGEBRAIC[16] is Tao in component TempCDv (dimensionless).
 * CONSTANTS[3] is Vlv0 in component ParaHeartP (UnitV).
 * ALGEBRAIC[19] is Qo in component TempCDa (UnitQ).
 * CONSTANTS[4] is CVmi in component ParaHeartP (UnitCV).
 * ALGEBRAIC[5] is E in component EAtrium (UnitE).
 * STATES[2] is V in component TempCDa (UnitV).
 * CONSTANTS[5] is PlaIni in component ParaHeartP (UnitP).
 * CONSTANTS[6] is VlaIni in component ParaHeartP (UnitV).
 * ALGEBRAIC[18] is Tao in component TempCDa (dimensionless).
 * CONSTANTS[7] is Vla0 in component ParaHeartP (UnitV).
 * CONSTANTS[8] is ElvMax in component ParaHeartP (UnitE).
 * CONSTANTS[9] is ElvMin in component ParaHeartP (UnitE).
 * CONSTANTS[10] is T in component ParaHeartP (second).
 * CONSTANTS[11] is Ts1 in component ParaHeartP (dimensionless).
 * CONSTANTS[12] is Ts2 in component ParaHeartP (dimensionless).
 * ALGEBRAIC[0] is mt in component EVentricle (second).
 * ALGEBRAIC[1] is et in component EVentricle (dimensionless).
 * CONSTANTS[13] is ElaMax in component ParaHeartP (UnitE).
 * CONSTANTS[14] is ElaMin in component ParaHeartP (UnitE).
 * CONSTANTS[15] is Tpwb in component ParaHeartP (dimensionless).
 * CONSTANTS[16] is Tpww in component ParaHeartP (dimensionless).
 * ALGEBRAIC[3] is mt in component EAtrium (second).
 * ALGEBRAIC[4] is et in component EAtrium (dimensionless).
 * STATES[3] is Qo in component TempRLC (UnitQ).
 * CONSTANTS[17] is Rsas in component ParaSys (UnitR).
 * CONSTANTS[18] is Csas in component ParaSys (UnitC).
 * CONSTANTS[19] is Lsas in component ParaSys (UnitL).
 * CONSTANTS[20] is P0sas in component ParaSys (UnitP).
 * CONSTANTS[21] is Q0sas in component ParaSys (UnitQ).
 * STATES[4] is Pi in component TempRLC (UnitP).
 * ALGEBRAIC[23] is Qo in component TJoint (UnitQ).
 * ALGEBRAIC[13] is Pi in component TempR (UnitP).
 * STATES[5] is Qo in component TempRLC (UnitQ).
 * CONSTANTS[22] is Rsat in component ParaSys (UnitR).
 * CONSTANTS[23] is Csat in component ParaSys (UnitC).
 * CONSTANTS[24] is Lsat in component ParaSys (UnitL).
 * CONSTANTS[25] is P0sat in component ParaSys (UnitP).
 * CONSTANTS[26] is Q0sat in component ParaSys (UnitQ).
 * ALGEBRAIC[8] is Pi in component TempR (UnitP).
 * ALGEBRAIC[7] is Qo in component TempR (UnitQ).
 * CONSTANTS[27] is Rsar in component ParaSys (UnitR).
 * STATES[6] is Pi in component TempRC (UnitP).
 * ALGEBRAIC[9] is Qo in component TempR (UnitQ).
 * CONSTANTS[28] is Rscp in component ParaSys (UnitR).
 * CONSTANTS[29] is Rsvn in component ParaSys (UnitR).
 * CONSTANTS[30] is Csvn in component ParaSys (UnitC).
 * CONSTANTS[31] is P0svn in component ParaSys (UnitP).
 * CONSTANTS[57] is Wn in component TempIPump (UnitRPM).
 * CONSTANTS[32] is Ts2 in component ParaHeartP (dimensionless).
 * CONSTANTS[33] is T in component ParaHeartP (second).
 * CONSTANTS[34] is Kp0 in component ParaIPump (UnitKp0).
 * CONSTANTS[35] is Kp1 in component ParaIPump (UnitKp1).
 * CONSTANTS[36] is Kp2 in component ParaIPump (UnitKp2).
 * CONSTANTS[37] is Kp3 in component ParaIPump (UnitKp3).
 * CONSTANTS[38] is Kp4 in component ParaIPump (UnitKp4).
 * CONSTANTS[39] is Kp5 in component ParaIPump (UnitKp5).
 * CONSTANTS[40] is Kp6 in component ParaIPump (UnitKp6).
 * CONSTANTS[41] is W in component ParaIPump (UnitRPM).
 * ALGEBRAIC[15] is dPv in component TempIPump (UnitP).
 * CONSTANTS[42] is ElaMax in component ParaHeartP (UnitE).
 * CONSTANTS[43] is ElaMin in component ParaHeartP (UnitE).
 * CONSTANTS[44] is PlaIni in component ParaHeartP (UnitP).
 * CONSTANTS[45] is VlaIni in component ParaHeartP (UnitV).
 * CONSTANTS[46] is ElvMax in component ParaHeartP (UnitE).
 * CONSTANTS[47] is ElvMin in component ParaHeartP (UnitE).
 * CONSTANTS[48] is PlvIni in component ParaHeartP (UnitP).
 * CONSTANTS[49] is VlvIni in component ParaHeartP (UnitV).
 * CONSTANTS[50] is Tpwb in component ParaHeartP (dimensionless).
 * CONSTANTS[51] is Tpww in component ParaHeartP (dimensionless).
 * CONSTANTS[52] is Ts1 in component ParaHeartP (dimensionless).
 * CONSTANTS[53] is CVao in component ParaHeartP (UnitCV).
 * CONSTANTS[54] is CVmi in component ParaHeartP (UnitCV).
 * CONSTANTS[55] is Vlv0 in component ParaHeartP (UnitV).
 * CONSTANTS[56] is Vla0 in component ParaHeartP (UnitV).
 * RATES[1] is d/dt V in component TempCDv (UnitV).
 * RATES[2] is d/dt V in component TempCDa (UnitV).
 * RATES[0] is d/dt Pi in component TempRLC (UnitP).
 * RATES[3] is d/dt Qo in component TempRLC (UnitQ).
 * RATES[4] is d/dt Pi in component TempRLC (UnitP).
 * RATES[5] is d/dt Qo in component TempRLC (UnitQ).
 * RATES[6] is d/dt Pi in component TempRC (UnitP).
 * There are a total of 20 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 350.;
CONSTANTS[1] = 1.0;
CONSTANTS[2] = 5.0;
CONSTANTS[3] = 500;
CONSTANTS[4] = 400.;
CONSTANTS[5] = 1.0;
CONSTANTS[6] = 4.0;
CONSTANTS[7] = 20;
CONSTANTS[8] = 0.5;
CONSTANTS[9] = 0.1;
CONSTANTS[10] = 1.0;
CONSTANTS[11] = 0.3;
CONSTANTS[12] = 0.45;
CONSTANTS[13] = 0.25;
CONSTANTS[14] = 0.15;
CONSTANTS[15] = 0.92;
CONSTANTS[16] = 0.09;
CONSTANTS[17] = 0.003;
CONSTANTS[18] = 0.08;
CONSTANTS[19] = 0.000062;
CONSTANTS[20] = 100.;
CONSTANTS[21] = 0.;
CONSTANTS[22] = 0.05;
CONSTANTS[23] = 1.6;
CONSTANTS[24] = 0.0017;
CONSTANTS[25] = 100.;
CONSTANTS[26] = 0.;
CONSTANTS[27] = 0.5;
CONSTANTS[28] = 0.52;
CONSTANTS[29] = 0.075;
CONSTANTS[30] = 20.5;
CONSTANTS[31] = 0.;
CONSTANTS[32] = 0.45;
CONSTANTS[33] = 1.0;
CONSTANTS[34] = 19.51840;
CONSTANTS[35] = -3.03610e-3;
CONSTANTS[36] = -1.23045;
CONSTANTS[37] = 5.78974e-4;
CONSTANTS[38] = -5.8777e-8;
CONSTANTS[39] = -1.27539e-6;
CONSTANTS[40] = 2.04834e-10;
CONSTANTS[41] = 3600;
CONSTANTS[42] = 0.25;
CONSTANTS[43] = 0.15;
CONSTANTS[44] = 1.0;
CONSTANTS[45] = 4.0;
CONSTANTS[46] = 0.5;
CONSTANTS[47] = 0.1;
CONSTANTS[48] = 1.0;
CONSTANTS[49] = 5.0;
CONSTANTS[50] = 0.92;
CONSTANTS[51] = 0.09;
CONSTANTS[52] = 0.3;
CONSTANTS[53] = 350.;
CONSTANTS[54] = 400.;
CONSTANTS[55] = 500;
CONSTANTS[56] = 20;
CONSTANTS[57] =  1.00000*CONSTANTS[41];
STATES[0] = CONSTANTS[20];
STATES[1] = CONSTANTS[3];
STATES[2] = CONSTANTS[7];
STATES[3] = CONSTANTS[21];
STATES[4] = CONSTANTS[25];
STATES[5] = CONSTANTS[26];
STATES[6] = CONSTANTS[31];
RATES[1] = 0.1001;
RATES[2] = 0.1001;
RATES[0] = 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[1] - ALGEBRAIC[22] - ALGEBRAIC[17];
resid[1] = RATES[2] - ALGEBRAIC[14] - ALGEBRAIC[19];
resid[2] = RATES[0] - (ALGEBRAIC[17] - STATES[3])/CONSTANTS[18];
resid[3] = RATES[3] - ((STATES[0] - ALGEBRAIC[6]) -  CONSTANTS[17]*STATES[3])/CONSTANTS[19];
resid[4] = RATES[4] - (ALGEBRAIC[23] - STATES[5])/CONSTANTS[23];
resid[5] = RATES[5] - ((STATES[4] - ALGEBRAIC[13]) -  CONSTANTS[22]*STATES[5])/CONSTANTS[24];
resid[6] = RATES[6] - (ALGEBRAIC[9] - ALGEBRAIC[14])/CONSTANTS[30];
}
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[6] = STATES[4];
ALGEBRAIC[7] = STATES[5];
ALGEBRAIC[9] = ALGEBRAIC[7];
ALGEBRAIC[8] = STATES[6]+ CONSTANTS[28]*ALGEBRAIC[7];
ALGEBRAIC[13] = ALGEBRAIC[8]+ CONSTANTS[27]*STATES[5];
ALGEBRAIC[3] = VOI -  CONSTANTS[10]*floor(VOI/CONSTANTS[10]);
ALGEBRAIC[4] = (CONDVAR[14]>=0.00000&&CONDVAR[15]<=0.00000 ? 1.00000 - cos(( 2.00000*3.14159*(ALGEBRAIC[3] -  (CONSTANTS[15] - 1.00000)*CONSTANTS[10]))/( CONSTANTS[16]*CONSTANTS[10])) : CONDVAR[16]>0.00000&&CONDVAR[17]<=0.00000 ? 0.00000 : CONDVAR[18]>0.00000&&CONDVAR[19]<=0.00000 ? 1.00000 - cos(( 2.00000*3.14159*(ALGEBRAIC[3] -  CONSTANTS[15]*CONSTANTS[10]))/( CONSTANTS[16]*CONSTANTS[10])) : 0.0/0.0);
ALGEBRAIC[5] = CONSTANTS[14]+( ALGEBRAIC[4]*(CONSTANTS[13] - CONSTANTS[14]))/2.00000;
ALGEBRAIC[11] = CONSTANTS[5]+ ALGEBRAIC[5]*(STATES[2] - CONSTANTS[6]);
ALGEBRAIC[14] = (STATES[6] - ALGEBRAIC[11])/CONSTANTS[29];
ALGEBRAIC[0] = VOI -  CONSTANTS[10]*floor(VOI/CONSTANTS[10]);
ALGEBRAIC[1] = (CONDVAR[8]>=0.00000&&CONDVAR[9]<=0.00000 ? 1.00000 - cos(( 3.14159*ALGEBRAIC[0])/( CONSTANTS[11]*CONSTANTS[10])) : CONDVAR[10]>0.00000&&CONDVAR[11]<=0.00000 ? 1.00000+cos(( 3.14159*(ALGEBRAIC[0] -  CONSTANTS[11]*CONSTANTS[10]))/( (CONSTANTS[12] - CONSTANTS[11])*CONSTANTS[10])) : CONDVAR[12]>0.00000&&CONDVAR[13]<0.00000 ? 0.00000 : 0.0/0.0);
ALGEBRAIC[2] = CONSTANTS[9]+( ALGEBRAIC[1]*(CONSTANTS[8] - CONSTANTS[9]))/2.00000;
ALGEBRAIC[10] = CONSTANTS[1]+ ALGEBRAIC[2]*(STATES[1] - CONSTANTS[2]);
ALGEBRAIC[16] = (CONDVAR[0]>=0.00000 ? 1.00000 : CONDVAR[1]<0.00000 ? 0.00000 : 0.0/0.0);
ALGEBRAIC[17] = (CONDVAR[2]>=0.00000 ?  CONSTANTS[0]*ALGEBRAIC[16]*pow(fabs(ALGEBRAIC[10] - STATES[0]), 0.500000) : CONDVAR[3]<0.00000 ?  -1.00000*CONSTANTS[0]*ALGEBRAIC[16]*pow(fabs(STATES[0] - ALGEBRAIC[10]), 0.500000) : 0.0/0.0);
ALGEBRAIC[12] = ALGEBRAIC[10];
ALGEBRAIC[18] = (CONDVAR[4]>=0.00000 ? 1.00000 : CONDVAR[5]<0.00000 ? 0.00000 : 0.0/0.0);
ALGEBRAIC[19] = (CONDVAR[6]>=0.00000 ?  CONSTANTS[4]*ALGEBRAIC[18]*pow(fabs(ALGEBRAIC[11] - ALGEBRAIC[12]), 0.500000) : CONDVAR[7]<0.00000 ?  -1.00000*CONSTANTS[4]*ALGEBRAIC[18]*pow(fabs(ALGEBRAIC[12] - ALGEBRAIC[11]), 0.500000) : 0.0/0.0);
ALGEBRAIC[15] = ALGEBRAIC[6] - ALGEBRAIC[12];
ALGEBRAIC[20] =  (CONSTANTS[34]+ CONSTANTS[35]*CONSTANTS[57]+ CONSTANTS[36]*ALGEBRAIC[15]+ CONSTANTS[37]*CONSTANTS[57]*ALGEBRAIC[15]+ CONSTANTS[38]*pow(CONSTANTS[57], 2.00000)*ALGEBRAIC[15]+ CONSTANTS[39]*CONSTANTS[57]*pow(ALGEBRAIC[15], 2.00000)+ CONSTANTS[40]*pow(CONSTANTS[57], 2.00000)*pow(ALGEBRAIC[15], 2.00000))*16.6667;
ALGEBRAIC[21] =  -1.00000*ALGEBRAIC[20];
ALGEBRAIC[22] = ALGEBRAIC[19]+ALGEBRAIC[21];
ALGEBRAIC[23] = STATES[3]+ALGEBRAIC[20];
}
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] = ALGEBRAIC[10] - STATES[0];
CONDVAR[1] = ALGEBRAIC[10] - STATES[0];
CONDVAR[2] = ALGEBRAIC[10] - STATES[0];
CONDVAR[3] = ALGEBRAIC[10] - STATES[0];
CONDVAR[4] = ALGEBRAIC[11] - ALGEBRAIC[12];
CONDVAR[5] = ALGEBRAIC[11] - ALGEBRAIC[12];
CONDVAR[6] = ALGEBRAIC[11] - ALGEBRAIC[12];
CONDVAR[7] = ALGEBRAIC[11] - ALGEBRAIC[12];
CONDVAR[8] = ALGEBRAIC[0] - 0.00000;
CONDVAR[9] = ALGEBRAIC[0] -  CONSTANTS[11]*CONSTANTS[10];
CONDVAR[10] = ALGEBRAIC[0] -  CONSTANTS[11]*CONSTANTS[10];
CONDVAR[11] = ALGEBRAIC[0] -  CONSTANTS[12]*CONSTANTS[10];
CONDVAR[12] = ALGEBRAIC[0] -  CONSTANTS[12]*CONSTANTS[10];
CONDVAR[13] = ALGEBRAIC[0] - CONSTANTS[10];
CONDVAR[14] = ALGEBRAIC[3] - 0.00000;
CONDVAR[15] = ALGEBRAIC[3] -  ((CONSTANTS[15]+CONSTANTS[16]) - 1.00000)*CONSTANTS[10];
CONDVAR[16] = ALGEBRAIC[3] -  ((CONSTANTS[15]+CONSTANTS[16]) - 1.00000)*CONSTANTS[10];
CONDVAR[17] = ALGEBRAIC[3] -  CONSTANTS[15]*CONSTANTS[10];
CONDVAR[18] = ALGEBRAIC[3] -  CONSTANTS[15]*CONSTANTS[10];
CONDVAR[19] = ALGEBRAIC[3] - CONSTANTS[10];
}