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 6 entries in the algebraic variable array. There are a total of 2 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 (minute). * STATES[0] is G in component G (mg_per_litre). * ALGEBRAIC[0] is Gin in component G (mg_per_litre_minute). * ALGEBRAIC[2] is f2_G in component f2_G (mg_per_minute). * ALGEBRAIC[3] is f3_G in component f3_G (per_litre). * ALGEBRAIC[4] is f4_I in component f4_I (mg_per_minute). * ALGEBRAIC[5] is f5_I in component f5_I (mg_per_minute). * STATES[1] is I in component I (mU_per_litre). * ALGEBRAIC[1] is Iin in component I (mU_per_litre_minute). * CONSTANTS[0] is di in component model_parameters (first_order_rate_constant). * CONSTANTS[1] is C2 in component model_parameters (mg_per_litre). * CONSTANTS[2] is Ub in component model_parameters (mg_per_minute). * CONSTANTS[3] is Vg in component model_parameters (litre). * CONSTANTS[4] is C3 in component model_parameters (mg_per_litre). * CONSTANTS[5] is C4 in component model_parameters (mU_per_litre). * CONSTANTS[6] is Vi in component model_parameters (litre). * CONSTANTS[7] is U0 in component model_parameters (mg_per_minute). * CONSTANTS[8] is Um in component model_parameters (mg_per_minute). * CONSTANTS[9] is beta in component model_parameters (dimensionless). * CONSTANTS[10] is ti in component model_parameters (minute). * CONSTANTS[11] is Vp in component model_parameters (litre). * CONSTANTS[12] is C5 in component model_parameters (mU_per_litre). * CONSTANTS[13] is Rg in component model_parameters (mg_per_minute). * CONSTANTS[14] is alpha in component model_parameters (litre_per_mU). * RATES[0] is d/dt G in component G (mg_per_litre). * RATES[1] is d/dt I in component I (mU_per_litre). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { STATES[0] = 150.0; STATES[1] = 5.0; CONSTANTS[0] = 0.0107; CONSTANTS[1] = 144; CONSTANTS[2] = 72.0; CONSTANTS[3] = 10.0; CONSTANTS[4] = 1000.0; CONSTANTS[5] = 80.0; CONSTANTS[6] = 11.0; CONSTANTS[7] = 40.0; CONSTANTS[8] = 940.0; CONSTANTS[9] = 1.77; CONSTANTS[10] = 100.0; CONSTANTS[11] = 3.0; CONSTANTS[12] = 26.0; CONSTANTS[13] = 180.0; CONSTANTS[14] = 0.29; } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[1] = (VOI<=30.0000&&VOI>=0.00000 ? 0.250000 : VOI<120.000&&VOI>=30.0000 ? 0.250000+ 1.00000*(1.00000+(VOI - 120.000)/90.0000) : VOI<240.000&&VOI>=120.000 ? 0.250000+ 1.00000*(1.00000 - 0.500000*((VOI - 120.000)/120.000)) : VOI<=480.000&&VOI>=240.000 ? 0.250000+ 0.500000*(1.00000 - (VOI - 240.000)/240.000) : VOI<530.000&&VOI>480.000 ? 0.250000 : VOI<620.000&&VOI>=530.000 ? 0.250000+ 1.00000*(1.00000+(VOI - 620.000)/90.0000) : VOI<740.000&&VOI>=620.000 ? 0.250000+ 1.00000*(1.00000 - 0.500000*((VOI - 620.000)/120.000)) : VOI<=980.000&&VOI>=740.000 ? 0.250000+ 0.500000*(1.00000 - (VOI - 740.000)/240.000) : 0.0/0.0); RATES[1] = ALGEBRAIC[1] - CONSTANTS[0]*STATES[1]; ALGEBRAIC[0] = (VOI<15.0000&&VOI>=0.00000 ? 0.0500000+ (5.00000/15.0000)*VOI : VOI<45.0000&&VOI>=15.0000 ? 0.0500000+ 5.00000*((45.0000 - VOI)/(45.0000 - 15.0000)) : VOI<=240.000&&VOI>=45.0000 ? 0.0500000 : VOI>240.000&&VOI<255.000 ? 0.0500000+ (5.00000/255.000)*VOI : VOI<285.000&&VOI>=255.000 ? 0.0500000+ 5.00000*((285.000 - VOI)/(285.000 - 255.000)) : VOI<=480.000&&VOI>=285.000 ? 0.0500000 : VOI<495.000&&VOI>480.000 ? 0.0500000+ (5.00000/495.000)*VOI : VOI<525.000&&VOI>=495.000 ? 0.0500000+ 5.00000*((525.000 - VOI)/(525.000 - 495.000)) : VOI<=720.000&&VOI>=525.000 ? 0.0500000 : VOI>720.000&&VOI<735.000 ? 0.0500000+ (5.00000/735.000)*VOI : VOI<765.000&&VOI>=735.000 ? 0.0500000+ 5.00000*((765.000 - VOI)/(765.000 - 735.000)) : VOI<=960.000&&VOI>=765.000 ? 0.0500000 : 0.0/0.0); ALGEBRAIC[2] = CONSTANTS[2]*(1.00000 - exp(- STATES[0]/( CONSTANTS[1]*CONSTANTS[3]*1.00000))); ALGEBRAIC[3] = STATES[0]/( CONSTANTS[4]*CONSTANTS[3]); ALGEBRAIC[4] = CONSTANTS[7]+(CONSTANTS[8] - CONSTANTS[7])/(1.00000+exp( - CONSTANTS[9]*log(STATES[1]/( CONSTANTS[5]*(1.00000/CONSTANTS[6]+1.00000/( 0.200000*CONSTANTS[10])))))); ALGEBRAIC[5] = CONSTANTS[13]/(1.00000+exp( CONSTANTS[14]*(STATES[1]/( 1.00000*( 1.00000*CONSTANTS[11] - CONSTANTS[12]))))); RATES[0] = (ALGEBRAIC[0]+ 1.00000*ALGEBRAIC[5]) - ( 1.00000*ALGEBRAIC[2]+ ALGEBRAIC[3]*ALGEBRAIC[4]); } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[1] = (VOI<=30.0000&&VOI>=0.00000 ? 0.250000 : VOI<120.000&&VOI>=30.0000 ? 0.250000+ 1.00000*(1.00000+(VOI - 120.000)/90.0000) : VOI<240.000&&VOI>=120.000 ? 0.250000+ 1.00000*(1.00000 - 0.500000*((VOI - 120.000)/120.000)) : VOI<=480.000&&VOI>=240.000 ? 0.250000+ 0.500000*(1.00000 - (VOI - 240.000)/240.000) : VOI<530.000&&VOI>480.000 ? 0.250000 : VOI<620.000&&VOI>=530.000 ? 0.250000+ 1.00000*(1.00000+(VOI - 620.000)/90.0000) : VOI<740.000&&VOI>=620.000 ? 0.250000+ 1.00000*(1.00000 - 0.500000*((VOI - 620.000)/120.000)) : VOI<=980.000&&VOI>=740.000 ? 0.250000+ 0.500000*(1.00000 - (VOI - 740.000)/240.000) : 0.0/0.0); ALGEBRAIC[0] = (VOI<15.0000&&VOI>=0.00000 ? 0.0500000+ (5.00000/15.0000)*VOI : VOI<45.0000&&VOI>=15.0000 ? 0.0500000+ 5.00000*((45.0000 - VOI)/(45.0000 - 15.0000)) : VOI<=240.000&&VOI>=45.0000 ? 0.0500000 : VOI>240.000&&VOI<255.000 ? 0.0500000+ (5.00000/255.000)*VOI : VOI<285.000&&VOI>=255.000 ? 0.0500000+ 5.00000*((285.000 - VOI)/(285.000 - 255.000)) : VOI<=480.000&&VOI>=285.000 ? 0.0500000 : VOI<495.000&&VOI>480.000 ? 0.0500000+ (5.00000/495.000)*VOI : VOI<525.000&&VOI>=495.000 ? 0.0500000+ 5.00000*((525.000 - VOI)/(525.000 - 495.000)) : VOI<=720.000&&VOI>=525.000 ? 0.0500000 : VOI>720.000&&VOI<735.000 ? 0.0500000+ (5.00000/735.000)*VOI : VOI<765.000&&VOI>=735.000 ? 0.0500000+ 5.00000*((765.000 - VOI)/(765.000 - 735.000)) : VOI<=960.000&&VOI>=765.000 ? 0.0500000 : 0.0/0.0); ALGEBRAIC[2] = CONSTANTS[2]*(1.00000 - exp(- STATES[0]/( CONSTANTS[1]*CONSTANTS[3]*1.00000))); ALGEBRAIC[3] = STATES[0]/( CONSTANTS[4]*CONSTANTS[3]); ALGEBRAIC[4] = CONSTANTS[7]+(CONSTANTS[8] - CONSTANTS[7])/(1.00000+exp( - CONSTANTS[9]*log(STATES[1]/( CONSTANTS[5]*(1.00000/CONSTANTS[6]+1.00000/( 0.200000*CONSTANTS[10])))))); ALGEBRAIC[5] = CONSTANTS[13]/(1.00000+exp( CONSTANTS[14]*(STATES[1]/( 1.00000*( 1.00000*CONSTANTS[11] - CONSTANTS[12]))))); }