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 =108;
end
% There are a total of 55 entries in each of the rate and state variable arrays.
% There are a total of 130 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 (second)');
    LEGEND_CONSTANTS(:,1) = strpad('R in component model_parameters (joule_per_kilomole_kelvin)');
    LEGEND_CONSTANTS(:,2) = strpad('T in component model_parameters (kelvin)');
    LEGEND_CONSTANTS(:,3) = strpad('F in component model_parameters (coulomb_per_mole)');
    LEGEND_CONSTANTS(:,4) = strpad('Na_e in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,5) = strpad('Ca_e in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,6) = strpad('K_e in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,7) = strpad('ATP_i in component model_parameters (millimolar)');
    LEGEND_CONSTANTS(:,128) = strpad('Vt in component model_parameters (cm3)');
    LEGEND_CONSTANTS(:,85) = strpad('Vd in component model_parameters (cm3)');
    LEGEND_CONSTANTS(:,87) = strpad('Vmyo in component model_parameters (cm3)');
    LEGEND_CONSTANTS(:,81) = strpad('Sms in component model_parameters (cm2)');
    LEGEND_CONSTANTS(:,91) = strpad('Smt in component model_parameters (cm2)');
    LEGEND_CONSTANTS(:,130) = strpad('Cms in component model_parameters (microF)');
    LEGEND_CONSTANTS(:,129) = strpad('Cmt in component model_parameters (microF)');
    LEGEND_CONSTANTS(:,90) = strpad('Rst in component model_parameters (ohm)');
    LEGEND_CONSTANTS(:,88) = strpad('VSRup in component model_parameters (cm3)');
    LEGEND_CONSTANTS(:,86) = strpad('VSRrel in component model_parameters (cm3)');
    LEGEND_CONSTANTS(:,84) = strpad('Vc in component model_parameters (cm3)');
    LEGEND_CONSTANTS(:,89) = strpad('pt in component model_parameters (dimensionless)');
    LEGEND_CONSTANTS(:,8) = strpad('Rot in component model_parameters (ohm_cm)');
    LEGEND_CONSTANTS(:,9) = strpad('rt in component model_parameters (cm)');
    LEGEND_CONSTANTS(:,10) = strpad('Lt in component model_parameters (cm)');
    LEGEND_CONSTANTS(:,11) = strpad('rc in component model_parameters (cm)');
    LEGEND_CONSTANTS(:,12) = strpad('Lc in component model_parameters (cm)');
    LEGEND_CONSTANTS(:,13) = strpad('ptcm in component model_parameters (per_cm2)');
    LEGEND_ALGEBRAIC(:,15) = strpad('i_circ in component i_circ (microA)');
    LEGEND_STATES(:,1) = strpad('Vm_s in component Vm_s (millivolt)');
    LEGEND_STATES(:,2) = strpad('Vm_t in component Vm_t (millivolt)');
    LEGEND_CONSTANTS(:,92) = strpad('g_Na_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,93) = strpad('g_Naps_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,94) = strpad('q_Kr_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,95) = strpad('q_Ks_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,96) = strpad('g_Kp_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,97) = strpad('g_Kto_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,98) = strpad('g_K1_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,99) = strpad('g_KNa_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,100) = strpad('g_KATP_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,101) = strpad('g_Nab_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,102) = strpad('g_Cab_s in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,103) = strpad('i_pCa_max_s in component membrane_permeabilities (microA)');
    LEGEND_CONSTANTS(:,104) = strpad('i_NaK_max_s in component membrane_permeabilities (microA)');
    LEGEND_CONSTANTS(:,105) = strpad('i_NaCa_max_s in component membrane_permeabilities (microA)');
    LEGEND_CONSTANTS(:,106) = strpad('P_CaL_s in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,107) = strpad('P_KL_s in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,108) = strpad('P_nsNa_s in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,109) = strpad('P_nsK_s in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,110) = strpad('g_Na_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,111) = strpad('g_Naps_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,112) = strpad('q_Kr_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,113) = strpad('q_Ks_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,114) = strpad('g_Kp_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,115) = strpad('g_Kto_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,116) = strpad('g_K1_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,117) = strpad('g_KNa_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,118) = strpad('g_KATP_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,119) = strpad('g_Nab_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,120) = strpad('g_Cab_t in component membrane_permeabilities (milliS)');
    LEGEND_CONSTANTS(:,121) = strpad('i_pCa_max_t in component membrane_permeabilities (microA)');
    LEGEND_CONSTANTS(:,122) = strpad('i_NaK_max_t in component membrane_permeabilities (microA)');
    LEGEND_CONSTANTS(:,123) = strpad('i_NaCa_max_t in component membrane_permeabilities (microA)');
    LEGEND_CONSTANTS(:,124) = strpad('P_CaL_t in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,125) = strpad('P_KL_t in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,126) = strpad('P_nsNa_t in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,127) = strpad('P_nsK_t in component membrane_permeabilities (litre_per_second)');
    LEGEND_CONSTANTS(:,14) = strpad('g_Na in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,15) = strpad('fNat in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,16) = strpad('g_Naps in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,17) = strpad('fNapst in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,18) = strpad('q_Kr in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,19) = strpad('fKrt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,20) = strpad('q_Ks in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,21) = strpad('fKst in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,22) = strpad('g_Kp in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,23) = strpad('fKpt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,24) = strpad('g_Kto in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,25) = strpad('fKtot in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,26) = strpad('g_K1 in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,27) = strpad('fK1t in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,28) = strpad('g_KNa in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,29) = strpad('fKNat in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,30) = strpad('g_KATP in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,31) = strpad('fKATPt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,32) = strpad('g_Nab in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,33) = strpad('fNabt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,34) = strpad('g_Cab in component membrane_permeabilities (milliS_per_cm2)');
    LEGEND_CONSTANTS(:,35) = strpad('fCabt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,36) = strpad('P_CaL in component membrane_permeabilities (litre_per_second_cm2)');
    LEGEND_CONSTANTS(:,37) = strpad('fCaLt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,38) = strpad('P_KL in component membrane_permeabilities (litre_per_second_cm2)');
    LEGEND_CONSTANTS(:,39) = strpad('P_nsNa in component membrane_permeabilities (litre_per_second_cm2)');
    LEGEND_CONSTANTS(:,40) = strpad('fnsNat in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,41) = strpad('P_nsK in component membrane_permeabilities (litre_per_second_cm2)');
    LEGEND_CONSTANTS(:,42) = strpad('fnsKt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,43) = strpad('i_NaCa_max in component membrane_permeabilities (microA_per_cm2)');
    LEGEND_CONSTANTS(:,44) = strpad('fNaCat in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,45) = strpad('i_NaK_max in component membrane_permeabilities (microA_per_cm2)');
    LEGEND_CONSTANTS(:,46) = strpad('fNaKt in component membrane_permeabilities (dimensionless)');
    LEGEND_CONSTANTS(:,47) = strpad('i_pCa_max in component membrane_permeabilities (microA_per_cm2)');
    LEGEND_CONSTANTS(:,48) = strpad('fpCat in component membrane_permeabilities (dimensionless)');
    LEGEND_ALGEBRAIC(:,30) = strpad('i_Kext in component i_Kext (microA)');
    LEGEND_CONSTANTS(:,49) = strpad('stim_Period in component i_Kext (second)');
    LEGEND_ALGEBRAIC(:,36) = strpad('i_Na_s in component i_Na_s (microA)');
    LEGEND_ALGEBRAIC(:,33) = strpad('E_Na_s in component i_Na_s (millivolt)');
    LEGEND_STATES(:,3) = strpad('Na_i in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,4) = strpad('K_i in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,5) = strpad('m in component i_Na_s_m_gate (dimensionless)');
    LEGEND_STATES(:,6) = strpad('h in component i_Na_s_h_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,1) = strpad('m_infinity in component i_Na_s_m_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,16) = strpad('tau_m in component i_Na_s_m_gate (second)');
    LEGEND_ALGEBRAIC(:,2) = strpad('h_infinity in component i_Na_s_h_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,17) = strpad('tau_h in component i_Na_s_h_gate (second)');
    LEGEND_ALGEBRAIC(:,40) = strpad('i_Na_t in component i_Na_t (microA)');
    LEGEND_ALGEBRAIC(:,39) = strpad('E_Na_t in component i_Na_t (millivolt)');
    LEGEND_STATES(:,7) = strpad('Na_t in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,8) = strpad('K_t in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,9) = strpad('m in component i_Na_t_m_gate (dimensionless)');
    LEGEND_STATES(:,10) = strpad('h in component i_Na_t_h_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,3) = strpad('m_infinity in component i_Na_t_m_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,18) = strpad('tau_m in component i_Na_t_m_gate (second)');
    LEGEND_ALGEBRAIC(:,4) = strpad('h_infinity in component i_Na_t_h_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,19) = strpad('tau_h in component i_Na_t_h_gate (second)');
    LEGEND_ALGEBRAIC(:,41) = strpad('i_Naps_s in component i_Naps_s (microA)');
    LEGEND_ALGEBRAIC(:,42) = strpad('i_Naps_t in component i_Naps_t (microA)');
    LEGEND_ALGEBRAIC(:,43) = strpad('i_CaL_s in component i_CaL_s (microA)');
    LEGEND_ALGEBRAIC(:,45) = strpad('i_KL_s in component i_CaL_s (microA)');
    LEGEND_ALGEBRAIC(:,5) = strpad('alfas in component i_CaL_s (per_second)');
    LEGEND_ALGEBRAIC(:,20) = strpad('betas in component i_CaL_s (per_second)');
    LEGEND_ALGEBRAIC(:,31) = strpad('gama in component i_CaL_s (per_second)');
    LEGEND_CONSTANTS(:,50) = strpad('omega in component i_CaL_s (per_second)');
    LEGEND_CONSTANTS(:,51) = strpad('a in component i_CaL_s (dimensionless)');
    LEGEND_CONSTANTS(:,52) = strpad('b in component i_CaL_s (dimensionless)');
    LEGEND_CONSTANTS(:,53) = strpad('f in component i_CaL_s (per_second)');
    LEGEND_CONSTANTS(:,54) = strpad('g in component i_CaL_s (per_second)');
    LEGEND_CONSTANTS(:,55) = strpad('f2 in component i_CaL_s (per_second)');
    LEGEND_CONSTANTS(:,56) = strpad('g2 in component i_CaL_s (per_second)');
    LEGEND_ALGEBRAIC(:,34) = strpad('alfa2s in component i_CaL_s (per_second)');
    LEGEND_ALGEBRAIC(:,37) = strpad('beta2s in component i_CaL_s (per_second)');
    LEGEND_STATES(:,11) = strpad('Cst in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,12) = strpad('C1 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,13) = strpad('C2 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,14) = strpad('C3 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,15) = strpad('C4 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,16) = strpad('Co in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,17) = strpad('Ccast in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,18) = strpad('Cca1 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,19) = strpad('Cca2 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,20) = strpad('Cca3 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,21) = strpad('Cca4 in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,22) = strpad('Ccao in component i_CaL_s (dimensionless)');
    LEGEND_STATES(:,23) = strpad('Ca_ss in component ion_concentrations (millimolar)');
    LEGEND_ALGEBRAIC(:,44) = strpad('i_CaL_t in component i_CaL_t (microA)');
    LEGEND_STATES(:,24) = strpad('y in component i_CaL_s_y_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,6) = strpad('y_infinity in component i_CaL_s_y_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,21) = strpad('tau_y in component i_CaL_s_y_gate (second)');
    LEGEND_ALGEBRAIC(:,46) = strpad('i_KL_t in component i_CaL_t (microA)');
    LEGEND_ALGEBRAIC(:,22) = strpad('alfat in component i_CaL_t (per_second)');
    LEGEND_ALGEBRAIC(:,32) = strpad('betat in component i_CaL_t (per_second)');
    LEGEND_ALGEBRAIC(:,7) = strpad('gama in component i_CaL_t (per_second)');
    LEGEND_CONSTANTS(:,57) = strpad('omega in component i_CaL_t (per_second)');
    LEGEND_CONSTANTS(:,58) = strpad('a in component i_CaL_t (dimensionless)');
    LEGEND_CONSTANTS(:,59) = strpad('b in component i_CaL_t (dimensionless)');
    LEGEND_CONSTANTS(:,60) = strpad('f in component i_CaL_t (per_second)');
    LEGEND_CONSTANTS(:,61) = strpad('g in component i_CaL_t (per_second)');
    LEGEND_CONSTANTS(:,62) = strpad('f2 in component i_CaL_t (per_second)');
    LEGEND_CONSTANTS(:,63) = strpad('g2 in component i_CaL_t (per_second)');
    LEGEND_ALGEBRAIC(:,35) = strpad('alfa2t in component i_CaL_t (per_second)');
    LEGEND_ALGEBRAIC(:,38) = strpad('beta2t in component i_CaL_t (per_second)');
    LEGEND_STATES(:,25) = strpad('TCst in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,26) = strpad('TC1 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,27) = strpad('TC2 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,28) = strpad('TC3 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,29) = strpad('TC4 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,30) = strpad('TCo in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,31) = strpad('TCcast in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,32) = strpad('TCca1 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,33) = strpad('TCca2 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,34) = strpad('TCca3 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,35) = strpad('TCca4 in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,36) = strpad('TCcao in component i_CaL_t (dimensionless)');
    LEGEND_STATES(:,37) = strpad('Ca_t in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,38) = strpad('y in component i_CaL_t_y_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,8) = strpad('y_infinity in component i_CaL_t_y_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,23) = strpad('tau_y in component i_CaL_t_y_gate (second)');
    LEGEND_ALGEBRAIC(:,49) = strpad('i_Kr_s in component i_Kr_s (microA)');
    LEGEND_ALGEBRAIC(:,47) = strpad('E_Kr_s in component i_Kr_s (millivolt)');
    LEGEND_STATES(:,39) = strpad('xr in component i_Kr_s_xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,48) = strpad('xri in component i_Kr_s_xri_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,9) = strpad('xr_infinity in component i_Kr_s_xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,24) = strpad('tau_xr in component i_Kr_s_xr_gate (second)');
    LEGEND_ALGEBRAIC(:,52) = strpad('i_Kr_t in component i_Kr_t (microA)');
    LEGEND_ALGEBRAIC(:,50) = strpad('E_Kr_t in component i_Kr_t (millivolt)');
    LEGEND_STATES(:,40) = strpad('xr in component i_Kr_t_xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,51) = strpad('xri in component i_Kr_t_xri_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,10) = strpad('xr_infinity in component i_Kr_t_xr_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,25) = strpad('tau_xr in component i_Kr_t_xr_gate (second)');
    LEGEND_ALGEBRAIC(:,54) = strpad('i_Ks_s in component i_Ks_s (microA)');
    LEGEND_ALGEBRAIC(:,53) = strpad('E_Ks_s in component i_Ks_s (millivolt)');
    LEGEND_CONSTANTS(:,64) = strpad('PRNaK in component i_Ks_s (dimensionless)');
    LEGEND_STATES(:,41) = strpad('Ca_i in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,42) = strpad('xs in component i_Ks_s_xs_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,11) = strpad('xs_infinity in component i_Ks_s_xs_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,26) = strpad('tau_xs in component i_Ks_s_xs_gate (second)');
    LEGEND_ALGEBRAIC(:,56) = strpad('i_Ks_t in component i_Ks_t (microA)');
    LEGEND_ALGEBRAIC(:,55) = strpad('E_Ks_t in component i_Ks_t (millivolt)');
    LEGEND_CONSTANTS(:,65) = strpad('PRNaK in component i_Ks_t (dimensionless)');
    LEGEND_STATES(:,43) = strpad('xs in component i_Ks_t_xs_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,12) = strpad('xs_infinity in component i_Ks_t_xs_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,27) = strpad('tau_xs in component i_Ks_t_xs_gate (second)');
    LEGEND_ALGEBRAIC(:,60) = strpad('i_K1_s in component i_K1_s (microA)');
    LEGEND_ALGEBRAIC(:,57) = strpad('E_K1_s in component i_K1_s (millivolt)');
    LEGEND_ALGEBRAIC(:,58) = strpad('aK1s in component i_K1_s (dimensionless)');
    LEGEND_ALGEBRAIC(:,59) = strpad('bK1s in component i_K1_s (dimensionless)');
    LEGEND_ALGEBRAIC(:,64) = strpad('i_K1_t in component i_K1_t (microA)');
    LEGEND_ALGEBRAIC(:,61) = strpad('E_K1_t in component i_K1_t (millivolt)');
    LEGEND_ALGEBRAIC(:,62) = strpad('aK1t in component i_K1_t (dimensionless)');
    LEGEND_ALGEBRAIC(:,63) = strpad('bK1t in component i_K1_t (dimensionless)');
    LEGEND_ALGEBRAIC(:,67) = strpad('i_Kp_s in component i_Kp_s (microA)');
    LEGEND_ALGEBRAIC(:,66) = strpad('kps in component i_Kp_s (dimensionless)');
    LEGEND_ALGEBRAIC(:,65) = strpad('E_Kp_s in component i_Kp_s (millivolt)');
    LEGEND_ALGEBRAIC(:,70) = strpad('i_Kp_t in component i_Kp_t (microA)');
    LEGEND_ALGEBRAIC(:,69) = strpad('kpt in component i_Kp_t (dimensionless)');
    LEGEND_ALGEBRAIC(:,68) = strpad('E_Kp_t in component i_Kp_t (millivolt)');
    LEGEND_ALGEBRAIC(:,72) = strpad('i_Kto_s in component i_Kto_s (microA)');
    LEGEND_CONSTANTS(:,66) = strpad('fr2 in component i_Kto_s (dimensionless)');
    LEGEND_ALGEBRAIC(:,71) = strpad('E_Kto_s in component i_Kto_s (millivolt)');
    LEGEND_STATES(:,44) = strpad('r2 in component i_Kto_s_r2_gate (dimensionless)');
    LEGEND_STATES(:,45) = strpad('r3 in component i_Kto_s_r3_gate (dimensionless)');
    LEGEND_CONSTANTS(:,67) = strpad('tau_r2 in component i_Kto_s_r2_gate (second)');
    LEGEND_ALGEBRAIC(:,13) = strpad('r2_infinity in component i_Kto_s_r2_gate (dimensionless)');
    LEGEND_CONSTANTS(:,68) = strpad('tau_r3 in component i_Kto_s_r3_gate (second)');
    LEGEND_ALGEBRAIC(:,28) = strpad('r3_infinity in component i_Kto_s_r3_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,74) = strpad('i_Kto_t in component i_Kto_t (microA)');
    LEGEND_CONSTANTS(:,69) = strpad('fr2 in component i_Kto_t (dimensionless)');
    LEGEND_ALGEBRAIC(:,73) = strpad('E_Kto_t in component i_Kto_t (millivolt)');
    LEGEND_STATES(:,46) = strpad('r2 in component i_Kto_t_r2_gate (dimensionless)');
    LEGEND_STATES(:,47) = strpad('r3 in component i_Kto_t_r3_gate (dimensionless)');
    LEGEND_CONSTANTS(:,70) = strpad('tau_r2 in component i_Kto_t_r2_gate (second)');
    LEGEND_ALGEBRAIC(:,14) = strpad('r2_infinity in component i_Kto_t_r2_gate (dimensionless)');
    LEGEND_ALGEBRAIC(:,29) = strpad('r3_infinity in component i_Kto_t_r3_gate (dimensionless)');
    LEGEND_CONSTANTS(:,71) = strpad('tau_r3 in component i_Kto_t_r3_gate (second)');
    LEGEND_ALGEBRAIC(:,76) = strpad('i_KNa_s in component i_KNa_s (microA)');
    LEGEND_ALGEBRAIC(:,75) = strpad('E_KNa_s in component i_KNa_s (millivolt)');
    LEGEND_ALGEBRAIC(:,78) = strpad('i_KNa_t in component i_KNa_t (microA)');
    LEGEND_ALGEBRAIC(:,77) = strpad('E_KNa_t in component i_KNa_t (millivolt)');
    LEGEND_ALGEBRAIC(:,79) = strpad('i_nsNa_s in component i_nsNa_s (microA)');
    LEGEND_ALGEBRAIC(:,80) = strpad('i_nsNa_t in component i_nsNa_t (microA)');
    LEGEND_ALGEBRAIC(:,81) = strpad('i_nsK_s in component i_nsK_s (microA)');
    LEGEND_ALGEBRAIC(:,82) = strpad('i_nsK_t in component i_nsK_t (microA)');
    LEGEND_ALGEBRAIC(:,83) = strpad('i_Nab_s in component i_Nab_s (microA)');
    LEGEND_ALGEBRAIC(:,84) = strpad('i_Nab_t in component i_Nab_t (microA)');
    LEGEND_ALGEBRAIC(:,86) = strpad('i_Cab_s in component i_Cab_s (microA)');
    LEGEND_ALGEBRAIC(:,85) = strpad('E_Ca_s in component i_Cab_s (millivolt)');
    LEGEND_ALGEBRAIC(:,88) = strpad('i_Cab_t in component i_Cab_t (microA)');
    LEGEND_ALGEBRAIC(:,87) = strpad('E_Ca_t in component i_Cab_t (millivolt)');
    LEGEND_ALGEBRAIC(:,89) = strpad('i_NaCa_s in component i_NaCa_s (microA)');
    LEGEND_ALGEBRAIC(:,90) = strpad('i_NaCa_t in component i_NaCa_t (microA)');
    LEGEND_ALGEBRAIC(:,91) = strpad('i_NaK_s in component i_NaK_s (microA)');
    LEGEND_ALGEBRAIC(:,92) = strpad('i_NaK_t in component i_NaK_t (microA)');
    LEGEND_ALGEBRAIC(:,94) = strpad('i_pCa_s in component i_pCa_s (microA)');
    LEGEND_ALGEBRAIC(:,95) = strpad('i_pCa_t in component i_pCa_t (microA)');
    LEGEND_ALGEBRAIC(:,99) = strpad('i_KATP_s in component i_KATP_s (microA)');
    LEGEND_ALGEBRAIC(:,96) = strpad('E_KATP_s in component i_KATP_s (millivolt)');
    LEGEND_ALGEBRAIC(:,103) = strpad('i_KATP_t in component i_KATP_t (microA)');
    LEGEND_ALGEBRAIC(:,101) = strpad('E_KATP_t in component i_KATP_t (millivolt)');
    LEGEND_ALGEBRAIC(:,93) = strpad('JteNa in component t_tubular_ion_fluxes (millimolar_per_second)');
    LEGEND_ALGEBRAIC(:,97) = strpad('JteCa in component t_tubular_ion_fluxes (millimolar_per_second)');
    LEGEND_ALGEBRAIC(:,105) = strpad('JteK in component t_tubular_ion_fluxes (millimolar_per_second)');
    LEGEND_CONSTANTS(:,72) = strpad('tau_Na in component t_tubular_ion_fluxes (second)');
    LEGEND_CONSTANTS(:,73) = strpad('tau_Ca in component t_tubular_ion_fluxes (second)');
    LEGEND_CONSTANTS(:,74) = strpad('tau_K in component t_tubular_ion_fluxes (second)');
    LEGEND_ALGEBRAIC(:,98) = strpad('JCaSRup in component JCaSRup (millimolar_per_second)');
    LEGEND_ALGEBRAIC(:,100) = strpad('JCaSRleak in component JCaSRleak (millimolar_per_second)');
    LEGEND_STATES(:,48) = strpad('CaSRup in component CaSRup (millimolar)');
    LEGEND_ALGEBRAIC(:,102) = strpad('Jtr in component Jtr (millimolar_per_second)');
    LEGEND_CONSTANTS(:,75) = strpad('tau_tr in component Jtr (second)');
    LEGEND_STATES(:,49) = strpad('CaSRrel in component CaSRrel (millimolar)');
    LEGEND_ALGEBRAIC(:,104) = strpad('JCaSRrel in component JCaSRrel (millimolar_per_second)');
    LEGEND_CONSTANTS(:,82) = strpad('kap in component JCaSRrel (per_millimolar4_per_second)');
    LEGEND_CONSTANTS(:,76) = strpad('kam in component JCaSRrel (per_second)');
    LEGEND_CONSTANTS(:,83) = strpad('kbp in component JCaSRrel (per_millimolar3_per_second)');
    LEGEND_CONSTANTS(:,77) = strpad('kbm in component JCaSRrel (per_second)');
    LEGEND_CONSTANTS(:,78) = strpad('kcp in component JCaSRrel (per_second)');
    LEGEND_CONSTANTS(:,79) = strpad('kcm in component JCaSRrel (per_second)');
    LEGEND_STATES(:,50) = strpad('F1 in component JCaSRrel (dimensionless)');
    LEGEND_STATES(:,51) = strpad('F2 in component JCaSRrel (dimensionless)');
    LEGEND_STATES(:,52) = strpad('F3 in component JCaSRrel (dimensionless)');
    LEGEND_STATES(:,53) = strpad('F4 in component JCaSRrel (dimensionless)');
    LEGEND_ALGEBRAIC(:,106) = strpad('JCad in component JCad (millimolar_per_second)');
    LEGEND_CONSTANTS(:,80) = strpad('tau_d in component JCad (second)');
    LEGEND_STATES(:,54) = strpad('BTRH in component ion_concentrations (millimolar)');
    LEGEND_STATES(:,55) = strpad('BTRL in component ion_concentrations (millimolar)');
    LEGEND_ALGEBRAIC(:,107) = strpad('dBTRH in component ion_concentrations (millimolar_per_second)');
    LEGEND_ALGEBRAIC(:,108) = strpad('dBTRL in component ion_concentrations (millimolar_per_second)');
    LEGEND_RATES(:,5) = strpad('d/dt m in component i_Na_s_m_gate (dimensionless)');
    LEGEND_RATES(:,6) = strpad('d/dt h in component i_Na_s_h_gate (dimensionless)');
    LEGEND_RATES(:,9) = strpad('d/dt m in component i_Na_t_m_gate (dimensionless)');
    LEGEND_RATES(:,10) = strpad('d/dt h in component i_Na_t_h_gate (dimensionless)');
    LEGEND_RATES(:,11) = strpad('d/dt Cst in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,12) = strpad('d/dt C1 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt C2 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt C3 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt C4 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,16) = strpad('d/dt Co in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,17) = strpad('d/dt Ccast in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,18) = strpad('d/dt Cca1 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,19) = strpad('d/dt Cca2 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,20) = strpad('d/dt Cca3 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,21) = strpad('d/dt Cca4 in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,22) = strpad('d/dt Ccao in component i_CaL_s (dimensionless)');
    LEGEND_RATES(:,24) = strpad('d/dt y in component i_CaL_s_y_gate (dimensionless)');
    LEGEND_RATES(:,25) = strpad('d/dt TCst in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,26) = strpad('d/dt TC1 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,27) = strpad('d/dt TC2 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,28) = strpad('d/dt TC3 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,29) = strpad('d/dt TC4 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,30) = strpad('d/dt TCo in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,31) = strpad('d/dt TCcast in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,32) = strpad('d/dt TCca1 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,33) = strpad('d/dt TCca2 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,34) = strpad('d/dt TCca3 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,35) = strpad('d/dt TCca4 in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,36) = strpad('d/dt TCcao in component i_CaL_t (dimensionless)');
    LEGEND_RATES(:,38) = strpad('d/dt y in component i_CaL_t_y_gate (dimensionless)');
    LEGEND_RATES(:,39) = strpad('d/dt xr in component i_Kr_s_xr_gate (dimensionless)');
    LEGEND_RATES(:,40) = strpad('d/dt xr in component i_Kr_t_xr_gate (dimensionless)');
    LEGEND_RATES(:,42) = strpad('d/dt xs in component i_Ks_s_xs_gate (dimensionless)');
    LEGEND_RATES(:,43) = strpad('d/dt xs in component i_Ks_t_xs_gate (dimensionless)');
    LEGEND_RATES(:,44) = strpad('d/dt r2 in component i_Kto_s_r2_gate (dimensionless)');
    LEGEND_RATES(:,45) = strpad('d/dt r3 in component i_Kto_s_r3_gate (dimensionless)');
    LEGEND_RATES(:,46) = strpad('d/dt r2 in component i_Kto_t_r2_gate (dimensionless)');
    LEGEND_RATES(:,47) = strpad('d/dt r3 in component i_Kto_t_r3_gate (dimensionless)');
    LEGEND_RATES(:,50) = strpad('d/dt F1 in component JCaSRrel (dimensionless)');
    LEGEND_RATES(:,51) = strpad('d/dt F2 in component JCaSRrel (dimensionless)');
    LEGEND_RATES(:,52) = strpad('d/dt F3 in component JCaSRrel (dimensionless)');
    LEGEND_RATES(:,53) = strpad('d/dt F4 in component JCaSRrel (dimensionless)');
    LEGEND_RATES(:,49) = strpad('d/dt CaSRrel in component CaSRrel (millimolar)');
    LEGEND_RATES(:,48) = strpad('d/dt CaSRup in component CaSRup (millimolar)');
    LEGEND_RATES(:,23) = strpad('d/dt Ca_ss in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,41) = strpad('d/dt Ca_i in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,54) = strpad('d/dt BTRH in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,55) = strpad('d/dt BTRL in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,3) = strpad('d/dt Na_i in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,4) = strpad('d/dt K_i in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,7) = strpad('d/dt Na_t in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,37) = strpad('d/dt Ca_t in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,8) = strpad('d/dt K_t in component ion_concentrations (millimolar)');
    LEGEND_RATES(:,1) = strpad('d/dt Vm_s in component Vm_s (millivolt)');
    LEGEND_RATES(:,2) = strpad('d/dt Vm_t in component Vm_t (millivolt)');
    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) = 8310;
    CONSTANTS(:,2) = 310;
    CONSTANTS(:,3) = 96500;
    CONSTANTS(:,4) = 140;
    CONSTANTS(:,5) = 1.8;
    CONSTANTS(:,6) = 5.4;
    CONSTANTS(:,7) = 6.8;
    CONSTANTS(:,8) = 83.33;
    CONSTANTS(:,9) = 148.15e-7;
    CONSTANTS(:,10) = 5.93e-4;
    CONSTANTS(:,11) = 5.93e-4;
    CONSTANTS(:,12) = 0.013;
    CONSTANTS(:,13) = 21028875;
    STATES(:,1) = -8.5207812e1;
    STATES(:,2) = -8.5208034e1;
    CONSTANTS(:,14) = 30;
    CONSTANTS(:,15) = 0.64;
    CONSTANTS(:,16) = 0.0053;
    CONSTANTS(:,17) = 0.526;
    CONSTANTS(:,18) = 0.8;
    CONSTANTS(:,19) = 0.526;
    CONSTANTS(:,20) = 0.1975;
    CONSTANTS(:,21) = 0.526;
    CONSTANTS(:,22) = 0.006;
    CONSTANTS(:,23) = 0.526;
    CONSTANTS(:,24) = 0;
    CONSTANTS(:,25) = 0.526;
    CONSTANTS(:,26) = 0.75;
    CONSTANTS(:,27) = 0.8;
    CONSTANTS(:,28) = 0.12848;
    CONSTANTS(:,29) = 0.526;
    CONSTANTS(:,30) = 1;
    CONSTANTS(:,31) = 0.526;
    CONSTANTS(:,32) = 0.00075;
    CONSTANTS(:,33) = 0.526;
    CONSTANTS(:,34) = 0.0021;
    CONSTANTS(:,35) = 0.526;
    CONSTANTS(:,36) = 48e-4;
    CONSTANTS(:,37) = 0.64;
    CONSTANTS(:,38) = 48e-7;
    CONSTANTS(:,39) = 1.75e-7;
    CONSTANTS(:,40) = 0.526;
    CONSTANTS(:,41) = 1.75e-7;
    CONSTANTS(:,42) = 0.526;
    CONSTANTS(:,43) = 0.00025;
    CONSTANTS(:,44) = 0.526;
    CONSTANTS(:,45) = 1.5;
    CONSTANTS(:,46) = 0.526;
    CONSTANTS(:,47) = 1.15;
    CONSTANTS(:,48) = 0.2;
    CONSTANTS(:,49) = 1;
    STATES(:,3) = 1.1120279e1;
    STATES(:,4) = 1.3678926e2;
    STATES(:,5) = 3.4130493e-3;
    STATES(:,6) = 8.2699973e-1;
    STATES(:,7) = 1.3993239e2;
    STATES(:,8) = 5.4140321e0;
    STATES(:,9) = 3.4129472e-3;
    STATES(:,10) = 8.2700551e-1;
    CONSTANTS(:,50) = 10;
    CONSTANTS(:,51) = 2;
    CONSTANTS(:,52) = 2;
    CONSTANTS(:,53) = 300;
    CONSTANTS(:,54) = 2000;
    CONSTANTS(:,55) = 5;
    CONSTANTS(:,56) = 7000;
    STATES(:,11) = 9.9797984e-1;
    STATES(:,12) = 7.5722514e-5;
    STATES(:,13) = 2.1545646e-9;
    STATES(:,14) = 2.7463178e-14;
    STATES(:,15) = -5.7569102e-17;
    STATES(:,16) = -1.3496934e-17;
    STATES(:,17) = 1.9155065e-3;
    STATES(:,18) = 5.8135383e-7;
    STATES(:,19) = 6.615513e-11;
    STATES(:,20) = 3.3426555e-15;
    STATES(:,21) = 4.6640361e-19;
    STATES(:,22) = 3.7986638e-22;
    STATES(:,23) = 9.5977033e-5;
    STATES(:,24) = 7.8134852e-1;
    CONSTANTS(:,57) = 10;
    CONSTANTS(:,58) = 2;
    CONSTANTS(:,59) = 2;
    CONSTANTS(:,60) = 300;
    CONSTANTS(:,61) = 2000;
    CONSTANTS(:,62) = 5;
    CONSTANTS(:,63) = 7000;
    STATES(:,25) = 9.9798934e-1;
    STATES(:,26) = 7.5720257e-5;
    STATES(:,27) = 2.1544156e-9;
    STATES(:,28) = 2.7459475e-14;
    STATES(:,29) = -5.7367189e-17;
    STATES(:,30) = -1.3449454e-17;
    STATES(:,31) = 1.9155245e-3;
    STATES(:,32) = 5.8133643e-7;
    STATES(:,33) = 6.6150547e-11;
    STATES(:,34) = 3.3423167e-15;
    STATES(:,35) = 4.6165955e-19;
    STATES(:,36) = 3.75926e-22;
    STATES(:,37) = 1.8476402e0;
    STATES(:,38) = 7.813477e-1;
    STATES(:,39) = 2.0469344e-4;
    STATES(:,40) = 2.0469344e-4;
    CONSTANTS(:,64) = 0.01833;
    STATES(:,41) = 8.8787034e-5;
    STATES(:,42) = 6.1359896e-3;
    CONSTANTS(:,65) = 0.01833;
    STATES(:,43) = 6.1359896e-3;
    CONSTANTS(:,66) = 1;
    STATES(:,44) = 9.625701e-1;
    STATES(:,45) = 9.6250049e-1;
    CONSTANTS(:,67) = 0.02;
    CONSTANTS(:,68) = 0.08;
    CONSTANTS(:,69) = 1;
    STATES(:,46) = 9.625701e-1;
    STATES(:,47) = 9.6250049e-1;
    CONSTANTS(:,70) = 0.02;
    CONSTANTS(:,71) = 0.08;
    CONSTANTS(:,72) = 0.2;
    CONSTANTS(:,73) = 0.24;
    CONSTANTS(:,74) = 0.2;
    STATES(:,48) = 1.0200296e0;
    CONSTANTS(:,75) = 0.03448;
    STATES(:,49) = 1.0326252e0;
    CONSTANTS(:,76) = 576;
    CONSTANTS(:,77) = 1930;
    CONSTANTS(:,78) = 18;
    CONSTANTS(:,79) = 0.8;
    STATES(:,50) = 8.053082e-1;
    STATES(:,51) = 2.6639195e-4;
    STATES(:,52) = 4.9455459e-10;
    STATES(:,53) = 1.9442578e-1;
    CONSTANTS(:,80) = 0.003125;
    STATES(:,54) = 9.6700747e-1;
    STATES(:,55) = 8.1740868e-2;
    CONSTANTS(:,81) =  2.00000.*3.14159.*power(CONSTANTS(:,11), 2.00000)+ 2.00000.*3.14159.*CONSTANTS(:,11).*CONSTANTS(:,12);
    CONSTANTS(:,82) =  3.00000.*1.21500e+13;
    CONSTANTS(:,83) = 4.05000e+09;
    CONSTANTS(:,84) =  3.14159.*power(CONSTANTS(:,11), 2.00000).*CONSTANTS(:,12);
    CONSTANTS(:,85) =  CONSTANTS(:,84).*0.680000.*6.00000e-05;
    CONSTANTS(:,86) =  CONSTANTS(:,84).*0.00316000;
    CONSTANTS(:,87) =  CONSTANTS(:,84).*0.680000;
    CONSTANTS(:,88) =  CONSTANTS(:,84).*0.0550000;
    CONSTANTS(:,89) =  CONSTANTS(:,13).*2.00000.*3.14159.*CONSTANTS(:,11).*CONSTANTS(:,12);
    CONSTANTS(:,90) = (( CONSTANTS(:,8).*CONSTANTS(:,10))./2.00000)./( 3.14159.*power(CONSTANTS(:,9), 2.00000).*CONSTANTS(:,89));
    CONSTANTS(:,91) =  2.00000.*3.14159.*CONSTANTS(:,9).*CONSTANTS(:,10).*CONSTANTS(:,89);
    CONSTANTS(:,92) =  CONSTANTS(:,14).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,15));
    CONSTANTS(:,93) =  CONSTANTS(:,16).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,17));
    CONSTANTS(:,94) =  CONSTANTS(:,18).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,19));
    CONSTANTS(:,95) =  CONSTANTS(:,20).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,21));
    CONSTANTS(:,96) =  CONSTANTS(:,22).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,23));
    CONSTANTS(:,97) =  CONSTANTS(:,24).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,25));
    CONSTANTS(:,98) =  CONSTANTS(:,26).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,27));
    CONSTANTS(:,99) =  CONSTANTS(:,28).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,29));
    CONSTANTS(:,100) =  CONSTANTS(:,30).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,31));
    CONSTANTS(:,101) =  CONSTANTS(:,32).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,33));
    CONSTANTS(:,102) =  CONSTANTS(:,34).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,35));
    CONSTANTS(:,103) =  CONSTANTS(:,47).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,48));
    CONSTANTS(:,104) =  CONSTANTS(:,45).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,46));
    CONSTANTS(:,105) =  CONSTANTS(:,43).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,44));
    CONSTANTS(:,106) =  CONSTANTS(:,36).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,37));
    CONSTANTS(:,107) =  CONSTANTS(:,38).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,37));
    CONSTANTS(:,108) =  CONSTANTS(:,39).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,40));
    CONSTANTS(:,109) =  CONSTANTS(:,41).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*(1.00000 - CONSTANTS(:,42));
    CONSTANTS(:,110) =  CONSTANTS(:,14).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,15);
    CONSTANTS(:,111) =  CONSTANTS(:,16).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,17);
    CONSTANTS(:,112) =  CONSTANTS(:,18).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,19);
    CONSTANTS(:,113) =  CONSTANTS(:,20).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,21);
    CONSTANTS(:,114) =  CONSTANTS(:,22).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,23);
    CONSTANTS(:,115) =  CONSTANTS(:,24).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,25);
    CONSTANTS(:,116) =  CONSTANTS(:,26).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,27);
    CONSTANTS(:,117) =  CONSTANTS(:,28).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,29);
    CONSTANTS(:,118) =  CONSTANTS(:,30).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,31);
    CONSTANTS(:,119) =  CONSTANTS(:,32).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,33);
    CONSTANTS(:,120) =  CONSTANTS(:,34).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,35);
    CONSTANTS(:,121) =  CONSTANTS(:,47).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,48);
    CONSTANTS(:,122) =  CONSTANTS(:,45).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,46);
    CONSTANTS(:,123) =  CONSTANTS(:,43).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,44);
    CONSTANTS(:,124) =  CONSTANTS(:,36).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,37);
    CONSTANTS(:,125) =  CONSTANTS(:,38).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,37);
    CONSTANTS(:,126) =  CONSTANTS(:,39).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,40);
    CONSTANTS(:,127) =  CONSTANTS(:,41).*(CONSTANTS(:,81)+CONSTANTS(:,91)).*CONSTANTS(:,42);
    CONSTANTS(:,128) =  3.14159.*power(CONSTANTS(:,9), 2.00000).*CONSTANTS(:,10).*CONSTANTS(:,89);
    CONSTANTS(:,129) =  CONSTANTS(:,91).*1.00000;
    CONSTANTS(:,130) =  CONSTANTS(:,81).*1.00000;
    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
    RATES(:,16) =  CONSTANTS(:,53).*STATES(:,15) -  CONSTANTS(:,54).*STATES(:,16);
    RATES(:,22) =  CONSTANTS(:,55).*STATES(:,21) -  CONSTANTS(:,56).*STATES(:,22);
    RATES(:,30) =  CONSTANTS(:,60).*STATES(:,29) -  CONSTANTS(:,61).*STATES(:,30);
    RATES(:,36) =  CONSTANTS(:,62).*STATES(:,35) -  CONSTANTS(:,63).*STATES(:,36);
    RATES(:,50) =  STATES(:,51).*CONSTANTS(:,76) -  STATES(:,50).*CONSTANTS(:,82).*power(STATES(:,23), 4.00000);
    RATES(:,51) = ( STATES(:,50).*CONSTANTS(:,82).*power(STATES(:,23), 4.00000)+ STATES(:,52).*CONSTANTS(:,77)+ STATES(:,53).*CONSTANTS(:,79)) -  STATES(:,51).*(CONSTANTS(:,76)+ CONSTANTS(:,83).*power(STATES(:,23), 3.00000)+CONSTANTS(:,78));
    RATES(:,52) =  STATES(:,51).*CONSTANTS(:,83).*power(STATES(:,23), 3.00000) -  STATES(:,52).*CONSTANTS(:,77);
    RATES(:,53) =  STATES(:,51).*CONSTANTS(:,78) -  STATES(:,53).*CONSTANTS(:,79);
    ALGEBRAIC(:,13) = 1.00600./(1.00000+exp((STATES(:,1)+36.6900+10.0000)./12.4300));
    RATES(:,44) = (ALGEBRAIC(:,13) - STATES(:,44))./CONSTANTS(:,67);
    ALGEBRAIC(:,14) = 1.00600./(1.00000+exp((STATES(:,2)+36.6900+10.0000)./12.4300));
    RATES(:,46) = (ALGEBRAIC(:,14) - STATES(:,46))./CONSTANTS(:,70);
    ALGEBRAIC(:,1) = 1.00000./(1.00000+exp(((STATES(:,1)+52.2000) - 9.00000)./ - 7.40000));
    ALGEBRAIC(:,16) = (0.00100000./( 101.600.*exp( STATES(:,1).*0.113500)+ 0.0226800.*exp(  - 0.0717000.*STATES(:,1)))+0.000100000)./4.83000;
    RATES(:,5) = (ALGEBRAIC(:,1) - STATES(:,5))./ALGEBRAIC(:,16);
    ALGEBRAIC(:,2) = 1.00000./(1.00000+exp(((STATES(:,1)+85.6000) - 9.00000)./5.50000));
    ALGEBRAIC(:,17) = (0.00100000./( 1.13810e-06.*exp(  - 0.101700.*STATES(:,1))+ 6.53700.*exp( STATES(:,1).*0.0801600))+0.000500000)./4.83000;
    RATES(:,6) = (ALGEBRAIC(:,2) - STATES(:,6))./ALGEBRAIC(:,17);
    ALGEBRAIC(:,3) = 1.00000./(1.00000+exp(((STATES(:,2)+52.2000) - 9.00000)./ - 7.40000));
    ALGEBRAIC(:,18) = (0.00100000./( 101.600.*exp( STATES(:,2).*0.113500)+ 0.0226800.*exp(  - 0.0717000.*STATES(:,2)))+0.000100000)./4.83000;
    RATES(:,9) = (ALGEBRAIC(:,3) - STATES(:,9))./ALGEBRAIC(:,18);
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp(((STATES(:,2)+85.6000) - 9.00000)./5.50000));
    ALGEBRAIC(:,19) = (0.00100000./( 1.13810e-06.*exp(  - 0.101700.*STATES(:,2))+ 6.53700.*exp( STATES(:,2).*0.0801600))+0.000500000)./4.83000;
    RATES(:,10) = (ALGEBRAIC(:,4) - STATES(:,10))./ALGEBRAIC(:,19);
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./6.00000));
    ALGEBRAIC(:,21) = 0.00100000./(0.0200000+ 0.0197000.*exp( - power( (STATES(:,1)+10.0000).*0.0337000, 2.00000)))+0.550000./(1.00000+exp( ((STATES(:,1)+40.0000)./9.50000).*4.00000));
    RATES(:,24) = (ALGEBRAIC(:,6) - STATES(:,24))./ALGEBRAIC(:,21);
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,2)+35.0000)./6.00000));
    ALGEBRAIC(:,23) = 0.00100000./(0.0200000+ 0.0197000.*exp( - power( (STATES(:,2)+10.0000).*0.0337000, 2.00000)))+0.550000./(1.00000+exp( ((STATES(:,2)+40.0000)./9.50000).*4.00000));
    RATES(:,38) = (ALGEBRAIC(:,8) - STATES(:,38))./ALGEBRAIC(:,23);
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+21.5000)./7.50000));
    ALGEBRAIC(:,24) = 0.00100000./(( 0.00138000.*(STATES(:,1)+14.2000))./(1.00000 - exp(  - 0.123000.*(STATES(:,1)+14.2000)))+( 0.000610000.*(STATES(:,1)+38.9000))./(exp( 0.145000.*(STATES(:,1)+38.9000)) - 1.00000));
    RATES(:,39) = (ALGEBRAIC(:,9) - STATES(:,39))./ALGEBRAIC(:,24);
    ALGEBRAIC(:,10) = 1.00000./(1.00000+exp( - (STATES(:,2)+21.5000)./7.50000));
    ALGEBRAIC(:,25) = 0.00100000./(( 0.00138000.*(STATES(:,2)+14.2000))./(1.00000 - exp(  - 0.123000.*(STATES(:,2)+14.2000)))+( 0.000610000.*(STATES(:,2)+38.9000))./(exp( 0.145000.*(STATES(:,2)+38.9000)) - 1.00000));
    RATES(:,40) = (ALGEBRAIC(:,10) - STATES(:,40))./ALGEBRAIC(:,25);
    ALGEBRAIC(:,11) = 1.00000./(1.00000+exp( - (STATES(:,1) - 1.50000)./16.7000));
    ALGEBRAIC(:,26) = 0.00100000./(( 7.19000e-05.*(STATES(:,1)+30.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,1)+30.0000)))+( 0.000131000.*(STATES(:,1)+30.0000))./(exp( 0.0687000.*(STATES(:,1)+30.0000)) - 1.00000));
    RATES(:,42) = (ALGEBRAIC(:,11) - STATES(:,42))./ALGEBRAIC(:,26);
    ALGEBRAIC(:,12) = 1.00000./(1.00000+exp( - (STATES(:,2) - 1.50000)./16.7000));
    ALGEBRAIC(:,27) = 0.00100000./(( 7.19000e-05.*(STATES(:,2)+30.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,2)+30.0000)))+( 0.000131000.*(STATES(:,2)+30.0000))./(exp( 0.0687000.*(STATES(:,2)+30.0000)) - 1.00000));
    RATES(:,43) = (ALGEBRAIC(:,12) - STATES(:,43))./ALGEBRAIC(:,27);
    ALGEBRAIC(:,28) = ALGEBRAIC(:,13);
    RATES(:,45) = (ALGEBRAIC(:,28) - STATES(:,45))./CONSTANTS(:,68);
    ALGEBRAIC(:,29) = ALGEBRAIC(:,14);
    RATES(:,47) = (ALGEBRAIC(:,29) - STATES(:,47))./CONSTANTS(:,71);
    ALGEBRAIC(:,5) =  400.000.*exp((STATES(:,1)+12.0000)./10.0000);
    ALGEBRAIC(:,20) =  50.0000.*exp( - (STATES(:,1)+12.0000)./13.0000);
    ALGEBRAIC(:,31) =  187.500.*STATES(:,23);
    RATES(:,11) = ( ALGEBRAIC(:,20).*STATES(:,12)+ CONSTANTS(:,50).*STATES(:,17)) -  ( 4.00000.*ALGEBRAIC(:,5)+ALGEBRAIC(:,31)).*STATES(:,11);
    RATES(:,12) = ( 4.00000.*ALGEBRAIC(:,5).*STATES(:,11)+ 2.00000.*ALGEBRAIC(:,20).*STATES(:,13)+ (CONSTANTS(:,50)./CONSTANTS(:,52)).*STATES(:,18)) -  (ALGEBRAIC(:,20)+ 3.00000.*ALGEBRAIC(:,5)+ ALGEBRAIC(:,31).*CONSTANTS(:,51)).*STATES(:,12);
    RATES(:,13) = ( 3.00000.*ALGEBRAIC(:,5).*STATES(:,12)+ 3.00000.*ALGEBRAIC(:,20).*STATES(:,14)+ (CONSTANTS(:,50)./power(CONSTANTS(:,52), 2.00000)).*STATES(:,19)) -  ( 2.00000.*ALGEBRAIC(:,20)+ 2.00000.*ALGEBRAIC(:,5)+ ALGEBRAIC(:,31).*power(CONSTANTS(:,51), 2.00000)).*STATES(:,13);
    RATES(:,14) = ( 2.00000.*ALGEBRAIC(:,5).*STATES(:,13)+ 4.00000.*ALGEBRAIC(:,20).*STATES(:,15)+ (CONSTANTS(:,50)./power(CONSTANTS(:,52), 3.00000)).*STATES(:,20)) -  ( 3.00000.*ALGEBRAIC(:,20)+ALGEBRAIC(:,5)+ ALGEBRAIC(:,31).*power(CONSTANTS(:,51), 3.00000)).*STATES(:,14);
    RATES(:,15) = ( ALGEBRAIC(:,5).*STATES(:,14)+ CONSTANTS(:,54).*STATES(:,16)+ (CONSTANTS(:,50)./power(CONSTANTS(:,52), 4.00000)).*STATES(:,21)) -  ( 4.00000.*ALGEBRAIC(:,20)+CONSTANTS(:,53)+ ALGEBRAIC(:,31).*power(CONSTANTS(:,51), 4.00000)).*STATES(:,15);
    ALGEBRAIC(:,22) =  400.000.*exp((STATES(:,2)+12.0000)./10.0000);
    ALGEBRAIC(:,32) =  50.0000.*exp( - (STATES(:,2)+12.0000)./13.0000);
    ALGEBRAIC(:,7) =  187.500.*STATES(:,23);
    RATES(:,25) = ( ALGEBRAIC(:,32).*STATES(:,26)+ CONSTANTS(:,57).*STATES(:,31)) -  ( 4.00000.*ALGEBRAIC(:,22)+ALGEBRAIC(:,7)).*STATES(:,25);
    RATES(:,26) = ( 4.00000.*ALGEBRAIC(:,22).*STATES(:,25)+ 2.00000.*ALGEBRAIC(:,32).*STATES(:,27)+ (CONSTANTS(:,57)./CONSTANTS(:,59)).*STATES(:,32)) -  (ALGEBRAIC(:,32)+ 3.00000.*ALGEBRAIC(:,22)+ ALGEBRAIC(:,7).*CONSTANTS(:,58)).*STATES(:,26);
    RATES(:,27) = ( 3.00000.*ALGEBRAIC(:,22).*STATES(:,26)+ 3.00000.*ALGEBRAIC(:,32).*STATES(:,28)+ (CONSTANTS(:,57)./power(CONSTANTS(:,59), 2.00000)).*STATES(:,33)) -  ( 2.00000.*ALGEBRAIC(:,32)+ 2.00000.*ALGEBRAIC(:,22)+ ALGEBRAIC(:,7).*power(CONSTANTS(:,58), 2.00000)).*STATES(:,27);
    RATES(:,28) = ( 2.00000.*ALGEBRAIC(:,22).*STATES(:,27)+ 4.00000.*ALGEBRAIC(:,32).*STATES(:,29)+ (CONSTANTS(:,57)./power(CONSTANTS(:,59), 3.00000)).*STATES(:,34)) -  ( 3.00000.*ALGEBRAIC(:,32)+ALGEBRAIC(:,22)+ ALGEBRAIC(:,7).*power(CONSTANTS(:,58), 3.00000)).*STATES(:,28);
    RATES(:,29) = ( ALGEBRAIC(:,22).*STATES(:,28)+ CONSTANTS(:,61).*STATES(:,30)+ (CONSTANTS(:,57)./power(CONSTANTS(:,59), 4.00000)).*STATES(:,35)) -  ( 4.00000.*ALGEBRAIC(:,32)+CONSTANTS(:,60)+ ALGEBRAIC(:,7).*power(CONSTANTS(:,58), 4.00000)).*STATES(:,29);
    ALGEBRAIC(:,34) =  ALGEBRAIC(:,5).*CONSTANTS(:,51);
    ALGEBRAIC(:,37) = ALGEBRAIC(:,20)./CONSTANTS(:,52);
    RATES(:,17) = ( ALGEBRAIC(:,37).*STATES(:,18)+ ALGEBRAIC(:,31).*STATES(:,11)) -  ( 4.00000.*ALGEBRAIC(:,34)+CONSTANTS(:,50)).*STATES(:,17);
    RATES(:,18) = ( 4.00000.*ALGEBRAIC(:,34).*STATES(:,17)+ 2.00000.*ALGEBRAIC(:,37).*STATES(:,19)+ ALGEBRAIC(:,31).*CONSTANTS(:,51).*STATES(:,12)) -  (ALGEBRAIC(:,37)+ 3.00000.*ALGEBRAIC(:,34)+CONSTANTS(:,50)./CONSTANTS(:,52)).*STATES(:,18);
    RATES(:,19) = ( 3.00000.*ALGEBRAIC(:,34).*STATES(:,18)+ 3.00000.*ALGEBRAIC(:,37).*STATES(:,20)+ ALGEBRAIC(:,31).*power(CONSTANTS(:,51), 2.00000).*STATES(:,13)) -  ( 2.00000.*ALGEBRAIC(:,37)+ 2.00000.*ALGEBRAIC(:,34)+CONSTANTS(:,50)./power(CONSTANTS(:,52), 2.00000)).*STATES(:,19);
    RATES(:,20) = ( 2.00000.*ALGEBRAIC(:,34).*STATES(:,19)+ 4.00000.*ALGEBRAIC(:,37).*STATES(:,21)+ ALGEBRAIC(:,31).*power(CONSTANTS(:,51), 3.00000).*STATES(:,14)) -  ( 3.00000.*ALGEBRAIC(:,37)+ALGEBRAIC(:,34)+CONSTANTS(:,50)./power(CONSTANTS(:,52), 3.00000)).*STATES(:,20);
    RATES(:,21) = ( ALGEBRAIC(:,34).*STATES(:,20)+ CONSTANTS(:,56).*STATES(:,22)+ ALGEBRAIC(:,31).*power(CONSTANTS(:,51), 4.00000).*STATES(:,15)) -  ( 4.00000.*ALGEBRAIC(:,37)+CONSTANTS(:,55)+CONSTANTS(:,50)./power(CONSTANTS(:,52), 4.00000)).*STATES(:,21);
    ALGEBRAIC(:,35) =  ALGEBRAIC(:,22).*CONSTANTS(:,58);
    ALGEBRAIC(:,38) = ALGEBRAIC(:,32)./CONSTANTS(:,59);
    RATES(:,31) = ( ALGEBRAIC(:,38).*STATES(:,32)+ ALGEBRAIC(:,7).*STATES(:,25)) -  ( 4.00000.*ALGEBRAIC(:,35)+CONSTANTS(:,57)).*STATES(:,31);
    RATES(:,32) = ( 4.00000.*ALGEBRAIC(:,35).*STATES(:,31)+ 2.00000.*ALGEBRAIC(:,38).*STATES(:,33)+ ALGEBRAIC(:,7).*CONSTANTS(:,58).*STATES(:,26)) -  (ALGEBRAIC(:,38)+ 3.00000.*ALGEBRAIC(:,35)+CONSTANTS(:,57)./CONSTANTS(:,59)).*STATES(:,32);
    RATES(:,33) = ( 3.00000.*ALGEBRAIC(:,35).*STATES(:,32)+ 3.00000.*ALGEBRAIC(:,38).*STATES(:,34)+ ALGEBRAIC(:,7).*power(CONSTANTS(:,58), 2.00000).*STATES(:,27)) -  ( 2.00000.*ALGEBRAIC(:,38)+ 2.00000.*ALGEBRAIC(:,35)+CONSTANTS(:,57)./power(CONSTANTS(:,59), 2.00000)).*STATES(:,33);
    RATES(:,34) = ( 2.00000.*ALGEBRAIC(:,35).*STATES(:,33)+ 4.00000.*ALGEBRAIC(:,38).*STATES(:,35)+ ALGEBRAIC(:,7).*power(CONSTANTS(:,58), 3.00000).*STATES(:,28)) -  ( 3.00000.*ALGEBRAIC(:,38)+ALGEBRAIC(:,35)+CONSTANTS(:,57)./power(CONSTANTS(:,59), 3.00000)).*STATES(:,34);
    RATES(:,35) = ( ALGEBRAIC(:,35).*STATES(:,34)+ CONSTANTS(:,63).*STATES(:,36)+ ALGEBRAIC(:,7).*power(CONSTANTS(:,58), 4.00000).*STATES(:,29)) -  ( 4.00000.*ALGEBRAIC(:,38)+CONSTANTS(:,62)+CONSTANTS(:,57)./power(CONSTANTS(:,59), 4.00000)).*STATES(:,35);
    ALGEBRAIC(:,36) =  CONSTANTS(:,92).*power(STATES(:,5), 3.00000).*STATES(:,6).*(STATES(:,1) - ( log((CONSTANTS(:,4)+ 0.120000.*CONSTANTS(:,6))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,40) =  CONSTANTS(:,110).*power(STATES(:,9), 3.00000).*STATES(:,10).*(STATES(:,2) - ( log((STATES(:,7)+ 0.120000.*STATES(:,8))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,41) =  (CONSTANTS(:,93)./(1.00000+exp(( - 54.0000 - STATES(:,1))./8.00000))).*(STATES(:,1) - ( log((CONSTANTS(:,4)+ 0.120000.*CONSTANTS(:,6))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,42) =  (CONSTANTS(:,111)./(1.00000+exp(( - 54.0000 - STATES(:,2))./8.00000))).*(STATES(:,2) - ( log((STATES(:,7)+ 0.120000.*STATES(:,8))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,79) = (( (( 1.00000.*CONSTANTS(:,108).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,3).*exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*CONSTANTS(:,4)))./(exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,80) = (( (( 1.00000.*CONSTANTS(:,126).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,3).*exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*STATES(:,7)))./(exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,33) = ( log(CONSTANTS(:,4)./STATES(:,3)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,83) =  CONSTANTS(:,101).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,39) = ( log(STATES(:,7)./STATES(:,3)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,84) =  CONSTANTS(:,119).*(STATES(:,2) - ALGEBRAIC(:,39));
    ALGEBRAIC(:,89) = ( CONSTANTS(:,105).*exp((  - 0.850000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,5) -  power(CONSTANTS(:,4), 3.00000).*STATES(:,41)))./(1.00000+ 0.000100000.*exp((  - 0.850000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,5)+ power(CONSTANTS(:,4), 3.00000).*STATES(:,41)));
    ALGEBRAIC(:,90) = ( CONSTANTS(:,123).*exp((  - 0.850000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*STATES(:,37) -  power(STATES(:,7), 3.00000).*STATES(:,41)))./(1.00000+ 0.000100000.*exp((  - 0.850000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*STATES(:,37)+ power(STATES(:,7), 3.00000).*STATES(:,41)));
    ALGEBRAIC(:,91) = ( (( (CONSTANTS(:,104)./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ (( 0.0365000.*1.00000)./7.00000).*(exp(CONSTANTS(:,4)./67.3000) - 1.00000).*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))).*1.00000)./(1.00000+power(10.0000./STATES(:,3), 1.50000))).*CONSTANTS(:,6))./(CONSTANTS(:,6)+1.50000);
    ALGEBRAIC(:,92) = ( (( (CONSTANTS(:,122)./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ (( 0.0365000.*1.00000)./7.00000).*(exp(STATES(:,7)./67.3000) - 1.00000).*exp((  - STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))).*1.00000)./(1.00000+power(10.0000./STATES(:,3), 1.50000))).*STATES(:,8))./(STATES(:,8)+1.50000);
    RATES(:,3) =  - (ALGEBRAIC(:,36)+ALGEBRAIC(:,40)+ALGEBRAIC(:,41)+ALGEBRAIC(:,42)+ALGEBRAIC(:,79)+ALGEBRAIC(:,80)+ALGEBRAIC(:,83)+ALGEBRAIC(:,84)+ 3.00000.*ALGEBRAIC(:,89)+ 3.00000.*ALGEBRAIC(:,90)+ 3.00000.*ALGEBRAIC(:,91)+ 3.00000.*ALGEBRAIC(:,92))./( CONSTANTS(:,3).*CONSTANTS(:,87));
    ALGEBRAIC(:,93) =  (( 1.00000.*CONSTANTS(:,128))./CONSTANTS(:,72)).*(STATES(:,7) - CONSTANTS(:,4));
    RATES(:,7) = ((ALGEBRAIC(:,40)+ALGEBRAIC(:,42)+ALGEBRAIC(:,80)+ALGEBRAIC(:,84)+ 3.00000.*ALGEBRAIC(:,90)+ 3.00000.*ALGEBRAIC(:,92))./CONSTANTS(:,3) -  1.00000.*ALGEBRAIC(:,93))./CONSTANTS(:,128);
    ALGEBRAIC(:,44) = ( (( 1.00000.*CONSTANTS(:,124).*4.00000.*(STATES(:,30)+STATES(:,36)).*STATES(:,38).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.00100000.*exp(( 2.00000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.341000.*STATES(:,37)))./(exp(( 2.00000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,87) = ( log(STATES(:,37)./STATES(:,41)).*CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3));
    ALGEBRAIC(:,88) =  CONSTANTS(:,120).*(STATES(:,2) - ALGEBRAIC(:,87));
    ALGEBRAIC(:,95) = ( CONSTANTS(:,121).*STATES(:,41))./(0.000500000+STATES(:,41));
    ALGEBRAIC(:,97) =  (( 1.00000.*CONSTANTS(:,128))./CONSTANTS(:,73)).*(STATES(:,37) - CONSTANTS(:,5));
    RATES(:,37) = ((  - 2.00000.*ALGEBRAIC(:,90)+ALGEBRAIC(:,44)+ALGEBRAIC(:,88)+ALGEBRAIC(:,95))./( 2.00000.*CONSTANTS(:,3)) -  1.00000.*ALGEBRAIC(:,97))./CONSTANTS(:,128);
    ALGEBRAIC(:,15) =  1000.00.*(STATES(:,2)./CONSTANTS(:,90) - STATES(:,1)./CONSTANTS(:,90));
    ALGEBRAIC(:,30) = piecewise({VOI -  floor(VOI./CONSTANTS(:,49)).*CONSTANTS(:,49)>=0.00000&VOI -  floor(VOI./CONSTANTS(:,49)).*CONSTANTS(:,49)<=0.00100000,  45.0000.*(CONSTANTS(:,81)+CONSTANTS(:,91)) }, 0.00000);
    ALGEBRAIC(:,43) = ( (( 1.00000.*CONSTANTS(:,106).*4.00000.*(STATES(:,16)+STATES(:,22)).*STATES(:,24).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.00100000.*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.341000.*CONSTANTS(:,5)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,45) = ( (( (( 1.00000.*CONSTANTS(:,107))./(1.00000 - (ALGEBRAIC(:,43)+ALGEBRAIC(:,44))./( 0.458000.*(CONSTANTS(:,81)+CONSTANTS(:,91))))).*(STATES(:,16)+STATES(:,22)).*STATES(:,24).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( STATES(:,4).*exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,47) = ( log(CONSTANTS(:,6)./STATES(:,4)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,48) = 1.00000./(1.00000+exp((STATES(:,1)+9.00000)./22.4000));
    ALGEBRAIC(:,49) =  CONSTANTS(:,94).*0.0261400.*power((CONSTANTS(:,6)./5.40000), 1.0 ./ 2).*STATES(:,39).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,47));
    ALGEBRAIC(:,53) = ( log((CONSTANTS(:,6)+ CONSTANTS(:,64).*CONSTANTS(:,4))./(STATES(:,4)+ CONSTANTS(:,64).*STATES(:,3))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,54) =  CONSTANTS(:,95).*(0.230800+0.769200./(1.00000+exp(( - arbitrary_log( 1.00000.*STATES(:,41), 10) - 4.20000)./0.600000))).*power(STATES(:,42), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,53));
    ALGEBRAIC(:,57) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,58) = 1020.00./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,57)) - 59.2150)));
    ALGEBRAIC(:,59) = ( 1000.00.*( 0.491240.*exp( 0.0803200.*((STATES(:,1) - ALGEBRAIC(:,57))+5.47600))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,57)) - 594.310))))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,57))+4.75300)));
    ALGEBRAIC(:,60) =  (( CONSTANTS(:,98).*power((CONSTANTS(:,6)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,58))./(ALGEBRAIC(:,58)+ALGEBRAIC(:,59))).*(STATES(:,1) - ALGEBRAIC(:,57));
    ALGEBRAIC(:,66) = 1.00000./(1.00000+exp((20.0000 - STATES(:,1))./5.00000));
    ALGEBRAIC(:,65) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,67) =  CONSTANTS(:,96).*ALGEBRAIC(:,66).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,71) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,72) =  (CONSTANTS(:,97)./( (1.00000+exp((STATES(:,1)+57.5300)./ - 5.86300)).*(1.00000+exp((STATES(:,1) - 45.8000)./25.8700)))).*( STATES(:,44).*CONSTANTS(:,66)+ STATES(:,45).*(1.00000 - CONSTANTS(:,66))).*(STATES(:,1) - ALGEBRAIC(:,71));
    ALGEBRAIC(:,75) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,76) =  (( CONSTANTS(:,99).*(0.800000 - 0.650000./(1.00000+exp((STATES(:,1)+125.000)./15.0000))).*0.850000)./(1.00000+power(66.0000./STATES(:,3), 2.80000))).*(STATES(:,1) - ALGEBRAIC(:,75));
    ALGEBRAIC(:,81) = (( (( 1.00000.*CONSTANTS(:,109).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,4).*exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,85) = ( log(CONSTANTS(:,5)./STATES(:,41)).*CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3));
    ALGEBRAIC(:,86) =  CONSTANTS(:,102).*(STATES(:,1) - ALGEBRAIC(:,85));
    ALGEBRAIC(:,94) = ( CONSTANTS(:,103).*STATES(:,41))./(0.000500000+STATES(:,41));
    ALGEBRAIC(:,96) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,99) =  (( CONSTANTS(:,100).*1.00000)./(1.00000+power(CONSTANTS(:,7)./0.114000, 2.00000))).*power(CONSTANTS(:,6)./4.00000, 0.240000).*(STATES(:,1) - ALGEBRAIC(:,96));
    RATES(:,1) = ( 1000.00.*(((((((((((((((((((ALGEBRAIC(:,30)+ALGEBRAIC(:,15)) - ALGEBRAIC(:,36)) - ALGEBRAIC(:,41)) - ALGEBRAIC(:,43)) - ALGEBRAIC(:,45)) - ALGEBRAIC(:,54)) - ALGEBRAIC(:,49)) - ALGEBRAIC(:,60)) - ALGEBRAIC(:,67)) - ALGEBRAIC(:,76)) - ALGEBRAIC(:,99)) - ALGEBRAIC(:,79)) - ALGEBRAIC(:,81)) - ALGEBRAIC(:,83)) - ALGEBRAIC(:,86)) - ALGEBRAIC(:,89)) - ALGEBRAIC(:,91)) - ALGEBRAIC(:,94)) - ALGEBRAIC(:,72)))./CONSTANTS(:,130);
    ALGEBRAIC(:,98) = ( 1.00000.*1000.00.*CONSTANTS(:,87).*0.00180000.*power(STATES(:,41), 2.00000))./(power(STATES(:,41), 2.00000)+power(0.000500000, 2.00000));
    ALGEBRAIC(:,100) =  1250.00.*CONSTANTS(:,87).*5.80000e-05.*(STATES(:,48) - STATES(:,41));
    ALGEBRAIC(:,102) =  (( 1.00000.*CONSTANTS(:,86))./CONSTANTS(:,75)).*(STATES(:,48) - STATES(:,49));
    RATES(:,48) = ((ALGEBRAIC(:,98) - ALGEBRAIC(:,100)) - ALGEBRAIC(:,102))./( 1.00000.*CONSTANTS(:,88));
    ALGEBRAIC(:,104) =  1800.00.*CONSTANTS(:,86).*(STATES(:,51)+STATES(:,52)).*(STATES(:,49) - STATES(:,23));
    RATES(:,49) = ( (1.00000./(1.00000+( 15.0000.*0.800000)./power(0.800000+STATES(:,49), 2.00000))).*(ALGEBRAIC(:,102) - ALGEBRAIC(:,104)))./CONSTANTS(:,86);
    ALGEBRAIC(:,46) = ( (( (( 1.00000.*CONSTANTS(:,125))./(1.00000 - (ALGEBRAIC(:,43)+ALGEBRAIC(:,44))./( 0.458000.*(CONSTANTS(:,81)+CONSTANTS(:,91))))).*(STATES(:,30)+STATES(:,36)).*STATES(:,38).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( STATES(:,4).*exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - STATES(:,8)))./(exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,50) = ( log(STATES(:,8)./STATES(:,4)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,51) = 1.00000./(1.00000+exp((STATES(:,2)+9.00000)./22.4000));
    ALGEBRAIC(:,52) =  CONSTANTS(:,112).*0.0261400.*power((STATES(:,8)./5.40000), 1.0 ./ 2).*STATES(:,40).*ALGEBRAIC(:,51).*(STATES(:,2) - ALGEBRAIC(:,50));
    ALGEBRAIC(:,55) = ( log((STATES(:,8)+ CONSTANTS(:,65).*STATES(:,7))./(STATES(:,4)+ CONSTANTS(:,65).*STATES(:,3))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,56) =  CONSTANTS(:,113).*(0.230800+0.769200./(1.00000+exp(( - arbitrary_log( 1.00000.*STATES(:,41), 10) - 4.20000)./0.600000))).*power(STATES(:,43), 2.00000).*(STATES(:,2) - ALGEBRAIC(:,55));
    ALGEBRAIC(:,61) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,62) = 1020.00./(1.00000+exp( 0.238500.*((STATES(:,2) - ALGEBRAIC(:,61)) - 59.2150)));
    ALGEBRAIC(:,63) = ( 1000.00.*( 0.491240.*exp( 0.0803200.*((STATES(:,2) - ALGEBRAIC(:,61))+5.47600))+exp( 0.0617500.*((STATES(:,2) - ALGEBRAIC(:,61)) - 594.310))))./(1.00000+exp(  - 0.514300.*((STATES(:,2) - ALGEBRAIC(:,61))+4.75300)));
    ALGEBRAIC(:,64) =  (( CONSTANTS(:,116).*power((STATES(:,8)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,62))./(ALGEBRAIC(:,62)+ALGEBRAIC(:,63))).*(STATES(:,2) - ALGEBRAIC(:,61));
    ALGEBRAIC(:,69) = 1.00000./(1.00000+exp((20.0000 - STATES(:,2))./5.00000));
    ALGEBRAIC(:,68) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,70) =  CONSTANTS(:,114).*ALGEBRAIC(:,69).*(STATES(:,2) - ALGEBRAIC(:,68));
    ALGEBRAIC(:,73) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,74) =  (CONSTANTS(:,115)./( (1.00000+exp((STATES(:,2)+57.5300)./ - 5.86300)).*(1.00000+exp((STATES(:,2) - 45.8000)./25.8700)))).*( STATES(:,46).*CONSTANTS(:,69)+ STATES(:,47).*(1.00000 - CONSTANTS(:,69))).*(STATES(:,2) - ALGEBRAIC(:,73));
    ALGEBRAIC(:,77) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,78) =  (( CONSTANTS(:,117).*(0.800000 - 0.650000./(1.00000+exp((STATES(:,2)+125.000)./15.0000))).*0.850000)./(1.00000+power(66.0000./STATES(:,3), 2.80000))).*(STATES(:,2) - ALGEBRAIC(:,77));
    ALGEBRAIC(:,82) = (( (( 1.00000.*CONSTANTS(:,127).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,4).*exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*STATES(:,8)))./(exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,101) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,103) =  (( CONSTANTS(:,118).*1.00000)./(1.00000+power(CONSTANTS(:,7)./0.114000, 2.00000))).*power(STATES(:,8)./4.00000, 0.240000).*(STATES(:,2) - ALGEBRAIC(:,101));
    RATES(:,4) =  - ((((  - 0.00000.*ALGEBRAIC(:,30)+ALGEBRAIC(:,54)+ALGEBRAIC(:,56)+ALGEBRAIC(:,49)+ALGEBRAIC(:,52)+ALGEBRAIC(:,60)+ALGEBRAIC(:,64)+ALGEBRAIC(:,67)+ALGEBRAIC(:,70)+ALGEBRAIC(:,45)+ALGEBRAIC(:,46)+ALGEBRAIC(:,76)+ALGEBRAIC(:,78)+ALGEBRAIC(:,81)+ALGEBRAIC(:,82)) -  2.00000.*ALGEBRAIC(:,91)) -  2.00000.*ALGEBRAIC(:,92))+ALGEBRAIC(:,99)+ALGEBRAIC(:,103)+ALGEBRAIC(:,72)+ALGEBRAIC(:,74))./( CONSTANTS(:,3).*CONSTANTS(:,87));
    RATES(:,2) = ( 1000.00.*(((((((((((((((((( - ALGEBRAIC(:,15) - ALGEBRAIC(:,40)) - ALGEBRAIC(:,42)) - ALGEBRAIC(:,44)) - ALGEBRAIC(:,46)) - ALGEBRAIC(:,56)) - ALGEBRAIC(:,52)) - ALGEBRAIC(:,64)) - ALGEBRAIC(:,70)) - ALGEBRAIC(:,78)) - ALGEBRAIC(:,103)) - ALGEBRAIC(:,80)) - ALGEBRAIC(:,82)) - ALGEBRAIC(:,84)) - ALGEBRAIC(:,88)) - ALGEBRAIC(:,90)) - ALGEBRAIC(:,92)) - ALGEBRAIC(:,95)) - ALGEBRAIC(:,74)))./CONSTANTS(:,129);
    ALGEBRAIC(:,106) = ( 1.00000.*(STATES(:,23) - STATES(:,41)).*CONSTANTS(:,87))./CONSTANTS(:,80);
    RATES(:,23) =  (1.00000./(1.00000+( 0.0500000.*0.00238000)./power(0.00238000+STATES(:,23), 2.00000))).*(( - (ALGEBRAIC(:,43)+ALGEBRAIC(:,44))./( 2.00000.*CONSTANTS(:,3).*CONSTANTS(:,85))+( 1.00000.*ALGEBRAIC(:,104))./CONSTANTS(:,85)) - ( 1.00000.*ALGEBRAIC(:,106))./CONSTANTS(:,85));
    ALGEBRAIC(:,105) =  (( 1.00000.*CONSTANTS(:,128))./CONSTANTS(:,74)).*(STATES(:,8) - CONSTANTS(:,6));
    RATES(:,8) = ((((ALGEBRAIC(:,56)+ALGEBRAIC(:,52)+ALGEBRAIC(:,64)+ALGEBRAIC(:,70)+ALGEBRAIC(:,78)+ALGEBRAIC(:,46)+ALGEBRAIC(:,82)) -  2.00000.*ALGEBRAIC(:,92))+ALGEBRAIC(:,103)+ALGEBRAIC(:,74))./CONSTANTS(:,3) -  1.00000.*ALGEBRAIC(:,105))./CONSTANTS(:,128);
    ALGEBRAIC(:,107) =  20000.0.*STATES(:,41).*(1.00000 - STATES(:,54)) -  0.0700000.*STATES(:,54);
    RATES(:,54) = ALGEBRAIC(:,107);
    ALGEBRAIC(:,108) =  40000.0.*STATES(:,41).*(1.00000 - STATES(:,55)) -  STATES(:,55).*40.0000;
    RATES(:,41) =  (1.00000./(1.00000+( 0.0500000.*0.00238000)./power(0.00238000+STATES(:,41), 2.00000))).*((((  - 2.00000.*(ALGEBRAIC(:,89)+ALGEBRAIC(:,90))+ALGEBRAIC(:,86)+ALGEBRAIC(:,88)+ALGEBRAIC(:,94)+ALGEBRAIC(:,95))./(  - 2.00000.*CONSTANTS(:,3).*CONSTANTS(:,87))+( 1.00000.*((ALGEBRAIC(:,106)+ALGEBRAIC(:,100)) - ALGEBRAIC(:,98)))./CONSTANTS(:,87)) -  ALGEBRAIC(:,107).*0.140000) -  ALGEBRAIC(:,108).*0.0700000);
    RATES(:,55) = ALGEBRAIC(:,108);
   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(:,13) = 1.00600./(1.00000+exp((STATES(:,1)+36.6900+10.0000)./12.4300));
    ALGEBRAIC(:,14) = 1.00600./(1.00000+exp((STATES(:,2)+36.6900+10.0000)./12.4300));
    ALGEBRAIC(:,1) = 1.00000./(1.00000+exp(((STATES(:,1)+52.2000) - 9.00000)./ - 7.40000));
    ALGEBRAIC(:,16) = (0.00100000./( 101.600.*exp( STATES(:,1).*0.113500)+ 0.0226800.*exp(  - 0.0717000.*STATES(:,1)))+0.000100000)./4.83000;
    ALGEBRAIC(:,2) = 1.00000./(1.00000+exp(((STATES(:,1)+85.6000) - 9.00000)./5.50000));
    ALGEBRAIC(:,17) = (0.00100000./( 1.13810e-06.*exp(  - 0.101700.*STATES(:,1))+ 6.53700.*exp( STATES(:,1).*0.0801600))+0.000500000)./4.83000;
    ALGEBRAIC(:,3) = 1.00000./(1.00000+exp(((STATES(:,2)+52.2000) - 9.00000)./ - 7.40000));
    ALGEBRAIC(:,18) = (0.00100000./( 101.600.*exp( STATES(:,2).*0.113500)+ 0.0226800.*exp(  - 0.0717000.*STATES(:,2)))+0.000100000)./4.83000;
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp(((STATES(:,2)+85.6000) - 9.00000)./5.50000));
    ALGEBRAIC(:,19) = (0.00100000./( 1.13810e-06.*exp(  - 0.101700.*STATES(:,2))+ 6.53700.*exp( STATES(:,2).*0.0801600))+0.000500000)./4.83000;
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./6.00000));
    ALGEBRAIC(:,21) = 0.00100000./(0.0200000+ 0.0197000.*exp( - power( (STATES(:,1)+10.0000).*0.0337000, 2.00000)))+0.550000./(1.00000+exp( ((STATES(:,1)+40.0000)./9.50000).*4.00000));
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,2)+35.0000)./6.00000));
    ALGEBRAIC(:,23) = 0.00100000./(0.0200000+ 0.0197000.*exp( - power( (STATES(:,2)+10.0000).*0.0337000, 2.00000)))+0.550000./(1.00000+exp( ((STATES(:,2)+40.0000)./9.50000).*4.00000));
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+21.5000)./7.50000));
    ALGEBRAIC(:,24) = 0.00100000./(( 0.00138000.*(STATES(:,1)+14.2000))./(1.00000 - exp(  - 0.123000.*(STATES(:,1)+14.2000)))+( 0.000610000.*(STATES(:,1)+38.9000))./(exp( 0.145000.*(STATES(:,1)+38.9000)) - 1.00000));
    ALGEBRAIC(:,10) = 1.00000./(1.00000+exp( - (STATES(:,2)+21.5000)./7.50000));
    ALGEBRAIC(:,25) = 0.00100000./(( 0.00138000.*(STATES(:,2)+14.2000))./(1.00000 - exp(  - 0.123000.*(STATES(:,2)+14.2000)))+( 0.000610000.*(STATES(:,2)+38.9000))./(exp( 0.145000.*(STATES(:,2)+38.9000)) - 1.00000));
    ALGEBRAIC(:,11) = 1.00000./(1.00000+exp( - (STATES(:,1) - 1.50000)./16.7000));
    ALGEBRAIC(:,26) = 0.00100000./(( 7.19000e-05.*(STATES(:,1)+30.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,1)+30.0000)))+( 0.000131000.*(STATES(:,1)+30.0000))./(exp( 0.0687000.*(STATES(:,1)+30.0000)) - 1.00000));
    ALGEBRAIC(:,12) = 1.00000./(1.00000+exp( - (STATES(:,2) - 1.50000)./16.7000));
    ALGEBRAIC(:,27) = 0.00100000./(( 7.19000e-05.*(STATES(:,2)+30.0000))./(1.00000 - exp(  - 0.148000.*(STATES(:,2)+30.0000)))+( 0.000131000.*(STATES(:,2)+30.0000))./(exp( 0.0687000.*(STATES(:,2)+30.0000)) - 1.00000));
    ALGEBRAIC(:,28) = ALGEBRAIC(:,13);
    ALGEBRAIC(:,29) = ALGEBRAIC(:,14);
    ALGEBRAIC(:,5) =  400.000.*exp((STATES(:,1)+12.0000)./10.0000);
    ALGEBRAIC(:,20) =  50.0000.*exp( - (STATES(:,1)+12.0000)./13.0000);
    ALGEBRAIC(:,31) =  187.500.*STATES(:,23);
    ALGEBRAIC(:,22) =  400.000.*exp((STATES(:,2)+12.0000)./10.0000);
    ALGEBRAIC(:,32) =  50.0000.*exp( - (STATES(:,2)+12.0000)./13.0000);
    ALGEBRAIC(:,7) =  187.500.*STATES(:,23);
    ALGEBRAIC(:,34) =  ALGEBRAIC(:,5).*CONSTANTS(:,51);
    ALGEBRAIC(:,37) = ALGEBRAIC(:,20)./CONSTANTS(:,52);
    ALGEBRAIC(:,35) =  ALGEBRAIC(:,22).*CONSTANTS(:,58);
    ALGEBRAIC(:,38) = ALGEBRAIC(:,32)./CONSTANTS(:,59);
    ALGEBRAIC(:,36) =  CONSTANTS(:,92).*power(STATES(:,5), 3.00000).*STATES(:,6).*(STATES(:,1) - ( log((CONSTANTS(:,4)+ 0.120000.*CONSTANTS(:,6))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,40) =  CONSTANTS(:,110).*power(STATES(:,9), 3.00000).*STATES(:,10).*(STATES(:,2) - ( log((STATES(:,7)+ 0.120000.*STATES(:,8))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,41) =  (CONSTANTS(:,93)./(1.00000+exp(( - 54.0000 - STATES(:,1))./8.00000))).*(STATES(:,1) - ( log((CONSTANTS(:,4)+ 0.120000.*CONSTANTS(:,6))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,42) =  (CONSTANTS(:,111)./(1.00000+exp(( - 54.0000 - STATES(:,2))./8.00000))).*(STATES(:,2) - ( log((STATES(:,7)+ 0.120000.*STATES(:,8))./(STATES(:,3)+ 0.120000.*STATES(:,4))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3));
    ALGEBRAIC(:,79) = (( (( 1.00000.*CONSTANTS(:,108).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,3).*exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*CONSTANTS(:,4)))./(exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,80) = (( (( 1.00000.*CONSTANTS(:,126).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,3).*exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*STATES(:,7)))./(exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,33) = ( log(CONSTANTS(:,4)./STATES(:,3)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,83) =  CONSTANTS(:,101).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,39) = ( log(STATES(:,7)./STATES(:,3)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,84) =  CONSTANTS(:,119).*(STATES(:,2) - ALGEBRAIC(:,39));
    ALGEBRAIC(:,89) = ( CONSTANTS(:,105).*exp((  - 0.850000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,5) -  power(CONSTANTS(:,4), 3.00000).*STATES(:,41)))./(1.00000+ 0.000100000.*exp((  - 0.850000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*CONSTANTS(:,5)+ power(CONSTANTS(:,4), 3.00000).*STATES(:,41)));
    ALGEBRAIC(:,90) = ( CONSTANTS(:,123).*exp((  - 0.850000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*STATES(:,37) -  power(STATES(:,7), 3.00000).*STATES(:,41)))./(1.00000+ 0.000100000.*exp((  - 0.850000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*power(STATES(:,3), 3.00000).*STATES(:,37)+ power(STATES(:,7), 3.00000).*STATES(:,41)));
    ALGEBRAIC(:,91) = ( (( (CONSTANTS(:,104)./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ (( 0.0365000.*1.00000)./7.00000).*(exp(CONSTANTS(:,4)./67.3000) - 1.00000).*exp((  - STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))).*1.00000)./(1.00000+power(10.0000./STATES(:,3), 1.50000))).*CONSTANTS(:,6))./(CONSTANTS(:,6)+1.50000);
    ALGEBRAIC(:,92) = ( (( (CONSTANTS(:,122)./(1.00000+ 0.124500.*exp((  - 0.100000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2)))+ (( 0.0365000.*1.00000)./7.00000).*(exp(STATES(:,7)./67.3000) - 1.00000).*exp((  - STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))))).*1.00000)./(1.00000+power(10.0000./STATES(:,3), 1.50000))).*STATES(:,8))./(STATES(:,8)+1.50000);
    ALGEBRAIC(:,93) =  (( 1.00000.*CONSTANTS(:,128))./CONSTANTS(:,72)).*(STATES(:,7) - CONSTANTS(:,4));
    ALGEBRAIC(:,44) = ( (( 1.00000.*CONSTANTS(:,124).*4.00000.*(STATES(:,30)+STATES(:,36)).*STATES(:,38).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.00100000.*exp(( 2.00000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.341000.*STATES(:,37)))./(exp(( 2.00000.*STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,87) = ( log(STATES(:,37)./STATES(:,41)).*CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3));
    ALGEBRAIC(:,88) =  CONSTANTS(:,120).*(STATES(:,2) - ALGEBRAIC(:,87));
    ALGEBRAIC(:,95) = ( CONSTANTS(:,121).*STATES(:,41))./(0.000500000+STATES(:,41));
    ALGEBRAIC(:,97) =  (( 1.00000.*CONSTANTS(:,128))./CONSTANTS(:,73)).*(STATES(:,37) - CONSTANTS(:,5));
    ALGEBRAIC(:,15) =  1000.00.*(STATES(:,2)./CONSTANTS(:,90) - STATES(:,1)./CONSTANTS(:,90));
    ALGEBRAIC(:,30) = piecewise({VOI -  floor(VOI./CONSTANTS(:,49)).*CONSTANTS(:,49)>=0.00000&VOI -  floor(VOI./CONSTANTS(:,49)).*CONSTANTS(:,49)<=0.00100000,  45.0000.*(CONSTANTS(:,81)+CONSTANTS(:,91)) }, 0.00000);
    ALGEBRAIC(:,43) = ( (( 1.00000.*CONSTANTS(:,106).*4.00000.*(STATES(:,16)+STATES(:,22)).*STATES(:,24).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.00100000.*exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.341000.*CONSTANTS(:,5)))./(exp(( 2.00000.*STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,45) = ( (( (( 1.00000.*CONSTANTS(:,107))./(1.00000 - (ALGEBRAIC(:,43)+ALGEBRAIC(:,44))./( 0.458000.*(CONSTANTS(:,81)+CONSTANTS(:,91))))).*(STATES(:,16)+STATES(:,22)).*STATES(:,24).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( STATES(:,4).*exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,47) = ( log(CONSTANTS(:,6)./STATES(:,4)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,48) = 1.00000./(1.00000+exp((STATES(:,1)+9.00000)./22.4000));
    ALGEBRAIC(:,49) =  CONSTANTS(:,94).*0.0261400.*power((CONSTANTS(:,6)./5.40000), 1.0 ./ 2).*STATES(:,39).*ALGEBRAIC(:,48).*(STATES(:,1) - ALGEBRAIC(:,47));
    ALGEBRAIC(:,53) = ( log((CONSTANTS(:,6)+ CONSTANTS(:,64).*CONSTANTS(:,4))./(STATES(:,4)+ CONSTANTS(:,64).*STATES(:,3))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,54) =  CONSTANTS(:,95).*(0.230800+0.769200./(1.00000+exp(( - arbitrary_log( 1.00000.*STATES(:,41), 10) - 4.20000)./0.600000))).*power(STATES(:,42), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,53));
    ALGEBRAIC(:,57) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,58) = 1020.00./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,57)) - 59.2150)));
    ALGEBRAIC(:,59) = ( 1000.00.*( 0.491240.*exp( 0.0803200.*((STATES(:,1) - ALGEBRAIC(:,57))+5.47600))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,57)) - 594.310))))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,57))+4.75300)));
    ALGEBRAIC(:,60) =  (( CONSTANTS(:,98).*power((CONSTANTS(:,6)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,58))./(ALGEBRAIC(:,58)+ALGEBRAIC(:,59))).*(STATES(:,1) - ALGEBRAIC(:,57));
    ALGEBRAIC(:,66) = 1.00000./(1.00000+exp((20.0000 - STATES(:,1))./5.00000));
    ALGEBRAIC(:,65) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,67) =  CONSTANTS(:,96).*ALGEBRAIC(:,66).*(STATES(:,1) - ALGEBRAIC(:,65));
    ALGEBRAIC(:,71) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,72) =  (CONSTANTS(:,97)./( (1.00000+exp((STATES(:,1)+57.5300)./ - 5.86300)).*(1.00000+exp((STATES(:,1) - 45.8000)./25.8700)))).*( STATES(:,44).*CONSTANTS(:,66)+ STATES(:,45).*(1.00000 - CONSTANTS(:,66))).*(STATES(:,1) - ALGEBRAIC(:,71));
    ALGEBRAIC(:,75) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,76) =  (( CONSTANTS(:,99).*(0.800000 - 0.650000./(1.00000+exp((STATES(:,1)+125.000)./15.0000))).*0.850000)./(1.00000+power(66.0000./STATES(:,3), 2.80000))).*(STATES(:,1) - ALGEBRAIC(:,75));
    ALGEBRAIC(:,81) = (( (( 1.00000.*CONSTANTS(:,109).*STATES(:,1).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,4).*exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*CONSTANTS(:,6)))./(exp(( STATES(:,1).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,85) = ( log(CONSTANTS(:,5)./STATES(:,41)).*CONSTANTS(:,1).*CONSTANTS(:,2))./( 2.00000.*CONSTANTS(:,3));
    ALGEBRAIC(:,86) =  CONSTANTS(:,102).*(STATES(:,1) - ALGEBRAIC(:,85));
    ALGEBRAIC(:,94) = ( CONSTANTS(:,103).*STATES(:,41))./(0.000500000+STATES(:,41));
    ALGEBRAIC(:,96) = ALGEBRAIC(:,47);
    ALGEBRAIC(:,99) =  (( CONSTANTS(:,100).*1.00000)./(1.00000+power(CONSTANTS(:,7)./0.114000, 2.00000))).*power(CONSTANTS(:,6)./4.00000, 0.240000).*(STATES(:,1) - ALGEBRAIC(:,96));
    ALGEBRAIC(:,98) = ( 1.00000.*1000.00.*CONSTANTS(:,87).*0.00180000.*power(STATES(:,41), 2.00000))./(power(STATES(:,41), 2.00000)+power(0.000500000, 2.00000));
    ALGEBRAIC(:,100) =  1250.00.*CONSTANTS(:,87).*5.80000e-05.*(STATES(:,48) - STATES(:,41));
    ALGEBRAIC(:,102) =  (( 1.00000.*CONSTANTS(:,86))./CONSTANTS(:,75)).*(STATES(:,48) - STATES(:,49));
    ALGEBRAIC(:,104) =  1800.00.*CONSTANTS(:,86).*(STATES(:,51)+STATES(:,52)).*(STATES(:,49) - STATES(:,23));
    ALGEBRAIC(:,46) = ( (( (( 1.00000.*CONSTANTS(:,125))./(1.00000 - (ALGEBRAIC(:,43)+ALGEBRAIC(:,44))./( 0.458000.*(CONSTANTS(:,81)+CONSTANTS(:,91))))).*(STATES(:,30)+STATES(:,36)).*STATES(:,38).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( STATES(:,4).*exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - STATES(:,8)))./(exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000);
    ALGEBRAIC(:,50) = ( log(STATES(:,8)./STATES(:,4)).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,51) = 1.00000./(1.00000+exp((STATES(:,2)+9.00000)./22.4000));
    ALGEBRAIC(:,52) =  CONSTANTS(:,112).*0.0261400.*power((STATES(:,8)./5.40000), 1.0 ./ 2).*STATES(:,40).*ALGEBRAIC(:,51).*(STATES(:,2) - ALGEBRAIC(:,50));
    ALGEBRAIC(:,55) = ( log((STATES(:,8)+ CONSTANTS(:,65).*STATES(:,7))./(STATES(:,4)+ CONSTANTS(:,65).*STATES(:,3))).*CONSTANTS(:,1).*CONSTANTS(:,2))./CONSTANTS(:,3);
    ALGEBRAIC(:,56) =  CONSTANTS(:,113).*(0.230800+0.769200./(1.00000+exp(( - arbitrary_log( 1.00000.*STATES(:,41), 10) - 4.20000)./0.600000))).*power(STATES(:,43), 2.00000).*(STATES(:,2) - ALGEBRAIC(:,55));
    ALGEBRAIC(:,61) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,62) = 1020.00./(1.00000+exp( 0.238500.*((STATES(:,2) - ALGEBRAIC(:,61)) - 59.2150)));
    ALGEBRAIC(:,63) = ( 1000.00.*( 0.491240.*exp( 0.0803200.*((STATES(:,2) - ALGEBRAIC(:,61))+5.47600))+exp( 0.0617500.*((STATES(:,2) - ALGEBRAIC(:,61)) - 594.310))))./(1.00000+exp(  - 0.514300.*((STATES(:,2) - ALGEBRAIC(:,61))+4.75300)));
    ALGEBRAIC(:,64) =  (( CONSTANTS(:,116).*power((STATES(:,8)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,62))./(ALGEBRAIC(:,62)+ALGEBRAIC(:,63))).*(STATES(:,2) - ALGEBRAIC(:,61));
    ALGEBRAIC(:,69) = 1.00000./(1.00000+exp((20.0000 - STATES(:,2))./5.00000));
    ALGEBRAIC(:,68) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,70) =  CONSTANTS(:,114).*ALGEBRAIC(:,69).*(STATES(:,2) - ALGEBRAIC(:,68));
    ALGEBRAIC(:,73) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,74) =  (CONSTANTS(:,115)./( (1.00000+exp((STATES(:,2)+57.5300)./ - 5.86300)).*(1.00000+exp((STATES(:,2) - 45.8000)./25.8700)))).*( STATES(:,46).*CONSTANTS(:,69)+ STATES(:,47).*(1.00000 - CONSTANTS(:,69))).*(STATES(:,2) - ALGEBRAIC(:,73));
    ALGEBRAIC(:,77) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,78) =  (( CONSTANTS(:,117).*(0.800000 - 0.650000./(1.00000+exp((STATES(:,2)+125.000)./15.0000))).*0.850000)./(1.00000+power(66.0000./STATES(:,3), 2.80000))).*(STATES(:,2) - ALGEBRAIC(:,77));
    ALGEBRAIC(:,82) = (( (( 1.00000.*CONSTANTS(:,127).*STATES(:,2).*power(CONSTANTS(:,3), 2.00000))./( CONSTANTS(:,1).*CONSTANTS(:,2))).*( 0.750000.*STATES(:,4).*exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) -  0.750000.*STATES(:,8)))./(exp(( STATES(:,2).*CONSTANTS(:,3))./( CONSTANTS(:,1).*CONSTANTS(:,2))) - 1.00000))./(1.00000+power(0.00250000./STATES(:,41), 3.00000));
    ALGEBRAIC(:,101) = ALGEBRAIC(:,50);
    ALGEBRAIC(:,103) =  (( CONSTANTS(:,118).*1.00000)./(1.00000+power(CONSTANTS(:,7)./0.114000, 2.00000))).*power(STATES(:,8)./4.00000, 0.240000).*(STATES(:,2) - ALGEBRAIC(:,101));
    ALGEBRAIC(:,106) = ( 1.00000.*(STATES(:,23) - STATES(:,41)).*CONSTANTS(:,87))./CONSTANTS(:,80);
    ALGEBRAIC(:,105) =  (( 1.00000.*CONSTANTS(:,128))./CONSTANTS(:,74)).*(STATES(:,8) - CONSTANTS(:,6));
    ALGEBRAIC(:,107) =  20000.0.*STATES(:,41).*(1.00000 - STATES(:,54)) -  0.0700000.*STATES(:,54);
    ALGEBRAIC(:,108) =  40000.0.*STATES(:,41).*(1.00000 - STATES(:,55)) -  STATES(:,55).*40.0000;
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

% Compute a logarithm to any base" +
function x = arbitrary_log(a, base)
    x = log(a) ./ log(base);
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