Generated Code

The following is matlab code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = mainFunction()
    % This is the "main function".  In Matlab, things work best if you rename this function to match the filename.
   [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel();
end

function [algebraicVariableCount] = getAlgebraicVariableCount() 
    % Used later when setting a global variable with the number of algebraic variables.
    % Note: This is not the "main method".  
    algebraicVariableCount =179;
end
% There are a total of 17 entries in each of the rate and state variable arrays.
% There are a total of 230 entries in the constant variable array.
%

function [VOI, STATES, ALGEBRAIC, CONSTANTS] = solveModel()
    % Create ALGEBRAIC of correct size
    global algebraicVariableCount;  algebraicVariableCount = getAlgebraicVariableCount();
    % Initialise constants and state variables
    [INIT_STATES, CONSTANTS] = initConsts;

    % Set timespan to solve over 
    tspan = [0, 10];

    % Set numerical accuracy options for ODE solver
    options = odeset('RelTol', 1e-06, 'AbsTol', 1e-06, 'MaxStep', 1);

    % Solve model with ODE solver
    [VOI, STATES] = ode15s(@(VOI, STATES)computeRates(VOI, STATES, CONSTANTS), tspan, INIT_STATES, options);

    % Compute algebraic variables
    [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS);
    ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI);

    % Plot state variables against variable of integration
    [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends();
    figure();
    plot(VOI, STATES);
    xlabel(LEGEND_VOI);
    l = legend(LEGEND_STATES);
    set(l,'Interpreter','none');
end

function [LEGEND_STATES, LEGEND_ALGEBRAIC, LEGEND_VOI, LEGEND_CONSTANTS] = createLegends()
    LEGEND_STATES = ''; LEGEND_ALGEBRAIC = ''; LEGEND_VOI = ''; LEGEND_CONSTANTS = '';
    LEGEND_VOI = strpad('time in component environment (day)');
    LEGEND_ALGEBRAIC(:,11) = strpad('U_Pd_PdPs in component Q_Pd (mole_per_day)');
    LEGEND_STATES(:,1) = strpad('Q_Pd in component Q_Pd (mole)');
    LEGEND_ALGEBRAIC(:,1) = strpad('C_Pd in component Q_Pd (molar)');
    LEGEND_ALGEBRAIC(:,9) = strpad('U_Pd_PdEx in component Q_Pd (mole_per_day)');
    LEGEND_CONSTANTS(:,156) = strpad('P_Pd_InPd in component Q_Pd (mole_per_day)');
    LEGEND_ALGEBRAIC(:,10) = strpad('v_PdPs in component Q_Pd (mole_per_day)');
    LEGEND_CONSTANTS(:,1) = strpad('v_PdPs_star in component Q_Pd (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,175) = strpad('M_Pd_PdPs in component Q_Pd (molar)');
    LEGEND_CONSTANTS(:,2) = strpad('M_Pd_PdPs_star in component Q_Pd (molar)');
    LEGEND_CONSTANTS(:,3) = strpad('Y_Pd_InPd in component Q_Pd (molar)');
    LEGEND_CONSTANTS(:,4) = strpad('D_Pd in component Q_Pd (litre_per_day)');
    LEGEND_CONSTANTS(:,155) = strpad('k_PdEx in component Q_Pd (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,5) = strpad('T_Pd in component Q_Pd (day)');
    LEGEND_CONSTANTS(:,6) = strpad('T_Pd_star in component Q_Pd (day)');
    LEGEND_STATES(:,2) = strpad('Q_Ma in component Q_Ma (gram)');
    LEGEND_STATES(:,3) = strpad('Q_Mc in component Q_Mc (gram)');
    LEGEND_CONSTANTS(:,7) = strpad('V_Ru in component model_parameters (litre)');
    LEGEND_CONSTANTS(:,8) = strpad('k_SoEx in component model_parameters (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,12) = strpad('C_Ps in component Q_Ps (molar)');
    LEGEND_ALGEBRAIC(:,49) = strpad('U_McPs_PsAm in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,37) = strpad('U_Ps_PsMa in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,50) = strpad('U_Ps_PsMc in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,36) = strpad('U_MaPs_PsAm in component Q_Ps (mole_per_day)');
    LEGEND_CONSTANTS(:,9) = strpad('M_Ha_McMa in component Q_Ps (molar)');
    LEGEND_STATES(:,4) = strpad('Q_Ps in component Q_Ps (mole)');
    LEGEND_CONSTANTS(:,177) = strpad('P_Ps_InPs in component Q_Ps (mole_per_day)');
    LEGEND_CONSTANTS(:,180) = strpad('P_Ps_SaPs in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,13) = strpad('P_Ps_PdPs in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,63) = strpad('P_Ps_MaMd in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,79) = strpad('P_Ps_McPs in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,14) = strpad('U_Ps_PsEx in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,77) = strpad('U_Mc_McPs in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,15) = strpad('v_Ma_PsAm in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,16) = strpad('v_Mc_PsAm in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,17) = strpad('v_PsMa in component Q_Ps (mole_per_day)');
    LEGEND_ALGEBRAIC(:,18) = strpad('v_PsMc in component Q_Ps (mole_per_day)');
    LEGEND_CONSTANTS(:,10) = strpad('v_PsAm_star in component Q_Ps (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,11) = strpad('v_PsMa_star in component Q_Ps (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,12) = strpad('v_PsMc_star in component Q_Ps (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,157) = strpad('k_PsEx in component Q_Ps (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,13) = strpad('Y_Ps_InPs in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,14) = strpad('Y_Ps_SaPs in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,15) = strpad('Y_Ps_PdPs in component Q_Ps (dimensionless)');
    LEGEND_CONSTANTS(:,16) = strpad('Y_Ps_MaMd in component Q_Ps (mole_per_gram)');
    LEGEND_CONSTANTS(:,17) = strpad('Y_Ps_McPs in component Q_Ps (dimensionless)');
    LEGEND_CONSTANTS(:,18) = strpad('D_Ps in component Q_Ps (litre_per_day)');
    LEGEND_CONSTANTS(:,19) = strpad('M_Ps_PsAm in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,20) = strpad('M_Ps_PsMa in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,21) = strpad('M_Ps_PsMc in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,22) = strpad('M_Ha_PsMa in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,23) = strpad('M_Hc_PsMc in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,24) = strpad('J_Ha_PsAm in component Q_Ps (molar)');
    LEGEND_CONSTANTS(:,25) = strpad('J_Hc_PsAm in component Q_Ps (molar)');
    LEGEND_ALGEBRAIC(:,76) = strpad('U_Mc_McEg in component Q_Mc (gram_per_day)');
    LEGEND_ALGEBRAIC(:,62) = strpad('U_Ma_MaMd in component Q_Ma (gram_per_day)');
    LEGEND_ALGEBRAIC(:,55) = strpad('U_Hc_PsMc in component Q_Hc (mole_per_day)');
    LEGEND_ALGEBRAIC(:,83) = strpad('U_Ha_McMa in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,35) = strpad('C_Ha in component Q_Ha (molar)');
    LEGEND_ALGEBRAIC(:,48) = strpad('C_Hc in component Q_Hc (molar)');
    LEGEND_CONSTANTS(:,26) = strpad('k_FlEx in component model_parameters (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,27) = strpad('J_Ha_McAm in component model_parameters (molar)');
    LEGEND_STATES(:,5) = strpad('Q_Pu in component Q_Pu (mole)');
    LEGEND_ALGEBRAIC(:,2) = strpad('C_Pu in component Q_Pu (molar)');
    LEGEND_CONSTANTS(:,158) = strpad('P_Pu_InPu in component Q_Pu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,3) = strpad('U_Pu_PuEx in component Q_Pu (mole_per_day)');
    LEGEND_CONSTANTS(:,28) = strpad('Y_Pu_InPu in component Q_Pu (molar)');
    LEGEND_CONSTANTS(:,29) = strpad('D_Pu in component Q_Pu (litre_per_day)');
    LEGEND_CONSTANTS(:,159) = strpad('k_PuEx in component Q_Pu (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,19) = strpad('C_Am in component Q_Am (molar)');
    LEGEND_ALGEBRAIC(:,52) = strpad('U_Am_AmMc in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,39) = strpad('U_Am_AmMa in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,78) = strpad('U_Mc_McAm in component Q_Am (mole_per_day)');
    LEGEND_STATES(:,6) = strpad('Q_Am in component Q_Am (mole)');
    LEGEND_CONSTANTS(:,181) = strpad('P_Am_InAm in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,23) = strpad('P_Am_UeAm in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,38) = strpad('P_MaAm_PsAm in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,51) = strpad('P_McAm_PsAm in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,80) = strpad('P_Am_McAm in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,20) = strpad('U_Am_AmAb in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,21) = strpad('U_Am_AmEx in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,22) = strpad('v_UeAm in component Q_Am (mole_per_day)');
    LEGEND_CONSTANTS(:,182) = strpad('v_AmAb in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,24) = strpad('v_AmMa in component Q_Am (mole_per_day)');
    LEGEND_ALGEBRAIC(:,25) = strpad('v_AmMc in component Q_Am (mole_per_day)');
    LEGEND_CONSTANTS(:,30) = strpad('v_UeAm_star in component Q_Am (mole_per_litre_day)');
    LEGEND_CONSTANTS(:,31) = strpad('v_AmAb_star in component Q_Am (mole_per_litre_day)');
    LEGEND_CONSTANTS(:,32) = strpad('v_AmMa_star in component Q_Am (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,33) = strpad('v_AmMc_star in component Q_Am (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,160) = strpad('k_AmEx in component Q_Am (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,34) = strpad('Y_Am_InAm in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,35) = strpad('Y_Am_UeAm in component Q_Am (dimensionless)');
    LEGEND_CONSTANTS(:,36) = strpad('Y_Am_PsAm in component Q_Am (dimensionless)');
    LEGEND_CONSTANTS(:,37) = strpad('Y_Am_McAm in component Q_Am (dimensionless)');
    LEGEND_CONSTANTS(:,38) = strpad('M_Am_AmMa in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,39) = strpad('M_Am_AmMc in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,40) = strpad('M_Am_AmAb in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,41) = strpad('M_pH_AmAb in component Q_Am (dimensionless)');
    LEGEND_CONSTANTS(:,42) = strpad('phi_pH_AmAb in component Q_Am (dimensionless)');
    LEGEND_CONSTANTS(:,43) = strpad('M_Ha_AmMa in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,44) = strpad('M_Hc_AmMc in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,45) = strpad('J_Am_UeAm in component Q_Am (molar)');
    LEGEND_CONSTANTS(:,46) = strpad('D_Am in component Q_Am (litre_per_day)');
    LEGEND_CONSTANTS(:,47) = strpad('pH in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,48) = strpad('f_Po_Ma in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,49) = strpad('f_Ni_Fe in component model_parameters (dimensionless)');
    LEGEND_STATES(:,7) = strpad('Q_Li in component Q_Li (mole)');
    LEGEND_ALGEBRAIC(:,4) = strpad('C_Li in component Q_Li (molar)');
    LEGEND_CONSTANTS(:,183) = strpad('P_Li_InLi in component Q_Li (mole_per_day)');
    LEGEND_ALGEBRAIC(:,64) = strpad('P_Li_MaMd in component Q_Li (mole_per_day)');
    LEGEND_ALGEBRAIC(:,26) = strpad('U_Li_LiEx in component Q_Li (mole_per_day)');
    LEGEND_CONSTANTS(:,50) = strpad('Y_Li_InLi in component Q_Li (molar)');
    LEGEND_CONSTANTS(:,51) = strpad('Y_Li_MaMd in component Q_Li (mole_per_gram)');
    LEGEND_CONSTANTS(:,52) = strpad('D_Li in component Q_Li (litre_per_day)');
    LEGEND_CONSTANTS(:,161) = strpad('k_LiEx in component Q_Li (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,30) = strpad('U_Sd_SdHa in component Q_Sd (mole_per_day)');
    LEGEND_STATES(:,8) = strpad('Q_Sd in component Q_Sd (mole)');
    LEGEND_ALGEBRAIC(:,27) = strpad('C_Sd in component Q_Sd (molar)');
    LEGEND_CONSTANTS(:,184) = strpad('P_Sd_InSd in component Q_Sd (mole_per_day)');
    LEGEND_ALGEBRAIC(:,28) = strpad('U_Sd_SdEx in component Q_Sd (mole_per_day)');
    LEGEND_CONSTANTS(:,53) = strpad('Y_Sd_InSd in component Q_Sd (molar)');
    LEGEND_CONSTANTS(:,54) = strpad('D_Sd in component Q_Sd (litre_per_day)');
    LEGEND_CONSTANTS(:,162) = strpad('k_SdEx in component Q_Sd (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,29) = strpad('v_SdHa in component Q_Sd (mole_per_day)');
    LEGEND_CONSTANTS(:,55) = strpad('v_SdHa_star in component Q_Sd (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,185) = strpad('M_Sd_SdHa in component Q_Sd (molar)');
    LEGEND_CONSTANTS(:,56) = strpad('M_Sd_SdHa_star in component Q_Sd (molar)');
    LEGEND_CONSTANTS(:,57) = strpad('T_Sd in component Q_Sd (day)');
    LEGEND_CONSTANTS(:,58) = strpad('T_Sd_star in component Q_Sd (day)');
    LEGEND_ALGEBRAIC(:,34) = strpad('U_Fd_FdHc in component Q_Fd (mole_per_day)');
    LEGEND_STATES(:,9) = strpad('Q_Fd in component Q_Fd (mole)');
    LEGEND_ALGEBRAIC(:,31) = strpad('C_Fd in component Q_Fd (molar)');
    LEGEND_CONSTANTS(:,186) = strpad('P_Fd_InFd in component Q_Fd (mole_per_day)');
    LEGEND_ALGEBRAIC(:,32) = strpad('U_Fd_FdEx in component Q_Fd (mole_per_day)');
    LEGEND_CONSTANTS(:,59) = strpad('Y_Fd_InFd in component Q_Fd (molar)');
    LEGEND_CONSTANTS(:,60) = strpad('D_Fd in component Q_Fd (litre_per_day)');
    LEGEND_CONSTANTS(:,163) = strpad('k_FdEx in component Q_Fd (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,33) = strpad('v_FdHc in component Q_Fd (mole_per_day)');
    LEGEND_CONSTANTS(:,61) = strpad('v_FdHc_star in component Q_Fd (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,187) = strpad('M_Fd_FdHc in component Q_Fd (molar)');
    LEGEND_CONSTANTS(:,62) = strpad('M_Fd_FdHc_star in component Q_Fd (molar)');
    LEGEND_CONSTANTS(:,63) = strpad('T_Fd in component Q_Fd (day)');
    LEGEND_CONSTANTS(:,64) = strpad('T_Fd_star in component Q_Fd (day)');
    LEGEND_CONSTANTS(:,65) = strpad('phi_pH_FdHc in component Q_Fd (dimensionless)');
    LEGEND_CONSTANTS(:,66) = strpad('M_pH_FdHc in component Q_Fd (dimensionless)');
    LEGEND_CONSTANTS(:,67) = strpad('pm in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,68) = strpad('f in component model_parameters (dimensionless)');
    LEGEND_STATES(:,10) = strpad('Q_Fu in component Q_Fu (mole)');
    LEGEND_ALGEBRAIC(:,5) = strpad('C_Fu in component Q_Fu (molar)');
    LEGEND_CONSTANTS(:,164) = strpad('P_Fu_InFu in component Q_Fu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,6) = strpad('U_Fu_FuEx in component Q_Fu (mole_per_day)');
    LEGEND_CONSTANTS(:,69) = strpad('Y_Fu_InFu in component Q_Fu (molar)');
    LEGEND_CONSTANTS(:,70) = strpad('D_Fu in component Q_Fu (litre_per_day)');
    LEGEND_CONSTANTS(:,165) = strpad('k_FuEx in component Q_Fu (first_order_rate_constant)');
    LEGEND_ALGEBRAIC(:,45) = strpad('U_Ha_HaAs in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,41) = strpad('U_Ha_AmMa in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,42) = strpad('U_Ha_PsMa in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,47) = strpad('U_Ha_HaVa in component Q_Ha (mole_per_day)');
    LEGEND_CONSTANTS(:,188) = strpad('P_Ha_WrHa in component Q_Ha (mole_per_day)');
    LEGEND_CONSTANTS(:,190) = strpad('P_Ha_LaHa in component Q_Ha (mole_per_day)');
    LEGEND_CONSTANTS(:,189) = strpad('P_Ha_SrHa in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,40) = strpad('P_Ha_SdHa in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,68) = strpad('P_Ha_MaMd in component Q_Ha (mole_per_day)');
    LEGEND_STATES(:,11) = strpad('Q_Ha in component Q_Ha (mole)');
    LEGEND_ALGEBRAIC(:,43) = strpad('U_Ha_HaEx in component Q_Ha (mole_per_day)');
    LEGEND_CONSTANTS(:,71) = strpad('R_Ha_AmMa in component Q_Ha (dimensionless)');
    LEGEND_CONSTANTS(:,72) = strpad('R_Ha_PsMa in component Q_Ha (dimensionless)');
    LEGEND_CONSTANTS(:,73) = strpad('R_Ha_McMa in component Q_Ha (mole_per_gram)');
    LEGEND_CONSTANTS(:,74) = strpad('M_Ha_HaAs in component Q_Ha (molar)');
    LEGEND_CONSTANTS(:,75) = strpad('M_Ha_HaVa in component Q_Ha (molar)');
    LEGEND_ALGEBRAIC(:,44) = strpad('v_HaAs in component Q_Ha (mole_per_day)');
    LEGEND_ALGEBRAIC(:,46) = strpad('v_HaVa in component Q_Ha (mole_per_day)');
    LEGEND_CONSTANTS(:,76) = strpad('v_HaAs_star in component Q_Ha (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,77) = strpad('v_HaVa_star in component Q_Ha (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,166) = strpad('k_HaEx in component Q_Ha (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,78) = strpad('Y_Ha_WrHa in component Q_Ha (molar)');
    LEGEND_CONSTANTS(:,79) = strpad('Y_Ha_SrHa in component Q_Ha (molar)');
    LEGEND_CONSTANTS(:,80) = strpad('Y_Ha_LaHa in component Q_Ha (molar)');
    LEGEND_CONSTANTS(:,81) = strpad('Y_Ha_SdHa in component Q_Ha (dimensionless)');
    LEGEND_CONSTANTS(:,82) = strpad('Y_Ha_MaMd in component Q_Ha (mole_per_gram)');
    LEGEND_CONSTANTS(:,83) = strpad('D_Wr in component Q_Ha (litre_per_day)');
    LEGEND_CONSTANTS(:,84) = strpad('D_Sr in component Q_Ha (litre_per_day)');
    LEGEND_CONSTANTS(:,85) = strpad('D_La in component Q_Ha (litre_per_day)');
    LEGEND_CONSTANTS(:,86) = strpad('J_Am_HaVa in component Q_Ha (molar)');
    LEGEND_CONSTANTS(:,87) = strpad('J_Ps_HaVa in component Q_Ha (molar)');
    LEGEND_ALGEBRAIC(:,67) = strpad('U_As_MaMd in component Q_As (gram_per_day)');
    LEGEND_ALGEBRAIC(:,81) = strpad('U_Mc_McMa in component Q_Ma (gram_per_day)');
    LEGEND_ALGEBRAIC(:,54) = strpad('U_Hc_AmMc in component Q_Hc (mole_per_day)');
    LEGEND_ALGEBRAIC(:,58) = strpad('U_Hc_HcVa in component Q_Hc (mole_per_day)');
    LEGEND_STATES(:,12) = strpad('Q_Hc in component Q_Hc (mole)');
    LEGEND_ALGEBRAIC(:,53) = strpad('P_Hc_FdHc in component Q_Hc (mole_per_day)');
    LEGEND_ALGEBRAIC(:,56) = strpad('U_Hc_HcEx in component Q_Hc (mole_per_day)');
    LEGEND_CONSTANTS(:,88) = strpad('R_Hc_AmMc in component Q_Hc (dimensionless)');
    LEGEND_CONSTANTS(:,89) = strpad('R_Hc_PsMc in component Q_Hc (dimensionless)');
    LEGEND_ALGEBRAIC(:,57) = strpad('v_HcVa in component Q_Hc (mole_per_day)');
    LEGEND_CONSTANTS(:,90) = strpad('v_HcVa_star in component Q_Hc (mole_per_gram_day)');
    LEGEND_CONSTANTS(:,167) = strpad('k_HcEx in component Q_Hc (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,91) = strpad('Y_Hc_FdHc in component Q_Hc (dimensionless)');
    LEGEND_CONSTANTS(:,92) = strpad('M_Hc_HcVa in component Q_Hc (molar)');
    LEGEND_CONSTANTS(:,93) = strpad('J_Am_HcVa in component Q_Hc (molar)');
    LEGEND_CONSTANTS(:,94) = strpad('J_Ps_HcVa in component Q_Hc (molar)');
    LEGEND_ALGEBRAIC(:,59) = strpad('C_Ma in component Q_Ma (gram_per_litre)');
    LEGEND_ALGEBRAIC(:,60) = strpad('P_Ma_AmMa in component Q_Ma (gram_per_day)');
    LEGEND_ALGEBRAIC(:,61) = strpad('P_Ma_PsMa in component Q_Ma (gram_per_day)');
    LEGEND_ALGEBRAIC(:,82) = strpad('P_Ma_McMa in component Q_Ma (gram_per_day)');
    LEGEND_ALGEBRAIC(:,65) = strpad('U_Ma_PoEx in component Q_Ma (gram_per_day)');
    LEGEND_ALGEBRAIC(:,7) = strpad('U_Ma_MaEx in component Q_Ma (gram_per_day)');
    LEGEND_CONSTANTS(:,178) = strpad('k_MaMd in component Q_Ma (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,95) = strpad('Y_Ma_AmMa in component Q_Ma (gram_per_mole)');
    LEGEND_CONSTANTS(:,96) = strpad('Y_Ma_PsMa in component Q_Ma (gram_per_mole)');
    LEGEND_CONSTANTS(:,97) = strpad('Y_Ma_McMa in component Q_Ma (dimensionless)');
    LEGEND_CONSTANTS(:,168) = strpad('k_MaEx in component model_parameters (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,176) = strpad('k_PoEx in component model_parameters (first_order_rate_constant)');
    LEGEND_STATES(:,13) = strpad('Q_As in component Q_As (gram)');
    LEGEND_ALGEBRAIC(:,8) = strpad('C_As in component Q_As (gram_per_litre)');
    LEGEND_ALGEBRAIC(:,66) = strpad('P_As_HaAs in component Q_As (gram_per_day)');
    LEGEND_ALGEBRAIC(:,71) = strpad('U_As_PoEx in component Q_As (gram_per_day)');
    LEGEND_ALGEBRAIC(:,69) = strpad('U_As_AsEx in component Q_As (gram_per_day)');
    LEGEND_CONSTANTS(:,169) = strpad('k_AsEx in component Q_As (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,179) = strpad('k_AsMd in component Q_As (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,98) = strpad('Y_As_HaAs in component Q_As (gram_per_mole)');
    LEGEND_ALGEBRAIC(:,70) = strpad('C_Mc in component Q_Mc (gram_per_litre)');
    LEGEND_ALGEBRAIC(:,72) = strpad('P_Mc_AmMc in component Q_Mc (gram_per_day)');
    LEGEND_ALGEBRAIC(:,73) = strpad('P_Mc_PsMc in component Q_Mc (gram_per_day)');
    LEGEND_ALGEBRAIC(:,74) = strpad('U_Mc_McEx in component Q_Mc (gram_per_day)');
    LEGEND_CONSTANTS(:,170) = strpad('k_McEx in component Q_Mc (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,99) = strpad('Y_Mc_AmMc in component Q_Mc (gram_per_mole)');
    LEGEND_CONSTANTS(:,100) = strpad('Y_Mc_PsMc in component Q_Mc (gram_per_mole)');
    LEGEND_ALGEBRAIC(:,75) = strpad('v_McEg in component Q_Mc (gram_per_day)');
    LEGEND_CONSTANTS(:,101) = strpad('v_McEg_star in component Q_Mc (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,102) = strpad('M_Mc_McEg in component Q_Mc (gram_per_litre)');
    LEGEND_STATES(:,14) = strpad('Q_Ac in component Q_Ac (mole)');
    LEGEND_ALGEBRAIC(:,84) = strpad('C_Ac in component Q_Ac (molar)');
    LEGEND_CONSTANTS(:,191) = strpad('P_Ac_InAc in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,160) = strpad('P_Ac_AmMa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,120) = strpad('P_Ac_AmMc in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,168) = strpad('P_Ac_PsMa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,132) = strpad('P_Ac_PsMc in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,176) = strpad('P_Ac_HaAs in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,152) = strpad('P_Ac_HaVa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,88) = strpad('P_Ac_HcVa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,92) = strpad('P_MaAc_PsAm in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,96) = strpad('P_McAc_PsAm in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,144) = strpad('P_Ac_McMa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,100) = strpad('P_Ac_McAm in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,104) = strpad('U_Ac_AcAb in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,108) = strpad('U_Ac_AcEx in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,112) = strpad('U_Hf_AmMa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,116) = strpad('U_Hf_AmMc in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,124) = strpad('U_Hf_PsMa in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,128) = strpad('U_Hf_PsMc in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,136) = strpad('U_Hf_HaAs in component Q_Ac (mole_per_day)');
    LEGEND_ALGEBRAIC(:,140) = strpad('U_Hf_McMa in component Q_Ac (mole_per_day)');
    LEGEND_CONSTANTS(:,103) = strpad('M_Ac_AcAb in component Q_Ac (molar)');
    LEGEND_CONSTANTS(:,200) = strpad('v_AcAb in component Q_Ac (mole_per_day)');
    LEGEND_CONSTANTS(:,104) = strpad('v_AcAb_star in component Q_Ac (mole_per_litre_day)');
    LEGEND_CONSTANTS(:,192) = strpad('Y_Ac_LaAc in component Q_Ac (dimensionless)');
    LEGEND_ALGEBRAIC(:,148) = strpad('Y_Ac_HaVa in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,194) = strpad('Y_Ac_PsVa in component Q_Ac (dimensionless)');
    LEGEND_ALGEBRAIC(:,156) = strpad('Y_Ac_AmMa in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,195) = strpad('Y_Ac_AmMc in component Q_Ac (dimensionless)');
    LEGEND_ALGEBRAIC(:,164) = strpad('Y_Ac_PsMa in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,196) = strpad('Y_Ac_PsMc in component Q_Ac (dimensionless)');
    LEGEND_ALGEBRAIC(:,172) = strpad('Y_Ac_HaAs in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,197) = strpad('Y_Ac_McMa in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,198) = strpad('Y_Ac_PsAm in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,199) = strpad('Y_Ac_McAm in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,105) = strpad('Y_Ac_WrAc in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,106) = strpad('Y_Ac_InAc in component Q_Ac (molar)');
    LEGEND_CONSTANTS(:,107) = strpad('Y_Ac_StAc in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,108) = strpad('Y_Ac_CeAc in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,109) = strpad('Y_Ac_HeAc in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,110) = strpad('Y_Ac_PsAc in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,193) = strpad('Y_Ac_HcVa in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,171) = strpad('k_AcEx in component Q_Ac (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,111) = strpad('D_Ac in component Q_Ac (litre_per_day)');
    LEGEND_CONSTANTS(:,112) = strpad('J_pH_AcAb in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,113) = strpad('phi_pH_AcAb in component Q_Ac (dimensionless)');
    LEGEND_CONSTANTS(:,114) = strpad('f_Hf_AmMa in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,115) = strpad('f_Hf_AmMc in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,116) = strpad('f_Hf_PsMa in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,117) = strpad('f_Hf_PsMc in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,118) = strpad('f_Hf_HaAs in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,119) = strpad('f_Hf_McMa in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,120) = strpad('f_Lc_Le in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,121) = strpad('f_Ce_Fd in component model_parameters (dimensionless)');
    LEGEND_STATES(:,15) = strpad('Q_Pr in component Q_Pr (mole)');
    LEGEND_ALGEBRAIC(:,85) = strpad('C_Pr in component Q_Pr (molar)');
    LEGEND_CONSTANTS(:,201) = strpad('P_Pr_InPr in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,161) = strpad('P_Pr_AmMa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,121) = strpad('P_Pr_AmMc in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,169) = strpad('P_Pr_PsMa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,133) = strpad('P_Pr_PsMc in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,177) = strpad('P_Pr_HaAs in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,153) = strpad('P_Pr_HaVa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,89) = strpad('P_Pr_HcVa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,93) = strpad('P_MaPr_PsAm in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,97) = strpad('P_McPr_PsAm in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,145) = strpad('P_Pr_McMa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,101) = strpad('P_Pr_McAm in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,105) = strpad('U_Pr_PrAb in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,109) = strpad('U_Pr_PrEx in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,113) = strpad('U_Hf_AmMa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,117) = strpad('U_Hf_AmMc in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,125) = strpad('U_Hf_PsMa in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,129) = strpad('U_Hf_PsMc in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,137) = strpad('U_Hf_HaAs in component Q_Pr (mole_per_day)');
    LEGEND_ALGEBRAIC(:,141) = strpad('U_Hf_McMa in component Q_Pr (mole_per_day)');
    LEGEND_CONSTANTS(:,122) = strpad('M_Pr_PrAb in component Q_Pr (molar)');
    LEGEND_CONSTANTS(:,210) = strpad('v_PrAb in component Q_Pr (mole_per_day)');
    LEGEND_CONSTANTS(:,123) = strpad('v_PrAb_star in component Q_Pr (mole_per_litre_day)');
    LEGEND_CONSTANTS(:,202) = strpad('Y_Pr_LaPr in component Q_Pr (dimensionless)');
    LEGEND_ALGEBRAIC(:,149) = strpad('Y_Pr_HaVa in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,204) = strpad('Y_Pr_PsVa in component Q_Pr (dimensionless)');
    LEGEND_ALGEBRAIC(:,157) = strpad('Y_Pr_AmMa in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,205) = strpad('Y_Pr_AmMc in component Q_Pr (dimensionless)');
    LEGEND_ALGEBRAIC(:,165) = strpad('Y_Pr_PsMa in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,206) = strpad('Y_Pr_PsMc in component Q_Pr (dimensionless)');
    LEGEND_ALGEBRAIC(:,173) = strpad('Y_Pr_HaAs in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,207) = strpad('Y_Pr_McMa in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,208) = strpad('Y_Pr_PsAm in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,209) = strpad('Y_Pr_McAm in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,124) = strpad('Y_Pr_WrPr in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,125) = strpad('Y_Pr_InPr in component Q_Pr (molar)');
    LEGEND_CONSTANTS(:,203) = strpad('Y_Pr_HcVa in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,126) = strpad('Y_Pr_StPr in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,127) = strpad('Y_Pr_CePr in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,128) = strpad('Y_Pr_HePr in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,129) = strpad('Y_Pr_PsPr in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,172) = strpad('k_PrEx in component Q_Pr (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,130) = strpad('D_Pr in component Q_Pr (litre_per_day)');
    LEGEND_CONSTANTS(:,131) = strpad('phi_pH_PrAb in component Q_Pr (dimensionless)');
    LEGEND_CONSTANTS(:,132) = strpad('J_pH_PrAb in component Q_Pr (dimensionless)');
    LEGEND_STATES(:,16) = strpad('Q_Bu in component Q_Bu (mole)');
    LEGEND_ALGEBRAIC(:,86) = strpad('C_Bu in component Q_Bu (molar)');
    LEGEND_CONSTANTS(:,211) = strpad('P_Bu_InBu in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,162) = strpad('P_Bu_AmMa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,122) = strpad('P_Bu_AmMc in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,170) = strpad('P_Bu_PsMa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,134) = strpad('P_Bu_PsMc in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,178) = strpad('P_Bu_HaAs in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,154) = strpad('P_Bu_HaVa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,90) = strpad('P_Bu_HcVa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,94) = strpad('P_MaBu_PsAm in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,98) = strpad('P_McBu_PsAm in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,146) = strpad('P_Bu_McMa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,102) = strpad('P_Bu_McAm in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,106) = strpad('U_Bu_BuAb in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,110) = strpad('U_Bu_BuEx in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,114) = strpad('U_Hf_AmMa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,118) = strpad('U_Hf_AmMc in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,126) = strpad('U_Hf_PsMa in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,130) = strpad('U_Hf_PsMc in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,138) = strpad('U_Hf_HaAs in component Q_Bu (mole_per_day)');
    LEGEND_ALGEBRAIC(:,142) = strpad('U_Hf_McMa in component Q_Bu (mole_per_day)');
    LEGEND_CONSTANTS(:,133) = strpad('M_Bu_BuAb in component Q_Bu (molar)');
    LEGEND_CONSTANTS(:,220) = strpad('v_BuAb in component Q_Bu (mole_per_day)');
    LEGEND_CONSTANTS(:,134) = strpad('v_BuAb_star in component Q_Bu (mole_per_litre_day)');
    LEGEND_CONSTANTS(:,212) = strpad('Y_Bu_LaBu in component Q_Bu (dimensionless)');
    LEGEND_ALGEBRAIC(:,150) = strpad('Y_Bu_HaVa in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,214) = strpad('Y_Bu_PsVa in component Q_Bu (dimensionless)');
    LEGEND_ALGEBRAIC(:,158) = strpad('Y_Bu_AmMa in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,215) = strpad('Y_Bu_AmMc in component Q_Bu (dimensionless)');
    LEGEND_ALGEBRAIC(:,166) = strpad('Y_Bu_PsMa in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,216) = strpad('Y_Bu_PsMc in component Q_Bu (dimensionless)');
    LEGEND_ALGEBRAIC(:,174) = strpad('Y_Bu_HaAs in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,217) = strpad('Y_Bu_McMa in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,218) = strpad('Y_Bu_PsAm in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,219) = strpad('Y_Bu_McAm in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,135) = strpad('Y_Bu_WrBu in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,136) = strpad('Y_Bu_InBu in component Q_Bu (molar)');
    LEGEND_CONSTANTS(:,213) = strpad('Y_Bu_HcVa in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,137) = strpad('Y_Bu_StBu in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,138) = strpad('Y_Bu_CeBu in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,139) = strpad('Y_Bu_HeBu in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,140) = strpad('Y_Bu_PsBu in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,173) = strpad('k_BuEx in component Q_Bu (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,141) = strpad('D_Bu in component Q_Bu (litre_per_day)');
    LEGEND_CONSTANTS(:,142) = strpad('phi_pH_BuAb in component Q_Bu (dimensionless)');
    LEGEND_CONSTANTS(:,143) = strpad('J_pH_BuAb in component Q_Bu (dimensionless)');
    LEGEND_STATES(:,17) = strpad('Q_Vl in component Q_Vl (mole)');
    LEGEND_ALGEBRAIC(:,87) = strpad('C_Vl in component Q_Vl (molar)');
    LEGEND_CONSTANTS(:,221) = strpad('P_Vl_InVl in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,163) = strpad('P_Vl_AmMa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,123) = strpad('P_Vl_AmMc in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,171) = strpad('P_Vl_PsMa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,135) = strpad('P_Vl_PsMc in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,179) = strpad('P_Vl_HaAs in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,155) = strpad('P_Vl_HaVa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,91) = strpad('P_Vl_HcVa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,95) = strpad('P_MaVl_PsAm in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,99) = strpad('P_McVl_PsAm in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,147) = strpad('P_Vl_McMa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,103) = strpad('P_Vl_McAm in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,107) = strpad('U_Vl_VlAb in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,111) = strpad('U_Vl_VlEx in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,115) = strpad('U_Hf_AmMa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,119) = strpad('U_Hf_AmMc in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,127) = strpad('U_Hf_PsMa in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,131) = strpad('U_Hf_PsMc in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,139) = strpad('U_Hf_HaAs in component Q_Vl (mole_per_day)');
    LEGEND_ALGEBRAIC(:,143) = strpad('U_Hf_McMa in component Q_Vl (mole_per_day)');
    LEGEND_CONSTANTS(:,144) = strpad('M_Vl_VlAb in component Q_Vl (molar)');
    LEGEND_CONSTANTS(:,230) = strpad('v_VlAb in component Q_Vl (mole_per_day)');
    LEGEND_CONSTANTS(:,145) = strpad('v_VlAb_star in component Q_Vl (mole_per_litre_day)');
    LEGEND_CONSTANTS(:,222) = strpad('Y_Vl_LaVl in component Q_Vl (dimensionless)');
    LEGEND_ALGEBRAIC(:,151) = strpad('Y_Vl_HaVa in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,224) = strpad('Y_Vl_PsVa in component Q_Vl (dimensionless)');
    LEGEND_ALGEBRAIC(:,159) = strpad('Y_Vl_AmMa in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,225) = strpad('Y_Vl_AmMc in component Q_Vl (dimensionless)');
    LEGEND_ALGEBRAIC(:,167) = strpad('Y_Vl_PsMa in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,226) = strpad('Y_Vl_PsMc in component Q_Vl (dimensionless)');
    LEGEND_ALGEBRAIC(:,175) = strpad('Y_Vl_HaAs in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,227) = strpad('Y_Vl_McMa in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,228) = strpad('Y_Vl_PsAm in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,229) = strpad('Y_Vl_McAm in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,146) = strpad('Y_Vl_WrVl in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,147) = strpad('Y_Vl_InVl in component Q_Vl (molar)');
    LEGEND_CONSTANTS(:,223) = strpad('Y_Vl_HcVa in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,148) = strpad('Y_Vl_StVl in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,149) = strpad('Y_Vl_CeVl in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,150) = strpad('Y_Vl_HeVl in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,151) = strpad('Y_Vl_PsVl in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,174) = strpad('k_VlEx in component Q_Vl (first_order_rate_constant)');
    LEGEND_CONSTANTS(:,152) = strpad('D_Vl in component Q_Vl (litre_per_day)');
    LEGEND_CONSTANTS(:,153) = strpad('phi_pH_VlAb in component Q_Vl (dimensionless)');
    LEGEND_CONSTANTS(:,154) = strpad('J_pH_VlAb in component Q_Vl (dimensionless)');
    LEGEND_RATES(:,1) = strpad('d/dt Q_Pd in component Q_Pd (mole)');
    LEGEND_RATES(:,4) = strpad('d/dt Q_Ps in component Q_Ps (mole)');
    LEGEND_RATES(:,5) = strpad('d/dt Q_Pu in component Q_Pu (mole)');
    LEGEND_RATES(:,6) = strpad('d/dt Q_Am in component Q_Am (mole)');
    LEGEND_RATES(:,7) = strpad('d/dt Q_Li in component Q_Li (mole)');
    LEGEND_RATES(:,8) = strpad('d/dt Q_Sd in component Q_Sd (mole)');
    LEGEND_RATES(:,9) = strpad('d/dt Q_Fd in component Q_Fd (mole)');
    LEGEND_RATES(:,10) = strpad('d/dt Q_Fu in component Q_Fu (mole)');
    LEGEND_RATES(:,11) = strpad('d/dt Q_Ha in component Q_Ha (mole)');
    LEGEND_RATES(:,12) = strpad('d/dt Q_Hc in component Q_Hc (mole)');
    LEGEND_RATES(:,2) = strpad('d/dt Q_Ma in component Q_Ma (gram)');
    LEGEND_RATES(:,13) = strpad('d/dt Q_As in component Q_As (gram)');
    LEGEND_RATES(:,3) = strpad('d/dt Q_Mc in component Q_Mc (gram)');
    LEGEND_RATES(:,14) = strpad('d/dt Q_Ac in component Q_Ac (mole)');
    LEGEND_RATES(:,15) = strpad('d/dt Q_Pr in component Q_Pr (mole)');
    LEGEND_RATES(:,16) = strpad('d/dt Q_Bu in component Q_Bu (mole)');
    LEGEND_RATES(:,17) = strpad('d/dt Q_Vl in component Q_Vl (mole)');
    LEGEND_STATES  = LEGEND_STATES';
    LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
    LEGEND_RATES = LEGEND_RATES';
    LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
    VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
    STATES(:,1) = 1.000;
    CONSTANTS(:,1) = 0.0576;
    CONSTANTS(:,2) = 0.264;
    CONSTANTS(:,3) = 0.0091;
    CONSTANTS(:,4) = 1.000;
    CONSTANTS(:,5) = 1.000;
    CONSTANTS(:,6) = 0.66;
    STATES(:,2) = 1.000;
    STATES(:,3) = 1.000;
    CONSTANTS(:,7) = 1.000;
    CONSTANTS(:,8) = 1.000;
    CONSTANTS(:,9) = 0.0248;
    STATES(:,4) = 1.000;
    CONSTANTS(:,10) = 0.0144;
    CONSTANTS(:,11) = 0.0576;
    CONSTANTS(:,12) = 0.0576;
    CONSTANTS(:,13) = 0.0091;
    CONSTANTS(:,14) = 0.0010;
    CONSTANTS(:,15) = 1.0;
    CONSTANTS(:,16) = 0.0067;
    CONSTANTS(:,17) = 0.0067;
    CONSTANTS(:,18) = 1.000;
    CONSTANTS(:,19) = 0.0289;
    CONSTANTS(:,20) = 0.0224;
    CONSTANTS(:,21) = 0.0224;
    CONSTANTS(:,22) = 0.0248;
    CONSTANTS(:,23) = 0.0248;
    CONSTANTS(:,24) = 0.0165;
    CONSTANTS(:,25) = 0.0165;
    CONSTANTS(:,26) = 1.000;
    CONSTANTS(:,27) = 0.0165;
    STATES(:,5) = 1.000;
    CONSTANTS(:,28) = 0.0091;
    CONSTANTS(:,29) = 1.000;
    STATES(:,6) = 1.000;
    CONSTANTS(:,30) = 0.00165;
    CONSTANTS(:,31) = 1.10;
    CONSTANTS(:,32) = 0.0528;
    CONSTANTS(:,33) = 0.0528;
    CONSTANTS(:,34) = 0.0588;
    CONSTANTS(:,35) = 2.0;
    CONSTANTS(:,36) = 1.257;
    CONSTANTS(:,37) = 0.0084;
    CONSTANTS(:,38) = 0.00135;
    CONSTANTS(:,39) = 0.00135;
    CONSTANTS(:,40) = 0.0132;
    CONSTANTS(:,41) = 7.5;
    CONSTANTS(:,42) = 7.85;
    CONSTANTS(:,43) = 0.0159;
    CONSTANTS(:,44) = 0.0159;
    CONSTANTS(:,45) = 0.00621;
    CONSTANTS(:,46) = 1.000;
    CONSTANTS(:,47) = 7.000;
    CONSTANTS(:,48) = 0.35;
    CONSTANTS(:,49) = 1.000;
    STATES(:,7) = 1.000;
    CONSTANTS(:,50) = 0.0015;
    CONSTANTS(:,51) = 0.00021;
    CONSTANTS(:,52) = 1.000;
    STATES(:,8) = 1.000;
    CONSTANTS(:,53) = 0.0062;
    CONSTANTS(:,54) = 1.000;
    CONSTANTS(:,55) = 0.2179;
    CONSTANTS(:,56) = 0.416;
    CONSTANTS(:,57) = 1.000;
    CONSTANTS(:,58) = 1.04;
    STATES(:,9) = 1.000;
    CONSTANTS(:,59) = 0.0062;
    CONSTANTS(:,60) = 1.000;
    CONSTANTS(:,61) = 0.1646;
    CONSTANTS(:,62) = 0.332;
    CONSTANTS(:,63) = 1.000;
    CONSTANTS(:,64) = 0.83;
    CONSTANTS(:,65) = 22.9;
    CONSTANTS(:,66) = 5.97;
    CONSTANTS(:,67) = 1.000;
    CONSTANTS(:,68) = 1.000;
    STATES(:,10) = 1.000;
    CONSTANTS(:,69) = 0.0062;
    CONSTANTS(:,70) = 1.000;
    STATES(:,11) = 1.000;
    CONSTANTS(:,71) = 1.793;
    CONSTANTS(:,72) = 1.291;
    CONSTANTS(:,73) = 0.0086;
    CONSTANTS(:,74) = 0.0268;
    CONSTANTS(:,75) = 0.055;
    CONSTANTS(:,76) = 0.053;
    CONSTANTS(:,77) = 0.1646;
    CONSTANTS(:,78) = 0.0062;
    CONSTANTS(:,79) = 0.0062;
    CONSTANTS(:,80) = 0.0025;
    CONSTANTS(:,81) = 1.0;
    CONSTANTS(:,82) = 0.0062;
    CONSTANTS(:,83) = 1.000;
    CONSTANTS(:,84) = 1.000;
    CONSTANTS(:,85) = 1.000;
    CONSTANTS(:,86) = 0.00861;
    CONSTANTS(:,87) = 0.01465;
    STATES(:,12) = 1.000;
    CONSTANTS(:,88) = 1.793;
    CONSTANTS(:,89) = 1.291;
    CONSTANTS(:,90) = 0.1646;
    CONSTANTS(:,91) = 1.0;
    CONSTANTS(:,92) = 0.055;
    CONSTANTS(:,93) = 0.00861;
    CONSTANTS(:,94) = 0.01465;
    CONSTANTS(:,95) = 118.91;
    CONSTANTS(:,96) = 149.48;
    CONSTANTS(:,97) = 149.48;
    STATES(:,13) = 1.000;
    CONSTANTS(:,98) = 112.5;
    CONSTANTS(:,99) = 118.91;
    CONSTANTS(:,100) = 149.48;
    CONSTANTS(:,101) = 15.439;
    CONSTANTS(:,102) = 34.694;
    STATES(:,14) = 1.000;
    CONSTANTS(:,103) = 0.338;
    CONSTANTS(:,104) = 7.86;
    CONSTANTS(:,105) = 1.000;
    CONSTANTS(:,106) = 0.0167;
    CONSTANTS(:,107) = 1.000;
    CONSTANTS(:,108) = 1.000;
    CONSTANTS(:,109) = 1.000;
    CONSTANTS(:,110) = 1.000;
    CONSTANTS(:,111) = 1.000;
    CONSTANTS(:,112) = 6.45;
    CONSTANTS(:,113) = 6.48;
    CONSTANTS(:,114) = 0.526;
    CONSTANTS(:,115) = 0.526;
    CONSTANTS(:,116) = 0.711;
    CONSTANTS(:,117) = 0.711;
    CONSTANTS(:,118) = 0.306;
    CONSTANTS(:,119) = 0.711;
    CONSTANTS(:,120) = 2.250;
    CONSTANTS(:,121) = 1.000;
    STATES(:,15) = 1.000;
    CONSTANTS(:,122) = 0.338;
    CONSTANTS(:,123) = 7.86;
    CONSTANTS(:,124) = 1.000;
    CONSTANTS(:,125) = 0.0135;
    CONSTANTS(:,126) = 1.000;
    CONSTANTS(:,127) = 1.000;
    CONSTANTS(:,128) = 1.000;
    CONSTANTS(:,129) = 1.000;
    CONSTANTS(:,130) = 1.000;
    CONSTANTS(:,131) = 6.48;
    CONSTANTS(:,132) = 6.45;
    STATES(:,16) = 1.000;
    CONSTANTS(:,133) = 0.338;
    CONSTANTS(:,134) = 7.86;
    CONSTANTS(:,135) = 1.000;
    CONSTANTS(:,136) = 0.0114;
    CONSTANTS(:,137) = 1.000;
    CONSTANTS(:,138) = 1.000;
    CONSTANTS(:,139) = 1.000;
    CONSTANTS(:,140) = 1.000;
    CONSTANTS(:,141) = 1.000;
    CONSTANTS(:,142) = 6.48;
    CONSTANTS(:,143) = 6.45;
    STATES(:,17) = 1.000;
    CONSTANTS(:,144) = 0.338;
    CONSTANTS(:,145) = 7.86;
    CONSTANTS(:,146) = 1.000;
    CONSTANTS(:,147) = 0.0098;
    CONSTANTS(:,148) = 1.000;
    CONSTANTS(:,149) = 1.000;
    CONSTANTS(:,150) = 1.000;
    CONSTANTS(:,151) = 1.000;
    CONSTANTS(:,152) = 1.000;
    CONSTANTS(:,153) = 6.48;
    CONSTANTS(:,154) = 6.45;
    CONSTANTS(:,155) = CONSTANTS(:,8);
    CONSTANTS(:,156) =  CONSTANTS(:,3).*CONSTANTS(:,4);
    CONSTANTS(:,157) = CONSTANTS(:,26);
    CONSTANTS(:,158) =  CONSTANTS(:,28).*CONSTANTS(:,29);
    CONSTANTS(:,159) = CONSTANTS(:,8);
    CONSTANTS(:,160) = CONSTANTS(:,26);
    CONSTANTS(:,161) = CONSTANTS(:,26);
    CONSTANTS(:,162) = CONSTANTS(:,8);
    CONSTANTS(:,163) = CONSTANTS(:,8);
    CONSTANTS(:,164) =  CONSTANTS(:,69).*CONSTANTS(:,70);
    CONSTANTS(:,165) = CONSTANTS(:,8);
    CONSTANTS(:,166) = CONSTANTS(:,26);
    CONSTANTS(:,167) = CONSTANTS(:,26);
    CONSTANTS(:,168) = CONSTANTS(:,26);
    CONSTANTS(:,169) = CONSTANTS(:,26);
    CONSTANTS(:,170) = CONSTANTS(:,8);
    CONSTANTS(:,171) = CONSTANTS(:,26);
    CONSTANTS(:,172) = CONSTANTS(:,26);
    CONSTANTS(:,173) = CONSTANTS(:,26);
    CONSTANTS(:,174) = CONSTANTS(:,26);
    CONSTANTS(:,175) =  CONSTANTS(:,2).*(CONSTANTS(:,5)./CONSTANTS(:,6));
    CONSTANTS(:,176) = CONSTANTS(:,8)./2.00000;
    CONSTANTS(:,177) =  CONSTANTS(:,13).*CONSTANTS(:,18);
    CONSTANTS(:,178) = CONSTANTS(:,168) - CONSTANTS(:,176);
    CONSTANTS(:,179) = CONSTANTS(:,168) - CONSTANTS(:,176);
    CONSTANTS(:,180) =  CONSTANTS(:,14).*CONSTANTS(:,18);
    CONSTANTS(:,181) =  CONSTANTS(:,34).*CONSTANTS(:,46);
    CONSTANTS(:,182) =  CONSTANTS(:,31).*power(1.00000, 0.250000).*power(CONSTANTS(:,7), 0.750000).*(1.00000+power(CONSTANTS(:,41)./CONSTANTS(:,47), CONSTANTS(:,42)));
    CONSTANTS(:,183) =  CONSTANTS(:,50).*CONSTANTS(:,52);
    CONSTANTS(:,184) =  CONSTANTS(:,53).*CONSTANTS(:,54);
    CONSTANTS(:,185) =  CONSTANTS(:,56).*(CONSTANTS(:,57)./CONSTANTS(:,58));
    CONSTANTS(:,186) =  CONSTANTS(:,59).*CONSTANTS(:,60);
    CONSTANTS(:,187) =  CONSTANTS(:,62).*(CONSTANTS(:,63)./CONSTANTS(:,64));
    CONSTANTS(:,188) =  CONSTANTS(:,78).*CONSTANTS(:,83);
    CONSTANTS(:,189) =  CONSTANTS(:,79).*CONSTANTS(:,84);
    CONSTANTS(:,190) =  CONSTANTS(:,80).*CONSTANTS(:,85);
    CONSTANTS(:,191) =  CONSTANTS(:,106).*CONSTANTS(:,111);
    CONSTANTS(:,192) =  CONSTANTS(:,120).*CONSTANTS(:,105);
    CONSTANTS(:,193) =  CONSTANTS(:,121).*CONSTANTS(:,108)+ (1.00000 - CONSTANTS(:,121)).*CONSTANTS(:,109);
    CONSTANTS(:,194) = CONSTANTS(:,110);
    CONSTANTS(:,195) = CONSTANTS(:,193);
    CONSTANTS(:,196) = CONSTANTS(:,193);
    CONSTANTS(:,197) = CONSTANTS(:,193);
    CONSTANTS(:,198) = CONSTANTS(:,194);
    CONSTANTS(:,199) = CONSTANTS(:,194);
    CONSTANTS(:,200) =  CONSTANTS(:,104).*power(1.00000, 0.250000).*(power(CONSTANTS(:,7), 0.750000)./(1.00000+power(CONSTANTS(:,47)./CONSTANTS(:,112), CONSTANTS(:,113))));
    CONSTANTS(:,201) =  CONSTANTS(:,125).*CONSTANTS(:,130);
    CONSTANTS(:,202) =  CONSTANTS(:,120).*CONSTANTS(:,124);
    CONSTANTS(:,203) =  CONSTANTS(:,121).*CONSTANTS(:,127)+ (1.00000 - CONSTANTS(:,121)).*CONSTANTS(:,128);
    CONSTANTS(:,204) = CONSTANTS(:,129);
    CONSTANTS(:,205) = CONSTANTS(:,203);
    CONSTANTS(:,206) = CONSTANTS(:,203);
    CONSTANTS(:,207) = CONSTANTS(:,203);
    CONSTANTS(:,208) = CONSTANTS(:,204);
    CONSTANTS(:,209) = CONSTANTS(:,204);
    CONSTANTS(:,210) =  CONSTANTS(:,123).*power(1.00000, 0.250000).*(power(CONSTANTS(:,7), 0.750000)./(1.00000+power(CONSTANTS(:,47)./CONSTANTS(:,132), CONSTANTS(:,131))));
    CONSTANTS(:,211) =  CONSTANTS(:,136).*CONSTANTS(:,141);
    CONSTANTS(:,212) =  CONSTANTS(:,120).*CONSTANTS(:,135);
    CONSTANTS(:,213) =  CONSTANTS(:,121).*CONSTANTS(:,138)+ (1.00000 - CONSTANTS(:,121)).*CONSTANTS(:,139);
    CONSTANTS(:,214) = CONSTANTS(:,140);
    CONSTANTS(:,215) = CONSTANTS(:,213);
    CONSTANTS(:,216) = CONSTANTS(:,213);
    CONSTANTS(:,217) = CONSTANTS(:,213);
    CONSTANTS(:,218) = CONSTANTS(:,214);
    CONSTANTS(:,219) = CONSTANTS(:,214);
    CONSTANTS(:,220) =  CONSTANTS(:,134).*power(1.00000, 0.250000).*(power(CONSTANTS(:,7), 0.750000)./(1.00000+power(CONSTANTS(:,47)./CONSTANTS(:,143), CONSTANTS(:,142))));
    CONSTANTS(:,221) =  CONSTANTS(:,147).*CONSTANTS(:,152);
    CONSTANTS(:,222) =  CONSTANTS(:,120).*CONSTANTS(:,146);
    CONSTANTS(:,223) =  CONSTANTS(:,121).*CONSTANTS(:,149)+ (1.00000 - CONSTANTS(:,121)).*CONSTANTS(:,150);
    CONSTANTS(:,224) = CONSTANTS(:,151);
    CONSTANTS(:,225) = CONSTANTS(:,223);
    CONSTANTS(:,226) = CONSTANTS(:,223);
    CONSTANTS(:,227) = CONSTANTS(:,223);
    CONSTANTS(:,228) = CONSTANTS(:,224);
    CONSTANTS(:,229) = CONSTANTS(:,224);
    CONSTANTS(:,230) =  CONSTANTS(:,145).*power(1.00000, 0.250000).*(power(CONSTANTS(:,7), 0.750000)./(1.00000+power(CONSTANTS(:,47)./CONSTANTS(:,154), CONSTANTS(:,153))));
    if (isempty(STATES)), warning('Initial values for states not set');, end
end

function [RATES, ALGEBRAIC] = computeRates(VOI, STATES, CONSTANTS)
    global algebraicVariableCount;
    statesSize = size(STATES);
    statesColumnCount = statesSize(2);
    if ( statesColumnCount == 1)
        STATES = STATES';
        ALGEBRAIC = zeros(1, algebraicVariableCount);
        utilOnes = 1;
    else
        statesRowCount = statesSize(1);
        ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
        RATES = zeros(statesRowCount, statesColumnCount);
        utilOnes = ones(statesRowCount, 1);
    end
    ALGEBRAIC(:,3) =  CONSTANTS(:,159).*STATES(:,5);
    RATES(:,5) = CONSTANTS(:,158) - ALGEBRAIC(:,3);
    ALGEBRAIC(:,6) =  CONSTANTS(:,165).*STATES(:,10);
    RATES(:,10) = CONSTANTS(:,164) - ALGEBRAIC(:,6);
    ALGEBRAIC(:,1) = STATES(:,1)./CONSTANTS(:,7);
    ALGEBRAIC(:,10) =  CONSTANTS(:,1).*(STATES(:,2)+STATES(:,3));
    ALGEBRAIC(:,11) = ALGEBRAIC(:,10)./(1.00000+CONSTANTS(:,175)./ALGEBRAIC(:,1));
    ALGEBRAIC(:,9) =  CONSTANTS(:,155).*STATES(:,1);
    RATES(:,1) = CONSTANTS(:,156) - (ALGEBRAIC(:,11)+ALGEBRAIC(:,9));
    ALGEBRAIC(:,27) = STATES(:,8)./CONSTANTS(:,7);
    ALGEBRAIC(:,29) =  CONSTANTS(:,55).*STATES(:,2);
    ALGEBRAIC(:,30) = ALGEBRAIC(:,29)./(1.00000+CONSTANTS(:,185)./ALGEBRAIC(:,27));
    ALGEBRAIC(:,28) =  CONSTANTS(:,162).*STATES(:,8);
    RATES(:,8) = CONSTANTS(:,184) - (ALGEBRAIC(:,30)+ALGEBRAIC(:,28));
    ALGEBRAIC(:,31) = STATES(:,9)./CONSTANTS(:,7);
    ALGEBRAIC(:,33) =  CONSTANTS(:,61).*STATES(:,3).*((1.00000 - ( VOI.*CONSTANTS(:,68))./1.00000)+(( VOI.*CONSTANTS(:,68))./1.00000)./(1.00000+power(CONSTANTS(:,66)./CONSTANTS(:,67), CONSTANTS(:,65))));
    ALGEBRAIC(:,34) = ALGEBRAIC(:,33)./(1.00000+CONSTANTS(:,187)./ALGEBRAIC(:,31));
    ALGEBRAIC(:,32) =  CONSTANTS(:,163).*STATES(:,9);
    RATES(:,9) = CONSTANTS(:,186) - (ALGEBRAIC(:,34)+ALGEBRAIC(:,32));
    ALGEBRAIC(:,12) = STATES(:,4)./CONSTANTS(:,7);
    ALGEBRAIC(:,18) =  CONSTANTS(:,12).*STATES(:,3);
    ALGEBRAIC(:,48) = STATES(:,12)./CONSTANTS(:,7);
    ALGEBRAIC(:,50) = ALGEBRAIC(:,18)./(1.00000+CONSTANTS(:,21)./ALGEBRAIC(:,12)+CONSTANTS(:,23)./ALGEBRAIC(:,48));
    ALGEBRAIC(:,55) =  CONSTANTS(:,89).*ALGEBRAIC(:,50);
    ALGEBRAIC(:,19) = STATES(:,6)./CONSTANTS(:,7);
    ALGEBRAIC(:,25) =  CONSTANTS(:,33).*STATES(:,3);
    ALGEBRAIC(:,52) = ALGEBRAIC(:,25)./(1.00000+CONSTANTS(:,39)./ALGEBRAIC(:,19)+CONSTANTS(:,44)./ALGEBRAIC(:,48));
    ALGEBRAIC(:,54) =  CONSTANTS(:,88).*ALGEBRAIC(:,52);
    ALGEBRAIC(:,57) =  CONSTANTS(:,90).*STATES(:,3);
    ALGEBRAIC(:,58) = ALGEBRAIC(:,57)./( (1.00000+CONSTANTS(:,92)./ALGEBRAIC(:,48)).*(1.00000+ALGEBRAIC(:,19)./CONSTANTS(:,93)+ALGEBRAIC(:,12)./CONSTANTS(:,94)));
    ALGEBRAIC(:,53) =  CONSTANTS(:,91).*ALGEBRAIC(:,34);
    ALGEBRAIC(:,56) =  CONSTANTS(:,167).*STATES(:,12);
    RATES(:,12) = ALGEBRAIC(:,53) - (ALGEBRAIC(:,54)+ALGEBRAIC(:,55)+ALGEBRAIC(:,58)+ALGEBRAIC(:,56));
    ALGEBRAIC(:,62) =  CONSTANTS(:,178).*STATES(:,2).*CONSTANTS(:,48);
    ALGEBRAIC(:,64) =  CONSTANTS(:,51).*ALGEBRAIC(:,62);
    ALGEBRAIC(:,26) =  CONSTANTS(:,161).*STATES(:,7);
    RATES(:,7) = (CONSTANTS(:,183)+ALGEBRAIC(:,64)) - ALGEBRAIC(:,26);
    ALGEBRAIC(:,67) =  CONSTANTS(:,179).*STATES(:,13).*CONSTANTS(:,48);
    ALGEBRAIC(:,35) = STATES(:,11)./CONSTANTS(:,7);
    ALGEBRAIC(:,44) =  CONSTANTS(:,76).*STATES(:,2);
    ALGEBRAIC(:,45) = ALGEBRAIC(:,44)./(1.00000+CONSTANTS(:,74)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,66) =  CONSTANTS(:,98).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,71) =  CONSTANTS(:,176).*STATES(:,13).*CONSTANTS(:,48);
    ALGEBRAIC(:,69) =  CONSTANTS(:,169).*STATES(:,13).*(1.00000 - CONSTANTS(:,48));
    RATES(:,13) = ALGEBRAIC(:,66) - (ALGEBRAIC(:,67)+ALGEBRAIC(:,69)+ALGEBRAIC(:,71));
    ALGEBRAIC(:,59) = STATES(:,2)./CONSTANTS(:,7);
    ALGEBRAIC(:,70) = STATES(:,3)./CONSTANTS(:,7);
    ALGEBRAIC(:,75) = ( CONSTANTS(:,101).*STATES(:,2).*CONSTANTS(:,48).*ALGEBRAIC(:,70))./(ALGEBRAIC(:,70)+ ALGEBRAIC(:,59).*(1.00000 - CONSTANTS(:,48)));
    ALGEBRAIC(:,76) = ALGEBRAIC(:,75)./(1.00000+CONSTANTS(:,102)./(ALGEBRAIC(:,70)+ ALGEBRAIC(:,59).*(1.00000 - CONSTANTS(:,48))));
    ALGEBRAIC(:,72) =  CONSTANTS(:,99).*ALGEBRAIC(:,52);
    ALGEBRAIC(:,73) =  CONSTANTS(:,100).*ALGEBRAIC(:,50);
    ALGEBRAIC(:,74) =  CONSTANTS(:,170).*STATES(:,3);
    RATES(:,3) = (ALGEBRAIC(:,72)+ALGEBRAIC(:,73)) - (ALGEBRAIC(:,76)+ALGEBRAIC(:,74));
    ALGEBRAIC(:,16) =  CONSTANTS(:,10).*STATES(:,3);
    ALGEBRAIC(:,49) = ALGEBRAIC(:,16)./(1.00000+CONSTANTS(:,19)./ALGEBRAIC(:,12)+ALGEBRAIC(:,48)./CONSTANTS(:,25));
    ALGEBRAIC(:,17) =  CONSTANTS(:,11).*STATES(:,2);
    ALGEBRAIC(:,37) = ALGEBRAIC(:,17)./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,12)+CONSTANTS(:,22)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,15) =  CONSTANTS(:,10).*STATES(:,2);
    ALGEBRAIC(:,36) = ALGEBRAIC(:,15)./(1.00000+CONSTANTS(:,19)./ALGEBRAIC(:,12)+ALGEBRAIC(:,35)./CONSTANTS(:,24));
    ALGEBRAIC(:,13) =  CONSTANTS(:,15).*ALGEBRAIC(:,11);
    ALGEBRAIC(:,63) =  CONSTANTS(:,16).*ALGEBRAIC(:,62);
    ALGEBRAIC(:,77) =  ALGEBRAIC(:,76).*(1.00000 - (1.00000./(1.00000+ALGEBRAIC(:,35)./CONSTANTS(:,27))+1.00000./(1.00000+CONSTANTS(:,9)./ALGEBRAIC(:,35))));
    ALGEBRAIC(:,79) =  CONSTANTS(:,17).*ALGEBRAIC(:,77);
    ALGEBRAIC(:,14) =  CONSTANTS(:,157).*STATES(:,4);
    RATES(:,4) = (CONSTANTS(:,177)+ALGEBRAIC(:,13)+ALGEBRAIC(:,63)+CONSTANTS(:,180)+ALGEBRAIC(:,79)) - (ALGEBRAIC(:,36)+ALGEBRAIC(:,49)+ALGEBRAIC(:,37)+ALGEBRAIC(:,50)+ALGEBRAIC(:,14));
    ALGEBRAIC(:,24) =  CONSTANTS(:,32).*STATES(:,2).*(1.00000 - CONSTANTS(:,48));
    ALGEBRAIC(:,39) = ALGEBRAIC(:,24)./(1.00000+CONSTANTS(:,38)./ALGEBRAIC(:,19)+CONSTANTS(:,43)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,22) =  CONSTANTS(:,30).*CONSTANTS(:,7).*(CONSTANTS(:,49)./(1.00000+ALGEBRAIC(:,19)./CONSTANTS(:,45)));
    ALGEBRAIC(:,23) =  CONSTANTS(:,35).*ALGEBRAIC(:,22);
    ALGEBRAIC(:,38) =  CONSTANTS(:,36).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,51) =  CONSTANTS(:,36).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,78) = ( 1.00000.*ALGEBRAIC(:,76))./(1.00000+ALGEBRAIC(:,35)./CONSTANTS(:,27));
    ALGEBRAIC(:,80) =  CONSTANTS(:,37).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,20) = CONSTANTS(:,182)./(1.00000+CONSTANTS(:,40)./ALGEBRAIC(:,19));
    ALGEBRAIC(:,21) =  CONSTANTS(:,160).*STATES(:,6);
    RATES(:,6) = (CONSTANTS(:,181)+ALGEBRAIC(:,38)+ALGEBRAIC(:,51)+ALGEBRAIC(:,23)+ALGEBRAIC(:,80)) - (ALGEBRAIC(:,20)+ALGEBRAIC(:,39)+ALGEBRAIC(:,52)+ALGEBRAIC(:,21));
    ALGEBRAIC(:,81) = ALGEBRAIC(:,76)./(1.00000+CONSTANTS(:,9)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,83) =  CONSTANTS(:,73).*ALGEBRAIC(:,81);
    ALGEBRAIC(:,41) =  CONSTANTS(:,71).*ALGEBRAIC(:,39);
    ALGEBRAIC(:,42) =  CONSTANTS(:,72).*ALGEBRAIC(:,37);
    ALGEBRAIC(:,46) =  CONSTANTS(:,77).*STATES(:,2);
    ALGEBRAIC(:,47) =  ALGEBRAIC(:,46).*((1.00000 - CONSTANTS(:,48))./( (1.00000+CONSTANTS(:,75)./ALGEBRAIC(:,35)).*(1.00000+ALGEBRAIC(:,19)./CONSTANTS(:,86)).*(ALGEBRAIC(:,12)./CONSTANTS(:,87))))+( ALGEBRAIC(:,46).*CONSTANTS(:,48))./(1.00000+CONSTANTS(:,75)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,40) =  CONSTANTS(:,81).*ALGEBRAIC(:,30);
    ALGEBRAIC(:,68) =  CONSTANTS(:,82).*ALGEBRAIC(:,67);
    ALGEBRAIC(:,43) =  CONSTANTS(:,166).*STATES(:,11);
    RATES(:,11) = (CONSTANTS(:,188)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)+CONSTANTS(:,190)) - (ALGEBRAIC(:,41)+ALGEBRAIC(:,42)+ALGEBRAIC(:,83)+ALGEBRAIC(:,45)+ALGEBRAIC(:,47)+ALGEBRAIC(:,43));
    ALGEBRAIC(:,60) =  CONSTANTS(:,95).*ALGEBRAIC(:,39);
    ALGEBRAIC(:,61) =  CONSTANTS(:,96).*ALGEBRAIC(:,37);
    ALGEBRAIC(:,82) =  CONSTANTS(:,97).*ALGEBRAIC(:,81);
    ALGEBRAIC(:,65) =  CONSTANTS(:,176).*STATES(:,2).*CONSTANTS(:,48);
    RATES(:,2) = (ALGEBRAIC(:,60)+ALGEBRAIC(:,61)+ALGEBRAIC(:,82)) - (ALGEBRAIC(:,62)+ALGEBRAIC(:,81)+ALGEBRAIC(:,65));
    ALGEBRAIC(:,112) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,148) = ( CONSTANTS(:,105).*CONSTANTS(:,188)+ CONSTANTS(:,192).*CONSTANTS(:,190)+ CONSTANTS(:,107).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,156) = ALGEBRAIC(:,148);
    ALGEBRAIC(:,160) =  ALGEBRAIC(:,156).*ALGEBRAIC(:,112);
    ALGEBRAIC(:,116) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,120) =  CONSTANTS(:,195).*ALGEBRAIC(:,116);
    ALGEBRAIC(:,124) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,164) = ALGEBRAIC(:,148);
    ALGEBRAIC(:,168) =  ALGEBRAIC(:,164).*ALGEBRAIC(:,124);
    ALGEBRAIC(:,128) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,132) =  CONSTANTS(:,196).*ALGEBRAIC(:,128);
    ALGEBRAIC(:,136) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,172) = ALGEBRAIC(:,148);
    ALGEBRAIC(:,176) =  ALGEBRAIC(:,172).*ALGEBRAIC(:,136);
    ALGEBRAIC(:,152) =  ALGEBRAIC(:,148).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,88) =  CONSTANTS(:,193).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,92) =  CONSTANTS(:,198).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,96) =  CONSTANTS(:,198).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,140) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,144) =  CONSTANTS(:,197).*ALGEBRAIC(:,140);
    ALGEBRAIC(:,100) =  CONSTANTS(:,199).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,84) = STATES(:,14)./CONSTANTS(:,7);
    ALGEBRAIC(:,104) = CONSTANTS(:,200)./(1.00000+CONSTANTS(:,103)./ALGEBRAIC(:,84));
    ALGEBRAIC(:,108) =  CONSTANTS(:,171).*STATES(:,14);
    RATES(:,14) = (CONSTANTS(:,191)+ALGEBRAIC(:,160)+ALGEBRAIC(:,120)+ALGEBRAIC(:,168)+ALGEBRAIC(:,132)+ALGEBRAIC(:,176)+ALGEBRAIC(:,152)+ALGEBRAIC(:,88)+ALGEBRAIC(:,92)+ALGEBRAIC(:,96)+ALGEBRAIC(:,144)+ALGEBRAIC(:,100)) - (ALGEBRAIC(:,104)+ALGEBRAIC(:,108));
    ALGEBRAIC(:,113) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,149) = ( CONSTANTS(:,124).*CONSTANTS(:,188)+ CONSTANTS(:,202).*CONSTANTS(:,190)+ CONSTANTS(:,126).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,157) = ALGEBRAIC(:,149);
    ALGEBRAIC(:,161) =  ALGEBRAIC(:,157).*ALGEBRAIC(:,113);
    ALGEBRAIC(:,117) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,121) =  CONSTANTS(:,205).*ALGEBRAIC(:,117);
    ALGEBRAIC(:,125) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,165) = ALGEBRAIC(:,149);
    ALGEBRAIC(:,169) =  ALGEBRAIC(:,165).*ALGEBRAIC(:,125);
    ALGEBRAIC(:,129) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,133) =  CONSTANTS(:,206).*ALGEBRAIC(:,129);
    ALGEBRAIC(:,137) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,173) = ALGEBRAIC(:,149);
    ALGEBRAIC(:,177) =  ALGEBRAIC(:,173).*ALGEBRAIC(:,137);
    ALGEBRAIC(:,153) =  ALGEBRAIC(:,149).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,89) =  CONSTANTS(:,203).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,93) =  CONSTANTS(:,208).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,97) =  CONSTANTS(:,208).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,141) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,145) =  CONSTANTS(:,207).*ALGEBRAIC(:,141);
    ALGEBRAIC(:,101) =  CONSTANTS(:,209).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,85) = STATES(:,15)./CONSTANTS(:,7);
    ALGEBRAIC(:,105) = CONSTANTS(:,210)./(1.00000+CONSTANTS(:,122)./ALGEBRAIC(:,85));
    ALGEBRAIC(:,109) =  CONSTANTS(:,172).*STATES(:,15);
    RATES(:,15) = (CONSTANTS(:,201)+ALGEBRAIC(:,161)+ALGEBRAIC(:,121)+ALGEBRAIC(:,169)+ALGEBRAIC(:,133)+ALGEBRAIC(:,177)+ALGEBRAIC(:,153)+ALGEBRAIC(:,89)+ALGEBRAIC(:,93)+ALGEBRAIC(:,97)+ALGEBRAIC(:,145)+ALGEBRAIC(:,101)) - (ALGEBRAIC(:,105)+ALGEBRAIC(:,109));
    ALGEBRAIC(:,114) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,150) = ( CONSTANTS(:,135).*CONSTANTS(:,188)+ CONSTANTS(:,212).*CONSTANTS(:,190)+ CONSTANTS(:,137).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,158) = ALGEBRAIC(:,150);
    ALGEBRAIC(:,162) =  ALGEBRAIC(:,158).*ALGEBRAIC(:,114);
    ALGEBRAIC(:,118) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,122) =  CONSTANTS(:,215).*ALGEBRAIC(:,118);
    ALGEBRAIC(:,126) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,166) = ALGEBRAIC(:,150);
    ALGEBRAIC(:,170) =  ALGEBRAIC(:,166).*ALGEBRAIC(:,126);
    ALGEBRAIC(:,130) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,134) =  CONSTANTS(:,216).*ALGEBRAIC(:,130);
    ALGEBRAIC(:,138) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,174) = ALGEBRAIC(:,150);
    ALGEBRAIC(:,178) =  ALGEBRAIC(:,174).*ALGEBRAIC(:,138);
    ALGEBRAIC(:,154) =  ALGEBRAIC(:,150).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,90) =  CONSTANTS(:,213).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,94) =  CONSTANTS(:,218).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,98) =  CONSTANTS(:,218).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,142) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,146) =  CONSTANTS(:,217).*ALGEBRAIC(:,142);
    ALGEBRAIC(:,102) =  CONSTANTS(:,219).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,86) = STATES(:,16)./CONSTANTS(:,7);
    ALGEBRAIC(:,106) = CONSTANTS(:,220)./(1.00000+CONSTANTS(:,133)./ALGEBRAIC(:,86));
    ALGEBRAIC(:,110) =  CONSTANTS(:,173).*STATES(:,16);
    RATES(:,16) = (CONSTANTS(:,211)+ALGEBRAIC(:,162)+ALGEBRAIC(:,122)+ALGEBRAIC(:,170)+ALGEBRAIC(:,134)+ALGEBRAIC(:,178)+ALGEBRAIC(:,154)+ALGEBRAIC(:,90)+ALGEBRAIC(:,94)+ALGEBRAIC(:,98)+ALGEBRAIC(:,146)+ALGEBRAIC(:,102)) - (ALGEBRAIC(:,106)+ALGEBRAIC(:,110));
    ALGEBRAIC(:,115) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,151) = ( CONSTANTS(:,146).*CONSTANTS(:,188)+ CONSTANTS(:,222).*CONSTANTS(:,190)+ CONSTANTS(:,148).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,159) = ALGEBRAIC(:,151);
    ALGEBRAIC(:,163) =  ALGEBRAIC(:,159).*ALGEBRAIC(:,115);
    ALGEBRAIC(:,119) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,123) =  CONSTANTS(:,225).*ALGEBRAIC(:,119);
    ALGEBRAIC(:,127) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,167) = ALGEBRAIC(:,151);
    ALGEBRAIC(:,171) =  ALGEBRAIC(:,167).*ALGEBRAIC(:,127);
    ALGEBRAIC(:,131) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,135) =  CONSTANTS(:,226).*ALGEBRAIC(:,131);
    ALGEBRAIC(:,139) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,175) = ALGEBRAIC(:,151);
    ALGEBRAIC(:,179) =  ALGEBRAIC(:,175).*ALGEBRAIC(:,139);
    ALGEBRAIC(:,155) =  ALGEBRAIC(:,151).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,91) =  CONSTANTS(:,223).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,95) =  CONSTANTS(:,228).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,99) =  CONSTANTS(:,228).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,143) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,147) =  CONSTANTS(:,227).*ALGEBRAIC(:,143);
    ALGEBRAIC(:,103) =  CONSTANTS(:,229).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,87) = STATES(:,17)./CONSTANTS(:,7);
    ALGEBRAIC(:,107) = CONSTANTS(:,230)./(1.00000+CONSTANTS(:,144)./ALGEBRAIC(:,87));
    ALGEBRAIC(:,111) =  CONSTANTS(:,174).*STATES(:,17);
    RATES(:,17) = (CONSTANTS(:,221)+ALGEBRAIC(:,163)+ALGEBRAIC(:,123)+ALGEBRAIC(:,171)+ALGEBRAIC(:,135)+ALGEBRAIC(:,179)+ALGEBRAIC(:,155)+ALGEBRAIC(:,91)+ALGEBRAIC(:,95)+ALGEBRAIC(:,99)+ALGEBRAIC(:,147)+ALGEBRAIC(:,103)) - (ALGEBRAIC(:,107)+ALGEBRAIC(:,111));
   RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
    statesSize = size(STATES);
    statesColumnCount = statesSize(2);
    if ( statesColumnCount == 1)
        STATES = STATES';
        utilOnes = 1;
    else
        statesRowCount = statesSize(1);
        utilOnes = ones(statesRowCount, 1);
    end
    ALGEBRAIC(:,3) =  CONSTANTS(:,159).*STATES(:,5);
    ALGEBRAIC(:,6) =  CONSTANTS(:,165).*STATES(:,10);
    ALGEBRAIC(:,1) = STATES(:,1)./CONSTANTS(:,7);
    ALGEBRAIC(:,10) =  CONSTANTS(:,1).*(STATES(:,2)+STATES(:,3));
    ALGEBRAIC(:,11) = ALGEBRAIC(:,10)./(1.00000+CONSTANTS(:,175)./ALGEBRAIC(:,1));
    ALGEBRAIC(:,9) =  CONSTANTS(:,155).*STATES(:,1);
    ALGEBRAIC(:,27) = STATES(:,8)./CONSTANTS(:,7);
    ALGEBRAIC(:,29) =  CONSTANTS(:,55).*STATES(:,2);
    ALGEBRAIC(:,30) = ALGEBRAIC(:,29)./(1.00000+CONSTANTS(:,185)./ALGEBRAIC(:,27));
    ALGEBRAIC(:,28) =  CONSTANTS(:,162).*STATES(:,8);
    ALGEBRAIC(:,31) = STATES(:,9)./CONSTANTS(:,7);
    ALGEBRAIC(:,33) =  CONSTANTS(:,61).*STATES(:,3).*((1.00000 - ( VOI.*CONSTANTS(:,68))./1.00000)+(( VOI.*CONSTANTS(:,68))./1.00000)./(1.00000+power(CONSTANTS(:,66)./CONSTANTS(:,67), CONSTANTS(:,65))));
    ALGEBRAIC(:,34) = ALGEBRAIC(:,33)./(1.00000+CONSTANTS(:,187)./ALGEBRAIC(:,31));
    ALGEBRAIC(:,32) =  CONSTANTS(:,163).*STATES(:,9);
    ALGEBRAIC(:,12) = STATES(:,4)./CONSTANTS(:,7);
    ALGEBRAIC(:,18) =  CONSTANTS(:,12).*STATES(:,3);
    ALGEBRAIC(:,48) = STATES(:,12)./CONSTANTS(:,7);
    ALGEBRAIC(:,50) = ALGEBRAIC(:,18)./(1.00000+CONSTANTS(:,21)./ALGEBRAIC(:,12)+CONSTANTS(:,23)./ALGEBRAIC(:,48));
    ALGEBRAIC(:,55) =  CONSTANTS(:,89).*ALGEBRAIC(:,50);
    ALGEBRAIC(:,19) = STATES(:,6)./CONSTANTS(:,7);
    ALGEBRAIC(:,25) =  CONSTANTS(:,33).*STATES(:,3);
    ALGEBRAIC(:,52) = ALGEBRAIC(:,25)./(1.00000+CONSTANTS(:,39)./ALGEBRAIC(:,19)+CONSTANTS(:,44)./ALGEBRAIC(:,48));
    ALGEBRAIC(:,54) =  CONSTANTS(:,88).*ALGEBRAIC(:,52);
    ALGEBRAIC(:,57) =  CONSTANTS(:,90).*STATES(:,3);
    ALGEBRAIC(:,58) = ALGEBRAIC(:,57)./( (1.00000+CONSTANTS(:,92)./ALGEBRAIC(:,48)).*(1.00000+ALGEBRAIC(:,19)./CONSTANTS(:,93)+ALGEBRAIC(:,12)./CONSTANTS(:,94)));
    ALGEBRAIC(:,53) =  CONSTANTS(:,91).*ALGEBRAIC(:,34);
    ALGEBRAIC(:,56) =  CONSTANTS(:,167).*STATES(:,12);
    ALGEBRAIC(:,62) =  CONSTANTS(:,178).*STATES(:,2).*CONSTANTS(:,48);
    ALGEBRAIC(:,64) =  CONSTANTS(:,51).*ALGEBRAIC(:,62);
    ALGEBRAIC(:,26) =  CONSTANTS(:,161).*STATES(:,7);
    ALGEBRAIC(:,67) =  CONSTANTS(:,179).*STATES(:,13).*CONSTANTS(:,48);
    ALGEBRAIC(:,35) = STATES(:,11)./CONSTANTS(:,7);
    ALGEBRAIC(:,44) =  CONSTANTS(:,76).*STATES(:,2);
    ALGEBRAIC(:,45) = ALGEBRAIC(:,44)./(1.00000+CONSTANTS(:,74)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,66) =  CONSTANTS(:,98).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,71) =  CONSTANTS(:,176).*STATES(:,13).*CONSTANTS(:,48);
    ALGEBRAIC(:,69) =  CONSTANTS(:,169).*STATES(:,13).*(1.00000 - CONSTANTS(:,48));
    ALGEBRAIC(:,59) = STATES(:,2)./CONSTANTS(:,7);
    ALGEBRAIC(:,70) = STATES(:,3)./CONSTANTS(:,7);
    ALGEBRAIC(:,75) = ( CONSTANTS(:,101).*STATES(:,2).*CONSTANTS(:,48).*ALGEBRAIC(:,70))./(ALGEBRAIC(:,70)+ ALGEBRAIC(:,59).*(1.00000 - CONSTANTS(:,48)));
    ALGEBRAIC(:,76) = ALGEBRAIC(:,75)./(1.00000+CONSTANTS(:,102)./(ALGEBRAIC(:,70)+ ALGEBRAIC(:,59).*(1.00000 - CONSTANTS(:,48))));
    ALGEBRAIC(:,72) =  CONSTANTS(:,99).*ALGEBRAIC(:,52);
    ALGEBRAIC(:,73) =  CONSTANTS(:,100).*ALGEBRAIC(:,50);
    ALGEBRAIC(:,74) =  CONSTANTS(:,170).*STATES(:,3);
    ALGEBRAIC(:,16) =  CONSTANTS(:,10).*STATES(:,3);
    ALGEBRAIC(:,49) = ALGEBRAIC(:,16)./(1.00000+CONSTANTS(:,19)./ALGEBRAIC(:,12)+ALGEBRAIC(:,48)./CONSTANTS(:,25));
    ALGEBRAIC(:,17) =  CONSTANTS(:,11).*STATES(:,2);
    ALGEBRAIC(:,37) = ALGEBRAIC(:,17)./(1.00000+CONSTANTS(:,20)./ALGEBRAIC(:,12)+CONSTANTS(:,22)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,15) =  CONSTANTS(:,10).*STATES(:,2);
    ALGEBRAIC(:,36) = ALGEBRAIC(:,15)./(1.00000+CONSTANTS(:,19)./ALGEBRAIC(:,12)+ALGEBRAIC(:,35)./CONSTANTS(:,24));
    ALGEBRAIC(:,13) =  CONSTANTS(:,15).*ALGEBRAIC(:,11);
    ALGEBRAIC(:,63) =  CONSTANTS(:,16).*ALGEBRAIC(:,62);
    ALGEBRAIC(:,77) =  ALGEBRAIC(:,76).*(1.00000 - (1.00000./(1.00000+ALGEBRAIC(:,35)./CONSTANTS(:,27))+1.00000./(1.00000+CONSTANTS(:,9)./ALGEBRAIC(:,35))));
    ALGEBRAIC(:,79) =  CONSTANTS(:,17).*ALGEBRAIC(:,77);
    ALGEBRAIC(:,14) =  CONSTANTS(:,157).*STATES(:,4);
    ALGEBRAIC(:,24) =  CONSTANTS(:,32).*STATES(:,2).*(1.00000 - CONSTANTS(:,48));
    ALGEBRAIC(:,39) = ALGEBRAIC(:,24)./(1.00000+CONSTANTS(:,38)./ALGEBRAIC(:,19)+CONSTANTS(:,43)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,22) =  CONSTANTS(:,30).*CONSTANTS(:,7).*(CONSTANTS(:,49)./(1.00000+ALGEBRAIC(:,19)./CONSTANTS(:,45)));
    ALGEBRAIC(:,23) =  CONSTANTS(:,35).*ALGEBRAIC(:,22);
    ALGEBRAIC(:,38) =  CONSTANTS(:,36).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,51) =  CONSTANTS(:,36).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,78) = ( 1.00000.*ALGEBRAIC(:,76))./(1.00000+ALGEBRAIC(:,35)./CONSTANTS(:,27));
    ALGEBRAIC(:,80) =  CONSTANTS(:,37).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,20) = CONSTANTS(:,182)./(1.00000+CONSTANTS(:,40)./ALGEBRAIC(:,19));
    ALGEBRAIC(:,21) =  CONSTANTS(:,160).*STATES(:,6);
    ALGEBRAIC(:,81) = ALGEBRAIC(:,76)./(1.00000+CONSTANTS(:,9)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,83) =  CONSTANTS(:,73).*ALGEBRAIC(:,81);
    ALGEBRAIC(:,41) =  CONSTANTS(:,71).*ALGEBRAIC(:,39);
    ALGEBRAIC(:,42) =  CONSTANTS(:,72).*ALGEBRAIC(:,37);
    ALGEBRAIC(:,46) =  CONSTANTS(:,77).*STATES(:,2);
    ALGEBRAIC(:,47) =  ALGEBRAIC(:,46).*((1.00000 - CONSTANTS(:,48))./( (1.00000+CONSTANTS(:,75)./ALGEBRAIC(:,35)).*(1.00000+ALGEBRAIC(:,19)./CONSTANTS(:,86)).*(ALGEBRAIC(:,12)./CONSTANTS(:,87))))+( ALGEBRAIC(:,46).*CONSTANTS(:,48))./(1.00000+CONSTANTS(:,75)./ALGEBRAIC(:,35));
    ALGEBRAIC(:,40) =  CONSTANTS(:,81).*ALGEBRAIC(:,30);
    ALGEBRAIC(:,68) =  CONSTANTS(:,82).*ALGEBRAIC(:,67);
    ALGEBRAIC(:,43) =  CONSTANTS(:,166).*STATES(:,11);
    ALGEBRAIC(:,60) =  CONSTANTS(:,95).*ALGEBRAIC(:,39);
    ALGEBRAIC(:,61) =  CONSTANTS(:,96).*ALGEBRAIC(:,37);
    ALGEBRAIC(:,82) =  CONSTANTS(:,97).*ALGEBRAIC(:,81);
    ALGEBRAIC(:,65) =  CONSTANTS(:,176).*STATES(:,2).*CONSTANTS(:,48);
    ALGEBRAIC(:,112) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,148) = ( CONSTANTS(:,105).*CONSTANTS(:,188)+ CONSTANTS(:,192).*CONSTANTS(:,190)+ CONSTANTS(:,107).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,156) = ALGEBRAIC(:,148);
    ALGEBRAIC(:,160) =  ALGEBRAIC(:,156).*ALGEBRAIC(:,112);
    ALGEBRAIC(:,116) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,120) =  CONSTANTS(:,195).*ALGEBRAIC(:,116);
    ALGEBRAIC(:,124) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,164) = ALGEBRAIC(:,148);
    ALGEBRAIC(:,168) =  ALGEBRAIC(:,164).*ALGEBRAIC(:,124);
    ALGEBRAIC(:,128) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,132) =  CONSTANTS(:,196).*ALGEBRAIC(:,128);
    ALGEBRAIC(:,136) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,172) = ALGEBRAIC(:,148);
    ALGEBRAIC(:,176) =  ALGEBRAIC(:,172).*ALGEBRAIC(:,136);
    ALGEBRAIC(:,152) =  ALGEBRAIC(:,148).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,88) =  CONSTANTS(:,193).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,92) =  CONSTANTS(:,198).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,96) =  CONSTANTS(:,198).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,140) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,144) =  CONSTANTS(:,197).*ALGEBRAIC(:,140);
    ALGEBRAIC(:,100) =  CONSTANTS(:,199).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,84) = STATES(:,14)./CONSTANTS(:,7);
    ALGEBRAIC(:,104) = CONSTANTS(:,200)./(1.00000+CONSTANTS(:,103)./ALGEBRAIC(:,84));
    ALGEBRAIC(:,108) =  CONSTANTS(:,171).*STATES(:,14);
    ALGEBRAIC(:,113) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,149) = ( CONSTANTS(:,124).*CONSTANTS(:,188)+ CONSTANTS(:,202).*CONSTANTS(:,190)+ CONSTANTS(:,126).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,157) = ALGEBRAIC(:,149);
    ALGEBRAIC(:,161) =  ALGEBRAIC(:,157).*ALGEBRAIC(:,113);
    ALGEBRAIC(:,117) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,121) =  CONSTANTS(:,205).*ALGEBRAIC(:,117);
    ALGEBRAIC(:,125) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,165) = ALGEBRAIC(:,149);
    ALGEBRAIC(:,169) =  ALGEBRAIC(:,165).*ALGEBRAIC(:,125);
    ALGEBRAIC(:,129) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,133) =  CONSTANTS(:,206).*ALGEBRAIC(:,129);
    ALGEBRAIC(:,137) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,173) = ALGEBRAIC(:,149);
    ALGEBRAIC(:,177) =  ALGEBRAIC(:,173).*ALGEBRAIC(:,137);
    ALGEBRAIC(:,153) =  ALGEBRAIC(:,149).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,89) =  CONSTANTS(:,203).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,93) =  CONSTANTS(:,208).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,97) =  CONSTANTS(:,208).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,141) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,145) =  CONSTANTS(:,207).*ALGEBRAIC(:,141);
    ALGEBRAIC(:,101) =  CONSTANTS(:,209).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,85) = STATES(:,15)./CONSTANTS(:,7);
    ALGEBRAIC(:,105) = CONSTANTS(:,210)./(1.00000+CONSTANTS(:,122)./ALGEBRAIC(:,85));
    ALGEBRAIC(:,109) =  CONSTANTS(:,172).*STATES(:,15);
    ALGEBRAIC(:,114) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,150) = ( CONSTANTS(:,135).*CONSTANTS(:,188)+ CONSTANTS(:,212).*CONSTANTS(:,190)+ CONSTANTS(:,137).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,158) = ALGEBRAIC(:,150);
    ALGEBRAIC(:,162) =  ALGEBRAIC(:,158).*ALGEBRAIC(:,114);
    ALGEBRAIC(:,118) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,122) =  CONSTANTS(:,215).*ALGEBRAIC(:,118);
    ALGEBRAIC(:,126) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,166) = ALGEBRAIC(:,150);
    ALGEBRAIC(:,170) =  ALGEBRAIC(:,166).*ALGEBRAIC(:,126);
    ALGEBRAIC(:,130) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,134) =  CONSTANTS(:,216).*ALGEBRAIC(:,130);
    ALGEBRAIC(:,138) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,174) = ALGEBRAIC(:,150);
    ALGEBRAIC(:,178) =  ALGEBRAIC(:,174).*ALGEBRAIC(:,138);
    ALGEBRAIC(:,154) =  ALGEBRAIC(:,150).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,90) =  CONSTANTS(:,213).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,94) =  CONSTANTS(:,218).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,98) =  CONSTANTS(:,218).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,142) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,146) =  CONSTANTS(:,217).*ALGEBRAIC(:,142);
    ALGEBRAIC(:,102) =  CONSTANTS(:,219).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,86) = STATES(:,16)./CONSTANTS(:,7);
    ALGEBRAIC(:,106) = CONSTANTS(:,220)./(1.00000+CONSTANTS(:,133)./ALGEBRAIC(:,86));
    ALGEBRAIC(:,110) =  CONSTANTS(:,173).*STATES(:,16);
    ALGEBRAIC(:,115) =  CONSTANTS(:,114).*ALGEBRAIC(:,41);
    ALGEBRAIC(:,151) = ( CONSTANTS(:,146).*CONSTANTS(:,188)+ CONSTANTS(:,222).*CONSTANTS(:,190)+ CONSTANTS(:,148).*(CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68)))./(CONSTANTS(:,188)+CONSTANTS(:,190)+CONSTANTS(:,189)+ALGEBRAIC(:,40)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,159) = ALGEBRAIC(:,151);
    ALGEBRAIC(:,163) =  ALGEBRAIC(:,159).*ALGEBRAIC(:,115);
    ALGEBRAIC(:,119) =  CONSTANTS(:,115).*ALGEBRAIC(:,54);
    ALGEBRAIC(:,123) =  CONSTANTS(:,225).*ALGEBRAIC(:,119);
    ALGEBRAIC(:,127) =  CONSTANTS(:,116).*ALGEBRAIC(:,42);
    ALGEBRAIC(:,167) = ALGEBRAIC(:,151);
    ALGEBRAIC(:,171) =  ALGEBRAIC(:,167).*ALGEBRAIC(:,127);
    ALGEBRAIC(:,131) =  CONSTANTS(:,117).*ALGEBRAIC(:,55);
    ALGEBRAIC(:,135) =  CONSTANTS(:,226).*ALGEBRAIC(:,131);
    ALGEBRAIC(:,139) =  CONSTANTS(:,118).*ALGEBRAIC(:,45);
    ALGEBRAIC(:,175) = ALGEBRAIC(:,151);
    ALGEBRAIC(:,179) =  ALGEBRAIC(:,175).*ALGEBRAIC(:,139);
    ALGEBRAIC(:,155) =  ALGEBRAIC(:,151).*ALGEBRAIC(:,47);
    ALGEBRAIC(:,91) =  CONSTANTS(:,223).*ALGEBRAIC(:,58);
    ALGEBRAIC(:,95) =  CONSTANTS(:,228).*ALGEBRAIC(:,36);
    ALGEBRAIC(:,99) =  CONSTANTS(:,228).*ALGEBRAIC(:,49);
    ALGEBRAIC(:,143) =  CONSTANTS(:,119).*ALGEBRAIC(:,83);
    ALGEBRAIC(:,147) =  CONSTANTS(:,227).*ALGEBRAIC(:,143);
    ALGEBRAIC(:,103) =  CONSTANTS(:,229).*ALGEBRAIC(:,78);
    ALGEBRAIC(:,87) = STATES(:,17)./CONSTANTS(:,7);
    ALGEBRAIC(:,107) = CONSTANTS(:,230)./(1.00000+CONSTANTS(:,144)./ALGEBRAIC(:,87));
    ALGEBRAIC(:,111) =  CONSTANTS(:,174).*STATES(:,17);
    ALGEBRAIC(:,2) = STATES(:,5)./CONSTANTS(:,7);
    ALGEBRAIC(:,4) = STATES(:,7)./CONSTANTS(:,7);
    ALGEBRAIC(:,5) = STATES(:,10)./CONSTANTS(:,7);
    ALGEBRAIC(:,7) =  CONSTANTS(:,168).*STATES(:,2).*(1.00000 - CONSTANTS(:,48));
    ALGEBRAIC(:,8) = STATES(:,13)./CONSTANTS(:,7);
end

% Pad out or shorten strings to a set length
function strout = strpad(strin)
    req_length = 160;
    insize = size(strin,2);
    if insize > req_length
        strout = strin(1:req_length);
    else
        strout = [strin, blanks(req_length - insize)];
    end
end