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 56 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 72 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (minute).
 * CONSTANTS[0] is ADHMK in component kidney (dimensionless).
 * CONSTANTS[1] is AMK in component kidney (dimensionless).
 * CONSTANTS[2] is AMNA in component kidney (dimensionless).
 * CONSTANTS[3] is ANM in component kidney (dimensionless).
 * CONSTANTS[4] is ANPX in component kidney (dimensionless).
 * CONSTANTS[5] is AUM in component kidney (dimensionless).
 * CONSTANTS[6] is CKE in component kidney (monovalent_mEq_per_litre).
 * CONSTANTS[7] is CNA in component kidney (monovalent_mEq_per_litre).
 * CONSTANTS[8] is HM1 in component kidney (dimensionless).
 * CONSTANTS[9] is MYOGRS in component kidney (dimensionless).
 * CONSTANTS[10] is PA in component kidney (mmHg).
 * CONSTANTS[11] is PAMKRN in component kidney (dimensionless).
 * CONSTANTS[12] is PPC in component kidney (mmHg).
 * CONSTANTS[13] is VTW in component kidney (litre).
 * ALGEBRAIC[0] is PAR in component perfusion_pressure (mmHg).
 * CONSTANTS[14] is GBL in component parameter_values (mmHg).
 * CONSTANTS[15] is RAPRSP in component parameter_values (mmHg).
 * CONSTANTS[16] is RFCDFT in component parameter_values (dimensionless).
 * CONSTANTS[17] is RCDFPC in component parameter_values (dimensionless).
 * CONSTANTS[18] is RCDFDP in component parameter_values (minute).
 * STATES[0] is PAR1 in component perfusion_pressure (mmHg).
 * ALGEBRAIC[2] is MDFLW in component proximal_tubular_and_macula_densa_flow (L_per_minute).
 * ALGEBRAIC[3] is RNAUG2 in component renal_autoregulatory_feedback_factor (dimensionless).
 * CONSTANTS[19] is RNAUGN in component parameter_values (minute_per_L).
 * CONSTANTS[20] is RNAULL in component parameter_values (dimensionless).
 * CONSTANTS[21] is RNAUUL in component parameter_values (dimensionless).
 * CONSTANTS[22] is RNAUAD in component parameter_values (per_minute).
 * ALGEBRAIC[4] is RNAUG1 in component renal_autoregulatory_feedback_factor (dimensionless).
 * ALGEBRAIC[5] is RNAUG1T in component renal_autoregulatory_feedback_factor (dimensionless).
 * STATES[1] is RNAUG3 in component renal_autoregulatory_feedback_factor (dimensionless).
 * CONSTANTS[63] is AUMK in component autonomic_effect_on_AAR (dimensionless).
 * CONSTANTS[23] is ARF in component parameter_values (dimensionless).
 * CONSTANTS[62] is AUMKT in component autonomic_effect_on_AAR (dimensionless).
 * CONSTANTS[65] is ANMAR in component angiotensin_effect_on_AAR (dimensionless).
 * CONSTANTS[24] is ANMAM in component parameter_values (dimensionless).
 * CONSTANTS[25] is ANMARL in component parameter_values (dimensionless).
 * CONSTANTS[64] is ANMAR1 in component angiotensin_effect_on_AAR (dimensionless).
 * ALGEBRAIC[6] is AAR1 in component AAR_calculation (mmHg_minute_per_L).
 * CONSTANTS[26] is AARK in component parameter_values (mmHg_minute_per_L).
 * ALGEBRAIC[7] is AAR in component atrial_natriuretic_peptide_effect_on_AAR (mmHg_minute_per_L).
 * CONSTANTS[27] is ANPXAF in component parameter_values (mmHg_minute_per_L).
 * CONSTANTS[28] is AARLL in component parameter_values (mmHg_minute_per_L).
 * ALGEBRAIC[8] is AART in component atrial_natriuretic_peptide_effect_on_AAR (mmHg_minute_per_L).
 * CONSTANTS[66] is AUMK2 in component autonomic_effect_on_EAR (dimensionless).
 * CONSTANTS[29] is AUMK1 in component parameter_values (dimensionless).
 * CONSTANTS[67] is ANMER in component angiotensin_effect_on_EAR (dimensionless).
 * CONSTANTS[30] is ANMEM in component parameter_values (dimensionless).
 * ALGEBRAIC[9] is RNAUG4 in component effect_of_renal_autoregulatory_feedback_on_EAR (dimensionless).
 * CONSTANTS[31] is EFAFR in component parameter_values (dimensionless).
 * ALGEBRAIC[10] is EAR in component EAR_calculation (mmHg_minute_per_L).
 * CONSTANTS[32] is EARK in component parameter_values (mmHg_minute_per_L).
 * CONSTANTS[33] is EARLL in component parameter_values (mmHg_minute_per_L).
 * ALGEBRAIC[11] is EAR1 in component EAR_calculation (mmHg_minute_per_L).
 * ALGEBRAIC[12] is RR in component total_renal_resistance (mmHg_minute_per_L).
 * ALGEBRAIC[13] is RFN in component normal_renal_blood_flow (L_per_minute).
 * ALGEBRAIC[24] is RBF in component actual_renal_blood_flow (L_per_minute).
 * CONSTANTS[34] is REK in component parameter_values (dimensionless).
 * ALGEBRAIC[14] is GFN in component glomerular_filtration_rate (L_per_minute).
 * ALGEBRAIC[15] is GLPC in component glomerular_colloid_osmotic_pressure (mmHg).
 * CONSTANTS[35] is GPPD in component parameter_values (dimensionless).
 * CONSTANTS[36] is GLPCA in component parameter_values (mmHg).
 * ALGEBRAIC[16] is EFAFPR in component glomerular_colloid_osmotic_pressure (dimensionless).
 * ALGEBRAIC[17] is EFAFPR1 in component glomerular_colloid_osmotic_pressure (dimensionless).
 * ALGEBRAIC[18] is GLP in component glomerular_pressure (mmHg).
 * ALGEBRAIC[19] is APD in component glomerular_pressure (mmHg).
 * ALGEBRAIC[25] is GFR in component glomerular_filtration_rate (L_per_minute).
 * CONSTANTS[37] is PXTP in component parameter_values (mmHg).
 * CONSTANTS[38] is GFLC in component parameter_values (L_per_minute_per_mmHg).
 * CONSTANTS[39] is GFNLL in component parameter_values (L_per_minute).
 * ALGEBRAIC[20] is PFL in component glomerular_filtration_rate (mmHg).
 * ALGEBRAIC[21] is GFN1 in component glomerular_filtration_rate (L_per_minute).
 * CONSTANTS[40] is MDFL1 in component parameter_values (dimensionless).
 * ALGEBRAIC[22] is PTFL in component proximal_tubular_and_macula_densa_flow (L_per_minute).
 * ALGEBRAIC[23] is MDFLWT in component proximal_tubular_and_macula_densa_flow (L_per_minute).
 * ALGEBRAIC[27] is RTSPPC in component renal_tissue_osmotic_pressure (mmHg).
 * CONSTANTS[41] is RTPPR in component parameter_values (dimensionless).
 * CONSTANTS[42] is RTPPRS in component parameter_values (mmHg).
 * ALGEBRAIC[26] is RTSPPC1 in component renal_tissue_osmotic_pressure (mmHg).
 * ALGEBRAIC[49] is UROD in component actual_urea_excretion_rate (mOsm_per_minute).
 * STATES[2] is PLUR in component glomerular_urea_concentration (mOsm).
 * CONSTANTS[43] is URFORM in component parameter_values (mOsm_per_minute).
 * ALGEBRAIC[1] is PLURC in component plasma_urea_concentration (mOsm_per_litre).
 * ALGEBRAIC[28] is RCPRS in component peritubular_capillary_pressure (mmHg).
 * CONSTANTS[44] is RFABX in component parameter_values (dimensionless).
 * CONSTANTS[45] is RVRS in component parameter_values (mmHg_minute_per_L).
 * ALGEBRAIC[33] is RFABD in component peritubular_capillary_reabsorption_factor (dimensionless).
 * CONSTANTS[46] is RTSPRS in component parameter_values (mmHg).
 * CONSTANTS[47] is RABSC in component parameter_values (per_mmHg).
 * CONSTANTS[48] is RFABDP in component parameter_values (dimensionless).
 * CONSTANTS[49] is RFABDM in component parameter_values (dimensionless).
 * ALGEBRAIC[29] is RABSPR in component peritubular_capillary_reabsorption_factor (mmHg).
 * ALGEBRAIC[30] is RFAB1 in component peritubular_capillary_reabsorption_factor (dimensionless).
 * ALGEBRAIC[31] is RFAB in component peritubular_capillary_reabsorption_factor (dimensionless).
 * ALGEBRAIC[32] is RFABD1 in component peritubular_capillary_reabsorption_factor (dimensionless).
 * ALGEBRAIC[34] is DTNAI in component distal_tubular_Na_delivery (monovalent_mEq_per_minute).
 * ALGEBRAIC[36] is DTNARA in component Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute).
 * CONSTANTS[50] is DTNAR in component parameter_values (monovalent_mEq_per_minute).
 * CONSTANTS[51] is DIURET in component parameter_values (dimensionless).
 * CONSTANTS[52] is AHMNAR in component parameter_values (dimensionless).
 * CONSTANTS[53] is DTNARL in component parameter_values (monovalent_mEq_per_minute).
 * ALGEBRAIC[35] is DTNARA1 in component Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute).
 * CONSTANTS[69] is DTNANG in component angiotensin_induced_Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute).
 * CONSTANTS[54] is ANMNAM in component parameter_values (dimensionless).
 * CONSTANTS[68] is DTNANG1 in component angiotensin_induced_Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute).
 * ALGEBRAIC[37] is DTKI in component distal_tubular_K_delivery (monovalent_mEq_per_minute).
 * ALGEBRAIC[38] is RFABK in component effect_of_physical_forces_on_distal_K_reabsorption (monovalent_mEq_per_minute).
 * CONSTANTS[55] is RFABKM in component parameter_values (monovalent_mEq_per_minute).
 * ALGEBRAIC[40] is MDFLK in component effect_of_fluid_flow_on_distal_K_reabsorption (monovalent_mEq_per_minute).
 * CONSTANTS[56] is MDFLKM in component parameter_values (monovalent_mEq_per_litre).
 * ALGEBRAIC[39] is MDFLK1 in component effect_of_fluid_flow_on_distal_K_reabsorption (monovalent_mEq_per_minute).
 * ALGEBRAIC[46] is KODN in component normal_K_excretion (monovalent_mEq_per_minute).
 * ALGEBRAIC[54] is VUDN in component normal_urine_volume (L_per_minute).
 * STATES[3] is DTKA in component K_reabsorption_into_distal_tubules (monovalent_mEq_per_minute).
 * ALGEBRAIC[41] is DTKSC in component K_secretion_from_distal_tubules (monovalent_mEq_per_minute).
 * CONSTANTS[57] is ANMKEM in component parameter_values (dimensionless).
 * CONSTANTS[58] is ANMKEL in component parameter_values (dimensionless).
 * CONSTANTS[59] is CKEEX in component parameter_values (dimensionless).
 * CONSTANTS[70] is ANMKE1 in component K_secretion_from_distal_tubules (dimensionless).
 * CONSTANTS[71] is ANMKE in component K_secretion_from_distal_tubules (dimensionless).
 * ALGEBRAIC[43] is NODN in component normal_Na_excretion (monovalent_mEq_per_minute).
 * ALGEBRAIC[42] is NODN1 in component normal_Na_excretion (monovalent_mEq_per_minute).
 * ALGEBRAIC[44] is KODN1 in component normal_K_excretion (monovalent_mEq_per_minute).
 * ALGEBRAIC[47] is DTURI in component normal_urea_excretion (mOsm_per_minute).
 * ALGEBRAIC[50] is OSMOPN1 in component normal_osmolar_and_water_excretion (mOsm_per_minute).
 * ALGEBRAIC[51] is OSMOPN in component normal_osmolar_and_water_excretion (mOsm_per_minute).
 * ALGEBRAIC[52] is OSMOP1T in component normal_urine_volume (mOsm_per_minute).
 * ALGEBRAIC[53] is OSMOP1 in component normal_urine_volume (mOsm_per_minute).
 * ALGEBRAIC[45] is NOD in component actual_Na_excretion_rate (monovalent_mEq_per_minute).
 * ALGEBRAIC[48] is KOD in component actual_K_excretion_rate (monovalent_mEq_per_minute).
 * ALGEBRAIC[55] is VUD in component actual_urine_volume (L_per_minute).
 * CONSTANTS[60] is RNAGTC in component parameter_values (minute).
 * CONSTANTS[61] is GFNDMP in component parameter_values (dimensionless).
 * RATES[0] is d/dt PAR1 in component perfusion_pressure (mmHg).
 * RATES[1] is d/dt RNAUG3 in component renal_autoregulatory_feedback_factor (dimensionless).
 * RATES[2] is d/dt PLUR in component glomerular_urea_concentration (mOsm).
 * RATES[3] is d/dt DTKA in component K_reabsorption_into_distal_tubules (monovalent_mEq_per_minute).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 1.0;
