/* 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[2] is ur0 in component ur0 (dimensionless). * ALGEBRAIC[6] 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[3] is ur1 in component ur1 (dimensionless). * ALGEBRAIC[5] 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). * There are a total of 5 condition variables. */ 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; RATES[0] = 0.1001; RATES[1] = 0.1001; RATES[2] = 0.1001; RATES[3] = 0.1001; RATES[4] = 0.1001; } void computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES, double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS) { resid[0] = RATES[0] - CONSTANTS[2]*( CONSTANTS[1]*STATES[0] - ( CONSTANTS[3]*pow(STATES[0] - CONSTANTS[4], 2.00000)*ALGEBRAIC[2]+ALGEBRAIC[6])); resid[1] = RATES[1] - (ALGEBRAIC[4] - STATES[1])/CONSTANTS[6]; resid[2] = RATES[2] - (ALGEBRAIC[8] - STATES[2])/CONSTANTS[9]; resid[3] = RATES[3] - (STATES[2] - STATES[3])/CONSTANTS[9]; resid[4] = RATES[4] - (ALGEBRAIC[0] - STATES[4])/CONSTANTS[10]; } 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[0] = CONSTANTS[0]*CONSTANTS[1]*pow(STATES[0], 4.00000); ALGEBRAIC[2] = (CONDVAR[2]>0.00000 ? 1.00000 : 0.00000); ALGEBRAIC[3] = (CONDVAR[3]>0.00000 ? 1.00000 : 0.00000); ALGEBRAIC[4] = (STATES[0] - CONSTANTS[5])*ALGEBRAIC[3]; ALGEBRAIC[1] = (CONDVAR[0]<0.00000 ? 0.00000 : CONDVAR[1]>0.00000 ? 0.00000 : 1.00000 - 1.30612*(STATES[0] - 1.12500)*(STATES[0] - 1.12500)); ALGEBRAIC[6] = STATES[3]*ALGEBRAIC[1]; ALGEBRAIC[5] = (ALGEBRAIC[4] - STATES[1])/CONSTANTS[6]; ALGEBRAIC[7] = (CONDVAR[4]>0.00000 ? 1.00000 : 0.00000); ALGEBRAIC[8] = CONSTANTS[8]*(1.00000 - exp(- ( CONSTANTS[7]*ALGEBRAIC[5])))*ALGEBRAIC[7]; } void getStateInformation(double* SI) { SI[0] = 1.0; SI[1] = 1.0; SI[2] = 1.0; SI[3] = 1.0; SI[4] = 1.0; } void computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES, double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS) { CONDVAR[0] = STATES[0] - 0.250000; CONDVAR[1] = STATES[0] - 2.00000; CONDVAR[2] = STATES[0] - CONSTANTS[4]; CONDVAR[3] = STATES[0] - CONSTANTS[5]; CONDVAR[4] = ALGEBRAIC[5] - 0.00000; }