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 =120;
end
% There are a total of 46 entries in each of the rate and state variable arrays.
% There are a total of 99 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 (ms)');
    LEGEND_CONSTANTS(:,1) = strpad('F in component model_parameters (C_per_mole)');
    LEGEND_CONSTANTS(:,2) = strpad('T in component model_parameters (kelvin)');
    LEGEND_CONSTANTS(:,3) = strpad('R in component model_parameters (J_per_kmole_K)');
    LEGEND_CONSTANTS(:,4) = strpad('K_o in component model_parameters (mM)');
    LEGEND_CONSTANTS(:,5) = strpad('Ca_o in component model_parameters (mM)');
    LEGEND_CONSTANTS(:,6) = strpad('Na_o in component model_parameters (mM)');
    LEGEND_CONSTANTS(:,7) = strpad('Cl_o in component model_parameters (mM)');
    LEGEND_CONSTANTS(:,94) = strpad('Vmyo in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,95) = strpad('Vnsr in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,90) = strpad('Vsr in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,96) = strpad('Vjsr in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,97) = strpad('Vss_sr in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,98) = strpad('Vss_CaL in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,92) = strpad('Acap in component cell_geometry (cm2)');
    LEGEND_CONSTANTS(:,93) = strpad('AF in component cell_geometry (uF_mole_per_C)');
    LEGEND_CONSTANTS(:,8) = strpad('l in component cell_geometry (cm)');
    LEGEND_CONSTANTS(:,9) = strpad('a in component cell_geometry (cm)');
    LEGEND_CONSTANTS(:,87) = strpad('vcell in component cell_geometry (uL)');
    LEGEND_CONSTANTS(:,91) = strpad('ageo in component cell_geometry (cm2)');
    LEGEND_STATES(:,1) = strpad('Vm in component membrane (mV)');
    LEGEND_ALGEBRAIC(:,13) = strpad('i_Stim in component membrane (uA_per_uF)');
    LEGEND_CONSTANTS(:,10) = strpad('stim_offset in component membrane (ms)');
    LEGEND_CONSTANTS(:,11) = strpad('stim_period in component membrane (ms)');
    LEGEND_CONSTANTS(:,12) = strpad('stim_duration in component membrane (ms)');
    LEGEND_CONSTANTS(:,13) = strpad('stim_amplitude in component membrane (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,1) = strpad('past in component membrane (ms)');
    LEGEND_ALGEBRAIC(:,74) = strpad('caiont in component membrane (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,91) = strpad('naiont in component membrane (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,115) = strpad('kiont in component membrane (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,119) = strpad('clont in component membrane (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,84) = strpad('INa in component INa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,37) = strpad('ICaL in component ICaL (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,107) = strpad('IK1 in component IK1 (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,97) = strpad('IKp in component IKp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,101) = strpad('IKs in component IKs (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,112) = strpad('IKr in component IKr (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,72) = strpad('IpCa in component IpCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,73) = strpad('ICab in component ICab (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,70) = strpad('INaCa in component INaCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,68) = strpad('INaCa_ss_sr in component INaCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,51) = strpad('INaK in component INaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,114) = strpad('Ito1 in component Ito1 (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,118) = strpad('Ito2 in component Ito2 (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,103) = strpad('IClb in component IClb (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,88) = strpad('INaL in component INaL (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,78) = strpad('INab in component INab (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,24) = strpad('gKs in component IKs (mS_per_uF)');
    LEGEND_CONSTANTS(:,14) = strpad('gKs_max in component IKs (mS_per_uF)');
    LEGEND_STATES(:,2) = strpad('C1 in component IKs (dimensionless)');
    LEGEND_STATES(:,3) = strpad('C2 in component IKs (dimensionless)');
    LEGEND_STATES(:,4) = strpad('C3 in component IKs (dimensionless)');
    LEGEND_STATES(:,5) = strpad('C4 in component IKs (dimensionless)');
    LEGEND_STATES(:,6) = strpad('C5 in component IKs (dimensionless)');
    LEGEND_STATES(:,7) = strpad('C6 in component IKs (dimensionless)');
    LEGEND_STATES(:,8) = strpad('C7 in component IKs (dimensionless)');
    LEGEND_STATES(:,9) = strpad('C8 in component IKs (dimensionless)');
    LEGEND_STATES(:,10) = strpad('C9 in component IKs (dimensionless)');
    LEGEND_STATES(:,11) = strpad('C10 in component IKs (dimensionless)');
    LEGEND_STATES(:,12) = strpad('C11 in component IKs (dimensionless)');
    LEGEND_STATES(:,13) = strpad('C12 in component IKs (dimensionless)');
    LEGEND_STATES(:,14) = strpad('C13 in component IKs (dimensionless)');
    LEGEND_STATES(:,15) = strpad('C14 in component IKs (dimensionless)');
    LEGEND_STATES(:,16) = strpad('C15 in component IKs (dimensionless)');
    LEGEND_STATES(:,17) = strpad('O1 in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,28) = strpad('O2 in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,31) = strpad('OKs in component IKs (dimensionless)');
    LEGEND_ALGEBRAIC(:,32) = strpad('alpha in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,35) = strpad('beta in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,40) = strpad('delta in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,38) = strpad('gamma in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,43) = strpad('eta in component IKs (per_ms)');
    LEGEND_CONSTANTS(:,86) = strpad('theta in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,46) = strpad('omega in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,49) = strpad('psi in component IKs (per_ms)');
    LEGEND_ALGEBRAIC(:,99) = strpad('EKs in component reversal_potentials (mV)');
    LEGEND_STATES(:,18) = strpad('Ca_i in component Ca (mM)');
    LEGEND_ALGEBRAIC(:,34) = strpad('ICaL_max in component ICaL (uA_per_uF)');
    LEGEND_CONSTANTS(:,15) = strpad('PCa in component ICaL (L_per_F_ms)');
    LEGEND_STATES(:,19) = strpad('C in component ICaL (dimensionless)');
    LEGEND_STATES(:,20) = strpad('O in component ICaL (dimensionless)');
    LEGEND_STATES(:,21) = strpad('C_star in component ICaL (dimensionless)');
    LEGEND_STATES(:,22) = strpad('O_star in component ICaL (dimensionless)');
    LEGEND_STATES(:,23) = strpad('CI in component ICaL (dimensionless)');
    LEGEND_STATES(:,24) = strpad('OI in component ICaL (dimensionless)');
    LEGEND_STATES(:,25) = strpad('CI_star in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,2) = strpad('OI_star in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,14) = strpad('ACT_tau in component ICaL (ms)');
    LEGEND_ALGEBRAIC(:,39) = strpad('IV_tau in component ICaL (ms)');
    LEGEND_ALGEBRAIC(:,54) = strpad('IV_tau_star in component ICaL (ms)');
    LEGEND_ALGEBRAIC(:,25) = strpad('ACT_infinity in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,36) = strpad('IV_infinity in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,47) = strpad('IV_infinity_star in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,52) = strpad('IV_beta_star in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,50) = strpad('IV_beta_infinity_star in component ICaL (dimensionless)');
    LEGEND_ALGEBRAIC(:,29) = strpad('alpha in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,33) = strpad('beta in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,60) = strpad('delta in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,41) = strpad('x in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,44) = strpad('y in component ICaL (per_ms)');
    LEGEND_CONSTANTS(:,16) = strpad('theta in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,62) = strpad('delta_I in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,56) = strpad('x_star in component ICaL (per_ms)');
    LEGEND_ALGEBRAIC(:,58) = strpad('y_star in component ICaL (per_ms)');
    LEGEND_CONSTANTS(:,17) = strpad('theta_I in component ICaL (per_ms)');
    LEGEND_CONSTANTS(:,18) = strpad('gamma_Cai in component ICaL (dimensionless)');
    LEGEND_CONSTANTS(:,19) = strpad('gamma_Cao in component ICaL (dimensionless)');
    LEGEND_STATES(:,26) = strpad('Ca_ss_CaL in component Ca (mM)');
    LEGEND_CONSTANTS(:,20) = strpad('g_Na in component INa (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,81) = strpad('ENa in component reversal_potentials (mV)');
    LEGEND_STATES(:,27) = strpad('m in component INa_m_gate (dimensionless)');
    LEGEND_STATES(:,28) = strpad('h in component INa_h_gate (dimensionless)');
    LEGEND_STATES(:,29) = strpad('j in component INa_j_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,3) = strpad('am in component INa_m_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,15) = strpad('bm in component INa_m_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,4) = strpad('ah in component INa_h_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,16) = strpad('bh in component INa_h_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,5) = strpad('aj in component INa_j_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,17) = strpad('bj in component INa_j_gate (per_ms)');
    LEGEND_CONSTANTS(:,21) = strpad('kmnai in component INaK (mM)');
    LEGEND_CONSTANTS(:,22) = strpad('kmko in component INaK (mM)');
    LEGEND_CONSTANTS(:,23) = strpad('ibarnak in component INaK (uA_per_uF)');
    LEGEND_CONSTANTS(:,24) = strpad('sigma in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,25) = strpad('V_half in component INaK (mV)');
    LEGEND_ALGEBRAIC(:,42) = strpad('phi in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,45) = strpad('fv in component INaK (dimensionless)');
    LEGEND_CONSTANTS(:,99) = strpad('PK in component INaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,48) = strpad('PNa in component INaK (dimensionless)');
    LEGEND_STATES(:,30) = strpad('Na_i in component Na (mM)');
    LEGEND_ALGEBRAIC(:,69) = strpad('INaCa_cai in component INaCa (uA_per_uF)');
    LEGEND_CONSTANTS(:,26) = strpad('KmCa_act in component INaCa (mM)');
    LEGEND_CONSTANTS(:,27) = strpad('Vmax in component INaCa (uA_per_uF)');
    LEGEND_CONSTANTS(:,28) = strpad('ksat in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,29) = strpad('eta in component INaCa (dimensionless)');
    LEGEND_CONSTANTS(:,30) = strpad('KmNai in component INaCa (mM)');
    LEGEND_CONSTANTS(:,31) = strpad('KmNao in component INaCa (mM)');
    LEGEND_CONSTANTS(:,32) = strpad('KmCai in component INaCa (mM)');
    LEGEND_CONSTANTS(:,33) = strpad('KmCao in component INaCa (mM)');
    LEGEND_STATES(:,31) = strpad('Ca_ss_sr in component Ca (mM)');
    LEGEND_STATES(:,32) = strpad('Na_ss_sr in component Na (mM)');
    LEGEND_ALGEBRAIC(:,53) = strpad('numerator in component INaCa (mM4_uA_per_uF)');
    LEGEND_ALGEBRAIC(:,63) = strpad('num_ss in component INaCa (mM4_uA_per_uF)');
    LEGEND_ALGEBRAIC(:,55) = strpad('denom_1 in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,57) = strpad('denom_2 in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,59) = strpad('denom_3 in component INaCa (mM4)');
    LEGEND_ALGEBRAIC(:,61) = strpad('denom_4 in component INaCa (mM4)');
    LEGEND_ALGEBRAIC(:,64) = strpad('denom_ss_1 in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,65) = strpad('denom_ss_2 in component INaCa (dimensionless)');
    LEGEND_ALGEBRAIC(:,66) = strpad('denom_ss_3 in component INaCa (mM4)');
    LEGEND_ALGEBRAIC(:,67) = strpad('denom_ss_4 in component INaCa (mM4)');
    LEGEND_CONSTANTS(:,34) = strpad('gKp in component IKp (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,71) = strpad('Kp in component IKp (dimensionless)');
    LEGEND_ALGEBRAIC(:,94) = strpad('EK in component reversal_potentials (mV)');
    LEGEND_CONSTANTS(:,35) = strpad('gpCa in component IpCa (uA_per_uF)');
    LEGEND_CONSTANTS(:,36) = strpad('KmpCa in component IpCa (mM)');
    LEGEND_CONSTANTS(:,37) = strpad('PCab in component ICab (L_per_F_ms)');
    LEGEND_CONSTANTS(:,38) = strpad('gamma_Ca_i in component ICab (dimensionless)');
    LEGEND_CONSTANTS(:,39) = strpad('gamma_Ca_o in component ICab (dimensionless)');
    LEGEND_CONSTANTS(:,40) = strpad('PNab in component INab (L_per_F_ms)');
    LEGEND_ALGEBRAIC(:,76) = strpad('phi in component INab (dimensionless)');
    LEGEND_CONSTANTS(:,41) = strpad('gClb in component IClb (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,102) = strpad('ECl in component reversal_potentials (mV)');
    LEGEND_CONSTANTS(:,42) = strpad('gNaL in component INaL (mS_per_uF)');
    LEGEND_STATES(:,33) = strpad('mL in component INaL_mL_gate (dimensionless)');
    LEGEND_STATES(:,34) = strpad('hL in component INaL_hL_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,6) = strpad('amL in component INaL_mL_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,18) = strpad('bmL in component INaL_mL_gate (per_ms)');
    LEGEND_CONSTANTS(:,43) = strpad('tau_hL in component INaL_hL_gate (ms)');
    LEGEND_ALGEBRAIC(:,7) = strpad('hL_infinity in component INaL_hL_gate (dimensionless)');
    LEGEND_CONSTANTS(:,44) = strpad('prnak in component reversal_potentials (dimensionless)');
    LEGEND_STATES(:,35) = strpad('K_i in component K (mM)');
    LEGEND_STATES(:,36) = strpad('Cl_i in component Cl (mM)');
    LEGEND_CONSTANTS(:,45) = strpad('g_K1_max in component IK1 (mS_per_uF)');
    LEGEND_CONSTANTS(:,88) = strpad('gK1 in component IK1 (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,106) = strpad('K1 in component IK1_K1_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,104) = strpad('alpha_k1 in component IK1_K1_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,105) = strpad('beta_k1 in component IK1_K1_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,108) = strpad('CT_Na_Cl in component CT_Na_Cl (mM_per_ms)');
    LEGEND_CONSTANTS(:,46) = strpad('CT_Na_Cl_max in component CT_Na_Cl (mM_per_ms)');
    LEGEND_ALGEBRAIC(:,109) = strpad('CT_K_Cl in component CT_K_Cl (mM_per_ms)');
    LEGEND_CONSTANTS(:,47) = strpad('CT_K_Cl_max in component CT_K_Cl (mM_per_ms)');
    LEGEND_CONSTANTS(:,89) = strpad('gKr in component IKr (mS_per_uF)');
    LEGEND_CONSTANTS(:,48) = strpad('gKr_max in component IKr (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,111) = strpad('r in component IKr_r_gate (dimensionless)');
    LEGEND_STATES(:,37) = strpad('xr in component IKr_xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,8) = strpad('xr_infinity in component IKr_xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,19) = strpad('tau_xr in component IKr_xr_gate (ms)');
    LEGEND_CONSTANTS(:,49) = strpad('gto1 in component Ito1 (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,113) = strpad('rto1 in component Ito1 (dimensionless)');
    LEGEND_STATES(:,38) = strpad('a in component Ito1_a_gate (dimensionless)');
    LEGEND_STATES(:,39) = strpad('i1f in component Ito1_i1f_gate (dimensionless)');
    LEGEND_STATES(:,40) = strpad('i1s in component Ito1_i1s_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,9) = strpad('alpha_a in component Ito1_a_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,20) = strpad('beta_a in component Ito1_a_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,26) = strpad('tau_a in component Ito1_a_gate (ms)');
    LEGEND_ALGEBRAIC(:,30) = strpad('a_infinity in component Ito1_a_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,21) = strpad('alpha_i1f in component Ito1_i1f_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,10) = strpad('beta_i1f in component Ito1_i1f_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,22) = strpad('alpha_i1s in component Ito1_i1s_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,11) = strpad('beta_i1s in component Ito1_i1s_gate (per_ms)');
    LEGEND_CONSTANTS(:,50) = strpad('PCl in component Ito2 (L_per_F_ms)');
    LEGEND_CONSTANTS(:,51) = strpad('zCl in component Ito2 (dimensionless)');
    LEGEND_ALGEBRAIC(:,116) = strpad('Ito2_max in component Ito2 (uA_per_uF)');
    LEGEND_CONSTANTS(:,52) = strpad('Ito2_max_scaling_factor in component Ito2 (dimensionless)');
    LEGEND_ALGEBRAIC(:,117) = strpad('KCa_ito2 in component Ito2 (dimensionless)');
    LEGEND_CONSTANTS(:,53) = strpad('kCa_ito2 in component Ito2 (mM_per_ms)');
    LEGEND_STATES(:,41) = strpad('Irel in component Irel (mM_per_ms)');
    LEGEND_STATES(:,42) = strpad('i2f in component Ito2_i2f_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,23) = strpad('alpha_i2f in component Ito2_i2f_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,12) = strpad('beta_i2f in component Ito2_i2f_gate (per_ms)');
    LEGEND_ALGEBRAIC(:,27) = strpad('i2f_infinity in component Ito2_i2f_gate (dimensionless)');
    LEGEND_CONSTANTS(:,54) = strpad('tau_i2f in component Ito2_i2f_gate (ms)');
    LEGEND_ALGEBRAIC(:,100) = strpad('rel_infinity in component Irel (mM_per_ms)');
    LEGEND_ALGEBRAIC(:,98) = strpad('tau_rel in component Irel (ms)');
    LEGEND_CONSTANTS(:,55) = strpad('Krel_infinity in component Irel (mM)');
    LEGEND_ALGEBRAIC(:,95) = strpad('alpha_rel in component Irel (mM_per_uA_per_uF_per_ms)');
    LEGEND_ALGEBRAIC(:,92) = strpad('beta_tau in component Irel (ms)');
    LEGEND_CONSTANTS(:,56) = strpad('beta_0 in component Irel (ms)');
    LEGEND_CONSTANTS(:,57) = strpad('kappa in component Irel (mM_per_uA_per_uF_per_ms_per_ms)');
    LEGEND_CONSTANTS(:,58) = strpad('h_rel in component Irel (dimensionless)');
    LEGEND_CONSTANTS(:,59) = strpad('h_beta in component Irel (dimensionless)');
    LEGEND_ALGEBRAIC(:,89) = strpad('delta_beta_CaMK in component Irel (dimensionless)');
    LEGEND_CONSTANTS(:,60) = strpad('delta_beta_0 in component Irel (dimensionless)');
    LEGEND_CONSTANTS(:,61) = strpad('K_beta in component Irel (mM)');
    LEGEND_CONSTANTS(:,62) = strpad('Krel_tau in component Irel (mM)');
    LEGEND_STATES(:,43) = strpad('Ca_JSR in component Ca (mM)');
    LEGEND_ALGEBRAIC(:,85) = strpad('CaMK_active in component CaMK_active (dimensionless)');
    LEGEND_ALGEBRAIC(:,96) = strpad('Iup in component Iup (mM_per_ms)');
    LEGEND_CONSTANTS(:,63) = strpad('kmup in component Iup (mM)');
    LEGEND_ALGEBRAIC(:,93) = strpad('delta_kmPLB in component Iup (mM)');
    LEGEND_CONSTANTS(:,64) = strpad('delta_kmPLB_bar in component Iup (mM)');
    LEGEND_CONSTANTS(:,65) = strpad('iupbar in component Iup (mM_per_ms)');
    LEGEND_ALGEBRAIC(:,90) = strpad('delta_iupCaMK in component Iup (dimensionless)');
    LEGEND_CONSTANTS(:,66) = strpad('delta_iupCaMK_bar in component Iup (dimensionless)');
    LEGEND_CONSTANTS(:,67) = strpad('kmCaMK in component Iup (mM)');
    LEGEND_ALGEBRAIC(:,75) = strpad('Ileak in component Ileak (mM_per_ms)');
    LEGEND_CONSTANTS(:,68) = strpad('nsrbar in component Ileak (mM)');
    LEGEND_STATES(:,44) = strpad('Ca_NSR in component Ca (mM)');
    LEGEND_ALGEBRAIC(:,77) = strpad('Itr in component Itr (mM_per_ms)');
    LEGEND_CONSTANTS(:,69) = strpad('tautr in component Itr (ms)');
    LEGEND_CONSTANTS(:,70) = strpad('tau_diff in component Ca (ms)');
    LEGEND_CONSTANTS(:,71) = strpad('tau_diff_ss in component Ca (ms)');
    LEGEND_ALGEBRAIC(:,79) = strpad('Idiff in component Ca (mM_per_ms)');
    LEGEND_ALGEBRAIC(:,83) = strpad('Idiff_ss in component Ca (mM_per_ms)');
    LEGEND_ALGEBRAIC(:,82) = strpad('bmyo in component Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,86) = strpad('bss_sr in component Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,87) = strpad('bss_cal in component Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,80) = strpad('bcsqn in component Ca (dimensionless)');
    LEGEND_CONSTANTS(:,72) = strpad('cmdn_bar in component Ca (mM)');
    LEGEND_CONSTANTS(:,73) = strpad('trpn_bar in component Ca (mM)');
    LEGEND_CONSTANTS(:,74) = strpad('km_cmdn in component Ca (mM)');
    LEGEND_CONSTANTS(:,75) = strpad('km_trpn in component Ca (mM)');
    LEGEND_CONSTANTS(:,76) = strpad('kmcsqn in component Ca (mM)');
    LEGEND_CONSTANTS(:,77) = strpad('csqnbar in component Ca (mM)');
    LEGEND_CONSTANTS(:,78) = strpad('BSRmax in component Ca (mM)');
    LEGEND_CONSTANTS(:,79) = strpad('KmBSR in component Ca (mM)');
    LEGEND_CONSTANTS(:,80) = strpad('BSLmax in component Ca (mM)');
    LEGEND_CONSTANTS(:,81) = strpad('KmBSL in component Ca (mM)');
    LEGEND_ALGEBRAIC(:,110) = strpad('Idiff_Na in component Na (mM_per_ms)');
    LEGEND_STATES(:,45) = strpad('Cl_ss in component Cl (mM)');
    LEGEND_ALGEBRAIC(:,120) = strpad('Idiff_Cl in component Cl (mM_per_ms)');
    LEGEND_CONSTANTS(:,82) = strpad('Km in component CaMK_active (mM)');
    LEGEND_STATES(:,46) = strpad('CaMK_trap in component CaMK_active (dimensionless)');
    LEGEND_CONSTANTS(:,83) = strpad('alpha_CaMK in component CaMK_active (per_ms)');
    LEGEND_CONSTANTS(:,84) = strpad('beta_CaMK in component CaMK_active (per_ms)');
    LEGEND_CONSTANTS(:,85) = strpad('CaMK_0 in component CaMK_active (dimensionless)');
    LEGEND_RATES(:,1) = strpad('d/dt Vm in component membrane (mV)');
    LEGEND_RATES(:,2) = strpad('d/dt C1 in component IKs (dimensionless)');
    LEGEND_RATES(:,3) = strpad('d/dt C2 in component IKs (dimensionless)');
    LEGEND_RATES(:,4) = strpad('d/dt C3 in component IKs (dimensionless)');
    LEGEND_RATES(:,5) = strpad('d/dt C4 in component IKs (dimensionless)');
    LEGEND_RATES(:,6) = strpad('d/dt C5 in component IKs (dimensionless)');
    LEGEND_RATES(:,7) = strpad('d/dt C6 in component IKs (dimensionless)');
    LEGEND_RATES(:,8) = strpad('d/dt C7 in component IKs (dimensionless)');
    LEGEND_RATES(:,9) = strpad('d/dt C8 in component IKs (dimensionless)');
    LEGEND_RATES(:,10) = strpad('d/dt C9 in component IKs (dimensionless)');
    LEGEND_RATES(:,11) = strpad('d/dt C10 in component IKs (dimensionless)');
    LEGEND_RATES(:,12) = strpad('d/dt C11 in component IKs (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt C12 in component IKs (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt C13 in component IKs (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt C14 in component IKs (dimensionless)');
    LEGEND_RATES(:,16) = strpad('d/dt C15 in component IKs (dimensionless)');
    LEGEND_RATES(:,17) = strpad('d/dt O1 in component IKs (dimensionless)');
    LEGEND_RATES(:,19) = strpad('d/dt C in component ICaL (dimensionless)');
    LEGEND_RATES(:,20) = strpad('d/dt O in component ICaL (dimensionless)');
    LEGEND_RATES(:,21) = strpad('d/dt C_star in component ICaL (dimensionless)');
    LEGEND_RATES(:,22) = strpad('d/dt O_star in component ICaL (dimensionless)');
    LEGEND_RATES(:,23) = strpad('d/dt CI in component ICaL (dimensionless)');
    LEGEND_RATES(:,24) = strpad('d/dt OI in component ICaL (dimensionless)');
    LEGEND_RATES(:,25) = strpad('d/dt CI_star in component ICaL (dimensionless)');
    LEGEND_RATES(:,27) = strpad('d/dt m in component INa_m_gate (dimensionless)');
    LEGEND_RATES(:,28) = strpad('d/dt h in component INa_h_gate (dimensionless)');
    LEGEND_RATES(:,29) = strpad('d/dt j in component INa_j_gate (dimensionless)');
    LEGEND_RATES(:,33) = strpad('d/dt mL in component INaL_mL_gate (dimensionless)');
    LEGEND_RATES(:,34) = strpad('d/dt hL in component INaL_hL_gate (dimensionless)');
    LEGEND_RATES(:,37) = strpad('d/dt xr in component IKr_xr_gate (dimensionless)');
    LEGEND_RATES(:,38) = strpad('d/dt a in component Ito1_a_gate (dimensionless)');
    LEGEND_RATES(:,39) = strpad('d/dt i1f in component Ito1_i1f_gate (dimensionless)');
    LEGEND_RATES(:,40) = strpad('d/dt i1s in component Ito1_i1s_gate (dimensionless)');
    LEGEND_RATES(:,42) = strpad('d/dt i2f in component Ito2_i2f_gate (dimensionless)');
    LEGEND_RATES(:,41) = strpad('d/dt Irel in component Irel (mM_per_ms)');
    LEGEND_RATES(:,18) = strpad('d/dt Ca_i in component Ca (mM)');
    LEGEND_RATES(:,31) = strpad('d/dt Ca_ss_sr in component Ca (mM)');
    LEGEND_RATES(:,26) = strpad('d/dt Ca_ss_CaL in component Ca (mM)');
    LEGEND_RATES(:,44) = strpad('d/dt Ca_NSR in component Ca (mM)');
    LEGEND_RATES(:,43) = strpad('d/dt Ca_JSR in component Ca (mM)');
    LEGEND_RATES(:,30) = strpad('d/dt Na_i in component Na (mM)');
    LEGEND_RATES(:,32) = strpad('d/dt Na_ss_sr in component Na (mM)');
    LEGEND_RATES(:,36) = strpad('d/dt Cl_i in component Cl (mM)');
    LEGEND_RATES(:,45) = strpad('d/dt Cl_ss in component Cl (mM)');
    LEGEND_RATES(:,35) = strpad('d/dt K_i in component K (mM)');
    LEGEND_RATES(:,46) = strpad('d/dt CaMK_trap in component CaMK_active (dimensionless)');
    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 = [];
    CONSTANTS(:,1) = 96485;
    CONSTANTS(:,2) = 310;
    CONSTANTS(:,3) = 8314;
    CONSTANTS(:,4) = 5.4;
    CONSTANTS(:,5) = 1.8;
    CONSTANTS(:,6) = 140;
    CONSTANTS(:,7) = 100;
    CONSTANTS(:,8) = 0.01;
    CONSTANTS(:,9) = 0.0011;
    STATES(:,1) = -87.4947322902196;
    CONSTANTS(:,10) = 0;
    CONSTANTS(:,11) = 1000;
    CONSTANTS(:,12) = 0.5;
    CONSTANTS(:,13) = -80;
    CONSTANTS(:,14) = 0.0826;
    STATES(:,2) = 0.476679784307081;
    STATES(:,3) = 0.255181042718489;
    STATES(:,4) = 0.0512272866698557;
    STATES(:,5) = 0.0045705849736195;
    STATES(:,6) = 0.000152923243503507;
    STATES(:,7) = 0.132814156809568;
    STATES(:,8) = 0.053324572164618;
    STATES(:,9) = 0.00713656414955778;
    STATES(:,10) = 0.000318368292970148;
    STATES(:,11) = 0.0138769647384953;
    STATES(:,12) = 0.00371438476499172;
    STATES(:,13) = 0.000248553788631871;
    STATES(:,14) = 0.000644426171899078;
    STATES(:,15) = 8.62495047666861e-5;
    STATES(:,16) = 1.12344645485893e-5;
    STATES(:,17) = 1.05292905767805e-5;
    STATES(:,18) = 8.38749860095482e-5;
    CONSTANTS(:,15) = 0.00015552;
    STATES(:,19) = 0.99996982093287;
    STATES(:,20) = 2.26882961412491e-5;
    STATES(:,21) = 7.49117189549873e-6;
    STATES(:,22) = 1.23556404128518e-10;
    STATES(:,23) = 5.89853003114132e-11;
    STATES(:,24) = 8.01952813127322e-17;
    STATES(:,25) = 1.9237001017021e-9;
    CONSTANTS(:,16) = 1;
    CONSTANTS(:,17) = 1e-6;
    CONSTANTS(:,18) = 1;
    CONSTANTS(:,19) = 0.341;
    STATES(:,26) = 0.000119239795531548;
    CONSTANTS(:,20) = 9.075;
    STATES(:,27) = 0.00101841101248412;
    STATES(:,28) = 0.991354143386887;
    STATES(:,29) = 0.99709036251243;
    CONSTANTS(:,21) = 2.6;
    CONSTANTS(:,22) = 1.5;
    CONSTANTS(:,23) = 1.4;
    CONSTANTS(:,24) = 1;
    CONSTANTS(:,25) = -92;
    STATES(:,30) = 8.01031392415197;
    CONSTANTS(:,26) = 0.000125;
    CONSTANTS(:,27) = 4.5;
    CONSTANTS(:,28) = 0.32;
    CONSTANTS(:,29) = 0.27;
    CONSTANTS(:,30) = 12.3;
    CONSTANTS(:,31) = 87.5;
    CONSTANTS(:,32) = 0.0036;
    CONSTANTS(:,33) = 1.3;
    STATES(:,31) = 0.00011296707102434;
    STATES(:,32) = 8.01033434859049;
    CONSTANTS(:,34) = 0.00276;
    CONSTANTS(:,35) = 0.0575;
    CONSTANTS(:,36) = 0.0005;
    CONSTANTS(:,37) = 1.99508e-7;
    CONSTANTS(:,38) = 1;
    CONSTANTS(:,39) = 0.341;
    CONSTANTS(:,40) = 3.2e-9;
    CONSTANTS(:,41) = 0.000225;
    CONSTANTS(:,42) = 0.0065;
    STATES(:,33) = 0.00101841101248412;
    STATES(:,34) = 0.319611809402137;
    CONSTANTS(:,43) = 600;
    CONSTANTS(:,44) = 0.01833;
    STATES(:,35) = 144.907134343314;
    STATES(:,36) = 20.6683603724432;
    CONSTANTS(:,45) = 0.5;
    CONSTANTS(:,46) = 2.46108e-5;
    CONSTANTS(:,47) = 1.77e-5;
    CONSTANTS(:,48) = 0.0138542;
    STATES(:,37) = 4.06959064407486e-6;
    CONSTANTS(:,49) = 0.497458;
    STATES(:,38) = 1.76776038804228e-5;
    STATES(:,39) = 0.997976503910799;
    STATES(:,40) = 0.947581184798815;
    CONSTANTS(:,50) = 9e-7;
    CONSTANTS(:,51) = -1;
    CONSTANTS(:,52) = 1;
    CONSTANTS(:,53) = 0.4;
    STATES(:,41) = 0.000714227102027745;
    STATES(:,42) = 0.996044894628276;
    CONSTANTS(:,54) = 8;
    CONSTANTS(:,55) = 1;
    CONSTANTS(:,56) = 4.75;
    CONSTANTS(:,57) = 0.1125;
    CONSTANTS(:,58) = 8;
    CONSTANTS(:,59) = 10;
    CONSTANTS(:,60) = 1;
    CONSTANTS(:,61) = 0.28;
    CONSTANTS(:,62) = 0.0123;
    STATES(:,43) = 0.993914988616979;
    CONSTANTS(:,63) = 0.00092;
    CONSTANTS(:,64) = 0.00017;
    CONSTANTS(:,65) = 0.004375;
    CONSTANTS(:,66) = 0.75;
    CONSTANTS(:,67) = 0.15;
    CONSTANTS(:,68) = 15;
    STATES(:,44) = 1.01475649943057;
    CONSTANTS(:,69) = 25;
    CONSTANTS(:,70) = 0.2;
    CONSTANTS(:,71) = 2;
    CONSTANTS(:,72) = 0.05;
    CONSTANTS(:,73) = 0.07;
    CONSTANTS(:,74) = 0.00238;
    CONSTANTS(:,75) = 0.0005;
    CONSTANTS(:,76) = 0.8;
    CONSTANTS(:,77) = 10;
    CONSTANTS(:,78) = 0.047;
    CONSTANTS(:,79) = 0.00087;
    CONSTANTS(:,80) = 1.124;
    CONSTANTS(:,81) = 0.0087;
    STATES(:,45) = 20.6683605553303;
    CONSTANTS(:,82) = 0.0015;
    STATES(:,46) = 0.0114911034744777;
    CONSTANTS(:,83) = 0.05;
    CONSTANTS(:,84) = 0.00068;
    CONSTANTS(:,85) = 0.05;
    CONSTANTS(:,86) = 0.0895383;
    CONSTANTS(:,87) =  1000.00.* pi.*CONSTANTS(:,9).*CONSTANTS(:,9).*CONSTANTS(:,8);
    CONSTANTS(:,88) =  CONSTANTS(:,45).*power((CONSTANTS(:,4)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,89) =  CONSTANTS(:,48).*power((CONSTANTS(:,4)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,90) =  CONSTANTS(:,87).*0.0600000;
    CONSTANTS(:,91) =  2.00000.* pi.*CONSTANTS(:,9).*CONSTANTS(:,9)+ 2.00000.* pi.*CONSTANTS(:,9).*CONSTANTS(:,8);
    CONSTANTS(:,92) =  CONSTANTS(:,91).*2.00000;
    CONSTANTS(:,93) = ( 1.00000.*1.00000.*CONSTANTS(:,92))./( CONSTANTS(:,1).*1.00000);
    CONSTANTS(:,94) =  CONSTANTS(:,87).*0.678000;
    CONSTANTS(:,95) =  CONSTANTS(:,87).*0.0552000;
    CONSTANTS(:,96) =  CONSTANTS(:,87).*0.00480000;
    CONSTANTS(:,97) =  CONSTANTS(:,87).*0.0200000;
    CONSTANTS(:,98) =  CONSTANTS(:,87).*0.00200000;
    CONSTANTS(:,99) = CONSTANTS(:,4)./(CONSTANTS(:,4)+CONSTANTS(:,22));
    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);
    else
        statesRowCount = statesSize(1);
        ALGEBRAIC = zeros(statesRowCount, algebraicVariableCount);
        RATES = zeros(statesRowCount, statesColumnCount);
    end
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+91.0000)./6.10000));
    RATES(:,34) = (ALGEBRAIC(:,7) - STATES(:,34))./CONSTANTS(:,43);
    ALGEBRAIC(:,3) = ( 0.320000.*(STATES(:,1)+47.1300))./(1.00000 - exp(  - 0.100000.*(STATES(:,1)+47.1300)));
    ALGEBRAIC(:,15) =  0.0800000.*exp( - STATES(:,1)./11.0000);
    RATES(:,27) =  ALGEBRAIC(:,3).*(1.00000 - STATES(:,27)) -  ALGEBRAIC(:,15).*STATES(:,27);
    ALGEBRAIC(:,4) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.135000.*exp((80.0000+STATES(:,1))./ - 6.80000));
    ALGEBRAIC(:,16) = piecewise({STATES(:,1)>= - 40.0000, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))) },  3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)));
    RATES(:,28) =  ALGEBRAIC(:,4).*(1.00000 - STATES(:,28)) -  ALGEBRAIC(:,16).*STATES(:,28);
    ALGEBRAIC(:,5) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( (  - 127140..*exp( 0.244400.*STATES(:,1)) -  6.94800e-05.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))));
    ALGEBRAIC(:,17) = piecewise({STATES(:,1)>= - 40.0000, ( 0.300000.*exp(  - 2.53500e-07.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.121200.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))));
    RATES(:,29) =  ALGEBRAIC(:,5).*(1.00000 - STATES(:,29)) -  ALGEBRAIC(:,17).*STATES(:,29);
    ALGEBRAIC(:,6) = ( 0.320000.*(STATES(:,1)+47.1300))./(1.00000 - exp(  - 0.100000.*(STATES(:,1)+47.1300)));
    ALGEBRAIC(:,18) =  0.0800000.*exp( - STATES(:,1)./11.0000);
    RATES(:,33) =  ALGEBRAIC(:,6).*(1.00000 - STATES(:,33)) -  ALGEBRAIC(:,18).*STATES(:,33);
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0850)./4.25000));
    ALGEBRAIC(:,19) = 1.00000./(( 0.000600000.*(STATES(:,1) - 1.73840))./(1.00000 - exp(  - 0.136000.*(STATES(:,1) - 1.73840)))+( 0.000300000.*(STATES(:,1)+38.3608))./(exp( 0.152200.*(STATES(:,1)+38.3608)) - 1.00000));
    RATES(:,37) = (ALGEBRAIC(:,8) - STATES(:,37))./ALGEBRAIC(:,19);
    ALGEBRAIC(:,21) = 0.0250000./(1.00000+exp((STATES(:,1)+58.0000)./5.00000));
    ALGEBRAIC(:,10) = 1.00000./( 9.79530.*(1.00000+exp((STATES(:,1)+19.0000)./ - 9.00000)));
    RATES(:,39) =  ALGEBRAIC(:,21).*(1.00000 - STATES(:,39)) -  ALGEBRAIC(:,10).*STATES(:,39);
    ALGEBRAIC(:,22) = 1.00000./( 250.000.*(1.00000+exp((STATES(:,1)+60.0000)./5.00000)));
    ALGEBRAIC(:,11) = 1.00000./( 9.79530.*(1.00000+exp((STATES(:,1)+19.0000)./ - 9.00000)));
    RATES(:,40) =  ALGEBRAIC(:,22).*(1.00000 - STATES(:,40)) -  ALGEBRAIC(:,11).*STATES(:,40);
    ALGEBRAIC(:,23) = 0.0250000./(1.00000+exp((STATES(:,1)+58.0000)./5.00000));
    ALGEBRAIC(:,12) = 1.00000./( 5.00000.*(1.00000+exp((STATES(:,1)+19.0000)./ - 9.00000)));
    ALGEBRAIC(:,27) = ALGEBRAIC(:,23)./(ALGEBRAIC(:,23)+ALGEBRAIC(:,12));
    RATES(:,42) = (ALGEBRAIC(:,27) - STATES(:,42))./CONSTANTS(:,54);
    ALGEBRAIC(:,9) = 1.00000./( 1.20890.*(1.00000+exp((STATES(:,1) - 18.4099)./ - 29.3814)));
    ALGEBRAIC(:,20) = 3.50000./(1.00000+exp((STATES(:,1)+100.000)./29.3814));
    ALGEBRAIC(:,26) = 1.00000./(ALGEBRAIC(:,9)+ALGEBRAIC(:,20));
    ALGEBRAIC(:,30) = 1.00000./(1.00000+exp((STATES(:,1)+9.43700)./ - 7.13300));
    RATES(:,38) = (ALGEBRAIC(:,30) - STATES(:,38))./ALGEBRAIC(:,26);
    ALGEBRAIC(:,32) =  0.0148646.*exp(( 0.0298773.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,35) =  0.0839863.*exp((  - 0.0554611.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    RATES(:,2) =   - 4.00000.*ALGEBRAIC(:,32).*STATES(:,2)+ ALGEBRAIC(:,35).*STATES(:,3);
    ALGEBRAIC(:,40) =  0.00311733.*exp((  - 0.426255.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,38) =  0.0146007.*exp(( 0.244650.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    RATES(:,3) =   - ( 3.00000.*ALGEBRAIC(:,32)+ALGEBRAIC(:,35)+ALGEBRAIC(:,38)).*STATES(:,3)+ 4.00000.*ALGEBRAIC(:,32).*STATES(:,2)+ 2.00000.*ALGEBRAIC(:,35).*STATES(:,4)+ ALGEBRAIC(:,40).*STATES(:,7);
    RATES(:,4) =   - ( 2.00000.*ALGEBRAIC(:,32)+ 2.00000.*ALGEBRAIC(:,35)+ 2.00000.*ALGEBRAIC(:,38)).*STATES(:,4)+ 3.00000.*ALGEBRAIC(:,32).*STATES(:,3)+ 3.00000.*ALGEBRAIC(:,35).*STATES(:,5)+ ALGEBRAIC(:,40).*STATES(:,8);
    RATES(:,5) =   - (ALGEBRAIC(:,32)+ 3.00000.*ALGEBRAIC(:,35)+ 3.00000.*ALGEBRAIC(:,38)).*STATES(:,5)+ 2.00000.*ALGEBRAIC(:,32).*STATES(:,4)+ 4.00000.*ALGEBRAIC(:,35).*STATES(:,6)+ ALGEBRAIC(:,40).*STATES(:,9);
    RATES(:,6) =   - ( 4.00000.*ALGEBRAIC(:,35)+ 4.00000.*ALGEBRAIC(:,38)).*STATES(:,6)+ ALGEBRAIC(:,32).*STATES(:,5)+ ALGEBRAIC(:,40).*STATES(:,10);
    RATES(:,7) =   - ( 3.00000.*ALGEBRAIC(:,32)+ALGEBRAIC(:,40)).*STATES(:,7)+ ALGEBRAIC(:,35).*STATES(:,8)+ ALGEBRAIC(:,38).*STATES(:,3);
    RATES(:,8) =   - ( 2.00000.*ALGEBRAIC(:,32)+ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ALGEBRAIC(:,40)).*STATES(:,8)+ 3.00000.*ALGEBRAIC(:,32).*STATES(:,7)+ 2.00000.*ALGEBRAIC(:,35).*STATES(:,9)+ 2.00000.*ALGEBRAIC(:,38).*STATES(:,4)+ 2.00000.*ALGEBRAIC(:,40).*STATES(:,11);
    RATES(:,9) =   - (ALGEBRAIC(:,32)+ 2.00000.*ALGEBRAIC(:,35)+ 2.00000.*ALGEBRAIC(:,38)+ALGEBRAIC(:,40)).*STATES(:,9)+ 2.00000.*ALGEBRAIC(:,32).*STATES(:,8)+ 3.00000.*ALGEBRAIC(:,35).*STATES(:,10)+ 3.00000.*ALGEBRAIC(:,38).*STATES(:,5)+ 2.00000.*ALGEBRAIC(:,40).*STATES(:,12);
    RATES(:,10) =   - ( 3.00000.*ALGEBRAIC(:,35)+ 3.00000.*ALGEBRAIC(:,38)+ALGEBRAIC(:,40)).*STATES(:,10)+ ALGEBRAIC(:,32).*STATES(:,9)+ 4.00000.*ALGEBRAIC(:,38).*STATES(:,6)+ 2.00000.*ALGEBRAIC(:,40).*STATES(:,13);
    RATES(:,11) =   - ( 2.00000.*ALGEBRAIC(:,32)+ 2.00000.*ALGEBRAIC(:,40)).*STATES(:,11)+ ALGEBRAIC(:,35).*STATES(:,12)+ ALGEBRAIC(:,38).*STATES(:,8);
    RATES(:,12) =   - (ALGEBRAIC(:,32)+ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ 2.00000.*ALGEBRAIC(:,40)).*STATES(:,12)+ 2.00000.*ALGEBRAIC(:,32).*STATES(:,11)+ 2.00000.*ALGEBRAIC(:,35).*STATES(:,13)+ 2.00000.*ALGEBRAIC(:,38).*STATES(:,9)+ 3.00000.*ALGEBRAIC(:,40).*STATES(:,14);
    RATES(:,13) =   - ( 2.00000.*ALGEBRAIC(:,35)+ 2.00000.*ALGEBRAIC(:,38)+ 2.00000.*ALGEBRAIC(:,40)).*STATES(:,13)+ ALGEBRAIC(:,32).*STATES(:,12)+ 3.00000.*ALGEBRAIC(:,38).*STATES(:,10)+ 3.00000.*ALGEBRAIC(:,40).*STATES(:,15);
    RATES(:,14) =   - (ALGEBRAIC(:,32)+ 3.00000.*ALGEBRAIC(:,40)).*STATES(:,14)+ ALGEBRAIC(:,35).*STATES(:,15)+ ALGEBRAIC(:,38).*STATES(:,12);
    RATES(:,15) =   - (ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ 3.00000.*ALGEBRAIC(:,40)).*STATES(:,15)+ ALGEBRAIC(:,32).*STATES(:,14)+ 2.00000.*ALGEBRAIC(:,38).*STATES(:,13)+ 4.00000.*ALGEBRAIC(:,40).*STATES(:,16);
    ALGEBRAIC(:,43) =  0.0773199.*exp((  - 0.0647261.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    RATES(:,16) =   - ( 4.00000.*ALGEBRAIC(:,40)+CONSTANTS(:,86)).*STATES(:,16)+ ALGEBRAIC(:,38).*STATES(:,15)+ ALGEBRAIC(:,43).*STATES(:,17);
    ALGEBRAIC(:,28) = 1.00000 - (STATES(:,2)+STATES(:,3)+STATES(:,4)+STATES(:,5)+STATES(:,6)+STATES(:,7)+STATES(:,8)+STATES(:,9)+STATES(:,10)+STATES(:,11)+STATES(:,12)+STATES(:,13)+STATES(:,14)+STATES(:,15)+STATES(:,16)+STATES(:,17));
    ALGEBRAIC(:,46) =  0.794055.*exp((  - 0.0801738.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,49) =  0.586382.*exp(( 0.282056.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    RATES(:,17) =   - (ALGEBRAIC(:,43)+ALGEBRAIC(:,49)).*STATES(:,17)+ ALGEBRAIC(:,46).*ALGEBRAIC(:,28)+ CONSTANTS(:,86).*STATES(:,16);
    ALGEBRAIC(:,14) = 0.590000+( 0.800000.*exp( 0.0520000.*(STATES(:,1)+13.0000)))./(1.00000+exp( 0.132000.*(STATES(:,1)+13.0000)));
    ALGEBRAIC(:,25) = 1.00000./(1.00000+exp( - (STATES(:,1) - 13.5600)./9.45000));
    ALGEBRAIC(:,29) = ALGEBRAIC(:,25)./ALGEBRAIC(:,14);
    ALGEBRAIC(:,33) = (1.00000 - ALGEBRAIC(:,25))./ALGEBRAIC(:,14);
    ALGEBRAIC(:,60) = 3.00000./(1.00000+power(0.00300000./STATES(:,26), 4.00000));
    ALGEBRAIC(:,39) = 1.00000./(1.00000./( 24.8280.*(1.00000+exp((STATES(:,1)+49.1000)./10.3490)))+1.00000./( 30.5530.*(1.00000+exp( - (STATES(:,1)+0.213000)./10.8070))));
    ALGEBRAIC(:,36) = (1.00000./(1.00000+exp((STATES(:,1)+17.5000)./3.00000))+0.250000)./1.25000;
    ALGEBRAIC(:,41) = ALGEBRAIC(:,36)./ALGEBRAIC(:,39);
    ALGEBRAIC(:,44) = (1.00000 - ALGEBRAIC(:,36))./ALGEBRAIC(:,39);
    RATES(:,19) =   - (ALGEBRAIC(:,29)+ALGEBRAIC(:,60)+ALGEBRAIC(:,44)).*STATES(:,19)+ ALGEBRAIC(:,33).*STATES(:,20)+ CONSTANTS(:,16).*STATES(:,21)+ ALGEBRAIC(:,41).*STATES(:,23);
    RATES(:,20) =   - (ALGEBRAIC(:,33)+ALGEBRAIC(:,60)+ALGEBRAIC(:,44)).*STATES(:,20)+ ALGEBRAIC(:,29).*STATES(:,19)+ CONSTANTS(:,16).*STATES(:,22)+ ALGEBRAIC(:,41).*STATES(:,24);
    ALGEBRAIC(:,50) = 25.0000 - 17.5000./(1.00000+power(0.00300000./STATES(:,26), 4.00000));
    ALGEBRAIC(:,52) = 1.00000./( ALGEBRAIC(:,50).*(1.00000+exp( - (STATES(:,1)+0.213000)./10.8070)));
    ALGEBRAIC(:,54) = 1.00000./(1.00000./( 24.8280.*(1.00000+exp((STATES(:,1)+49.1000)./10.3490)))+ALGEBRAIC(:,52));
    ALGEBRAIC(:,47) = (1.00000./(1.00000+exp((STATES(:,1)+17.5000)./3.00000))+0.000100000)./1.00010;
    ALGEBRAIC(:,56) = ALGEBRAIC(:,47)./ALGEBRAIC(:,54);
    ALGEBRAIC(:,58) = (1.00000 - ALGEBRAIC(:,47))./ALGEBRAIC(:,54);
    RATES(:,21) =   - (ALGEBRAIC(:,29)+CONSTANTS(:,16)+ALGEBRAIC(:,58)).*STATES(:,21)+ ALGEBRAIC(:,60).*STATES(:,19)+ ALGEBRAIC(:,33).*STATES(:,22)+ ALGEBRAIC(:,56).*STATES(:,25);
    ALGEBRAIC(:,2) = 1.00000 - (STATES(:,19)+STATES(:,20)+STATES(:,21)+STATES(:,22)+STATES(:,23)+STATES(:,24)+STATES(:,25));
    RATES(:,22) =   - (ALGEBRAIC(:,33)+CONSTANTS(:,16)+ALGEBRAIC(:,58)).*STATES(:,22)+ ALGEBRAIC(:,60).*STATES(:,20)+ ALGEBRAIC(:,29).*STATES(:,21)+ ALGEBRAIC(:,56).*ALGEBRAIC(:,2);
    ALGEBRAIC(:,62) = ( CONSTANTS(:,17).*ALGEBRAIC(:,41).*ALGEBRAIC(:,58).*ALGEBRAIC(:,60))./( ALGEBRAIC(:,44).*ALGEBRAIC(:,56).*CONSTANTS(:,16));
    RATES(:,23) =   - (ALGEBRAIC(:,29)+ALGEBRAIC(:,62)+ALGEBRAIC(:,41)).*STATES(:,23)+ ALGEBRAIC(:,44).*STATES(:,19)+ CONSTANTS(:,17).*STATES(:,25)+ ALGEBRAIC(:,33).*STATES(:,24);
    RATES(:,24) =   - (ALGEBRAIC(:,33)+ALGEBRAIC(:,62)+ALGEBRAIC(:,41)).*STATES(:,24)+ ALGEBRAIC(:,44).*STATES(:,20)+ CONSTANTS(:,17).*ALGEBRAIC(:,2)+ ALGEBRAIC(:,29).*STATES(:,23);
    RATES(:,25) =   - (ALGEBRAIC(:,29)+CONSTANTS(:,17)+ALGEBRAIC(:,56)).*STATES(:,25)+ ALGEBRAIC(:,62).*STATES(:,23)+ ALGEBRAIC(:,58).*STATES(:,21)+ ALGEBRAIC(:,33).*ALGEBRAIC(:,2);
    ALGEBRAIC(:,77) = (STATES(:,44) - STATES(:,43))./CONSTANTS(:,69);
    ALGEBRAIC(:,80) = 1.00000./(1.00000+( CONSTANTS(:,76).*CONSTANTS(:,77))./power(STATES(:,43)+CONSTANTS(:,76), 2.00000));
    RATES(:,43) =  ALGEBRAIC(:,80).*(ALGEBRAIC(:,77) - STATES(:,41));
    ALGEBRAIC(:,63) =  0.200000.*CONSTANTS(:,27).*( power(STATES(:,32), 3.00000).*CONSTANTS(:,5).*exp(( CONSTANTS(:,29).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  power(CONSTANTS(:,6), 3.00000).*STATES(:,31).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))));
    ALGEBRAIC(:,64) = 1.00000+power(CONSTANTS(:,26)./STATES(:,31), 2.00000);
    ALGEBRAIC(:,65) = 1.00000+ CONSTANTS(:,28).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,66) =  CONSTANTS(:,33).*power(STATES(:,32), 3.00000)+ power(CONSTANTS(:,31), 3.00000).*STATES(:,31)+ power(CONSTANTS(:,30), 3.00000).*CONSTANTS(:,5).*(1.00000+STATES(:,31)./CONSTANTS(:,32));
    ALGEBRAIC(:,67) =  CONSTANTS(:,32).*power(CONSTANTS(:,6), 3.00000).*(1.00000+power(STATES(:,32)./CONSTANTS(:,30), 3.00000))+ power(STATES(:,32), 3.00000).*CONSTANTS(:,5)+ power(CONSTANTS(:,6), 3.00000).*STATES(:,31);
    ALGEBRAIC(:,68) = ALGEBRAIC(:,63)./( ALGEBRAIC(:,64).*ALGEBRAIC(:,65).*(ALGEBRAIC(:,66)+ALGEBRAIC(:,67)));
    ALGEBRAIC(:,79) = (STATES(:,31) - STATES(:,18))./CONSTANTS(:,70);
    ALGEBRAIC(:,83) = (STATES(:,31) - STATES(:,26))./CONSTANTS(:,71);
    ALGEBRAIC(:,86) = 1.00000./(1.00000+( CONSTANTS(:,78).*CONSTANTS(:,79))./power(CONSTANTS(:,79)+STATES(:,31), 2.00000)+( CONSTANTS(:,80).*CONSTANTS(:,81))./power(CONSTANTS(:,81)+STATES(:,31), 2.00000));
    RATES(:,31) =   - ALGEBRAIC(:,86).*((ALGEBRAIC(:,79)+ALGEBRAIC(:,83)) - (( 2.00000.*ALGEBRAIC(:,68).*CONSTANTS(:,93))./( 2.00000.*CONSTANTS(:,97))+( STATES(:,41).*CONSTANTS(:,96))./CONSTANTS(:,97)));
    ALGEBRAIC(:,34) = ( (( CONSTANTS(:,15).*4.00000.*STATES(:,1).*power(CONSTANTS(:,1), 2.00000))./( CONSTANTS(:,3).*CONSTANTS(:,2))).*( CONSTANTS(:,18).*STATES(:,26).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  CONSTANTS(:,19).*CONSTANTS(:,5)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,37) =  ALGEBRAIC(:,34).*(STATES(:,20)+STATES(:,22));
    ALGEBRAIC(:,87) = 1.00000./(1.00000+( CONSTANTS(:,78).*CONSTANTS(:,79))./power(CONSTANTS(:,79)+STATES(:,26), 2.00000)+( CONSTANTS(:,80).*CONSTANTS(:,81))./power(CONSTANTS(:,81)+STATES(:,26), 2.00000));
    RATES(:,26) =   - ALGEBRAIC(:,87).*(( ALGEBRAIC(:,37).*CONSTANTS(:,93))./( 2.00000.*CONSTANTS(:,98)) - ( ALGEBRAIC(:,83).*CONSTANTS(:,97))./CONSTANTS(:,98));
    ALGEBRAIC(:,85) = ( CONSTANTS(:,85).*(1.00000 - STATES(:,46)))./(1.00000+CONSTANTS(:,82)./STATES(:,31))+STATES(:,46);
    RATES(:,46) =  CONSTANTS(:,83).*ALGEBRAIC(:,85).*(ALGEBRAIC(:,85) - STATES(:,46)) -  CONSTANTS(:,84).*STATES(:,46);
    ALGEBRAIC(:,72) = ( CONSTANTS(:,35).*STATES(:,18))./(CONSTANTS(:,36)+STATES(:,18));
    ALGEBRAIC(:,73) = ( (( CONSTANTS(:,37).*4.00000.*STATES(:,1).*power(CONSTANTS(:,1), 2.00000))./( CONSTANTS(:,3).*CONSTANTS(:,2))).*( CONSTANTS(:,38).*STATES(:,18).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  CONSTANTS(:,39).*CONSTANTS(:,5)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,53) =  0.800000.*CONSTANTS(:,27).*( power(STATES(:,30), 3.00000).*CONSTANTS(:,5).*exp(( CONSTANTS(:,29).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  power(CONSTANTS(:,6), 3.00000).*STATES(:,18).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))));
    ALGEBRAIC(:,55) = 1.00000+power(CONSTANTS(:,26)./STATES(:,18), 2.00000);
    ALGEBRAIC(:,57) = 1.00000+ CONSTANTS(:,28).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,59) =  CONSTANTS(:,33).*power(STATES(:,30), 3.00000)+ power(CONSTANTS(:,31), 3.00000).*STATES(:,18)+ power(CONSTANTS(:,30), 3.00000).*CONSTANTS(:,5).*(1.00000+STATES(:,18)./CONSTANTS(:,32));
    ALGEBRAIC(:,61) =  CONSTANTS(:,32).*power(CONSTANTS(:,6), 3.00000).*(1.00000+power(STATES(:,30)./CONSTANTS(:,30), 3.00000))+ power(STATES(:,30), 3.00000).*CONSTANTS(:,5)+ power(CONSTANTS(:,6), 3.00000).*STATES(:,18);
    ALGEBRAIC(:,69) = ALGEBRAIC(:,53)./( ALGEBRAIC(:,55).*ALGEBRAIC(:,57).*(ALGEBRAIC(:,59)+ALGEBRAIC(:,61)));
    ALGEBRAIC(:,70) = ALGEBRAIC(:,69)+ALGEBRAIC(:,68);
    ALGEBRAIC(:,93) = ( CONSTANTS(:,64).*ALGEBRAIC(:,85).*1.00000)./(CONSTANTS(:,67)+ ALGEBRAIC(:,85).*1.00000);
    ALGEBRAIC(:,90) = ( CONSTANTS(:,66).*ALGEBRAIC(:,85).*1.00000)./(CONSTANTS(:,67)+ ALGEBRAIC(:,85).*1.00000);
    ALGEBRAIC(:,96) = ( (ALGEBRAIC(:,90)+1.00000).*CONSTANTS(:,65).*STATES(:,18))./((STATES(:,18)+CONSTANTS(:,63)) - ALGEBRAIC(:,93));
    ALGEBRAIC(:,75) =  (0.00437500./CONSTANTS(:,68)).*STATES(:,44);
    ALGEBRAIC(:,82) = 1.00000./(1.00000+( CONSTANTS(:,72).*CONSTANTS(:,74))./power(STATES(:,18)+CONSTANTS(:,74), 2.00000)+( CONSTANTS(:,75).*CONSTANTS(:,73))./power(STATES(:,18)+CONSTANTS(:,75), 2.00000));
    RATES(:,18) =  ALGEBRAIC(:,82).*((  - ((ALGEBRAIC(:,73)+ALGEBRAIC(:,72)) -  2.00000.*ALGEBRAIC(:,70)).*CONSTANTS(:,93))./( CONSTANTS(:,94).*2.00000)+( (ALGEBRAIC(:,75) - ALGEBRAIC(:,96)).*CONSTANTS(:,95))./CONSTANTS(:,94)+( ALGEBRAIC(:,79).*CONSTANTS(:,97))./CONSTANTS(:,94));
    RATES(:,44) = ALGEBRAIC(:,96) - (ALGEBRAIC(:,75)+( ALGEBRAIC(:,77).*CONSTANTS(:,96))./CONSTANTS(:,95));
    ALGEBRAIC(:,89) = CONSTANTS(:,60)./(1.00000+power(CONSTANTS(:,61)./( 1.00000.*ALGEBRAIC(:,85)), CONSTANTS(:,59)));
    ALGEBRAIC(:,92) =  CONSTANTS(:,56).*(1.00000+ALGEBRAIC(:,89));
    ALGEBRAIC(:,95) =  ALGEBRAIC(:,92).*CONSTANTS(:,57);
    ALGEBRAIC(:,100) = ( ALGEBRAIC(:,37).*ALGEBRAIC(:,95))./(1.00000+power(CONSTANTS(:,55)./STATES(:,43), CONSTANTS(:,58)));
    ALGEBRAIC(:,98) = ALGEBRAIC(:,92)./(1.00000+CONSTANTS(:,62)./STATES(:,43));
    RATES(:,41) =  - (ALGEBRAIC(:,100)+STATES(:,41))./ALGEBRAIC(:,98);
    ALGEBRAIC(:,81) =  (( CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log(CONSTANTS(:,6)./STATES(:,30));
    ALGEBRAIC(:,84) =  CONSTANTS(:,20).*power(STATES(:,27), 3.00000).*STATES(:,28).*STATES(:,29).*(STATES(:,1) - ALGEBRAIC(:,81));
    ALGEBRAIC(:,42) = ( CONSTANTS(:,24).*(STATES(:,1) - CONSTANTS(:,25)).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2));
    ALGEBRAIC(:,45) = 1.00000./(1.00000+exp( - ALGEBRAIC(:,42)));
    ALGEBRAIC(:,48) = power(STATES(:,30)./(STATES(:,30)+CONSTANTS(:,21)), 3.00000);
    ALGEBRAIC(:,51) =  CONSTANTS(:,23).*ALGEBRAIC(:,45).*CONSTANTS(:,99).*ALGEBRAIC(:,48);
    ALGEBRAIC(:,88) =  CONSTANTS(:,42).*power(STATES(:,33), 3.00000).*STATES(:,34).*(STATES(:,1) - ALGEBRAIC(:,81));
    ALGEBRAIC(:,76) = ( CONSTANTS(:,1).*STATES(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2));
    ALGEBRAIC(:,78) = ( CONSTANTS(:,1).*CONSTANTS(:,40).*ALGEBRAIC(:,76).*( STATES(:,30).*exp(ALGEBRAIC(:,76)) - CONSTANTS(:,6)))./(exp(ALGEBRAIC(:,76)) - 1.00000);
    ALGEBRAIC(:,102) =  ((  - CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log(CONSTANTS(:,7)./STATES(:,36));
    ALGEBRAIC(:,108) = ( CONSTANTS(:,46).*power(ALGEBRAIC(:,81) - ALGEBRAIC(:,102), 4.00000))./(power(ALGEBRAIC(:,81) - ALGEBRAIC(:,102), 4.00000)+power(87.8251, 4.00000));
    ALGEBRAIC(:,110) = (STATES(:,32) - STATES(:,30))./CONSTANTS(:,70);
    RATES(:,30) =  - (( ( 3.00000.*ALGEBRAIC(:,70)+ 3.00000.*ALGEBRAIC(:,51)+ALGEBRAIC(:,84)+ALGEBRAIC(:,88)+ALGEBRAIC(:,78)).*CONSTANTS(:,93))./CONSTANTS(:,94) - (ALGEBRAIC(:,108)+( ALGEBRAIC(:,110).*CONSTANTS(:,97))./CONSTANTS(:,94)));
    RATES(:,32) =  - (( 3.00000.*ALGEBRAIC(:,68).*CONSTANTS(:,93))./CONSTANTS(:,97)+ALGEBRAIC(:,110));
    ALGEBRAIC(:,1) =  floor(VOI./CONSTANTS(:,11)).*CONSTANTS(:,11);
    ALGEBRAIC(:,13) = piecewise({VOI - ALGEBRAIC(:,1)>=CONSTANTS(:,10)&VOI - ALGEBRAIC(:,1)<=CONSTANTS(:,10)+CONSTANTS(:,12), CONSTANTS(:,13) }, 0.00000);
    ALGEBRAIC(:,94) =  (( CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log(CONSTANTS(:,4)./STATES(:,35));
    ALGEBRAIC(:,104) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,94)) - 59.2150)));
    ALGEBRAIC(:,105) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1) - ALGEBRAIC(:,94))+5.47600))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,94)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,94))+4.75300)));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,104)./(ALGEBRAIC(:,104)+ALGEBRAIC(:,105));
    ALGEBRAIC(:,107) =  CONSTANTS(:,88).*ALGEBRAIC(:,106).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,71) = 1.00000./(1.00000+exp((7.48800 - STATES(:,1))./5.98000));
    ALGEBRAIC(:,97) =  CONSTANTS(:,34).*ALGEBRAIC(:,71).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,24) =  CONSTANTS(:,14).*(1.00000+0.600000./(1.00000+power(3.80000e-05./STATES(:,18), 1.40000)));
    ALGEBRAIC(:,31) = STATES(:,17)+ALGEBRAIC(:,28);
    ALGEBRAIC(:,99) =  (( CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log((CONSTANTS(:,4)+ CONSTANTS(:,44).*CONSTANTS(:,6))./(STATES(:,35)+ CONSTANTS(:,44).*STATES(:,30)));
    ALGEBRAIC(:,101) =  ALGEBRAIC(:,24).*ALGEBRAIC(:,31).*(STATES(:,1) - ALGEBRAIC(:,99));
    ALGEBRAIC(:,111) = 1.00000./(1.00000+exp((STATES(:,1)+10.0000)./15.4000));
    ALGEBRAIC(:,112) =  CONSTANTS(:,89).*STATES(:,37).*ALGEBRAIC(:,111).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,113) = exp(STATES(:,1)./550.000);
    ALGEBRAIC(:,114) =  CONSTANTS(:,49).*power(STATES(:,38), 3.00000).*STATES(:,39).*STATES(:,40).*ALGEBRAIC(:,113).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,109) = ( CONSTANTS(:,47).*(ALGEBRAIC(:,94) - ALGEBRAIC(:,102)))./((ALGEBRAIC(:,94)+87.8251) - ALGEBRAIC(:,102));
    RATES(:,35) =  - (( ((ALGEBRAIC(:,101)+ALGEBRAIC(:,112)+ALGEBRAIC(:,107)+ALGEBRAIC(:,114)+ALGEBRAIC(:,97)+ALGEBRAIC(:,13)) -  2.00000.*ALGEBRAIC(:,51)).*CONSTANTS(:,93))./CONSTANTS(:,94) - ALGEBRAIC(:,109));
    ALGEBRAIC(:,74) = (ALGEBRAIC(:,37)+ALGEBRAIC(:,73)+ALGEBRAIC(:,72)) -  2.00000.*(ALGEBRAIC(:,70)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,91) = ALGEBRAIC(:,84)+ 3.00000.*(ALGEBRAIC(:,70)+ALGEBRAIC(:,68))+ 3.00000.*ALGEBRAIC(:,51)+ALGEBRAIC(:,88)+ALGEBRAIC(:,78);
    ALGEBRAIC(:,115) = ALGEBRAIC(:,112)+ALGEBRAIC(:,101)+ALGEBRAIC(:,107)+ALGEBRAIC(:,97)+  - 2.00000.*ALGEBRAIC(:,51)+ALGEBRAIC(:,114)+ALGEBRAIC(:,13);
    ALGEBRAIC(:,116) = ( (( CONSTANTS(:,50).*power(CONSTANTS(:,51), 2.00000).*STATES(:,1).*power(CONSTANTS(:,1), 2.00000))./( CONSTANTS(:,3).*CONSTANTS(:,2))).*(STATES(:,36) -  CONSTANTS(:,7).*exp(( STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)))))./(1.00000 - exp(( STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))));
    ALGEBRAIC(:,117) = 1.00000 - 1.00000./(1.00000+power(STATES(:,41)./CONSTANTS(:,53), 2.00000));
    ALGEBRAIC(:,118) =  ALGEBRAIC(:,116).*CONSTANTS(:,52).*STATES(:,42).*ALGEBRAIC(:,117);
    ALGEBRAIC(:,103) =  CONSTANTS(:,41).*(STATES(:,1) - ALGEBRAIC(:,102));
    ALGEBRAIC(:,119) = ALGEBRAIC(:,103)+ALGEBRAIC(:,118);
    RATES(:,1) =  - (ALGEBRAIC(:,91)+ALGEBRAIC(:,115)+ALGEBRAIC(:,74)+ALGEBRAIC(:,119));
    ALGEBRAIC(:,120) = (STATES(:,45) - STATES(:,36))./CONSTANTS(:,70);
    RATES(:,36) =  - (( ALGEBRAIC(:,103).*CONSTANTS(:,93))./(  - 1.00000.*CONSTANTS(:,94)) - (ALGEBRAIC(:,108)+ALGEBRAIC(:,109)+( ALGEBRAIC(:,120).*CONSTANTS(:,97))./CONSTANTS(:,94)));
    RATES(:,45) =  - (( ALGEBRAIC(:,118).*CONSTANTS(:,93))./(  - 1.00000.*CONSTANTS(:,97))+ALGEBRAIC(:,120));
   RATES = RATES';
end

% Calculate algebraic variables
function ALGEBRAIC = computeAlgebraic(ALGEBRAIC, CONSTANTS, STATES, VOI)
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+91.0000)./6.10000));
    ALGEBRAIC(:,3) = ( 0.320000.*(STATES(:,1)+47.1300))./(1.00000 - exp(  - 0.100000.*(STATES(:,1)+47.1300)));
    ALGEBRAIC(:,15) =  0.0800000.*exp( - STATES(:,1)./11.0000);
    ALGEBRAIC(:,4) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.135000.*exp((80.0000+STATES(:,1))./ - 6.80000));
    ALGEBRAIC(:,16) = piecewise({STATES(:,1)>= - 40.0000, 1.00000./( 0.130000.*(1.00000+exp((STATES(:,1)+10.6600)./ - 11.1000))) },  3.56000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.350000.*STATES(:,1)));
    ALGEBRAIC(:,5) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( (  - 127140..*exp( 0.244400.*STATES(:,1)) -  6.94800e-05.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))));
    ALGEBRAIC(:,17) = piecewise({STATES(:,1)>= - 40.0000, ( 0.300000.*exp(  - 2.53500e-07.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.121200.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))));
    ALGEBRAIC(:,6) = ( 0.320000.*(STATES(:,1)+47.1300))./(1.00000 - exp(  - 0.100000.*(STATES(:,1)+47.1300)));
    ALGEBRAIC(:,18) =  0.0800000.*exp( - STATES(:,1)./11.0000);
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0850)./4.25000));
    ALGEBRAIC(:,19) = 1.00000./(( 0.000600000.*(STATES(:,1) - 1.73840))./(1.00000 - exp(  - 0.136000.*(STATES(:,1) - 1.73840)))+( 0.000300000.*(STATES(:,1)+38.3608))./(exp( 0.152200.*(STATES(:,1)+38.3608)) - 1.00000));
    ALGEBRAIC(:,21) = 0.0250000./(1.00000+exp((STATES(:,1)+58.0000)./5.00000));
    ALGEBRAIC(:,10) = 1.00000./( 9.79530.*(1.00000+exp((STATES(:,1)+19.0000)./ - 9.00000)));
    ALGEBRAIC(:,22) = 1.00000./( 250.000.*(1.00000+exp((STATES(:,1)+60.0000)./5.00000)));
    ALGEBRAIC(:,11) = 1.00000./( 9.79530.*(1.00000+exp((STATES(:,1)+19.0000)./ - 9.00000)));
    ALGEBRAIC(:,23) = 0.0250000./(1.00000+exp((STATES(:,1)+58.0000)./5.00000));
    ALGEBRAIC(:,12) = 1.00000./( 5.00000.*(1.00000+exp((STATES(:,1)+19.0000)./ - 9.00000)));
    ALGEBRAIC(:,27) = ALGEBRAIC(:,23)./(ALGEBRAIC(:,23)+ALGEBRAIC(:,12));
    ALGEBRAIC(:,9) = 1.00000./( 1.20890.*(1.00000+exp((STATES(:,1) - 18.4099)./ - 29.3814)));
    ALGEBRAIC(:,20) = 3.50000./(1.00000+exp((STATES(:,1)+100.000)./29.3814));
    ALGEBRAIC(:,26) = 1.00000./(ALGEBRAIC(:,9)+ALGEBRAIC(:,20));
    ALGEBRAIC(:,30) = 1.00000./(1.00000+exp((STATES(:,1)+9.43700)./ - 7.13300));
    ALGEBRAIC(:,32) =  0.0148646.*exp(( 0.0298773.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,35) =  0.0839863.*exp((  - 0.0554611.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,40) =  0.00311733.*exp((  - 0.426255.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,38) =  0.0146007.*exp(( 0.244650.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,43) =  0.0773199.*exp((  - 0.0647261.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,28) = 1.00000 - (STATES(:,2)+STATES(:,3)+STATES(:,4)+STATES(:,5)+STATES(:,6)+STATES(:,7)+STATES(:,8)+STATES(:,9)+STATES(:,10)+STATES(:,11)+STATES(:,12)+STATES(:,13)+STATES(:,14)+STATES(:,15)+STATES(:,16)+STATES(:,17));
    ALGEBRAIC(:,46) =  0.794055.*exp((  - 0.0801738.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,49) =  0.586382.*exp(( 0.282056.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,14) = 0.590000+( 0.800000.*exp( 0.0520000.*(STATES(:,1)+13.0000)))./(1.00000+exp( 0.132000.*(STATES(:,1)+13.0000)));
    ALGEBRAIC(:,25) = 1.00000./(1.00000+exp( - (STATES(:,1) - 13.5600)./9.45000));
    ALGEBRAIC(:,29) = ALGEBRAIC(:,25)./ALGEBRAIC(:,14);
    ALGEBRAIC(:,33) = (1.00000 - ALGEBRAIC(:,25))./ALGEBRAIC(:,14);
    ALGEBRAIC(:,60) = 3.00000./(1.00000+power(0.00300000./STATES(:,26), 4.00000));
    ALGEBRAIC(:,39) = 1.00000./(1.00000./( 24.8280.*(1.00000+exp((STATES(:,1)+49.1000)./10.3490)))+1.00000./( 30.5530.*(1.00000+exp( - (STATES(:,1)+0.213000)./10.8070))));
    ALGEBRAIC(:,36) = (1.00000./(1.00000+exp((STATES(:,1)+17.5000)./3.00000))+0.250000)./1.25000;
    ALGEBRAIC(:,41) = ALGEBRAIC(:,36)./ALGEBRAIC(:,39);
    ALGEBRAIC(:,44) = (1.00000 - ALGEBRAIC(:,36))./ALGEBRAIC(:,39);
    ALGEBRAIC(:,50) = 25.0000 - 17.5000./(1.00000+power(0.00300000./STATES(:,26), 4.00000));
    ALGEBRAIC(:,52) = 1.00000./( ALGEBRAIC(:,50).*(1.00000+exp( - (STATES(:,1)+0.213000)./10.8070)));
    ALGEBRAIC(:,54) = 1.00000./(1.00000./( 24.8280.*(1.00000+exp((STATES(:,1)+49.1000)./10.3490)))+ALGEBRAIC(:,52));
    ALGEBRAIC(:,47) = (1.00000./(1.00000+exp((STATES(:,1)+17.5000)./3.00000))+0.000100000)./1.00010;
    ALGEBRAIC(:,56) = ALGEBRAIC(:,47)./ALGEBRAIC(:,54);
    ALGEBRAIC(:,58) = (1.00000 - ALGEBRAIC(:,47))./ALGEBRAIC(:,54);
    ALGEBRAIC(:,2) = 1.00000 - (STATES(:,19)+STATES(:,20)+STATES(:,21)+STATES(:,22)+STATES(:,23)+STATES(:,24)+STATES(:,25));
    ALGEBRAIC(:,62) = ( CONSTANTS(:,17).*ALGEBRAIC(:,41).*ALGEBRAIC(:,58).*ALGEBRAIC(:,60))./( ALGEBRAIC(:,44).*ALGEBRAIC(:,56).*CONSTANTS(:,16));
    ALGEBRAIC(:,77) = (STATES(:,44) - STATES(:,43))./CONSTANTS(:,69);
    ALGEBRAIC(:,80) = 1.00000./(1.00000+( CONSTANTS(:,76).*CONSTANTS(:,77))./power(STATES(:,43)+CONSTANTS(:,76), 2.00000));
    ALGEBRAIC(:,63) =  0.200000.*CONSTANTS(:,27).*( power(STATES(:,32), 3.00000).*CONSTANTS(:,5).*exp(( CONSTANTS(:,29).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  power(CONSTANTS(:,6), 3.00000).*STATES(:,31).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))));
    ALGEBRAIC(:,64) = 1.00000+power(CONSTANTS(:,26)./STATES(:,31), 2.00000);
    ALGEBRAIC(:,65) = 1.00000+ CONSTANTS(:,28).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,66) =  CONSTANTS(:,33).*power(STATES(:,32), 3.00000)+ power(CONSTANTS(:,31), 3.00000).*STATES(:,31)+ power(CONSTANTS(:,30), 3.00000).*CONSTANTS(:,5).*(1.00000+STATES(:,31)./CONSTANTS(:,32));
    ALGEBRAIC(:,67) =  CONSTANTS(:,32).*power(CONSTANTS(:,6), 3.00000).*(1.00000+power(STATES(:,32)./CONSTANTS(:,30), 3.00000))+ power(STATES(:,32), 3.00000).*CONSTANTS(:,5)+ power(CONSTANTS(:,6), 3.00000).*STATES(:,31);
    ALGEBRAIC(:,68) = ALGEBRAIC(:,63)./( ALGEBRAIC(:,64).*ALGEBRAIC(:,65).*(ALGEBRAIC(:,66)+ALGEBRAIC(:,67)));
    ALGEBRAIC(:,79) = (STATES(:,31) - STATES(:,18))./CONSTANTS(:,70);
    ALGEBRAIC(:,83) = (STATES(:,31) - STATES(:,26))./CONSTANTS(:,71);
    ALGEBRAIC(:,86) = 1.00000./(1.00000+( CONSTANTS(:,78).*CONSTANTS(:,79))./power(CONSTANTS(:,79)+STATES(:,31), 2.00000)+( CONSTANTS(:,80).*CONSTANTS(:,81))./power(CONSTANTS(:,81)+STATES(:,31), 2.00000));
    ALGEBRAIC(:,34) = ( (( CONSTANTS(:,15).*4.00000.*STATES(:,1).*power(CONSTANTS(:,1), 2.00000))./( CONSTANTS(:,3).*CONSTANTS(:,2))).*( CONSTANTS(:,18).*STATES(:,26).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  CONSTANTS(:,19).*CONSTANTS(:,5)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,37) =  ALGEBRAIC(:,34).*(STATES(:,20)+STATES(:,22));
    ALGEBRAIC(:,87) = 1.00000./(1.00000+( CONSTANTS(:,78).*CONSTANTS(:,79))./power(CONSTANTS(:,79)+STATES(:,26), 2.00000)+( CONSTANTS(:,80).*CONSTANTS(:,81))./power(CONSTANTS(:,81)+STATES(:,26), 2.00000));
    ALGEBRAIC(:,85) = ( CONSTANTS(:,85).*(1.00000 - STATES(:,46)))./(1.00000+CONSTANTS(:,82)./STATES(:,31))+STATES(:,46);
    ALGEBRAIC(:,72) = ( CONSTANTS(:,35).*STATES(:,18))./(CONSTANTS(:,36)+STATES(:,18));
    ALGEBRAIC(:,73) = ( (( CONSTANTS(:,37).*4.00000.*STATES(:,1).*power(CONSTANTS(:,1), 2.00000))./( CONSTANTS(:,3).*CONSTANTS(:,2))).*( CONSTANTS(:,38).*STATES(:,18).*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  CONSTANTS(:,39).*CONSTANTS(:,5)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,53) =  0.800000.*CONSTANTS(:,27).*( power(STATES(:,30), 3.00000).*CONSTANTS(:,5).*exp(( CONSTANTS(:,29).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))) -  power(CONSTANTS(:,6), 3.00000).*STATES(:,18).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))));
    ALGEBRAIC(:,55) = 1.00000+power(CONSTANTS(:,26)./STATES(:,18), 2.00000);
    ALGEBRAIC(:,57) = 1.00000+ CONSTANTS(:,28).*exp(( (CONSTANTS(:,29) - 1.00000).*STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)));
    ALGEBRAIC(:,59) =  CONSTANTS(:,33).*power(STATES(:,30), 3.00000)+ power(CONSTANTS(:,31), 3.00000).*STATES(:,18)+ power(CONSTANTS(:,30), 3.00000).*CONSTANTS(:,5).*(1.00000+STATES(:,18)./CONSTANTS(:,32));
    ALGEBRAIC(:,61) =  CONSTANTS(:,32).*power(CONSTANTS(:,6), 3.00000).*(1.00000+power(STATES(:,30)./CONSTANTS(:,30), 3.00000))+ power(STATES(:,30), 3.00000).*CONSTANTS(:,5)+ power(CONSTANTS(:,6), 3.00000).*STATES(:,18);
    ALGEBRAIC(:,69) = ALGEBRAIC(:,53)./( ALGEBRAIC(:,55).*ALGEBRAIC(:,57).*(ALGEBRAIC(:,59)+ALGEBRAIC(:,61)));
    ALGEBRAIC(:,70) = ALGEBRAIC(:,69)+ALGEBRAIC(:,68);
    ALGEBRAIC(:,93) = ( CONSTANTS(:,64).*ALGEBRAIC(:,85).*1.00000)./(CONSTANTS(:,67)+ ALGEBRAIC(:,85).*1.00000);
    ALGEBRAIC(:,90) = ( CONSTANTS(:,66).*ALGEBRAIC(:,85).*1.00000)./(CONSTANTS(:,67)+ ALGEBRAIC(:,85).*1.00000);
    ALGEBRAIC(:,96) = ( (ALGEBRAIC(:,90)+1.00000).*CONSTANTS(:,65).*STATES(:,18))./((STATES(:,18)+CONSTANTS(:,63)) - ALGEBRAIC(:,93));
    ALGEBRAIC(:,75) =  (0.00437500./CONSTANTS(:,68)).*STATES(:,44);
    ALGEBRAIC(:,82) = 1.00000./(1.00000+( CONSTANTS(:,72).*CONSTANTS(:,74))./power(STATES(:,18)+CONSTANTS(:,74), 2.00000)+( CONSTANTS(:,75).*CONSTANTS(:,73))./power(STATES(:,18)+CONSTANTS(:,75), 2.00000));
    ALGEBRAIC(:,89) = CONSTANTS(:,60)./(1.00000+power(CONSTANTS(:,61)./( 1.00000.*ALGEBRAIC(:,85)), CONSTANTS(:,59)));
    ALGEBRAIC(:,92) =  CONSTANTS(:,56).*(1.00000+ALGEBRAIC(:,89));
    ALGEBRAIC(:,95) =  ALGEBRAIC(:,92).*CONSTANTS(:,57);
    ALGEBRAIC(:,100) = ( ALGEBRAIC(:,37).*ALGEBRAIC(:,95))./(1.00000+power(CONSTANTS(:,55)./STATES(:,43), CONSTANTS(:,58)));
    ALGEBRAIC(:,98) = ALGEBRAIC(:,92)./(1.00000+CONSTANTS(:,62)./STATES(:,43));
    ALGEBRAIC(:,81) =  (( CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log(CONSTANTS(:,6)./STATES(:,30));
    ALGEBRAIC(:,84) =  CONSTANTS(:,20).*power(STATES(:,27), 3.00000).*STATES(:,28).*STATES(:,29).*(STATES(:,1) - ALGEBRAIC(:,81));
    ALGEBRAIC(:,42) = ( CONSTANTS(:,24).*(STATES(:,1) - CONSTANTS(:,25)).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2));
    ALGEBRAIC(:,45) = 1.00000./(1.00000+exp( - ALGEBRAIC(:,42)));
    ALGEBRAIC(:,48) = power(STATES(:,30)./(STATES(:,30)+CONSTANTS(:,21)), 3.00000);
    ALGEBRAIC(:,51) =  CONSTANTS(:,23).*ALGEBRAIC(:,45).*CONSTANTS(:,99).*ALGEBRAIC(:,48);
    ALGEBRAIC(:,88) =  CONSTANTS(:,42).*power(STATES(:,33), 3.00000).*STATES(:,34).*(STATES(:,1) - ALGEBRAIC(:,81));
    ALGEBRAIC(:,76) = ( CONSTANTS(:,1).*STATES(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2));
    ALGEBRAIC(:,78) = ( CONSTANTS(:,1).*CONSTANTS(:,40).*ALGEBRAIC(:,76).*( STATES(:,30).*exp(ALGEBRAIC(:,76)) - CONSTANTS(:,6)))./(exp(ALGEBRAIC(:,76)) - 1.00000);
    ALGEBRAIC(:,102) =  ((  - CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log(CONSTANTS(:,7)./STATES(:,36));
    ALGEBRAIC(:,108) = ( CONSTANTS(:,46).*power(ALGEBRAIC(:,81) - ALGEBRAIC(:,102), 4.00000))./(power(ALGEBRAIC(:,81) - ALGEBRAIC(:,102), 4.00000)+power(87.8251, 4.00000));
    ALGEBRAIC(:,110) = (STATES(:,32) - STATES(:,30))./CONSTANTS(:,70);
    ALGEBRAIC(:,1) =  floor(VOI./CONSTANTS(:,11)).*CONSTANTS(:,11);
    ALGEBRAIC(:,13) = piecewise({VOI - ALGEBRAIC(:,1)>=CONSTANTS(:,10)&VOI - ALGEBRAIC(:,1)<=CONSTANTS(:,10)+CONSTANTS(:,12), CONSTANTS(:,13) }, 0.00000);
    ALGEBRAIC(:,94) =  (( CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log(CONSTANTS(:,4)./STATES(:,35));
    ALGEBRAIC(:,104) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,94)) - 59.2150)));
    ALGEBRAIC(:,105) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1) - ALGEBRAIC(:,94))+5.47600))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,94)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,94))+4.75300)));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,104)./(ALGEBRAIC(:,104)+ALGEBRAIC(:,105));
    ALGEBRAIC(:,107) =  CONSTANTS(:,88).*ALGEBRAIC(:,106).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,71) = 1.00000./(1.00000+exp((7.48800 - STATES(:,1))./5.98000));
    ALGEBRAIC(:,97) =  CONSTANTS(:,34).*ALGEBRAIC(:,71).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,24) =  CONSTANTS(:,14).*(1.00000+0.600000./(1.00000+power(3.80000e-05./STATES(:,18), 1.40000)));
    ALGEBRAIC(:,31) = STATES(:,17)+ALGEBRAIC(:,28);
    ALGEBRAIC(:,99) =  (( CONSTANTS(:,3).*CONSTANTS(:,2))./CONSTANTS(:,1)).*log((CONSTANTS(:,4)+ CONSTANTS(:,44).*CONSTANTS(:,6))./(STATES(:,35)+ CONSTANTS(:,44).*STATES(:,30)));
    ALGEBRAIC(:,101) =  ALGEBRAIC(:,24).*ALGEBRAIC(:,31).*(STATES(:,1) - ALGEBRAIC(:,99));
    ALGEBRAIC(:,111) = 1.00000./(1.00000+exp((STATES(:,1)+10.0000)./15.4000));
    ALGEBRAIC(:,112) =  CONSTANTS(:,89).*STATES(:,37).*ALGEBRAIC(:,111).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,113) = exp(STATES(:,1)./550.000);
    ALGEBRAIC(:,114) =  CONSTANTS(:,49).*power(STATES(:,38), 3.00000).*STATES(:,39).*STATES(:,40).*ALGEBRAIC(:,113).*(STATES(:,1) - ALGEBRAIC(:,94));
    ALGEBRAIC(:,109) = ( CONSTANTS(:,47).*(ALGEBRAIC(:,94) - ALGEBRAIC(:,102)))./((ALGEBRAIC(:,94)+87.8251) - ALGEBRAIC(:,102));
    ALGEBRAIC(:,74) = (ALGEBRAIC(:,37)+ALGEBRAIC(:,73)+ALGEBRAIC(:,72)) -  2.00000.*(ALGEBRAIC(:,70)+ALGEBRAIC(:,68));
    ALGEBRAIC(:,91) = ALGEBRAIC(:,84)+ 3.00000.*(ALGEBRAIC(:,70)+ALGEBRAIC(:,68))+ 3.00000.*ALGEBRAIC(:,51)+ALGEBRAIC(:,88)+ALGEBRAIC(:,78);
    ALGEBRAIC(:,115) = ALGEBRAIC(:,112)+ALGEBRAIC(:,101)+ALGEBRAIC(:,107)+ALGEBRAIC(:,97)+  - 2.00000.*ALGEBRAIC(:,51)+ALGEBRAIC(:,114)+ALGEBRAIC(:,13);
    ALGEBRAIC(:,116) = ( (( CONSTANTS(:,50).*power(CONSTANTS(:,51), 2.00000).*STATES(:,1).*power(CONSTANTS(:,1), 2.00000))./( CONSTANTS(:,3).*CONSTANTS(:,2))).*(STATES(:,36) -  CONSTANTS(:,7).*exp(( STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2)))))./(1.00000 - exp(( STATES(:,1).*CONSTANTS(:,1))./( CONSTANTS(:,3).*CONSTANTS(:,2))));
    ALGEBRAIC(:,117) = 1.00000 - 1.00000./(1.00000+power(STATES(:,41)./CONSTANTS(:,53), 2.00000));
    ALGEBRAIC(:,118) =  ALGEBRAIC(:,116).*CONSTANTS(:,52).*STATES(:,42).*ALGEBRAIC(:,117);
    ALGEBRAIC(:,103) =  CONSTANTS(:,41).*(STATES(:,1) - ALGEBRAIC(:,102));
    ALGEBRAIC(:,119) = ALGEBRAIC(:,103)+ALGEBRAIC(:,118);
    ALGEBRAIC(:,120) = (STATES(:,45) - STATES(:,36))./CONSTANTS(:,70);
end

% Compute result of a piecewise function
function x = piecewise(cases, default)
    set = [0];
    for i = 1:2:length(cases)
        if (length(cases{i+1}) == 1)
            x(cases{i} & ~set,:) = cases{i+1};
        else
            x(cases{i} & ~set,:) = cases{i+1}(cases{i} & ~set);
        end
        set = set | cases{i};
        if(set), break, end
    end
    if (length(default) == 1)
        x(~set,:) = default;
    else
        x(~set,:) = default(~set);
    end
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