CONSTANTS[1] = 1.037;
CONSTANTS[2] = 1.0;
CONSTANTS[3] = 0.987545;
CONSTANTS[4] = 1.0;
CONSTANTS[5] = 1.00066;
CONSTANTS[6] = 4.44092;
CONSTANTS[7] = 142.035;
CONSTANTS[8] = 0.39984739;
CONSTANTS[9] = 1.0;
CONSTANTS[10] = 103.525;
CONSTANTS[11] = 1.0;
CONSTANTS[12] = 29.9941;
CONSTANTS[13] = 39.8952;
CONSTANTS[14] = 0;
CONSTANTS[15] = 0;
CONSTANTS[16] = 0;
CONSTANTS[17] = 0;
CONSTANTS[18] = 2000;
STATES[0] = 103.525;
CONSTANTS[19] = 0.6;
CONSTANTS[20] = 0.3;
CONSTANTS[21] = 10;
CONSTANTS[22] = 0;
STATES[1] = 0.0;
CONSTANTS[23] = 0.5;
CONSTANTS[24] = 1.4;
CONSTANTS[25] = 0.86;
CONSTANTS[26] = 1;
CONSTANTS[27] = 1.5;
CONSTANTS[28] = 4;
CONSTANTS[29] = 0.3;
CONSTANTS[30] = 1.6;
CONSTANTS[31] = 0;
CONSTANTS[32] = 1;
CONSTANTS[33] = 24;
CONSTANTS[34] = 1;
CONSTANTS[35] = 1.0;
CONSTANTS[36] = 1.0;
CONSTANTS[37] = 8;
CONSTANTS[38] = 0.0208333;
CONSTANTS[39] = 0.001;
CONSTANTS[40] = 10;
CONSTANTS[41] = 0.9;
CONSTANTS[42] = 15.2;
STATES[2] = 159.549;
CONSTANTS[43] = 0.24;
CONSTANTS[44] = 0.8;
CONSTANTS[45] = 19.167;
CONSTANTS[46] = 6;
CONSTANTS[47] = 0.5;
CONSTANTS[48] = 1;
CONSTANTS[49] = 0.3;
CONSTANTS[50] = 0.675;
CONSTANTS[51] = 1;
CONSTANTS[52] = 0.3;
CONSTANTS[53] = 1e-06;
CONSTANTS[54] = 1;
CONSTANTS[55] = 0.03;
CONSTANTS[56] = 0.667;
STATES[3] = 0.0367573;
CONSTANTS[57] = 2;
CONSTANTS[58] = 0.3;
CONSTANTS[59] = 4;
CONSTANTS[60] = 15;
CONSTANTS[61] = 3;
CONSTANTS[62] =  (CONSTANTS[5] - 1.00000)*CONSTANTS[23]+1.00000;
CONSTANTS[63] = (CONSTANTS[62]<0.800000 ? 0.800000 : CONSTANTS[62]);
CONSTANTS[64] =  (CONSTANTS[3] - 1.00000)*CONSTANTS[24]+1.00000;
CONSTANTS[65] = (CONSTANTS[64]<CONSTANTS[25] ? CONSTANTS[25] : CONSTANTS[64]);
CONSTANTS[66] =  (CONSTANTS[63] - 1.00000)*CONSTANTS[29]+1.00000;
CONSTANTS[67] =  (CONSTANTS[3] - 1.00000)*CONSTANTS[30]+1.00000;
CONSTANTS[68] =  ( (CONSTANTS[3] - 1.00000)*CONSTANTS[54]+1.00000)*0.100000;
CONSTANTS[69] = (CONSTANTS[68]<0.00000 ? 0.00000 : CONSTANTS[68]);
CONSTANTS[70] =  (CONSTANTS[3] - 1.00000)*CONSTANTS[57]+1.00000;
CONSTANTS[71] = (CONSTANTS[70]<CONSTANTS[58] ? CONSTANTS[58] : CONSTANTS[70]);
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
RATES[0] = ((100.000+ (CONSTANTS[10] - 100.000)*CONSTANTS[17]) - STATES[0])/CONSTANTS[18];
ALGEBRAIC[0] = (CONSTANTS[15]>0.00000&&CONSTANTS[16]<=0.00000 ? CONSTANTS[15] : CONSTANTS[16]>0.00000 ? STATES[0] : CONSTANTS[10] - CONSTANTS[14]);
rootfind_0(VOI, CONSTANTS, RATES, STATES, ALGEBRAIC, pret);
RATES[1] =  (ALGEBRAIC[3] - 1.00000)*CONSTANTS[22];
ALGEBRAIC[1] = STATES[2]/CONSTANTS[13];
ALGEBRAIC[47] =  pow(ALGEBRAIC[14], 2.00000)*ALGEBRAIC[1]*3.84000;
ALGEBRAIC[49] =  ALGEBRAIC[47]*CONSTANTS[34];
RATES[2] = CONSTANTS[43] - ALGEBRAIC[49];
ALGEBRAIC[34] =  ALGEBRAIC[2]*CONSTANTS[7]*0.00616190;
ALGEBRAIC[37] = ( ALGEBRAIC[34]*CONSTANTS[6])/CONSTANTS[7];
ALGEBRAIC[26] =  ALGEBRAIC[15]*CONSTANTS[41] - CONSTANTS[42];
ALGEBRAIC[27] = (ALGEBRAIC[26]<1.00000 ? 1.00000 : ALGEBRAIC[26]);
ALGEBRAIC[28] =  ( (ALGEBRAIC[13] - 1.20000)*CONSTANTS[44]+1.20000)*CONSTANTS[45];
ALGEBRAIC[29] = ((ALGEBRAIC[15]+CONSTANTS[46]) - ALGEBRAIC[28]) - ALGEBRAIC[27];
ALGEBRAIC[30] =  ALGEBRAIC[29]*CONSTANTS[47];
ALGEBRAIC[31] = ALGEBRAIC[30];
ALGEBRAIC[32] =  (ALGEBRAIC[31] - 1.00000)*CONSTANTS[49]+1.00000;
ALGEBRAIC[33] = (ALGEBRAIC[32]<0.000100000 ? 0.000100000 : ALGEBRAIC[32]);
ALGEBRAIC[38] =  (ALGEBRAIC[33] - 1.00000)*CONSTANTS[55];
ALGEBRAIC[39] =  (ALGEBRAIC[2] - 1.00000)*CONSTANTS[56]+1.00000;
ALGEBRAIC[40] = (ALGEBRAIC[39]<0.100000 ? 0.100000 : ALGEBRAIC[39]);
ALGEBRAIC[41] = ( pow(CONSTANTS[6]/4.40000, CONSTANTS[59])*CONSTANTS[1]*0.0800000*ALGEBRAIC[40])/CONSTANTS[71];
ALGEBRAIC[44] = ((ALGEBRAIC[37]+ALGEBRAIC[41]) - STATES[3]) - ALGEBRAIC[38];
ALGEBRAIC[46] = (ALGEBRAIC[44]<0.00000 ? 0.00000 : ALGEBRAIC[44]);
ALGEBRAIC[35] =  (( CONSTANTS[2]*ALGEBRAIC[33]*CONSTANTS[50])/CONSTANTS[51])*( (CONSTANTS[0] - 1.00000)*CONSTANTS[52]+1.00000);
ALGEBRAIC[36] = (ALGEBRAIC[35]<CONSTANTS[53] ? CONSTANTS[53] : ALGEBRAIC[35]);
ALGEBRAIC[42] = (ALGEBRAIC[34] - ALGEBRAIC[36]) - CONSTANTS[69];
ALGEBRAIC[43] = (ALGEBRAIC[42]<1.00000e-08 ? 1.00000e-08 : ALGEBRAIC[42]);
ALGEBRAIC[50] = ALGEBRAIC[47]+ 2.00000*(ALGEBRAIC[43]+ALGEBRAIC[46]);
ALGEBRAIC[51] = (ALGEBRAIC[50]>0.600000 ? 0.600000 : ALGEBRAIC[50]);
ALGEBRAIC[52] = ALGEBRAIC[50] - 0.600000;
ALGEBRAIC[53] = (ALGEBRAIC[52]<0.00000 ? 0.00000 : ALGEBRAIC[52]);
ALGEBRAIC[54] = ALGEBRAIC[51]/( 600.000*CONSTANTS[0])+ALGEBRAIC[53]/360.000;
RATES[3] =  ( (ALGEBRAIC[46]/ALGEBRAIC[54])*0.000451800 - STATES[3])*1.00000;
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = (CONSTANTS[15]>0.00000&&CONSTANTS[16]<=0.00000 ? CONSTANTS[15] : CONSTANTS[16]>0.00000 ? STATES[0] : CONSTANTS[10] - CONSTANTS[14]);
ALGEBRAIC[1] = STATES[2]/CONSTANTS[13];
ALGEBRAIC[47] =  pow(ALGEBRAIC[14], 2.00000)*ALGEBRAIC[1]*3.84000;
ALGEBRAIC[49] =  ALGEBRAIC[47]*CONSTANTS[34];
ALGEBRAIC[34] =  ALGEBRAIC[2]*CONSTANTS[7]*0.00616190;
ALGEBRAIC[37] = ( ALGEBRAIC[34]*CONSTANTS[6])/CONSTANTS[7];
ALGEBRAIC[26] =  ALGEBRAIC[15]*CONSTANTS[41] - CONSTANTS[42];
ALGEBRAIC[27] = (ALGEBRAIC[26]<1.00000 ? 1.00000 : ALGEBRAIC[26]);
ALGEBRAIC[28] =  ( (ALGEBRAIC[13] - 1.20000)*CONSTANTS[44]+1.20000)*CONSTANTS[45];
ALGEBRAIC[29] = ((ALGEBRAIC[15]+CONSTANTS[46]) - ALGEBRAIC[28]) - ALGEBRAIC[27];
ALGEBRAIC[30] =  ALGEBRAIC[29]*CONSTANTS[47];
ALGEBRAIC[31] = ALGEBRAIC[30];
ALGEBRAIC[32] =  (ALGEBRAIC[31] - 1.00000)*CONSTANTS[49]+1.00000;
ALGEBRAIC[33] = (ALGEBRAIC[32]<0.000100000 ? 0.000100000 : ALGEBRAIC[32]);
ALGEBRAIC[38] =  (ALGEBRAIC[33] - 1.00000)*CONSTANTS[55];
ALGEBRAIC[39] =  (ALGEBRAIC[2] - 1.00000)*CONSTANTS[56]+1.00000;
ALGEBRAIC[40] = (ALGEBRAIC[39]<0.100000 ? 0.100000 : ALGEBRAIC[39]);
ALGEBRAIC[41] = ( pow(CONSTANTS[6]/4.40000, CONSTANTS[59])*CONSTANTS[1]*0.0800000*ALGEBRAIC[40])/CONSTANTS[71];
ALGEBRAIC[44] = ((ALGEBRAIC[37]+ALGEBRAIC[41]) - STATES[3]) - ALGEBRAIC[38];
ALGEBRAIC[46] = (ALGEBRAIC[44]<0.00000 ? 0.00000 : ALGEBRAIC[44]);
ALGEBRAIC[35] =  (( CONSTANTS[2]*ALGEBRAIC[33]*CONSTANTS[50])/CONSTANTS[51])*( (CONSTANTS[0] - 1.00000)*CONSTANTS[52]+1.00000);
ALGEBRAIC[36] = (ALGEBRAIC[35]<CONSTANTS[53] ? CONSTANTS[53] : ALGEBRAIC[35]);
ALGEBRAIC[42] = (ALGEBRAIC[34] - ALGEBRAIC[36]) - CONSTANTS[69];
ALGEBRAIC[43] = (ALGEBRAIC[42]<1.00000e-08 ? 1.00000e-08 : ALGEBRAIC[42]);
ALGEBRAIC[50] = ALGEBRAIC[47]+ 2.00000*(ALGEBRAIC[43]+ALGEBRAIC[46]);
ALGEBRAIC[51] = (ALGEBRAIC[50]>0.600000 ? 0.600000 : ALGEBRAIC[50]);
ALGEBRAIC[52] = ALGEBRAIC[50] - 0.600000;
ALGEBRAIC[53] = (ALGEBRAIC[52]<0.00000 ? 0.00000 : ALGEBRAIC[52]);
ALGEBRAIC[54] = ALGEBRAIC[51]/( 600.000*CONSTANTS[0])+ALGEBRAIC[53]/360.000;
ALGEBRAIC[24] =  CONSTANTS[34]*ALGEBRAIC[13];
ALGEBRAIC[25] =  ALGEBRAIC[14]*CONSTANTS[34];
ALGEBRAIC[45] =  ALGEBRAIC[43]*CONSTANTS[34];
ALGEBRAIC[48] =  ALGEBRAIC[46]*CONSTANTS[34];
ALGEBRAIC[55] =  ALGEBRAIC[54]*CONSTANTS[34];
}

