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 1 entries in the algebraic variable array.
   There are a total of 4 entries in each of the rate and state variable arrays.
   There are a total of 9 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (day).
 * CONSTANTS[0] is s in component uninfected (per_day_mm3).
 * CONSTANTS[1] is r in component uninfected (per_day).
 * CONSTANTS[2] is T_max in component uninfected (per_mm3).
 * CONSTANTS[3] is mu_T in component uninfected (per_day).
 * CONSTANTS[4] is k_1 in component latently_infected (mm3_per_day).
 * STATES[0] is T_1 in component latently_infected (per_mm3).
 * STATES[1] is T_2 in component actively_infected (per_mm3).
 * STATES[2] is V in component free_virus_particle (per_mm3).
 * STATES[3] is T in component uninfected (per_mm3).
 * CONSTANTS[5] is k_2 in component actively_infected (per_day).
 * CONSTANTS[6] is mu_b in component actively_infected (per_day).
 * CONSTANTS[7] is mu_V in component free_virus_particle (per_day).
 * CONSTANTS[8] is N in component free_virus_particle (dimensionless).
 * ALGEBRAIC[0] is T_tot in component T_cell_population (per_mm3).
 * RATES[3] is d/dt T in component uninfected (per_mm3).
 * RATES[0] is d/dt T_1 in component latently_infected (per_mm3).
 * RATES[1] is d/dt T_2 in component actively_infected (per_mm3).
 * RATES[2] is d/dt V in component free_virus_particle (per_mm3).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 10;
CONSTANTS[1] = 0.03;
CONSTANTS[2] = 1500;
CONSTANTS[3] = 0.02;
CONSTANTS[4] = 2.4E-5;
STATES[0] = 0;
STATES[1] = 0;
STATES[2] = 1.0E-3;
STATES[3] = 1000;
CONSTANTS[5] = 3E-3;
CONSTANTS[6] = 0.24;
CONSTANTS[7] = 2.4;
CONSTANTS[8] = 1400;
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
RATES[3] = ((CONSTANTS[0] -  CONSTANTS[3]*STATES[3])+ CONSTANTS[1]*STATES[3]*(1.00000 - (STATES[3]+STATES[0]+STATES[1])/CONSTANTS[2])) -  CONSTANTS[4]*STATES[2]*STATES[3];
RATES[0] = ( CONSTANTS[4]*STATES[2]*STATES[3] -  CONSTANTS[3]*STATES[0]) -  CONSTANTS[5]*STATES[0];
RATES[1] =  CONSTANTS[5]*STATES[0] -  CONSTANTS[6]*STATES[1];
RATES[2] = ( CONSTANTS[8]*CONSTANTS[6]*STATES[1] -  CONSTANTS[4]*STATES[2]*STATES[3]) -  CONSTANTS[7]*STATES[2];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = STATES[3]+STATES[0]+STATES[1];
}