/* There are a total of 2 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 13 entries in the constant variable array. */ /* * VOI is time in component environment (day). * CONSTANTS[9] is T in component T (per_ml). * CONSTANTS[0] is k in component kinetic_parameters (ml_per_day). * CONSTANTS[1] is p in component kinetic_parameters (first_order_rate_constant). * CONSTANTS[2] is c in component kinetic_parameters (first_order_rate_constant). * CONSTANTS[3] is delta in component kinetic_parameters (first_order_rate_constant). * STATES[0] is I in component I (per_ml). * CONSTANTS[10] is I_0 in component I (per_ml). * CONSTANTS[11] is k_ in component kinetic_parameters (ml_per_day). * STATES[1] is E4 in component E4 (per_ml). * CONSTANTS[4] is VI_0 in component VI (per_ml). * STATES[2] is VI in component VI (per_ml). * ALGEBRAIC[1] is h in component Heavyside_function (dimensionless). * STATES[3] is VNI in component VNI (per_ml). * ALGEBRAIC[0] is V in component virus_total (per_ml). * STATES[4] is E1 in component E1 (per_ml). * CONSTANTS[12] is b_ in component kinetic_parameters (day). * STATES[5] is E2 in component E2 (per_ml). * STATES[6] is E3 in component E3 (per_ml). * CONSTANTS[5] is tau_p in component Heavyside_function (day). * CONSTANTS[6] is b in component kinetic_parameters (day). * CONSTANTS[7] is m in component kinetic_parameters (first_order_rate_constant). * CONSTANTS[8] is n in component kinetic_parameters (dimensionless). * RATES[0] is d/dt I in component I (per_ml). * RATES[2] is d/dt VI in component VI (per_ml). * RATES[3] is d/dt VNI in component VNI (per_ml). * RATES[4] is d/dt E1 in component E1 (per_ml). * RATES[5] is d/dt E2 in component E2 (per_ml). * RATES[6] is d/dt E3 in component E3 (per_ml). * RATES[1] is d/dt E4 in component E4 (per_ml). * There are a total of 1 condition variables. */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 2.4e-5; CONSTANTS[1] = 774; CONSTANTS[2] = 3; CONSTANTS[3] = 0.5; STATES[0] = 0.1; STATES[1] = 0; CONSTANTS[4] = 200000; STATES[2] = 200000; STATES[3] = 0; STATES[4] = 0; STATES[5] = 0; STATES[6] = 0; CONSTANTS[5] = 0; CONSTANTS[6] = 0.25; CONSTANTS[7] = 0.01; CONSTANTS[8] = 4; CONSTANTS[9] = ( CONSTANTS[2]*CONSTANTS[3])/( CONSTANTS[0]*CONSTANTS[1]); CONSTANTS[10] = (CONSTANTS[2]/CONSTANTS[1])*CONSTANTS[4]; CONSTANTS[11] = CONSTANTS[0]/pow(1.00000+ CONSTANTS[7]*CONSTANTS[6], CONSTANTS[8]); CONSTANTS[12] = CONSTANTS[6]/(1.00000+ CONSTANTS[7]*CONSTANTS[6]); RATES[0] = 0.1001; RATES[2] = 0.1001; RATES[3] = 0.1001; RATES[4] = 0.1001; RATES[5] = 0.1001; RATES[6] = 0.1001; RATES[1] = 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[11]*CONSTANTS[9]*STATES[1] - CONSTANTS[3]*STATES[0]; resid[1] = RATES[2] - (1.00000 - ALGEBRAIC[1])*CONSTANTS[1]*STATES[0] - CONSTANTS[2]*STATES[2]; resid[2] = RATES[3] - ALGEBRAIC[1]*CONSTANTS[1]*STATES[0] - CONSTANTS[2]*STATES[3]; resid[3] = RATES[4] - (STATES[2] - STATES[4])/CONSTANTS[12]; resid[4] = RATES[5] - (STATES[4] - STATES[5])/CONSTANTS[12]; resid[5] = RATES[6] - (STATES[5] - STATES[6])/CONSTANTS[12]; resid[6] = RATES[1] - (STATES[6] - STATES[1])/CONSTANTS[12]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = STATES[2]+STATES[3]; } void computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[1] = (CONDVAR[0]<0.00000 ? 0.00000 : 1.00000); } 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] = VOI - CONSTANTS[5]; }