void objfunc_0(double *p, double *hx, int m, int n, void *adata)
{
  struct rootfind_info* rfi = (struct rootfind_info*)adata;
#define VOI rfi->aVOI
#define CONSTANTS rfi->aCONSTANTS
#define RATES rfi->aRATES
#define STATES rfi->aSTATES
#define ALGEBRAIC rfi->aALGEBRAIC
#define pret rfi->aPRET
  ALGEBRAIC[2] = p[0];
  ALGEBRAIC[3] = p[1];
  ALGEBRAIC[4] = p[2];
  ALGEBRAIC[5] = p[3];
  ALGEBRAIC[6] = p[4];
  ALGEBRAIC[7] = p[5];
  ALGEBRAIC[8] = p[6];
  ALGEBRAIC[9] = p[7];
  ALGEBRAIC[10] = p[8];
  ALGEBRAIC[11] = p[9];
  ALGEBRAIC[12] = p[10];
  ALGEBRAIC[13] = p[11];
  ALGEBRAIC[14] = p[12];
  ALGEBRAIC[15] = p[13];
  ALGEBRAIC[16] = p[14];
  ALGEBRAIC[17] = p[15];
  ALGEBRAIC[18] = p[16];
  ALGEBRAIC[19] = p[17];
  ALGEBRAIC[20] = p[18];
  ALGEBRAIC[21] = p[19];
  ALGEBRAIC[22] = p[20];
  ALGEBRAIC[23] = p[21];
  hx[0] = ALGEBRAIC[5] - ( (ALGEBRAIC[2] - 1.00000)*CONSTANTS[19]+1.00000);
  hx[1] = ALGEBRAIC[4] - (ALGEBRAIC[5]<CONSTANTS[20] ? CONSTANTS[20] : ALGEBRAIC[5]>CONSTANTS[21] ? CONSTANTS[21] : ALGEBRAIC[5]);
  hx[2] = ALGEBRAIC[3] - (ALGEBRAIC[4] - STATES[1]);
  hx[3] = ALGEBRAIC[6] -  CONSTANTS[26]*CONSTANTS[11]*CONSTANTS[63]*ALGEBRAIC[3]*CONSTANTS[65]*40.0000*CONSTANTS[9];
  hx[4] = ALGEBRAIC[8] - ((ALGEBRAIC[6] -  CONSTANTS[4]*CONSTANTS[27])+CONSTANTS[27]);
  hx[5] = ALGEBRAIC[7] - (ALGEBRAIC[8]<CONSTANTS[28] ? CONSTANTS[28] : ALGEBRAIC[8]);
  hx[6] = ALGEBRAIC[9] - ( (ALGEBRAIC[3] - 1.00000)*CONSTANTS[31]+1.00000);
  hx[7] = ALGEBRAIC[11] -  43.3330*CONSTANTS[32]*CONSTANTS[67]*ALGEBRAIC[9]*CONSTANTS[9]*CONSTANTS[66];
  hx[8] = ALGEBRAIC[10] - (ALGEBRAIC[11]<CONSTANTS[33] ? CONSTANTS[33] : ALGEBRAIC[11]);
  hx[9] = ALGEBRAIC[12] - (ALGEBRAIC[7]+ALGEBRAIC[10]);
  hx[10] = ALGEBRAIC[13] - ALGEBRAIC[0]/ALGEBRAIC[12];
  hx[11] = ALGEBRAIC[17] - ( ALGEBRAIC[13]*(1.00000 - CONSTANTS[8]))/( ALGEBRAIC[13]*(1.00000 - CONSTANTS[8]) - ALGEBRAIC[14]);
  hx[12] = ALGEBRAIC[16] - (ALGEBRAIC[17]<1.00000 ? 1.00000 : ALGEBRAIC[17]);
  hx[13] = ALGEBRAIC[15] - (CONSTANTS[36]>0.00000 ?  pow(ALGEBRAIC[16], 1.35000)*CONSTANTS[12]*0.980000 : CONSTANTS[12]+4.00000);
  hx[14] = ALGEBRAIC[19] -  ALGEBRAIC[7]*ALGEBRAIC[13];
  hx[15] = ALGEBRAIC[18] - (ALGEBRAIC[0] - ALGEBRAIC[19]);
  hx[16] = ALGEBRAIC[20] - ((ALGEBRAIC[18] - ALGEBRAIC[15]) - CONSTANTS[37]);
  hx[17] = ALGEBRAIC[21] -  ALGEBRAIC[20]*CONSTANTS[38];
  hx[18] = ALGEBRAIC[14] - (ALGEBRAIC[21]<CONSTANTS[39] ? CONSTANTS[39] : ALGEBRAIC[21]);
  hx[19] = ALGEBRAIC[22] -  ALGEBRAIC[14]*8.00000;
  hx[20] = ALGEBRAIC[23] - ( (ALGEBRAIC[22] - 1.00000)*CONSTANTS[40]+1.00000);
  hx[21] = ALGEBRAIC[2] - (ALGEBRAIC[23]<0.00000 ? 0.00000 : ALGEBRAIC[23]);
#undef VOI
#undef CONSTANTS
#undef RATES
#undef STATES
#undef ALGEBRAIC
#undef pret
}
void rootfind_0(double VOI, double* CONSTANTS, double* RATES,
double* STATES, double* ALGEBRAIC, int* pret)
{
  static double p[22] = {1.00051,1.00071,1.00071,1.00071,40,40,40,0.6,42.4737,42.4737,84.8171,1.22057,0.125006,37.8383,1.20569,1.20569,51.842,47.88,6.00368,0.125006,1.00005,1.00051};
  double bp[22], work[LM_DIF_WORKSZ(22, 22)];
  struct rootfind_info rfi;
  rfi.aVOI = VOI;
  rfi.aCONSTANTS = CONSTANTS;
  rfi.aRATES = RATES;
  rfi.aSTATES = STATES;
  rfi.aALGEBRAIC = ALGEBRAIC;
  rfi.aPRET = pret;
  do_levmar(objfunc_0, p, bp, work, pret, 22, &rfi);
  ALGEBRAIC[2] = p[0];
  ALGEBRAIC[3] = p[1];
  ALGEBRAIC[4] = p[2];
  ALGEBRAIC[5] = p[3];
  ALGEBRAIC[6] = p[4];
  ALGEBRAIC[7] = p[5];
  ALGEBRAIC[8] = p[6];
  ALGEBRAIC[9] = p[7];
  ALGEBRAIC[10] = p[8];
  ALGEBRAIC[11] = p[9];
  ALGEBRAIC[12] = p[10];
  ALGEBRAIC[13] = p[11];
  ALGEBRAIC[14] = p[12];
  ALGEBRAIC[15] = p[13];
  ALGEBRAIC[16] = p[14];
  ALGEBRAIC[17] = p[15];
  ALGEBRAIC[18] = p[16];
  ALGEBRAIC[19] = p[17];
  ALGEBRAIC[20] = p[18];
  ALGEBRAIC[21] = p[19];
  ALGEBRAIC[22] = p[20];
  ALGEBRAIC[23] = p[21];
}