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 =114;
end
% There are a total of 39 entries in each of the rate and state variable arrays.
% There are a total of 124 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_ALGEBRAIC(:,10) = strpad('I_app in component Protocol (uA_per_uF)');
    LEGEND_VOI = strpad('time in component environment (msec)');
    LEGEND_STATES(:,1) = strpad('V_m in component membrane_potential (mV)');
    LEGEND_CONSTANTS(:,1) = strpad('epi in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,2) = strpad('R in component parameters (joule_per_kelvin_per_kilomole)');
    LEGEND_CONSTANTS(:,96) = strpad('Frdy in component parameters (coulomb_per_mole)');
    LEGEND_CONSTANTS(:,106) = strpad('Temp in component parameters (kelvin)');
    LEGEND_CONSTANTS(:,110) = strpad('FoRT in component parameters (per_mV)');
    LEGEND_CONSTANTS(:,3) = strpad('Cmem in component parameters (farad)');
    LEGEND_CONSTANTS(:,111) = strpad('Qpow in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,4) = strpad('cellLength in component parameters (um)');
    LEGEND_CONSTANTS(:,97) = strpad('cellRadius in component parameters (um)');
    LEGEND_CONSTANTS(:,5) = strpad('junctionLength in component parameters (um)');
    LEGEND_CONSTANTS(:,98) = strpad('junctionRadius in component parameters (um)');
    LEGEND_CONSTANTS(:,6) = strpad('distSLcyto in component parameters (um)');
    LEGEND_CONSTANTS(:,7) = strpad('distJuncSL in component parameters (um)');
    LEGEND_CONSTANTS(:,8) = strpad('DcaJuncSL in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,9) = strpad('DcaSLcyto in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,10) = strpad('DnaJuncSL in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,11) = strpad('DnaSLcyto in component parameters (cm2_per_sec)');
    LEGEND_CONSTANTS(:,107) = strpad('Vcell in component parameters (liter)');
    LEGEND_CONSTANTS(:,112) = strpad('Vmyo in component parameters (liter)');
    LEGEND_CONSTANTS(:,113) = strpad('Vsr in component parameters (liter)');
    LEGEND_CONSTANTS(:,114) = strpad('Vsl in component parameters (liter)');
    LEGEND_CONSTANTS(:,115) = strpad('Vjunc in component parameters (liter)');
    LEGEND_CONSTANTS(:,108) = strpad('SAjunc in component parameters (um2)');
    LEGEND_CONSTANTS(:,109) = strpad('SAsl in component parameters (um2)');
    LEGEND_CONSTANTS(:,12) = strpad('J_ca_juncsl in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,13) = strpad('J_ca_slmyo in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,14) = strpad('J_na_juncsl in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,15) = strpad('J_na_slmyo in component parameters (liters_per_msec)');
    LEGEND_CONSTANTS(:,16) = strpad('Fjunc in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,99) = strpad('Fsl in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,17) = strpad('Fjunc_CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,100) = strpad('Fsl_CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,116) = strpad('Cli in component parameters (mM)');
    LEGEND_CONSTANTS(:,117) = strpad('Clo in component parameters (mM)');
    LEGEND_CONSTANTS(:,18) = strpad('Ko in component parameters (mM)');
    LEGEND_CONSTANTS(:,19) = strpad('Nao in component parameters (mM)');
    LEGEND_CONSTANTS(:,20) = strpad('Cao in component parameters (mM)');
    LEGEND_CONSTANTS(:,21) = strpad('Mgi in component parameters (mM)');
    LEGEND_ALGEBRAIC(:,23) = strpad('ena_junc in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,27) = strpad('ena_sl in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,31) = strpad('ek in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,33) = strpad('eca_junc in component parameters (mV)');
    LEGEND_ALGEBRAIC(:,34) = strpad('eca_sl in component parameters (mV)');
    LEGEND_CONSTANTS(:,123) = strpad('ecl in component parameters (mV)');
    LEGEND_CONSTANTS(:,22) = strpad('GNa in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,23) = strpad('GNaB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,24) = strpad('IbarNaK in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,25) = strpad('KmNaip in component parameters (mM)');
    LEGEND_CONSTANTS(:,26) = strpad('KmKo in component parameters (mM)');
    LEGEND_CONSTANTS(:,27) = strpad('Q10NaK in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,28) = strpad('Q10KmNai in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,29) = strpad('pNaK in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,30) = strpad('gkp in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,31) = strpad('GClCa in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,32) = strpad('GClB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,33) = strpad('KdClCa in component parameters (mM)');
    LEGEND_CONSTANTS(:,34) = strpad('pNa in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,35) = strpad('pCa in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,36) = strpad('pK in component parameters (cm_per_sec)');
    LEGEND_CONSTANTS(:,37) = strpad('Q10CaL in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,38) = strpad('IbarNCX in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,39) = strpad('KmCai in component parameters (mM)');
    LEGEND_CONSTANTS(:,40) = strpad('KmCao in component parameters (mM)');
    LEGEND_CONSTANTS(:,41) = strpad('KmNai in component parameters (mM)');
    LEGEND_CONSTANTS(:,42) = strpad('KmNao in component parameters (mM)');
    LEGEND_CONSTANTS(:,43) = strpad('ksat in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,44) = strpad('nu in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,45) = strpad('Kdact in component parameters (mM)');
    LEGEND_CONSTANTS(:,46) = strpad('Q10NCX in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,47) = strpad('IbarSLCaP in component parameters (uA_per_uF)');
    LEGEND_CONSTANTS(:,48) = strpad('KmPCa in component parameters (mM)');
    LEGEND_CONSTANTS(:,49) = strpad('GCaB in component parameters (mS_per_uF)');
    LEGEND_CONSTANTS(:,50) = strpad('Q10SLCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,51) = strpad('Q10SRCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,52) = strpad('Vmax_SRCaP in component parameters (mM_per_msec)');
    LEGEND_CONSTANTS(:,53) = strpad('Kmf in component parameters (mM)');
    LEGEND_CONSTANTS(:,54) = strpad('Kmr in component parameters (mM)');
    LEGEND_CONSTANTS(:,55) = strpad('hillSRCaP in component parameters (dimensionless)');
    LEGEND_CONSTANTS(:,56) = strpad('ks in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,57) = strpad('koCa in component parameters (per_mM2_per_msec)');
    LEGEND_CONSTANTS(:,58) = strpad('kom in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,105) = strpad('kiCa in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,59) = strpad('kim in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,60) = strpad('ec50SR in component parameters (mM)');
    LEGEND_CONSTANTS(:,61) = strpad('Bmax_Naj in component parameters (mM)');
    LEGEND_CONSTANTS(:,62) = strpad('Bmax_Nasl in component parameters (mM)');
    LEGEND_CONSTANTS(:,63) = strpad('koff_na in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,64) = strpad('kon_na in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,65) = strpad('Bmax_TnClow in component parameters (mM)');
    LEGEND_CONSTANTS(:,66) = strpad('koff_tncl in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,67) = strpad('kon_tncl in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,68) = strpad('Bmax_TnChigh in component parameters (mM)');
    LEGEND_CONSTANTS(:,69) = strpad('koff_tnchca in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,70) = strpad('kon_tnchca in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,71) = strpad('koff_tnchmg in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,72) = strpad('kon_tnchmg in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,73) = strpad('Bmax_CaM in component parameters (mM)');
    LEGEND_CONSTANTS(:,74) = strpad('koff_cam in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,75) = strpad('kon_cam in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,76) = strpad('Bmax_myosin in component parameters (mM)');
    LEGEND_CONSTANTS(:,77) = strpad('koff_myoca in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,78) = strpad('kon_myoca in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,79) = strpad('koff_myomg in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,80) = strpad('kon_myomg in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,81) = strpad('Bmax_SR in component parameters (mM)');
    LEGEND_CONSTANTS(:,82) = strpad('koff_sr in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,83) = strpad('kon_sr in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,118) = strpad('Bmax_SLlowsl in component parameters (mM)');
    LEGEND_CONSTANTS(:,119) = strpad('Bmax_SLlowj in component parameters (mM)');
    LEGEND_CONSTANTS(:,84) = strpad('koff_sll in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,85) = strpad('kon_sll in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,120) = strpad('Bmax_SLhighsl in component parameters (mM)');
    LEGEND_CONSTANTS(:,121) = strpad('Bmax_SLhighj in component parameters (mM)');
    LEGEND_CONSTANTS(:,86) = strpad('koff_slh in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,87) = strpad('kon_slh in component parameters (per_mM_per_msec)');
    LEGEND_CONSTANTS(:,122) = strpad('Bmax_Csqn in component parameters (mM)');
    LEGEND_CONSTANTS(:,88) = strpad('koff_csqn in component parameters (per_msec)');
    LEGEND_CONSTANTS(:,89) = strpad('kon_csqn in component parameters (per_mM_per_msec)');
    LEGEND_STATES(:,2) = strpad('Na_j in component Na_Concentrations (mM)');
    LEGEND_STATES(:,3) = strpad('Na_sl in component Na_Concentrations (mM)');
    LEGEND_STATES(:,4) = strpad('K_i in component K_Concentration (mM)');
    LEGEND_STATES(:,5) = strpad('Ca_j in component Ca_Concentrations (mM)');
    LEGEND_STATES(:,6) = strpad('Ca_sl in component Ca_Concentrations (mM)');
    LEGEND_ALGEBRAIC(:,1) = strpad('mss in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,12) = strpad('taum in component I_Na (msec)');
    LEGEND_ALGEBRAIC(:,2) = strpad('ah in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,13) = strpad('bh in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,25) = strpad('tauh in component I_Na (msec)');
    LEGEND_ALGEBRAIC(:,29) = strpad('hss in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,3) = strpad('aj in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,14) = strpad('bj in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,26) = strpad('tauj in component I_Na (msec)');
    LEGEND_ALGEBRAIC(:,30) = strpad('jss in component I_Na (dimensionless)');
    LEGEND_STATES(:,7) = strpad('m in component I_Na (dimensionless)');
    LEGEND_STATES(:,8) = strpad('h in component I_Na (dimensionless)');
    LEGEND_STATES(:,9) = strpad('j in component I_Na (dimensionless)');
    LEGEND_ALGEBRAIC(:,35) = strpad('I_Na_junc in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,36) = strpad('I_Na_sl in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,37) = strpad('I_Na in component I_Na (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,38) = strpad('I_nabk_junc in component I_NaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,39) = strpad('I_nabk_sl in component I_NaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,40) = strpad('I_nabk in component I_NaBK (uA_per_uF)');
    LEGEND_CONSTANTS(:,101) = strpad('sigma in component I_NaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,41) = strpad('fnak in component I_NaK (dimensionless)');
    LEGEND_ALGEBRAIC(:,42) = strpad('I_nak_junc in component I_NaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,43) = strpad('I_nak_sl in component I_NaK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,44) = strpad('I_nak in component I_NaK (uA_per_uF)');
    LEGEND_CONSTANTS(:,102) = strpad('gkr in component I_Kr (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,4) = strpad('xrss in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,15) = strpad('tauxr in component I_Kr (msec)');
    LEGEND_STATES(:,10) = strpad('x_kr in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,45) = strpad('rkr in component I_Kr (dimensionless)');
    LEGEND_ALGEBRAIC(:,46) = strpad('I_kr in component I_Kr (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,47) = strpad('kp_kp in component I_Kp (dimensionless)');
    LEGEND_ALGEBRAIC(:,48) = strpad('I_kp_junc in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,49) = strpad('I_kp_sl in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,50) = strpad('I_kp in component I_Kp (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,51) = strpad('eks in component I_Ks (mV)');
    LEGEND_CONSTANTS(:,90) = strpad('gks_junc in component I_Ks (mS_per_uF)');
    LEGEND_CONSTANTS(:,91) = strpad('gks_sl in component I_Ks (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,5) = strpad('xsss in component I_Ks (dimensionless)');
    LEGEND_ALGEBRAIC(:,16) = strpad('tauxs in component I_Ks (msec)');
    LEGEND_STATES(:,11) = strpad('x_ks in component I_Ks (dimensionless)');
    LEGEND_ALGEBRAIC(:,52) = strpad('I_ks_junc in component I_Ks (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,53) = strpad('I_ks_sl in component I_Ks (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,54) = strpad('I_ks in component I_Ks (uA_per_uF)');
    LEGEND_STATES(:,12) = strpad('Na_i in component Na_Concentrations (mM)');
    LEGEND_CONSTANTS(:,103) = strpad('GtoSlow in component I_to (mS_per_uF)');
    LEGEND_CONSTANTS(:,104) = strpad('GtoFast in component I_to (mS_per_uF)');
    LEGEND_ALGEBRAIC(:,6) = strpad('xtoss in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,7) = strpad('ytoss in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,17) = strpad('tauxtos in component I_to (msec)');
    LEGEND_ALGEBRAIC(:,18) = strpad('tauytos in component I_to (msec)');
    LEGEND_STATES(:,13) = strpad('x_to_s in component I_to (dimensionless)');
    LEGEND_STATES(:,14) = strpad('y_to_s in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,55) = strpad('I_tos in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,19) = strpad('tauxtof in component I_to (msec)');
    LEGEND_ALGEBRAIC(:,20) = strpad('tauytof in component I_to (msec)');
    LEGEND_STATES(:,15) = strpad('x_to_f in component I_to (dimensionless)');
    LEGEND_STATES(:,16) = strpad('y_to_f in component I_to (dimensionless)');
    LEGEND_ALGEBRAIC(:,56) = strpad('I_tof in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,57) = strpad('I_to in component I_to (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,58) = strpad('aki in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,59) = strpad('bki in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,60) = strpad('kiss in component I_Ki (dimensionless)');
    LEGEND_ALGEBRAIC(:,61) = strpad('I_ki in component I_Ki (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,62) = strpad('I_ClCa_junc in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,63) = strpad('I_ClCa_sl in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,64) = strpad('I_ClCa in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,65) = strpad('I_Clbk in component I_ClCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,8) = strpad('fss in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,9) = strpad('dss in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,21) = strpad('taud in component I_Ca (msec)');
    LEGEND_ALGEBRAIC(:,22) = strpad('tauf in component I_Ca (msec)');
    LEGEND_STATES(:,17) = strpad('d in component I_Ca (dimensionless)');
    LEGEND_STATES(:,18) = strpad('f in component I_Ca (dimensionless)');
    LEGEND_STATES(:,19) = strpad('f_Ca_Bj in component I_Ca (dimensionless)');
    LEGEND_STATES(:,20) = strpad('f_Ca_Bsl in component I_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,92) = strpad('fcaCaMSL in component I_Ca (dimensionless)');
    LEGEND_CONSTANTS(:,93) = strpad('fcaCaj in component I_Ca (dimensionless)');
    LEGEND_ALGEBRAIC(:,66) = strpad('ibarca_j in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,67) = strpad('ibarca_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,68) = strpad('ibark in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,69) = strpad('ibarna_j in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,70) = strpad('ibarna_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,71) = strpad('I_Ca_junc in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,72) = strpad('I_Ca_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,73) = strpad('I_Ca in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,74) = strpad('I_CaK in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,75) = strpad('I_CaNa_junc in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,76) = strpad('I_CaNa_sl in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,77) = strpad('I_CaNa in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,79) = strpad('I_Catot in component I_Ca (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,78) = strpad('Ka_junc in component I_NCX (dimensionless)');
    LEGEND_ALGEBRAIC(:,80) = strpad('Ka_sl in component I_NCX (dimensionless)');
    LEGEND_ALGEBRAIC(:,81) = strpad('s1_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,82) = strpad('s1_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,83) = strpad('s2_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,84) = strpad('s3_junc in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,85) = strpad('s2_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,86) = strpad('s3_sl in component I_NCX (mM4)');
    LEGEND_ALGEBRAIC(:,87) = strpad('I_ncx_junc in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,88) = strpad('I_ncx_sl in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,90) = strpad('I_ncx in component I_NCX (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,91) = strpad('I_pca_junc in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,93) = strpad('I_pca_sl in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,94) = strpad('I_pca in component I_PCa (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,95) = strpad('I_cabk_junc in component I_CaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,96) = strpad('I_cabk_sl in component I_CaBK (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,97) = strpad('I_cabk in component I_CaBK (uA_per_uF)');
    LEGEND_CONSTANTS(:,94) = strpad('MaxSR in component SR_Fluxes (dimensionless)');
    LEGEND_CONSTANTS(:,95) = strpad('MinSR in component SR_Fluxes (dimensionless)');
    LEGEND_ALGEBRAIC(:,11) = strpad('kCaSR in component SR_Fluxes (dimensionless)');
    LEGEND_ALGEBRAIC(:,24) = strpad('koSRCa in component SR_Fluxes (per_mM2_per_msec)');
    LEGEND_ALGEBRAIC(:,28) = strpad('kiSRCa in component SR_Fluxes (per_mM_per_msec)');
    LEGEND_ALGEBRAIC(:,32) = strpad('RI in component SR_Fluxes (mM)');
    LEGEND_STATES(:,21) = strpad('Ry_Rr in component SR_Fluxes (mM)');
    LEGEND_STATES(:,22) = strpad('Ry_Ro in component SR_Fluxes (mM)');
    LEGEND_STATES(:,23) = strpad('Ry_Ri in component SR_Fluxes (mM)');
    LEGEND_ALGEBRAIC(:,98) = strpad('J_SRCarel in component SR_Fluxes (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,99) = strpad('J_serca in component SR_Fluxes (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,100) = strpad('J_SRleak in component SR_Fluxes (mM_per_msec)');
    LEGEND_STATES(:,24) = strpad('Ca_sr in component SR_Ca_Concentrations (mM)');
    LEGEND_STATES(:,25) = strpad('Ca_i in component Ca_Concentrations (mM)');
    LEGEND_STATES(:,26) = strpad('Na_Bj in component Na_Buffers (mM)');
    LEGEND_STATES(:,27) = strpad('Na_Bsl in component Na_Buffers (mM)');
    LEGEND_ALGEBRAIC(:,102) = strpad('dNa_Bj_dt in component Na_Buffers (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,103) = strpad('dNa_Bsl_dt in component Na_Buffers (mM_per_msec)');
    LEGEND_STATES(:,28) = strpad('Tn_CL in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,29) = strpad('Tn_CHc in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,30) = strpad('Tn_CHm in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,31) = strpad('CaM in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,32) = strpad('Myo_c in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,33) = strpad('Myo_m in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_STATES(:,34) = strpad('SRB in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_ALGEBRAIC(:,101) = strpad('J_CaB_cytosol in component Cytosolic_Ca_Buffers (mM_per_msec)');
    LEGEND_STATES(:,35) = strpad('SLL_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_STATES(:,36) = strpad('SLL_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_STATES(:,37) = strpad('SLH_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_STATES(:,38) = strpad('SLH_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_ALGEBRAIC(:,104) = strpad('J_CaB_junction in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
    LEGEND_ALGEBRAIC(:,105) = strpad('J_CaB_sl in component Junctional_and_SL_Ca_Buffers (mM_per_msec)');
    LEGEND_STATES(:,39) = strpad('Csqn_b in component SR_Ca_Concentrations (mM)');
    LEGEND_ALGEBRAIC(:,106) = strpad('I_Na_tot_junc in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,107) = strpad('I_Na_tot_sl in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,92) = strpad('I_Na_tot_sl2 in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,89) = strpad('I_Na_tot_junc2 in component Na_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,108) = strpad('I_K_tot in component K_Concentration (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,109) = strpad('I_Ca_tot_junc in component Ca_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,110) = strpad('I_Ca_tot_sl in component Ca_Concentrations (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,111) = strpad('I_Na_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,112) = strpad('I_Cl_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,113) = strpad('I_Ca_tot in component membrane_potential (uA_per_uF)');
    LEGEND_ALGEBRAIC(:,114) = strpad('I_tot in component membrane_potential (uA_per_uF)');
    LEGEND_RATES(:,7) = strpad('d/dt m in component I_Na (dimensionless)');
    LEGEND_RATES(:,8) = strpad('d/dt h in component I_Na (dimensionless)');
    LEGEND_RATES(:,9) = strpad('d/dt j in component I_Na (dimensionless)');
    LEGEND_RATES(:,10) = strpad('d/dt x_kr in component I_Kr (dimensionless)');
    LEGEND_RATES(:,11) = strpad('d/dt x_ks in component I_Ks (dimensionless)');
    LEGEND_RATES(:,13) = strpad('d/dt x_to_s in component I_to (dimensionless)');
    LEGEND_RATES(:,14) = strpad('d/dt y_to_s in component I_to (dimensionless)');
    LEGEND_RATES(:,15) = strpad('d/dt x_to_f in component I_to (dimensionless)');
    LEGEND_RATES(:,16) = strpad('d/dt y_to_f in component I_to (dimensionless)');
    LEGEND_RATES(:,17) = strpad('d/dt d in component I_Ca (dimensionless)');
    LEGEND_RATES(:,18) = strpad('d/dt f in component I_Ca (dimensionless)');
    LEGEND_RATES(:,19) = strpad('d/dt f_Ca_Bj in component I_Ca (dimensionless)');
    LEGEND_RATES(:,20) = strpad('d/dt f_Ca_Bsl in component I_Ca (dimensionless)');
    LEGEND_RATES(:,21) = strpad('d/dt Ry_Rr in component SR_Fluxes (mM)');
    LEGEND_RATES(:,22) = strpad('d/dt Ry_Ro in component SR_Fluxes (mM)');
    LEGEND_RATES(:,23) = strpad('d/dt Ry_Ri in component SR_Fluxes (mM)');
    LEGEND_RATES(:,26) = strpad('d/dt Na_Bj in component Na_Buffers (mM)');
    LEGEND_RATES(:,27) = strpad('d/dt Na_Bsl in component Na_Buffers (mM)');
    LEGEND_RATES(:,28) = strpad('d/dt Tn_CL in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,29) = strpad('d/dt Tn_CHc in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,30) = strpad('d/dt Tn_CHm in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,31) = strpad('d/dt CaM in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,32) = strpad('d/dt Myo_c in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,33) = strpad('d/dt Myo_m in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,34) = strpad('d/dt SRB in component Cytosolic_Ca_Buffers (mM)');
    LEGEND_RATES(:,35) = strpad('d/dt SLL_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,36) = strpad('d/dt SLL_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,37) = strpad('d/dt SLH_j in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,38) = strpad('d/dt SLH_sl in component Junctional_and_SL_Ca_Buffers (mM)');
    LEGEND_RATES(:,39) = strpad('d/dt Csqn_b in component SR_Ca_Concentrations (mM)');
    LEGEND_RATES(:,24) = strpad('d/dt Ca_sr in component SR_Ca_Concentrations (mM)');
    LEGEND_RATES(:,2) = strpad('d/dt Na_j in component Na_Concentrations (mM)');
    LEGEND_RATES(:,3) = strpad('d/dt Na_sl in component Na_Concentrations (mM)');
    LEGEND_RATES(:,12) = strpad('d/dt Na_i in component Na_Concentrations (mM)');
    LEGEND_RATES(:,4) = strpad('d/dt K_i in component K_Concentration (mM)');
    LEGEND_RATES(:,5) = strpad('d/dt Ca_j in component Ca_Concentrations (mM)');
    LEGEND_RATES(:,6) = strpad('d/dt Ca_sl in component Ca_Concentrations (mM)');
    LEGEND_RATES(:,25) = strpad('d/dt Ca_i in component Ca_Concentrations (mM)');
    LEGEND_RATES(:,1) = strpad('d/dt V_m in component membrane_potential (mV)');
    LEGEND_STATES  = LEGEND_STATES';
    LEGEND_ALGEBRAIC = LEGEND_ALGEBRAIC';
    LEGEND_RATES = LEGEND_RATES';
    LEGEND_CONSTANTS = LEGEND_CONSTANTS';
end

function [STATES, CONSTANTS] = initConsts()
    VOI = 0; CONSTANTS = []; STATES = []; ALGEBRAIC = [];
    STATES(:,1) = -8.09763e1;
    STATES(:,2) = 9.06;
    STATES(:,3) = 9.06;
    STATES(:,4) = 120;
    STATES(:,5) = 1.737475e-4;
    STATES(:,6) = 1.031812e-4;
    STATES(:,7) = 1.405627e-3;
    STATES(:,8) = 9.867005e-1;
    STATES(:,9) = 9.91562e-1;
    STATES(:,10) = 8.641386e-3;
    STATES(:,11) = 5.412034e-3;
    STATES(:,12) = 9.06;
    STATES(:,13) = 4.051574e-3;
    STATES(:,14) = 9.945511e-1;
    STATES(:,15) = 4.051574e-3;
    STATES(:,16) = 9.945511e-1;
    STATES(:,17) = 7.175662e-6;
    STATES(:,18) = 1.000681;
    STATES(:,19) = 2.421991e-2;
    STATES(:,20) = 1.452605e-2;
    STATES(:,21) = 8.884332e-1;
    STATES(:,22) = 8.156628e-7;
    STATES(:,23) = 1.024274e-7;
    STATES(:,24) = 0.1e-1;
    STATES(:,25) = 8.597401e-5;
    STATES(:,26) = 3.539892;
    STATES(:,27) = 7.720854e-1;
    STATES(:,28) = 8.773191e-3;
    STATES(:,29) = 1.078283e-1;
    STATES(:,30) = 1.524002e-2;
    STATES(:,31) = 2.911916e-4;
    STATES(:,32) = 1.298754e-3;
    STATES(:,33) = 1.381982e-1;
    STATES(:,34) = 2.143165e-3;
    STATES(:,35) = 9.566355e-3;
    STATES(:,36) = 1.110363e-1;
    STATES(:,37) = 7.347888e-3;
    STATES(:,38) = 7.297378e-2;
    STATES(:,39) = 1.242988;
    CONSTANTS(:,1) = 1.00000;
    CONSTANTS(:,2) = 8314.00;
    CONSTANTS(:,3) = 1.38100e-10;
    CONSTANTS(:,4) = 100.000;
    CONSTANTS(:,5) = 0.160000;
    CONSTANTS(:,6) = 0.450000;
    CONSTANTS(:,7) = 0.500000;
    CONSTANTS(:,8) = 1.64000e-06;
    CONSTANTS(:,9) = 1.22000e-06;
    CONSTANTS(:,10) = 1.09000e-05;
    CONSTANTS(:,11) = 1.79000e-05;
    CONSTANTS(:,12) = 8.24130e-13;
    CONSTANTS(:,13) = 3.27430e-12;
    CONSTANTS(:,14) = 1.83130e-14;
    CONSTANTS(:,15) = 1.63860e-12;
    CONSTANTS(:,16) = 0.110000;
    CONSTANTS(:,17) = 0.900000;
    CONSTANTS(:,18) = 5.40000;
    CONSTANTS(:,19) = 140.000;
    CONSTANTS(:,20) = 1.80000;
    CONSTANTS(:,21) = 1.00000;
    CONSTANTS(:,22) = 23.0000;
    CONSTANTS(:,23) = 0.000597000;
    CONSTANTS(:,24) =  1.00000.*1.80000;
    CONSTANTS(:,25) = 11.0000;
    CONSTANTS(:,26) = 1.50000;
    CONSTANTS(:,27) = 1.63000;
    CONSTANTS(:,28) = 1.39000;
    CONSTANTS(:,29) = 0.0183300;
    CONSTANTS(:,30) =  2.00000.*0.00100000;
    CONSTANTS(:,31) =  0.500000.*0.109625;
    CONSTANTS(:,32) =  1.00000.*0.00900000;
    CONSTANTS(:,33) = 0.100000;
    CONSTANTS(:,34) =  0.500000.*1.50000e-08;
    CONSTANTS(:,35) =  0.500000.*0.000540000;
    CONSTANTS(:,36) =  0.500000.*2.70000e-07;
    CONSTANTS(:,37) = 1.80000;
    CONSTANTS(:,38) =  1.00000.*4.50000;
    CONSTANTS(:,39) = 0.00359000;
    CONSTANTS(:,40) = 1.30000;
    CONSTANTS(:,41) = 12.2900;
    CONSTANTS(:,42) = 87.5000;
    CONSTANTS(:,43) = 0.320000;
    CONSTANTS(:,44) = 0.270000;
    CONSTANTS(:,45) = 0.000150000;
    CONSTANTS(:,46) = 1.57000;
    CONSTANTS(:,47) = 0.0673000;
    CONSTANTS(:,48) = 0.000500000;
    CONSTANTS(:,49) = 0.000551300;
    CONSTANTS(:,50) = 2.35000;
    CONSTANTS(:,51) = 2.60000;
    CONSTANTS(:,52) = 0.00531140;
    CONSTANTS(:,53) = 0.000246000;
    CONSTANTS(:,54) = 1.70000;
    CONSTANTS(:,55) = 1.78700;
    CONSTANTS(:,56) = 25.0000;
    CONSTANTS(:,57) = 10.0000;
    CONSTANTS(:,58) = 0.0600000;
    CONSTANTS(:,59) = 0.00500000;
    CONSTANTS(:,60) = 0.450000;
    CONSTANTS(:,61) = 7.56100;
    CONSTANTS(:,62) = 1.65000;
    CONSTANTS(:,63) = 0.00100000;
    CONSTANTS(:,64) = 0.000100000;
    CONSTANTS(:,65) = 0.0700000;
    CONSTANTS(:,66) = 0.0196000;
    CONSTANTS(:,67) = 32.7000;
    CONSTANTS(:,68) = 0.140000;
    CONSTANTS(:,69) = 3.20000e-05;
    CONSTANTS(:,70) = 2.37000;
    CONSTANTS(:,71) = 0.00333000;
    CONSTANTS(:,72) = 0.00300000;
    CONSTANTS(:,73) = 0.0240000;
    CONSTANTS(:,74) = 0.238000;
    CONSTANTS(:,75) = 34.0000;
    CONSTANTS(:,76) = 0.140000;
    CONSTANTS(:,77) = 0.000460000;
    CONSTANTS(:,78) = 13.8000;
    CONSTANTS(:,79) = 5.70000e-05;
    CONSTANTS(:,80) = 0.0157000;
    CONSTANTS(:,81) =  19.0000.*0.000900000;
    CONSTANTS(:,82) = 0.0600000;
    CONSTANTS(:,83) = 100.000;
    CONSTANTS(:,84) = 1.30000;
    CONSTANTS(:,85) = 100.000;
    CONSTANTS(:,86) = 0.0300000;
    CONSTANTS(:,87) = 100.000;
    CONSTANTS(:,88) = 65.0000;
    CONSTANTS(:,89) = 100.000;
    CONSTANTS(:,90) = 0.00350000;
    CONSTANTS(:,91) = 0.00350000;
    CONSTANTS(:,92) = 0.00000;
    CONSTANTS(:,93) = 0.00000;
    CONSTANTS(:,94) = 15.0000;
    CONSTANTS(:,95) = 1.00000;
    CONSTANTS(:,123) = 0.00000;
    CONSTANTS(:,96) = 96485.0;
    CONSTANTS(:,97) = 10.2500;
    CONSTANTS(:,98) = 0.0150000;
    CONSTANTS(:,99) = 1.00000 - CONSTANTS(:,16);
    CONSTANTS(:,100) = 1.00000 - CONSTANTS(:,17);
    CONSTANTS(:,101) = (exp(CONSTANTS(:,19)./67.3000) - 1.00000)./7.00000;
    CONSTANTS(:,102) =  0.0350000.*power((CONSTANTS(:,18)./5.40000), 1.0 ./ 2);
    CONSTANTS(:,103) = piecewise({CONSTANTS(:,1)==1.00000,  1.00000.*0.130000.*0.120000 },  0.130000.*0.300000.*0.964000);
    CONSTANTS(:,104) = piecewise({CONSTANTS(:,1)==1.00000,  1.00000.*0.130000.*0.880000 },  0.130000.*0.300000.*0.0360000);
    CONSTANTS(:,105) = 0.500000;
    CONSTANTS(:,106) = 310.000;
    CONSTANTS(:,107) =   pi.*power(CONSTANTS(:,97), 2.00000).*CONSTANTS(:,4).*1.00000e-15;
    CONSTANTS(:,108) =  20150.0.* pi.*2.00000.*CONSTANTS(:,5).*CONSTANTS(:,98);
    CONSTANTS(:,109) =   pi.*2.00000.*CONSTANTS(:,97).*CONSTANTS(:,4);
    CONSTANTS(:,110) = CONSTANTS(:,96)./( CONSTANTS(:,2).*CONSTANTS(:,106));
    CONSTANTS(:,111) = (CONSTANTS(:,106) - 310.000)./10.0000;
    CONSTANTS(:,112) =  0.650000.*CONSTANTS(:,107);
    CONSTANTS(:,113) =  0.0350000.*CONSTANTS(:,107);
    CONSTANTS(:,114) =  0.0200000.*CONSTANTS(:,107);
    CONSTANTS(:,115) =  0.0539000.*0.0100000.*CONSTANTS(:,107);
    CONSTANTS(:,116) = 15.0000;
    CONSTANTS(:,117) = 150.000;
    CONSTANTS(:,118) = ( 0.0374000.*CONSTANTS(:,112))./CONSTANTS(:,114);
    CONSTANTS(:,119) =  (( 0.00460000.*CONSTANTS(:,112))./CONSTANTS(:,115)).*0.100000;
    CONSTANTS(:,120) = ( 0.0134000.*CONSTANTS(:,112))./CONSTANTS(:,114);
    CONSTANTS(:,121) =  (( 0.00165000.*CONSTANTS(:,112))./CONSTANTS(:,115)).*0.100000;
    CONSTANTS(:,122) = ( 0.140000.*CONSTANTS(:,112))./CONSTANTS(:,113);
    CONSTANTS(:,123) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,116)./CONSTANTS(:,117));
    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(:,4) = CONSTANTS(:,123);
    RATES(:,19) =  (( 1.70000.*STATES(:,5))./1.00000).*(1.00000 - STATES(:,19)) -  0.0119000.*STATES(:,19);
    RATES(:,20) =  (( 1.70000.*STATES(:,6))./1.00000).*(1.00000 - STATES(:,20)) -  0.0119000.*STATES(:,20);
    RATES(:,28) =  CONSTANTS(:,67).*STATES(:,25).*(CONSTANTS(:,65) - STATES(:,28)) -  CONSTANTS(:,66).*STATES(:,28);
    RATES(:,29) =  CONSTANTS(:,70).*STATES(:,25).*((CONSTANTS(:,68) - STATES(:,29)) - STATES(:,30)) -  CONSTANTS(:,69).*STATES(:,29);
    RATES(:,30) =  CONSTANTS(:,72).*CONSTANTS(:,21).*((CONSTANTS(:,68) - STATES(:,29)) - STATES(:,30)) -  CONSTANTS(:,71).*STATES(:,30);
    RATES(:,31) =  CONSTANTS(:,75).*STATES(:,25).*(CONSTANTS(:,73) - STATES(:,31)) -  CONSTANTS(:,74).*STATES(:,31);
    RATES(:,32) =  CONSTANTS(:,78).*STATES(:,25).*((CONSTANTS(:,76) - STATES(:,32)) - STATES(:,33)) -  CONSTANTS(:,77).*STATES(:,32);
    RATES(:,33) =  CONSTANTS(:,80).*CONSTANTS(:,21).*((CONSTANTS(:,76) - STATES(:,32)) - STATES(:,33)) -  CONSTANTS(:,79).*STATES(:,33);
    RATES(:,34) =  CONSTANTS(:,83).*STATES(:,25).*(CONSTANTS(:,81) - STATES(:,34)) -  CONSTANTS(:,82).*STATES(:,34);
    RATES(:,35) =  CONSTANTS(:,85).*STATES(:,5).*(CONSTANTS(:,119) - STATES(:,35)) -  CONSTANTS(:,84).*STATES(:,35);
    RATES(:,36) =  CONSTANTS(:,85).*STATES(:,6).*(CONSTANTS(:,118) - STATES(:,36)) -  CONSTANTS(:,84).*STATES(:,36);
    RATES(:,37) =  CONSTANTS(:,87).*STATES(:,5).*(CONSTANTS(:,121) - STATES(:,37)) -  CONSTANTS(:,86).*STATES(:,37);
    RATES(:,38) =  CONSTANTS(:,87).*STATES(:,6).*(CONSTANTS(:,120) - STATES(:,38)) -  CONSTANTS(:,86).*STATES(:,38);
    RATES(:,39) =  CONSTANTS(:,89).*STATES(:,24).*(CONSTANTS(:,122) - STATES(:,39)) -  CONSTANTS(:,88).*STATES(:,39);
    RATES(:,12) =  (CONSTANTS(:,15)./CONSTANTS(:,112)).*(STATES(:,3) - STATES(:,12));
    ALGEBRAIC(:,1) = 1.00000./power(1.00000+exp( - (56.8600+STATES(:,1))./9.03000), 2.00000);
    ALGEBRAIC(:,12) =  0.129200.*exp( - power((STATES(:,1)+45.7900)./15.5400, 2.00000))+ 0.0648700.*exp( - power((STATES(:,1) - 4.82300)./51.1200, 2.00000));
    RATES(:,7) = (ALGEBRAIC(:,1) - STATES(:,7))./ALGEBRAIC(:,12);
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0000)./5.00000));
    ALGEBRAIC(:,15) = ( (550.000./(1.00000+exp(( - 22.0000 - STATES(:,1))./9.00000))).*6.00000)./(1.00000+exp((STATES(:,1) -  - 11.0000)./9.00000))+230.000./(1.00000+exp((STATES(:,1) -  - 40.0000)./20.0000));
    RATES(:,10) = (ALGEBRAIC(:,4) - STATES(:,10))./ALGEBRAIC(:,15);
    ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.80000)./14.2500));
    ALGEBRAIC(:,16) = 990.100./(1.00000+exp( - (STATES(:,1)+2.43600)./14.1200));
    RATES(:,11) = (ALGEBRAIC(:,5) - STATES(:,11))./ALGEBRAIC(:,16);
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.0000)./13.0000));
    ALGEBRAIC(:,17) = 9.00000./(1.00000+exp((STATES(:,1)+3.00000)./15.0000))+0.500000;
    RATES(:,13) = (ALGEBRAIC(:,6) - STATES(:,13))./ALGEBRAIC(:,17);
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+19.5000)./5.00000));
    ALGEBRAIC(:,18) = 800.000./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+30.0000;
    RATES(:,14) = (ALGEBRAIC(:,7) - STATES(:,14))./ALGEBRAIC(:,18);
    ALGEBRAIC(:,19) =  8.50000.*exp( - power((STATES(:,1)+45.0000)./50.0000, 2.00000))+0.500000;
    RATES(:,15) = (ALGEBRAIC(:,6) - STATES(:,15))./ALGEBRAIC(:,19);
    ALGEBRAIC(:,20) =  85.0000.*exp( - power(STATES(:,1)+40.0000, 2.00000)./220.000)+7.00000;
    RATES(:,16) = (ALGEBRAIC(:,7) - STATES(:,16))./ALGEBRAIC(:,20);
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+5.00000)./6.00000));
    ALGEBRAIC(:,21) = ( 1.00000.*ALGEBRAIC(:,9).*(1.00000 - exp( - (STATES(:,1)+5.00000)./6.00000)))./( 0.0350000.*(STATES(:,1)+5.00000));
    RATES(:,17) = (ALGEBRAIC(:,9) - STATES(:,17))./ALGEBRAIC(:,21);
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./9.00000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000));
    ALGEBRAIC(:,22) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+14.5000), 2.00000))+0.0200000);
    RATES(:,18) = (ALGEBRAIC(:,8) - STATES(:,18))./ALGEBRAIC(:,22);
    ALGEBRAIC(:,11) = CONSTANTS(:,94) - (CONSTANTS(:,94) - CONSTANTS(:,95))./(1.00000+power(CONSTANTS(:,60)./STATES(:,24), 2.50000));
    ALGEBRAIC(:,24) = CONSTANTS(:,57)./ALGEBRAIC(:,11);
    ALGEBRAIC(:,28) =  CONSTANTS(:,105).*ALGEBRAIC(:,11);
    RATES(:,22) = ( ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*STATES(:,21) -  CONSTANTS(:,58).*STATES(:,22)) - ( ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,22) -  CONSTANTS(:,59).*STATES(:,23));
    ALGEBRAIC(:,2) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000));
    ALGEBRAIC(:,13) = piecewise({STATES(:,1)>= - 40.0000, 0.770000./( 0.130000.*(1.00000+exp( - (STATES(:,1)+10.6600)./11.1000))) },  2.70000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.348500.*STATES(:,1)));
    ALGEBRAIC(:,25) = 1.00000./(ALGEBRAIC(:,2)+ALGEBRAIC(:,13));
    ALGEBRAIC(:,29) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    RATES(:,8) = (ALGEBRAIC(:,29) - STATES(:,8))./ALGEBRAIC(:,25);
    ALGEBRAIC(:,3) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( (  - 25428.0.*exp( 0.244400.*STATES(:,1)) -  6.94800e-06.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))));
    ALGEBRAIC(:,14) = piecewise({STATES(:,1)>= - 40.0000, ( 0.600000.*exp( 0.0570000.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.0242400.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))));
    ALGEBRAIC(:,26) = 1.00000./(ALGEBRAIC(:,3)+ALGEBRAIC(:,14));
    ALGEBRAIC(:,30) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    RATES(:,9) = (ALGEBRAIC(:,30) - STATES(:,9))./ALGEBRAIC(:,26);
    ALGEBRAIC(:,32) = ((1.00000 - STATES(:,21)) - STATES(:,22)) - STATES(:,23);
    RATES(:,21) = ( CONSTANTS(:,59).*ALGEBRAIC(:,32) -  ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,21)) - ( ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*STATES(:,21) -  CONSTANTS(:,58).*STATES(:,22));
    RATES(:,23) = ( ALGEBRAIC(:,28).*STATES(:,5).*STATES(:,22) -  CONSTANTS(:,59).*STATES(:,23)) - ( CONSTANTS(:,58).*STATES(:,23) -  ALGEBRAIC(:,24).*power(STATES(:,5), 2.00000).*ALGEBRAIC(:,32));
    ALGEBRAIC(:,98) =  (( CONSTANTS(:,56).*STATES(:,22))./1.00000).*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,99) = ( power(CONSTANTS(:,51), CONSTANTS(:,111)).*CONSTANTS(:,52).*(power(STATES(:,25)./CONSTANTS(:,53), CONSTANTS(:,55)) - power(STATES(:,24)./CONSTANTS(:,54), CONSTANTS(:,55))))./(1.00000+power(STATES(:,25)./CONSTANTS(:,53), CONSTANTS(:,55))+power(STATES(:,24)./CONSTANTS(:,54), CONSTANTS(:,55)));
    ALGEBRAIC(:,100) =  5.34800e-06.*(STATES(:,24) - STATES(:,5));
    RATES(:,24) = (ALGEBRAIC(:,99) - (( ALGEBRAIC(:,100).*CONSTANTS(:,112))./CONSTANTS(:,113)+ALGEBRAIC(:,98))) - ( CONSTANTS(:,89).*STATES(:,24).*(CONSTANTS(:,122) - STATES(:,39)) -  CONSTANTS(:,88).*STATES(:,39));
    ALGEBRAIC(:,101) = ((((((((((( CONSTANTS(:,67).*STATES(:,25).*(CONSTANTS(:,65) - STATES(:,28)) -  CONSTANTS(:,66).*STATES(:,28))+ CONSTANTS(:,70).*STATES(:,25).*((CONSTANTS(:,68) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,69).*STATES(:,29))+ CONSTANTS(:,72).*CONSTANTS(:,21).*((CONSTANTS(:,68) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,71).*STATES(:,30))+ CONSTANTS(:,75).*STATES(:,25).*(CONSTANTS(:,73) - STATES(:,31))) -  CONSTANTS(:,74).*STATES(:,31))+ CONSTANTS(:,78).*STATES(:,25).*((CONSTANTS(:,76) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,77).*STATES(:,32))+ CONSTANTS(:,80).*CONSTANTS(:,21).*((CONSTANTS(:,76) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,79).*STATES(:,33))+( CONSTANTS(:,83).*STATES(:,25).*(CONSTANTS(:,81) - STATES(:,34)) -  CONSTANTS(:,82).*STATES(:,34));
    RATES(:,25) = ((  - ALGEBRAIC(:,99).*CONSTANTS(:,113))./CONSTANTS(:,112) - ALGEBRAIC(:,101))+ (CONSTANTS(:,13)./CONSTANTS(:,112)).*(STATES(:,6) - STATES(:,25));
    ALGEBRAIC(:,102) =  CONSTANTS(:,64).*STATES(:,2).*(CONSTANTS(:,61) - STATES(:,26)) -  CONSTANTS(:,63).*STATES(:,26);
    RATES(:,26) = ALGEBRAIC(:,102);
    ALGEBRAIC(:,103) =  CONSTANTS(:,64).*STATES(:,3).*(CONSTANTS(:,62) - STATES(:,27)) -  CONSTANTS(:,63).*STATES(:,27);
    RATES(:,27) = ALGEBRAIC(:,103);
    ALGEBRAIC(:,23) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,19)./STATES(:,2));
    ALGEBRAIC(:,35) =  CONSTANTS(:,16).*CONSTANTS(:,22).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,38) =  CONSTANTS(:,16).*CONSTANTS(:,23).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,41) = 1.00000./(1.00000+ 0.124500.*exp(  - 0.100000.*STATES(:,1).*CONSTANTS(:,110))+ 0.0365000.*CONSTANTS(:,101).*exp(  - STATES(:,1).*CONSTANTS(:,110)));
    ALGEBRAIC(:,42) = (( CONSTANTS(:,16).*CONSTANTS(:,24).*ALGEBRAIC(:,41).*CONSTANTS(:,18))./(1.00000+power(CONSTANTS(:,25)./STATES(:,2), 4.00000)))./(CONSTANTS(:,18)+CONSTANTS(:,26));
    ALGEBRAIC(:,69) = ( CONSTANTS(:,34).*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.750000.*STATES(:,2).*exp( STATES(:,1).*CONSTANTS(:,110)) -  0.750000.*CONSTANTS(:,19)))./(exp( STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,75) =  CONSTANTS(:,17).*ALGEBRAIC(:,69).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,93)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,78) = 1.00000./(1.00000+power(CONSTANTS(:,45)./STATES(:,5), 2.00000));
    ALGEBRAIC(:,81) =  exp( CONSTANTS(:,44).*STATES(:,1).*CONSTANTS(:,110)).*power(STATES(:,2), 3.00000).*CONSTANTS(:,20);
    ALGEBRAIC(:,83) =  exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)).*power(CONSTANTS(:,19), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,84) =  CONSTANTS(:,39).*power(CONSTANTS(:,19), 3.00000).*(1.00000+power(STATES(:,2)./CONSTANTS(:,41), 3.00000))+ power(CONSTANTS(:,42), 3.00000).*STATES(:,5).*(1.00000+STATES(:,5)./CONSTANTS(:,39))+ CONSTANTS(:,40).*power(STATES(:,2), 3.00000)+ power(STATES(:,2), 3.00000).*CONSTANTS(:,20)+ power(CONSTANTS(:,19), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,87) = (( CONSTANTS(:,16).*CONSTANTS(:,38).*power(CONSTANTS(:,46), CONSTANTS(:,111)).*ALGEBRAIC(:,78).*(ALGEBRAIC(:,81) - ALGEBRAIC(:,83)))./ALGEBRAIC(:,84))./(1.00000+ CONSTANTS(:,43).*exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ 3.00000.*ALGEBRAIC(:,87)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,75);
    RATES(:,2) = ((  - ALGEBRAIC(:,106).*CONSTANTS(:,3))./( CONSTANTS(:,115).*CONSTANTS(:,96))+ (CONSTANTS(:,14)./CONSTANTS(:,115)).*(STATES(:,3) - STATES(:,2))) - ALGEBRAIC(:,102);
    ALGEBRAIC(:,27) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,19)./STATES(:,3));
    ALGEBRAIC(:,36) =  CONSTANTS(:,99).*CONSTANTS(:,22).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,39) =  CONSTANTS(:,99).*CONSTANTS(:,23).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,43) = (( CONSTANTS(:,99).*CONSTANTS(:,24).*ALGEBRAIC(:,41).*CONSTANTS(:,18))./(1.00000+power(CONSTANTS(:,25)./STATES(:,3), 4.00000)))./(CONSTANTS(:,18)+CONSTANTS(:,26));
    ALGEBRAIC(:,70) = ( CONSTANTS(:,34).*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.750000.*STATES(:,3).*exp( STATES(:,1).*CONSTANTS(:,110)) -  0.750000.*CONSTANTS(:,19)))./(exp( STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,76) =  CONSTANTS(:,100).*ALGEBRAIC(:,70).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,92)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,80) = 1.00000./(1.00000+power(CONSTANTS(:,45)./STATES(:,6), 2.00000));
    ALGEBRAIC(:,82) =  exp( CONSTANTS(:,44).*STATES(:,1).*CONSTANTS(:,110)).*power(STATES(:,3), 3.00000).*CONSTANTS(:,20);
    ALGEBRAIC(:,85) =  exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)).*power(CONSTANTS(:,19), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,86) =  CONSTANTS(:,39).*power(CONSTANTS(:,19), 3.00000).*(1.00000+power(STATES(:,3)./CONSTANTS(:,41), 3.00000))+ power(CONSTANTS(:,42), 3.00000).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,39))+ CONSTANTS(:,40).*power(STATES(:,3), 3.00000)+ power(STATES(:,3), 3.00000).*CONSTANTS(:,20)+ power(CONSTANTS(:,19), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,88) = (( CONSTANTS(:,99).*CONSTANTS(:,38).*power(CONSTANTS(:,46), CONSTANTS(:,111)).*ALGEBRAIC(:,80).*(ALGEBRAIC(:,82) - ALGEBRAIC(:,85)))./ALGEBRAIC(:,86))./(1.00000+ CONSTANTS(:,43).*exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)));
    ALGEBRAIC(:,107) = ALGEBRAIC(:,36)+ALGEBRAIC(:,39)+ 3.00000.*ALGEBRAIC(:,88)+ 3.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,76);
    RATES(:,3) = ((  - ALGEBRAIC(:,107).*CONSTANTS(:,3))./( CONSTANTS(:,114).*CONSTANTS(:,96))+ (CONSTANTS(:,14)./CONSTANTS(:,114)).*(STATES(:,2) - STATES(:,3))+ (CONSTANTS(:,15)./CONSTANTS(:,114)).*(STATES(:,12) - STATES(:,3))) - ALGEBRAIC(:,103);
    ALGEBRAIC(:,104) = ( CONSTANTS(:,85).*STATES(:,5).*(CONSTANTS(:,119) - STATES(:,35)) -  CONSTANTS(:,84).*STATES(:,35))+( CONSTANTS(:,87).*STATES(:,5).*(CONSTANTS(:,121) - STATES(:,37)) -  CONSTANTS(:,86).*STATES(:,37));
    ALGEBRAIC(:,66) = ( CONSTANTS(:,35).*4.00000.*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.341000.*STATES(:,5).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) -  0.341000.*CONSTANTS(:,20)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,71) =  CONSTANTS(:,17).*ALGEBRAIC(:,66).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,93)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,91) = ( CONSTANTS(:,16).*power(CONSTANTS(:,50), CONSTANTS(:,111)).*CONSTANTS(:,47).*power(STATES(:,5), 1.60000))./(power(CONSTANTS(:,48), 1.60000)+power(STATES(:,5), 1.60000));
    ALGEBRAIC(:,33) =  ((1.00000./CONSTANTS(:,110))./2.00000).*log(CONSTANTS(:,20)./STATES(:,5));
    ALGEBRAIC(:,95) =  CONSTANTS(:,16).*CONSTANTS(:,49).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,109) = (ALGEBRAIC(:,71)+ALGEBRAIC(:,95)+ALGEBRAIC(:,91)) -  2.00000.*ALGEBRAIC(:,87);
    RATES(:,5) = (((  - ALGEBRAIC(:,109).*CONSTANTS(:,3))./( CONSTANTS(:,115).*2.00000.*CONSTANTS(:,96))+ (CONSTANTS(:,12)./CONSTANTS(:,115)).*(STATES(:,6) - STATES(:,5))) - ALGEBRAIC(:,104))+( ALGEBRAIC(:,98).*CONSTANTS(:,113))./CONSTANTS(:,115)+( ALGEBRAIC(:,100).*CONSTANTS(:,112))./CONSTANTS(:,115);
    ALGEBRAIC(:,105) = ( CONSTANTS(:,85).*STATES(:,6).*(CONSTANTS(:,118) - STATES(:,36)) -  CONSTANTS(:,84).*STATES(:,36))+( CONSTANTS(:,87).*STATES(:,6).*(CONSTANTS(:,120) - STATES(:,38)) -  CONSTANTS(:,86).*STATES(:,38));
    ALGEBRAIC(:,67) = ( CONSTANTS(:,35).*4.00000.*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.341000.*STATES(:,6).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) -  0.341000.*CONSTANTS(:,20)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,72) =  CONSTANTS(:,100).*ALGEBRAIC(:,67).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,92)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,93) = ( CONSTANTS(:,99).*power(CONSTANTS(:,50), CONSTANTS(:,111)).*CONSTANTS(:,47).*power(STATES(:,6), 1.60000))./(power(CONSTANTS(:,48), 1.60000)+power(STATES(:,6), 1.60000));
    ALGEBRAIC(:,34) =  ((1.00000./CONSTANTS(:,110))./2.00000).*log(CONSTANTS(:,20)./STATES(:,6));
    ALGEBRAIC(:,96) =  CONSTANTS(:,99).*CONSTANTS(:,49).*(STATES(:,1) - ALGEBRAIC(:,34));
    ALGEBRAIC(:,110) = (ALGEBRAIC(:,72)+ALGEBRAIC(:,96)+ALGEBRAIC(:,93)) -  2.00000.*ALGEBRAIC(:,88);
    RATES(:,6) = ((  - ALGEBRAIC(:,110).*CONSTANTS(:,3))./( CONSTANTS(:,114).*2.00000.*CONSTANTS(:,96))+ (CONSTANTS(:,12)./CONSTANTS(:,114)).*(STATES(:,5) - STATES(:,6))+ (CONSTANTS(:,13)./CONSTANTS(:,114)).*(STATES(:,25) - STATES(:,6))) - ALGEBRAIC(:,105);
    ALGEBRAIC(:,10) = piecewise({VOI>=0.00000&VOI<=5.00000, 9.50000 , VOI>=310.000&VOI<=315.000, 9.50000 }, 0.00000);
    ALGEBRAIC(:,44) = ALGEBRAIC(:,42)+ALGEBRAIC(:,43);
    ALGEBRAIC(:,31) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,18)./STATES(:,4));
    ALGEBRAIC(:,45) = 1.00000./(1.00000+exp((STATES(:,1)+74.0000)./24.0000));
    ALGEBRAIC(:,46) =  CONSTANTS(:,102).*STATES(:,10).*ALGEBRAIC(:,45).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,47) = 1.00000./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,48) =  CONSTANTS(:,16).*CONSTANTS(:,30).*ALGEBRAIC(:,47).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,49) =  CONSTANTS(:,99).*CONSTANTS(:,30).*ALGEBRAIC(:,47).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,50) = ALGEBRAIC(:,48)+ALGEBRAIC(:,49);
    ALGEBRAIC(:,51) =  (1.00000./CONSTANTS(:,110)).*log((CONSTANTS(:,18)+ CONSTANTS(:,29).*CONSTANTS(:,19))./(STATES(:,4)+ CONSTANTS(:,29).*STATES(:,12)));
    ALGEBRAIC(:,52) =  CONSTANTS(:,16).*CONSTANTS(:,90).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,51));
    ALGEBRAIC(:,53) =  CONSTANTS(:,99).*CONSTANTS(:,91).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,51));
    ALGEBRAIC(:,54) = ALGEBRAIC(:,52)+ALGEBRAIC(:,53);
    ALGEBRAIC(:,55) =  CONSTANTS(:,103).*STATES(:,13).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,56) =  CONSTANTS(:,104).*STATES(:,15).*STATES(:,16).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,57) = ALGEBRAIC(:,55)+ALGEBRAIC(:,56);
    ALGEBRAIC(:,58) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,31)) - 59.2150)));
    ALGEBRAIC(:,59) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,31)))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,31)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,31))+4.75300)));
    ALGEBRAIC(:,60) = ALGEBRAIC(:,58)./(ALGEBRAIC(:,58)+ALGEBRAIC(:,59));
    ALGEBRAIC(:,61) =  1.00000.*0.350000.*power((CONSTANTS(:,18)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,60).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,68) = ( CONSTANTS(:,36).*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.750000.*STATES(:,4).*exp( STATES(:,1).*CONSTANTS(:,110)) -  0.750000.*CONSTANTS(:,18)))./(exp( STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,74) =  ALGEBRAIC(:,68).*STATES(:,17).*STATES(:,18).*( CONSTANTS(:,17).*(CONSTANTS(:,93)+(1.00000 - STATES(:,19)))+ CONSTANTS(:,100).*(CONSTANTS(:,92)+(1.00000 - STATES(:,20)))).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,108) = ((ALGEBRAIC(:,57)+ALGEBRAIC(:,46)+ALGEBRAIC(:,54)+ALGEBRAIC(:,61)) -  2.00000.*ALGEBRAIC(:,44))+ALGEBRAIC(:,74)+ALGEBRAIC(:,50);
    ALGEBRAIC(:,111) = ALGEBRAIC(:,106)+ALGEBRAIC(:,107);
    ALGEBRAIC(:,62) =  (( CONSTANTS(:,16).*CONSTANTS(:,31))./(1.00000+CONSTANTS(:,33)./STATES(:,5))).*(STATES(:,1) - CONSTANTS(:,123));
    ALGEBRAIC(:,63) =  (( CONSTANTS(:,99).*CONSTANTS(:,31))./(1.00000+CONSTANTS(:,33)./STATES(:,6))).*(STATES(:,1) - CONSTANTS(:,123));
    ALGEBRAIC(:,64) = ALGEBRAIC(:,62)+ALGEBRAIC(:,63);
    ALGEBRAIC(:,65) =  CONSTANTS(:,32).*(STATES(:,1) - CONSTANTS(:,123));
    ALGEBRAIC(:,112) = ALGEBRAIC(:,64)+ALGEBRAIC(:,65);
    ALGEBRAIC(:,113) = ALGEBRAIC(:,109)+ALGEBRAIC(:,110);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,111)+ALGEBRAIC(:,112)+ALGEBRAIC(:,113)+ALGEBRAIC(:,108);
    RATES(:,1) =  - (ALGEBRAIC(:,114) - ALGEBRAIC(:,10));
   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(:,1) = 1.00000./power(1.00000+exp( - (56.8600+STATES(:,1))./9.03000), 2.00000);
    ALGEBRAIC(:,12) =  0.129200.*exp( - power((STATES(:,1)+45.7900)./15.5400, 2.00000))+ 0.0648700.*exp( - power((STATES(:,1) - 4.82300)./51.1200, 2.00000));
    ALGEBRAIC(:,4) = 1.00000./(1.00000+exp( - (STATES(:,1)+10.0000)./5.00000));
    ALGEBRAIC(:,15) = ( (550.000./(1.00000+exp(( - 22.0000 - STATES(:,1))./9.00000))).*6.00000)./(1.00000+exp((STATES(:,1) -  - 11.0000)./9.00000))+230.000./(1.00000+exp((STATES(:,1) -  - 40.0000)./20.0000));
    ALGEBRAIC(:,5) = 1.00000./(1.00000+exp( - (STATES(:,1)+3.80000)./14.2500));
    ALGEBRAIC(:,16) = 990.100./(1.00000+exp( - (STATES(:,1)+2.43600)./14.1200));
    ALGEBRAIC(:,6) = 1.00000./(1.00000+exp( - (STATES(:,1) - 19.0000)./13.0000));
    ALGEBRAIC(:,17) = 9.00000./(1.00000+exp((STATES(:,1)+3.00000)./15.0000))+0.500000;
    ALGEBRAIC(:,7) = 1.00000./(1.00000+exp((STATES(:,1)+19.5000)./5.00000));
    ALGEBRAIC(:,18) = 800.000./(1.00000+exp((STATES(:,1)+60.0000)./10.0000))+30.0000;
    ALGEBRAIC(:,19) =  8.50000.*exp( - power((STATES(:,1)+45.0000)./50.0000, 2.00000))+0.500000;
    ALGEBRAIC(:,20) =  85.0000.*exp( - power(STATES(:,1)+40.0000, 2.00000)./220.000)+7.00000;
    ALGEBRAIC(:,9) = 1.00000./(1.00000+exp( - (STATES(:,1)+5.00000)./6.00000));
    ALGEBRAIC(:,21) = ( 1.00000.*ALGEBRAIC(:,9).*(1.00000 - exp( - (STATES(:,1)+5.00000)./6.00000)))./( 0.0350000.*(STATES(:,1)+5.00000));
    ALGEBRAIC(:,8) = 1.00000./(1.00000+exp((STATES(:,1)+35.0000)./9.00000))+0.600000./(1.00000+exp((50.0000 - STATES(:,1))./20.0000));
    ALGEBRAIC(:,22) = 1.00000./( 0.0197000.*exp( - power( 0.0337000.*(STATES(:,1)+14.5000), 2.00000))+0.0200000);
    ALGEBRAIC(:,11) = CONSTANTS(:,94) - (CONSTANTS(:,94) - CONSTANTS(:,95))./(1.00000+power(CONSTANTS(:,60)./STATES(:,24), 2.50000));
    ALGEBRAIC(:,24) = CONSTANTS(:,57)./ALGEBRAIC(:,11);
    ALGEBRAIC(:,28) =  CONSTANTS(:,105).*ALGEBRAIC(:,11);
    ALGEBRAIC(:,2) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 },  0.0570000.*exp( - (STATES(:,1)+80.0000)./6.80000));
    ALGEBRAIC(:,13) = piecewise({STATES(:,1)>= - 40.0000, 0.770000./( 0.130000.*(1.00000+exp( - (STATES(:,1)+10.6600)./11.1000))) },  2.70000.*exp( 0.0790000.*STATES(:,1))+ 310000..*exp( 0.348500.*STATES(:,1)));
    ALGEBRAIC(:,25) = 1.00000./(ALGEBRAIC(:,2)+ALGEBRAIC(:,13));
    ALGEBRAIC(:,29) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,3) = piecewise({STATES(:,1)>= - 40.0000, 0.00000 }, ( (  - 25428.0.*exp( 0.244400.*STATES(:,1)) -  6.94800e-06.*exp(  - 0.0439100.*STATES(:,1))).*(STATES(:,1)+37.7800))./(1.00000+exp( 0.311000.*(STATES(:,1)+79.2300))));
    ALGEBRAIC(:,14) = piecewise({STATES(:,1)>= - 40.0000, ( 0.600000.*exp( 0.0570000.*STATES(:,1)))./(1.00000+exp(  - 0.100000.*(STATES(:,1)+32.0000))) }, ( 0.0242400.*exp(  - 0.0105200.*STATES(:,1)))./(1.00000+exp(  - 0.137800.*(STATES(:,1)+40.1400))));
    ALGEBRAIC(:,26) = 1.00000./(ALGEBRAIC(:,3)+ALGEBRAIC(:,14));
    ALGEBRAIC(:,30) = 1.00000./power(1.00000+exp((STATES(:,1)+71.5500)./7.43000), 2.00000);
    ALGEBRAIC(:,32) = ((1.00000 - STATES(:,21)) - STATES(:,22)) - STATES(:,23);
    ALGEBRAIC(:,98) =  (( CONSTANTS(:,56).*STATES(:,22))./1.00000).*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,99) = ( power(CONSTANTS(:,51), CONSTANTS(:,111)).*CONSTANTS(:,52).*(power(STATES(:,25)./CONSTANTS(:,53), CONSTANTS(:,55)) - power(STATES(:,24)./CONSTANTS(:,54), CONSTANTS(:,55))))./(1.00000+power(STATES(:,25)./CONSTANTS(:,53), CONSTANTS(:,55))+power(STATES(:,24)./CONSTANTS(:,54), CONSTANTS(:,55)));
    ALGEBRAIC(:,100) =  5.34800e-06.*(STATES(:,24) - STATES(:,5));
    ALGEBRAIC(:,101) = ((((((((((( CONSTANTS(:,67).*STATES(:,25).*(CONSTANTS(:,65) - STATES(:,28)) -  CONSTANTS(:,66).*STATES(:,28))+ CONSTANTS(:,70).*STATES(:,25).*((CONSTANTS(:,68) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,69).*STATES(:,29))+ CONSTANTS(:,72).*CONSTANTS(:,21).*((CONSTANTS(:,68) - STATES(:,29)) - STATES(:,30))) -  CONSTANTS(:,71).*STATES(:,30))+ CONSTANTS(:,75).*STATES(:,25).*(CONSTANTS(:,73) - STATES(:,31))) -  CONSTANTS(:,74).*STATES(:,31))+ CONSTANTS(:,78).*STATES(:,25).*((CONSTANTS(:,76) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,77).*STATES(:,32))+ CONSTANTS(:,80).*CONSTANTS(:,21).*((CONSTANTS(:,76) - STATES(:,32)) - STATES(:,33))) -  CONSTANTS(:,79).*STATES(:,33))+( CONSTANTS(:,83).*STATES(:,25).*(CONSTANTS(:,81) - STATES(:,34)) -  CONSTANTS(:,82).*STATES(:,34));
    ALGEBRAIC(:,102) =  CONSTANTS(:,64).*STATES(:,2).*(CONSTANTS(:,61) - STATES(:,26)) -  CONSTANTS(:,63).*STATES(:,26);
    ALGEBRAIC(:,103) =  CONSTANTS(:,64).*STATES(:,3).*(CONSTANTS(:,62) - STATES(:,27)) -  CONSTANTS(:,63).*STATES(:,27);
    ALGEBRAIC(:,23) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,19)./STATES(:,2));
    ALGEBRAIC(:,35) =  CONSTANTS(:,16).*CONSTANTS(:,22).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,38) =  CONSTANTS(:,16).*CONSTANTS(:,23).*(STATES(:,1) - ALGEBRAIC(:,23));
    ALGEBRAIC(:,41) = 1.00000./(1.00000+ 0.124500.*exp(  - 0.100000.*STATES(:,1).*CONSTANTS(:,110))+ 0.0365000.*CONSTANTS(:,101).*exp(  - STATES(:,1).*CONSTANTS(:,110)));
    ALGEBRAIC(:,42) = (( CONSTANTS(:,16).*CONSTANTS(:,24).*ALGEBRAIC(:,41).*CONSTANTS(:,18))./(1.00000+power(CONSTANTS(:,25)./STATES(:,2), 4.00000)))./(CONSTANTS(:,18)+CONSTANTS(:,26));
    ALGEBRAIC(:,69) = ( CONSTANTS(:,34).*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.750000.*STATES(:,2).*exp( STATES(:,1).*CONSTANTS(:,110)) -  0.750000.*CONSTANTS(:,19)))./(exp( STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,75) =  CONSTANTS(:,17).*ALGEBRAIC(:,69).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,93)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,78) = 1.00000./(1.00000+power(CONSTANTS(:,45)./STATES(:,5), 2.00000));
    ALGEBRAIC(:,81) =  exp( CONSTANTS(:,44).*STATES(:,1).*CONSTANTS(:,110)).*power(STATES(:,2), 3.00000).*CONSTANTS(:,20);
    ALGEBRAIC(:,83) =  exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)).*power(CONSTANTS(:,19), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,84) =  CONSTANTS(:,39).*power(CONSTANTS(:,19), 3.00000).*(1.00000+power(STATES(:,2)./CONSTANTS(:,41), 3.00000))+ power(CONSTANTS(:,42), 3.00000).*STATES(:,5).*(1.00000+STATES(:,5)./CONSTANTS(:,39))+ CONSTANTS(:,40).*power(STATES(:,2), 3.00000)+ power(STATES(:,2), 3.00000).*CONSTANTS(:,20)+ power(CONSTANTS(:,19), 3.00000).*STATES(:,5);
    ALGEBRAIC(:,87) = (( CONSTANTS(:,16).*CONSTANTS(:,38).*power(CONSTANTS(:,46), CONSTANTS(:,111)).*ALGEBRAIC(:,78).*(ALGEBRAIC(:,81) - ALGEBRAIC(:,83)))./ALGEBRAIC(:,84))./(1.00000+ CONSTANTS(:,43).*exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)));
    ALGEBRAIC(:,106) = ALGEBRAIC(:,35)+ALGEBRAIC(:,38)+ 3.00000.*ALGEBRAIC(:,87)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,75);
    ALGEBRAIC(:,27) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,19)./STATES(:,3));
    ALGEBRAIC(:,36) =  CONSTANTS(:,99).*CONSTANTS(:,22).*power(STATES(:,7), 3.00000).*STATES(:,8).*STATES(:,9).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,39) =  CONSTANTS(:,99).*CONSTANTS(:,23).*(STATES(:,1) - ALGEBRAIC(:,27));
    ALGEBRAIC(:,43) = (( CONSTANTS(:,99).*CONSTANTS(:,24).*ALGEBRAIC(:,41).*CONSTANTS(:,18))./(1.00000+power(CONSTANTS(:,25)./STATES(:,3), 4.00000)))./(CONSTANTS(:,18)+CONSTANTS(:,26));
    ALGEBRAIC(:,70) = ( CONSTANTS(:,34).*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.750000.*STATES(:,3).*exp( STATES(:,1).*CONSTANTS(:,110)) -  0.750000.*CONSTANTS(:,19)))./(exp( STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,76) =  CONSTANTS(:,100).*ALGEBRAIC(:,70).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,92)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,80) = 1.00000./(1.00000+power(CONSTANTS(:,45)./STATES(:,6), 2.00000));
    ALGEBRAIC(:,82) =  exp( CONSTANTS(:,44).*STATES(:,1).*CONSTANTS(:,110)).*power(STATES(:,3), 3.00000).*CONSTANTS(:,20);
    ALGEBRAIC(:,85) =  exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)).*power(CONSTANTS(:,19), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,86) =  CONSTANTS(:,39).*power(CONSTANTS(:,19), 3.00000).*(1.00000+power(STATES(:,3)./CONSTANTS(:,41), 3.00000))+ power(CONSTANTS(:,42), 3.00000).*STATES(:,6).*(1.00000+STATES(:,6)./CONSTANTS(:,39))+ CONSTANTS(:,40).*power(STATES(:,3), 3.00000)+ power(STATES(:,3), 3.00000).*CONSTANTS(:,20)+ power(CONSTANTS(:,19), 3.00000).*STATES(:,6);
    ALGEBRAIC(:,88) = (( CONSTANTS(:,99).*CONSTANTS(:,38).*power(CONSTANTS(:,46), CONSTANTS(:,111)).*ALGEBRAIC(:,80).*(ALGEBRAIC(:,82) - ALGEBRAIC(:,85)))./ALGEBRAIC(:,86))./(1.00000+ CONSTANTS(:,43).*exp( (CONSTANTS(:,44) - 1.00000).*STATES(:,1).*CONSTANTS(:,110)));
    ALGEBRAIC(:,107) = ALGEBRAIC(:,36)+ALGEBRAIC(:,39)+ 3.00000.*ALGEBRAIC(:,88)+ 3.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,76);
    ALGEBRAIC(:,104) = ( CONSTANTS(:,85).*STATES(:,5).*(CONSTANTS(:,119) - STATES(:,35)) -  CONSTANTS(:,84).*STATES(:,35))+( CONSTANTS(:,87).*STATES(:,5).*(CONSTANTS(:,121) - STATES(:,37)) -  CONSTANTS(:,86).*STATES(:,37));
    ALGEBRAIC(:,66) = ( CONSTANTS(:,35).*4.00000.*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.341000.*STATES(:,5).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) -  0.341000.*CONSTANTS(:,20)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,71) =  CONSTANTS(:,17).*ALGEBRAIC(:,66).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,19))+CONSTANTS(:,93)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,91) = ( CONSTANTS(:,16).*power(CONSTANTS(:,50), CONSTANTS(:,111)).*CONSTANTS(:,47).*power(STATES(:,5), 1.60000))./(power(CONSTANTS(:,48), 1.60000)+power(STATES(:,5), 1.60000));
    ALGEBRAIC(:,33) =  ((1.00000./CONSTANTS(:,110))./2.00000).*log(CONSTANTS(:,20)./STATES(:,5));
    ALGEBRAIC(:,95) =  CONSTANTS(:,16).*CONSTANTS(:,49).*(STATES(:,1) - ALGEBRAIC(:,33));
    ALGEBRAIC(:,109) = (ALGEBRAIC(:,71)+ALGEBRAIC(:,95)+ALGEBRAIC(:,91)) -  2.00000.*ALGEBRAIC(:,87);
    ALGEBRAIC(:,105) = ( CONSTANTS(:,85).*STATES(:,6).*(CONSTANTS(:,118) - STATES(:,36)) -  CONSTANTS(:,84).*STATES(:,36))+( CONSTANTS(:,87).*STATES(:,6).*(CONSTANTS(:,120) - STATES(:,38)) -  CONSTANTS(:,86).*STATES(:,38));
    ALGEBRAIC(:,67) = ( CONSTANTS(:,35).*4.00000.*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.341000.*STATES(:,6).*exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) -  0.341000.*CONSTANTS(:,20)))./(exp( 2.00000.*STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,72) =  CONSTANTS(:,100).*ALGEBRAIC(:,67).*STATES(:,17).*STATES(:,18).*((1.00000 - STATES(:,20))+CONSTANTS(:,92)).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,93) = ( CONSTANTS(:,99).*power(CONSTANTS(:,50), CONSTANTS(:,111)).*CONSTANTS(:,47).*power(STATES(:,6), 1.60000))./(power(CONSTANTS(:,48), 1.60000)+power(STATES(:,6), 1.60000));
    ALGEBRAIC(:,34) =  ((1.00000./CONSTANTS(:,110))./2.00000).*log(CONSTANTS(:,20)./STATES(:,6));
    ALGEBRAIC(:,96) =  CONSTANTS(:,99).*CONSTANTS(:,49).*(STATES(:,1) - ALGEBRAIC(:,34));
    ALGEBRAIC(:,110) = (ALGEBRAIC(:,72)+ALGEBRAIC(:,96)+ALGEBRAIC(:,93)) -  2.00000.*ALGEBRAIC(:,88);
    ALGEBRAIC(:,10) = piecewise({VOI>=0.00000&VOI<=5.00000, 9.50000 , VOI>=310.000&VOI<=315.000, 9.50000 }, 0.00000);
    ALGEBRAIC(:,44) = ALGEBRAIC(:,42)+ALGEBRAIC(:,43);
    ALGEBRAIC(:,31) =  (1.00000./CONSTANTS(:,110)).*log(CONSTANTS(:,18)./STATES(:,4));
    ALGEBRAIC(:,45) = 1.00000./(1.00000+exp((STATES(:,1)+74.0000)./24.0000));
    ALGEBRAIC(:,46) =  CONSTANTS(:,102).*STATES(:,10).*ALGEBRAIC(:,45).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,47) = 1.00000./(1.00000+exp(7.48800 - STATES(:,1)./5.98000));
    ALGEBRAIC(:,48) =  CONSTANTS(:,16).*CONSTANTS(:,30).*ALGEBRAIC(:,47).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,49) =  CONSTANTS(:,99).*CONSTANTS(:,30).*ALGEBRAIC(:,47).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,50) = ALGEBRAIC(:,48)+ALGEBRAIC(:,49);
    ALGEBRAIC(:,51) =  (1.00000./CONSTANTS(:,110)).*log((CONSTANTS(:,18)+ CONSTANTS(:,29).*CONSTANTS(:,19))./(STATES(:,4)+ CONSTANTS(:,29).*STATES(:,12)));
    ALGEBRAIC(:,52) =  CONSTANTS(:,16).*CONSTANTS(:,90).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,51));
    ALGEBRAIC(:,53) =  CONSTANTS(:,99).*CONSTANTS(:,91).*power(STATES(:,11), 2.00000).*(STATES(:,1) - ALGEBRAIC(:,51));
    ALGEBRAIC(:,54) = ALGEBRAIC(:,52)+ALGEBRAIC(:,53);
    ALGEBRAIC(:,55) =  CONSTANTS(:,103).*STATES(:,13).*STATES(:,14).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,56) =  CONSTANTS(:,104).*STATES(:,15).*STATES(:,16).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,57) = ALGEBRAIC(:,55)+ALGEBRAIC(:,56);
    ALGEBRAIC(:,58) = 1.02000./(1.00000+exp( 0.238500.*((STATES(:,1) - ALGEBRAIC(:,31)) - 59.2150)));
    ALGEBRAIC(:,59) = ( 0.491240.*exp( 0.0803200.*((STATES(:,1)+5.47600) - ALGEBRAIC(:,31)))+exp( 0.0617500.*((STATES(:,1) - ALGEBRAIC(:,31)) - 594.310)))./(1.00000+exp(  - 0.514300.*((STATES(:,1) - ALGEBRAIC(:,31))+4.75300)));
    ALGEBRAIC(:,60) = ALGEBRAIC(:,58)./(ALGEBRAIC(:,58)+ALGEBRAIC(:,59));
    ALGEBRAIC(:,61) =  1.00000.*0.350000.*power((CONSTANTS(:,18)./5.40000), 1.0 ./ 2).*ALGEBRAIC(:,60).*(STATES(:,1) - ALGEBRAIC(:,31));
    ALGEBRAIC(:,68) = ( CONSTANTS(:,36).*STATES(:,1).*CONSTANTS(:,96).*CONSTANTS(:,110).*( 0.750000.*STATES(:,4).*exp( STATES(:,1).*CONSTANTS(:,110)) -  0.750000.*CONSTANTS(:,18)))./(exp( STATES(:,1).*CONSTANTS(:,110)) - 1.00000);
    ALGEBRAIC(:,74) =  ALGEBRAIC(:,68).*STATES(:,17).*STATES(:,18).*( CONSTANTS(:,17).*(CONSTANTS(:,93)+(1.00000 - STATES(:,19)))+ CONSTANTS(:,100).*(CONSTANTS(:,92)+(1.00000 - STATES(:,20)))).*power(CONSTANTS(:,37), CONSTANTS(:,111)).*0.450000.*1.00000;
    ALGEBRAIC(:,108) = ((ALGEBRAIC(:,57)+ALGEBRAIC(:,46)+ALGEBRAIC(:,54)+ALGEBRAIC(:,61)) -  2.00000.*ALGEBRAIC(:,44))+ALGEBRAIC(:,74)+ALGEBRAIC(:,50);
    ALGEBRAIC(:,111) = ALGEBRAIC(:,106)+ALGEBRAIC(:,107);
    ALGEBRAIC(:,62) =  (( CONSTANTS(:,16).*CONSTANTS(:,31))./(1.00000+CONSTANTS(:,33)./STATES(:,5))).*(STATES(:,1) - CONSTANTS(:,123));
    ALGEBRAIC(:,63) =  (( CONSTANTS(:,99).*CONSTANTS(:,31))./(1.00000+CONSTANTS(:,33)./STATES(:,6))).*(STATES(:,1) - CONSTANTS(:,123));
    ALGEBRAIC(:,64) = ALGEBRAIC(:,62)+ALGEBRAIC(:,63);
    ALGEBRAIC(:,65) =  CONSTANTS(:,32).*(STATES(:,1) - CONSTANTS(:,123));
    ALGEBRAIC(:,112) = ALGEBRAIC(:,64)+ALGEBRAIC(:,65);
    ALGEBRAIC(:,113) = ALGEBRAIC(:,109)+ALGEBRAIC(:,110);
    ALGEBRAIC(:,114) = ALGEBRAIC(:,111)+ALGEBRAIC(:,112)+ALGEBRAIC(:,113)+ALGEBRAIC(:,108);
    ALGEBRAIC(:,37) = ALGEBRAIC(:,35)+ALGEBRAIC(:,36);
    ALGEBRAIC(:,40) = ALGEBRAIC(:,38)+ALGEBRAIC(:,39);
    ALGEBRAIC(:,73) = ALGEBRAIC(:,71)+ALGEBRAIC(:,72);
    ALGEBRAIC(:,77) = ALGEBRAIC(:,75)+ALGEBRAIC(:,76);
    ALGEBRAIC(:,79) = ALGEBRAIC(:,73)+ALGEBRAIC(:,74)+ALGEBRAIC(:,77);
    ALGEBRAIC(:,89) =  3.00000.*ALGEBRAIC(:,87)+ 3.00000.*ALGEBRAIC(:,42)+ALGEBRAIC(:,75);
    ALGEBRAIC(:,90) = ALGEBRAIC(:,87)+ALGEBRAIC(:,88);
    ALGEBRAIC(:,92) =  3.00000.*ALGEBRAIC(:,88)+ 3.00000.*ALGEBRAIC(:,43)+ALGEBRAIC(:,76);
    ALGEBRAIC(:,94) = ALGEBRAIC(:,91)+ALGEBRAIC(:,93);
    ALGEBRAIC(:,97) = ALGEBRAIC(:,95)+ALGEBRAIC(:,96);
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