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 9 entries in the algebraic variable array. There are a total of 5 entries in each of the rate and state variable arrays. There are a total of 11 entries in the constant variable array. */ /* * VOI is time in component environment (dimensionless). * ALGEBRAIC[0] is f in component f (dimensionless). * CONSTANTS[0] is a in component f (dimensionless). * STATES[0] is r in component r (dimensionless). * CONSTANTS[1] is p in component model_parameters (dimensionless). * CONSTANTS[2] is beta in component r (dimensionless). * CONSTANTS[3] is alpha in component r (dimensionless). * ALGEBRAIC[5] is ur0 in component ur0 (dimensionless). * ALGEBRAIC[3] is m in component m (dimensionless). * CONSTANTS[4] is r0 in component model_parameters (dimensionless). * ALGEBRAIC[4] is y in component y (dimensionless). * CONSTANTS[5] is r1 in component model_parameters (dimensionless). * ALGEBRAIC[2] is ur1 in component ur1 (dimensionless). * ALGEBRAIC[6] is z in component z (dimensionless). * CONSTANTS[6] is t1 in component model_parameters (dimensionless). * STATES[1] is x1 in component x1 (dimensionless). * ALGEBRAIC[8] is q in component q (dimensionless). * CONSTANTS[7] is d in component q (dimensionless). * CONSTANTS[8] is k in component q (dimensionless). * ALGEBRAIC[7] is uz in component uz (dimensionless). * STATES[2] is x2 in component x2 (dimensionless). * CONSTANTS[9] is t2 in component model_parameters (dimensionless). * STATES[3] is x3 in component x3 (dimensionless). * ALGEBRAIC[1] is phi in component phi (dimensionless). * STATES[4] is h in component h (dimensionless). * CONSTANTS[10] is t4 in component model_parameters (dimensionless). * RATES[0] is d/dt r in component r (dimensionless). * RATES[1] is d/dt x1 in component x1 (dimensionless). * RATES[2] is d/dt x2 in component x2 (dimensionless). * RATES[3] is d/dt x3 in component x3 (dimensionless). * RATES[4] is d/dt h in component h (dimensionless). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 1.0; STATES[0] = 0.5; CONSTANTS[1] = 1.05; CONSTANTS[2] = 1.0; CONSTANTS[3] = 1.0; CONSTANTS[4] = 0.5; CONSTANTS[5] = 1.2; CONSTANTS[6] = 0.1; STATES[1] = 0.0; CONSTANTS[7] = 5.0; CONSTANTS[8] = 10.5; STATES[2] = 0.0; CONSTANTS[9] = 0.5; STATES[3] = 0.0; STATES[4] = 0.0; CONSTANTS[10] = 20.0; } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { RATES[3] = (STATES[2] - STATES[3])/CONSTANTS[9]; ALGEBRAIC[0] = CONSTANTS[0]*CONSTANTS[1]*pow(STATES[0], 4.00000); RATES[4] = (ALGEBRAIC[0] - STATES[4])/CONSTANTS[10]; ALGEBRAIC[2] = (STATES[0]>CONSTANTS[5] ? 1.00000 : 0.00000); ALGEBRAIC[4] = (STATES[0] - CONSTANTS[5])*ALGEBRAIC[2]; RATES[1] = (ALGEBRAIC[4] - STATES[1])/CONSTANTS[6]; ALGEBRAIC[5] = (STATES[0]>CONSTANTS[4] ? 1.00000 : 0.00000); ALGEBRAIC[1] = (STATES[0]<0.250000 ? 0.00000 : STATES[0]>2.00000 ? 0.00000 : 1.00000 - 1.30612*(STATES[0] - 1.12500)*(STATES[0] - 1.12500)); ALGEBRAIC[3] = STATES[3]*ALGEBRAIC[1]; RATES[0] = CONSTANTS[2]*( CONSTANTS[1]*STATES[0] - ( CONSTANTS[3]*pow(STATES[0] - CONSTANTS[4], 2.00000)*ALGEBRAIC[5]+ALGEBRAIC[3])); ALGEBRAIC[6] = (ALGEBRAIC[4] - STATES[1])/CONSTANTS[6]; ALGEBRAIC[7] = (ALGEBRAIC[6]>0.00000 ? 1.00000 : 0.00000); ALGEBRAIC[8] = CONSTANTS[8]*(1.00000 - exp(- ( CONSTANTS[7]*ALGEBRAIC[6])))*ALGEBRAIC[7]; RATES[2] = (ALGEBRAIC[8] - STATES[2])/CONSTANTS[9]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = CONSTANTS[0]*CONSTANTS[1]*pow(STATES[0], 4.00000); ALGEBRAIC[2] = (STATES[0]>CONSTANTS[5] ? 1.00000 : 0.00000); ALGEBRAIC[4] = (STATES[0] - CONSTANTS[5])*ALGEBRAIC[2]; ALGEBRAIC[5] = (STATES[0]>CONSTANTS[4] ? 1.00000 : 0.00000); ALGEBRAIC[1] = (STATES[0]<0.250000 ? 0.00000 : STATES[0]>2.00000 ? 0.00000 : 1.00000 - 1.30612*(STATES[0] - 1.12500)*(STATES[0] - 1.12500)); ALGEBRAIC[3] = STATES[3]*ALGEBRAIC[1]; ALGEBRAIC[6] = (ALGEBRAIC[4] - STATES[1])/CONSTANTS[6]; ALGEBRAIC[7] = (ALGEBRAIC[6]>0.00000 ? 1.00000 : 0.00000); ALGEBRAIC[8] = CONSTANTS[8]*(1.00000 - exp(- ( CONSTANTS[7]*ALGEBRAIC[6])))*ALGEBRAIC[7]; }