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 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[10] is Pi in component TempCDa (UnitP). * STATES[0] is Pi in component TempRLC (UnitP). * ALGEBRAIC[18] is Qo in component TempRC (UnitQ). * ALGEBRAIC[21] is Qvi in component TempIPump (UnitQ). * ALGEBRAIC[5] is Qo in component TempCDv (UnitQ). * ALGEBRAIC[6] is Pi in component TJoint (UnitP). * ALGEBRAIC[19] is Qvo in component TempIPump (UnitQ). * ALGEBRAIC[14] is Pi in component TJoint (UnitP). * ALGEBRAIC[3] is Pi in component TempCDv (UnitP). * ALGEBRAIC[23] 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[4] is Tao in component TempCDv (dimensionless). * CONSTANTS[3] is Vlv0 in component ParaHeartP (UnitV). * ALGEBRAIC[12] is Qo in component TempCDa (UnitQ). * CONSTANTS[4] is CVmi in component ParaHeartP (UnitCV). * ALGEBRAIC[9] 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[11] 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[7] is mt in component EAtrium (second). * ALGEBRAIC[8] 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[22] is Qo in component TJoint (UnitQ). * ALGEBRAIC[20] 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[17] is Pi in component TempR (UnitP). * ALGEBRAIC[13] is Qo in component TempR (UnitQ). * CONSTANTS[27] is Rsar in component ParaSys (UnitR). * STATES[6] is Pi in component TempRC (UnitP). * ALGEBRAIC[15] 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[16] 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). */ 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]; } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = VOI - CONSTANTS[10]*floor(VOI/CONSTANTS[10]); ALGEBRAIC[1] = (ALGEBRAIC[0]>=0.00000&&ALGEBRAIC[0]<= CONSTANTS[11]*CONSTANTS[10] ? 1.00000 - cos(( 3.14159*ALGEBRAIC[0])/( CONSTANTS[11]*CONSTANTS[10])) : ALGEBRAIC[0]> CONSTANTS[11]*CONSTANTS[10]&&ALGEBRAIC[0]<= CONSTANTS[12]*CONSTANTS[10] ? 1.00000+cos(( 3.14159*(ALGEBRAIC[0] - CONSTANTS[11]*CONSTANTS[10]))/( (CONSTANTS[12] - CONSTANTS[11])*CONSTANTS[10])) : ALGEBRAIC[0]> CONSTANTS[12]*CONSTANTS[10]&&ALGEBRAIC[0]<CONSTANTS[10] ? 0.00000 : 0.0/0.0); ALGEBRAIC[2] = CONSTANTS[9]+( ALGEBRAIC[1]*(CONSTANTS[8] - CONSTANTS[9]))/2.00000; ALGEBRAIC[3] = CONSTANTS[1]+ ALGEBRAIC[2]*(STATES[1] - CONSTANTS[2]); ALGEBRAIC[4] = (ALGEBRAIC[3]>=STATES[0] ? 1.00000 : ALGEBRAIC[3]<STATES[0] ? 0.00000 : 0.0/0.0); ALGEBRAIC[5] = (ALGEBRAIC[3]>=STATES[0] ? CONSTANTS[0]*ALGEBRAIC[4]*pow(fabs(ALGEBRAIC[3] - STATES[0]), 0.500000) : ALGEBRAIC[3]<STATES[0] ? -1.00000*CONSTANTS[0]*ALGEBRAIC[4]*pow(fabs(STATES[0] - ALGEBRAIC[3]), 0.500000) : 0.0/0.0); RATES[0] = (ALGEBRAIC[5] - STATES[3])/CONSTANTS[18]; ALGEBRAIC[14] = STATES[4]; RATES[3] = ((STATES[0] - ALGEBRAIC[14]) - CONSTANTS[17]*STATES[3])/CONSTANTS[19]; ALGEBRAIC[7] = VOI - CONSTANTS[10]*floor(VOI/CONSTANTS[10]); ALGEBRAIC[8] = (ALGEBRAIC[7]>=0.00000&&ALGEBRAIC[7]<= ((CONSTANTS[15]+CONSTANTS[16]) - 1.00000)*CONSTANTS[10] ? 1.00000 - cos(( 2.00000*3.14159*(ALGEBRAIC[7] - (CONSTANTS[15] - 1.00000)*CONSTANTS[10]))/( CONSTANTS[16]*CONSTANTS[10])) : ALGEBRAIC[7]> ((CONSTANTS[15]+CONSTANTS[16]) - 1.00000)*CONSTANTS[10]&&ALGEBRAIC[7]<= CONSTANTS[15]*CONSTANTS[10] ? 0.00000 : ALGEBRAIC[7]> CONSTANTS[15]*CONSTANTS[10]&&ALGEBRAIC[7]<=CONSTANTS[10] ? 1.00000 - cos(( 2.00000*3.14159*(ALGEBRAIC[7] - CONSTANTS[15]*CONSTANTS[10]))/( CONSTANTS[16]*CONSTANTS[10])) : 0.0/0.0); ALGEBRAIC[9] = CONSTANTS[14]+( ALGEBRAIC[8]*(CONSTANTS[13] - CONSTANTS[14]))/2.00000; ALGEBRAIC[10] = CONSTANTS[5]+ ALGEBRAIC[9]*(STATES[2] - CONSTANTS[6]); ALGEBRAIC[18] = (STATES[6] - ALGEBRAIC[10])/CONSTANTS[29]; ALGEBRAIC[6] = ALGEBRAIC[3]; ALGEBRAIC[11] = (ALGEBRAIC[10]>=ALGEBRAIC[6] ? 1.00000 : ALGEBRAIC[10]<ALGEBRAIC[6] ? 0.00000 : 0.0/0.0); ALGEBRAIC[12] = (ALGEBRAIC[10]>=ALGEBRAIC[6] ? CONSTANTS[4]*ALGEBRAIC[11]*pow(fabs(ALGEBRAIC[10] - ALGEBRAIC[6]), 0.500000) : ALGEBRAIC[10]<ALGEBRAIC[6] ? -1.00000*CONSTANTS[4]*ALGEBRAIC[11]*pow(fabs(ALGEBRAIC[6] - ALGEBRAIC[10]), 0.500000) : 0.0/0.0); RATES[2] = ALGEBRAIC[18] - ALGEBRAIC[12]; ALGEBRAIC[13] = STATES[5]; ALGEBRAIC[17] = STATES[6]+ CONSTANTS[28]*ALGEBRAIC[13]; ALGEBRAIC[20] = ALGEBRAIC[17]+ CONSTANTS[27]*STATES[5]; RATES[5] = ((STATES[4] - ALGEBRAIC[20]) - CONSTANTS[22]*STATES[5])/CONSTANTS[24]; ALGEBRAIC[15] = ALGEBRAIC[13]; RATES[6] = (ALGEBRAIC[15] - ALGEBRAIC[18])/CONSTANTS[30]; ALGEBRAIC[16] = ALGEBRAIC[14] - ALGEBRAIC[6]; ALGEBRAIC[19] = (CONSTANTS[34]+ CONSTANTS[35]*CONSTANTS[57]+ CONSTANTS[36]*ALGEBRAIC[16]+ CONSTANTS[37]*CONSTANTS[57]*ALGEBRAIC[16]+ CONSTANTS[38]*pow(CONSTANTS[57], 2.00000)*ALGEBRAIC[16]+ CONSTANTS[39]*CONSTANTS[57]*pow(ALGEBRAIC[16], 2.00000)+ CONSTANTS[40]*pow(CONSTANTS[57], 2.00000)*pow(ALGEBRAIC[16], 2.00000))*16.6667; ALGEBRAIC[22] = STATES[3]+ALGEBRAIC[19]; RATES[4] = (ALGEBRAIC[22] - STATES[5])/CONSTANTS[23]; ALGEBRAIC[21] = -1.00000*ALGEBRAIC[19]; ALGEBRAIC[23] = ALGEBRAIC[12]+ALGEBRAIC[21]; RATES[1] = ALGEBRAIC[23] - ALGEBRAIC[5]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = VOI - CONSTANTS[10]*floor(VOI/CONSTANTS[10]); ALGEBRAIC[1] = (ALGEBRAIC[0]>=0.00000&&ALGEBRAIC[0]<= CONSTANTS[11]*CONSTANTS[10] ? 1.00000 - cos(( 3.14159*ALGEBRAIC[0])/( CONSTANTS[11]*CONSTANTS[10])) : ALGEBRAIC[0]> CONSTANTS[11]*CONSTANTS[10]&&ALGEBRAIC[0]<= CONSTANTS[12]*CONSTANTS[10] ? 1.00000+cos(( 3.14159*(ALGEBRAIC[0] - CONSTANTS[11]*CONSTANTS[10]))/( (CONSTANTS[12] - CONSTANTS[11])*CONSTANTS[10])) : ALGEBRAIC[0]> CONSTANTS[12]*CONSTANTS[10]&&ALGEBRAIC[0]<CONSTANTS[10] ? 0.00000 : 0.0/0.0); ALGEBRAIC[2] = CONSTANTS[9]+( ALGEBRAIC[1]*(CONSTANTS[8] - CONSTANTS[9]))/2.00000; ALGEBRAIC[3] = CONSTANTS[1]+ ALGEBRAIC[2]*(STATES[1] - CONSTANTS[2]); ALGEBRAIC[4] = (ALGEBRAIC[3]>=STATES[0] ? 1.00000 : ALGEBRAIC[3]<STATES[0] ? 0.00000 : 0.0/0.0); ALGEBRAIC[5] = (ALGEBRAIC[3]>=STATES[0] ? CONSTANTS[0]*ALGEBRAIC[4]*pow(fabs(ALGEBRAIC[3] - STATES[0]), 0.500000) : ALGEBRAIC[3]<STATES[0] ? -1.00000*CONSTANTS[0]*ALGEBRAIC[4]*pow(fabs(STATES[0] - ALGEBRAIC[3]), 0.500000) : 0.0/0.0); ALGEBRAIC[14] = STATES[4]; ALGEBRAIC[7] = VOI - CONSTANTS[10]*floor(VOI/CONSTANTS[10]); ALGEBRAIC[8] = (ALGEBRAIC[7]>=0.00000&&ALGEBRAIC[7]<= ((CONSTANTS[15]+CONSTANTS[16]) - 1.00000)*CONSTANTS[10] ? 1.00000 - cos(( 2.00000*3.14159*(ALGEBRAIC[7] - (CONSTANTS[15] - 1.00000)*CONSTANTS[10]))/( CONSTANTS[16]*CONSTANTS[10])) : ALGEBRAIC[7]> ((CONSTANTS[15]+CONSTANTS[16]) - 1.00000)*CONSTANTS[10]&&ALGEBRAIC[7]<= CONSTANTS[15]*CONSTANTS[10] ? 0.00000 : ALGEBRAIC[7]> CONSTANTS[15]*CONSTANTS[10]&&ALGEBRAIC[7]<=CONSTANTS[10] ? 1.00000 - cos(( 2.00000*3.14159*(ALGEBRAIC[7] - CONSTANTS[15]*CONSTANTS[10]))/( CONSTANTS[16]*CONSTANTS[10])) : 0.0/0.0); ALGEBRAIC[9] = CONSTANTS[14]+( ALGEBRAIC[8]*(CONSTANTS[13] - CONSTANTS[14]))/2.00000; ALGEBRAIC[10] = CONSTANTS[5]+ ALGEBRAIC[9]*(STATES[2] - CONSTANTS[6]); ALGEBRAIC[18] = (STATES[6] - ALGEBRAIC[10])/CONSTANTS[29]; ALGEBRAIC[6] = ALGEBRAIC[3]; ALGEBRAIC[11] = (ALGEBRAIC[10]>=ALGEBRAIC[6] ? 1.00000 : ALGEBRAIC[10]<ALGEBRAIC[6] ? 0.00000 : 0.0/0.0); ALGEBRAIC[12] = (ALGEBRAIC[10]>=ALGEBRAIC[6] ? CONSTANTS[4]*ALGEBRAIC[11]*pow(fabs(ALGEBRAIC[10] - ALGEBRAIC[6]), 0.500000) : ALGEBRAIC[10]<ALGEBRAIC[6] ? -1.00000*CONSTANTS[4]*ALGEBRAIC[11]*pow(fabs(ALGEBRAIC[6] - ALGEBRAIC[10]), 0.500000) : 0.0/0.0); ALGEBRAIC[13] = STATES[5]; ALGEBRAIC[17] = STATES[6]+ CONSTANTS[28]*ALGEBRAIC[13]; ALGEBRAIC[20] = ALGEBRAIC[17]+ CONSTANTS[27]*STATES[5]; ALGEBRAIC[15] = ALGEBRAIC[13]; ALGEBRAIC[16] = ALGEBRAIC[14] - ALGEBRAIC[6]; ALGEBRAIC[19] = (CONSTANTS[34]+ CONSTANTS[35]*CONSTANTS[57]+ CONSTANTS[36]*ALGEBRAIC[16]+ CONSTANTS[37]*CONSTANTS[57]*ALGEBRAIC[16]+ CONSTANTS[38]*pow(CONSTANTS[57], 2.00000)*ALGEBRAIC[16]+ CONSTANTS[39]*CONSTANTS[57]*pow(ALGEBRAIC[16], 2.00000)+ CONSTANTS[40]*pow(CONSTANTS[57], 2.00000)*pow(ALGEBRAIC[16], 2.00000))*16.6667; ALGEBRAIC[22] = STATES[3]+ALGEBRAIC[19]; ALGEBRAIC[21] = -1.00000*ALGEBRAIC[19]; ALGEBRAIC[23] = ALGEBRAIC[12]+ALGEBRAIC[21]; }