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 =56;
end
% There are a total of 4 entries in each of the rate and state variable arrays.
% There are a total of 578 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_CONSTANTS(:,1) = strpad('PA in component input_values (mmHg)');
    LEGEND_CONSTANTS(:,2) = strpad('AUM in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,3) = strpad('ANM in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,4) = strpad('MYOGRS in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,5) = strpad('PAMKRN in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,6) = strpad('HM1 in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,7) = strpad('PPC in component input_values (mmHg)');
    LEGEND_CONSTANTS(:,8) = strpad('VTW in component input_values (litre)');
    LEGEND_CONSTANTS(:,9) = strpad('CNA in component input_values (monovalent_mEq_per_litre)');
    LEGEND_CONSTANTS(:,10) = strpad('ADHMK in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,11) = strpad('AMNA in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,12) = strpad('CKE in component input_values (monovalent_mEq_per_litre)');
    LEGEND_CONSTANTS(:,13) = strpad('AMK in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,14) = strpad('ANPX in component input_values (dimensionless)');
    LEGEND_CONSTANTS(:,15) = strpad('A1K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,16) = strpad('A2K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,17) = strpad('A3K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,18) = strpad('A4K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,19) = strpad('A4K2 in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,20) = strpad('AARK in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,21) = strpad('AARLL in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,22) = strpad('ADHINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,23) = strpad('ADHKLL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,24) = strpad('ADHKUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,25) = strpad('ADHPAM in component parameter_values (per_mmHg2)');
    LEGEND_CONSTANTS(:,26) = strpad('ADHPUL in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,27) = strpad('ADHTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,28) = strpad('ADHVLL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,29) = strpad('ADHVUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,30) = strpad('AH10 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,31) = strpad('AH11 in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,32) = strpad('AH9 in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,33) = strpad('AHMNAR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,34) = strpad('AHTHM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,35) = strpad('ALCLK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,36) = strpad('ALDINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,37) = strpad('ALDKNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,38) = strpad('ALDMM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,39) = strpad('AM1LL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,40) = strpad('AM1UL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,41) = strpad('AMCSNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,42) = strpad('AMKM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,43) = strpad('AMKMUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,44) = strpad('AMM1LM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,45) = strpad('AMM4 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,46) = strpad('AMNALL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,47) = strpad('AMNAM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,48) = strpad('AMNAUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,49) = strpad('AMT in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,50) = strpad('ANCSNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,51) = strpad('ANGINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,52) = strpad('ANGKNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,53) = strpad('ANMALD in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,54) = strpad('ANMAM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,55) = strpad('ANMARL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,56) = strpad('ANMEM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,57) = strpad('ANMKEL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,58) = strpad('ANMKEM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,59) = strpad('ANMLL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,60) = strpad('ANMNAM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,61) = strpad('ANMSLT in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,62) = strpad('ANMTM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,63) = strpad('ANMUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,64) = strpad('ANPTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,65) = strpad('ANPXAF in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,66) = strpad('ANPXUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,67) = strpad('ANT in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,68) = strpad('ANULL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,69) = strpad('ANUM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,70) = strpad('ANUVM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,71) = strpad('ANV in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,72) = strpad('ANXM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,73) = strpad('ANY in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,74) = strpad('AR1LM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,75) = strpad('AR2LM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,76) = strpad('ARF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,77) = strpad('AUC1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,78) = strpad('AUDMP in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,79) = strpad('AUK in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,80) = strpad('AUL in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,81) = strpad('AULPM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,82) = strpad('AUM1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,83) = strpad('AUM2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,84) = strpad('AUMAX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,85) = strpad('AUMIN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,86) = strpad('AUMK1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,87) = strpad('AUN1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,88) = strpad('AURG in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,89) = strpad('AUS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,90) = strpad('AUSLP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,91) = strpad('AUTO in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,92) = strpad('AUTOGN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,93) = strpad('AUTOSN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,94) = strpad('AUX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,95) = strpad('BAROTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,96) = strpad('CFC in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,97) = strpad('CKEEX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,98) = strpad('CMPTSS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,99) = strpad('CN2 in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,100) = strpad('CN7 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,101) = strpad('CNR in component parameter_values (monovalent_mEq_per_litre)');
    LEGEND_CONSTANTS(:,102) = strpad('CPF in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,103) = strpad('CPK in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,104) = strpad('CPR in component parameter_values (gram_per_L)');
    LEGEND_CONSTANTS(:,105) = strpad('CV in component parameter_values (L_per_mmHg)');
    LEGEND_CONSTANTS(:,106) = strpad('CRRFLX in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,107) = strpad('DIURET in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,108) = strpad('DHDTR in component parameter_values (per_mmHg_per_minute)');
    LEGEND_CONSTANTS(:,109) = strpad('DTNAR in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,110) = strpad('DTNARL in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,111) = strpad('EARK in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,112) = strpad('EARLL in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,113) = strpad('EFAFR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,114) = strpad('EXC in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,115) = strpad('EXCML in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,116) = strpad('EXCXP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,117) = strpad('EXCXP2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,118) = strpad('EXE in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,119) = strpad('GCOPF in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,120) = strpad('GFLC in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,121) = strpad('GFNDMP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,122) = strpad('GFNLL in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,123) = strpad('GPPD in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,124) = strpad('HM6 in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,125) = strpad('HM8 in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,126) = strpad('HTAUML in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,127) = strpad('KORGN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,128) = strpad('KORNER in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,129) = strpad('KORREN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,130) = strpad('KORTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,131) = strpad('LPDE in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,132) = strpad('LPK in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,133) = strpad('LPPR in component parameter_values (gram_per_minute)');
    LEGEND_CONSTANTS(:,134) = strpad('MDFL1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,135) = strpad('MDFLKM in component parameter_values (monovalent_mEq_per_litre)');
    LEGEND_CONSTANTS(:,136) = strpad('MDFLW2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,137) = strpad('MDFLWX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,138) = strpad('MDMP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,139) = strpad('O2A in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,140) = strpad('O2CHMO in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,141) = strpad('OMM in component parameter_values (mL_per_minute)');
    LEGEND_CONSTANTS(:,142) = strpad('PA4 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,143) = strpad('PAEX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,144) = strpad('PCE in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,145) = strpad('PCR in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,146) = strpad('PR1LL in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,147) = strpad('PGHF in component parameter_values (L_mmHg_per_gram)');
    LEGEND_CONSTANTS(:,148) = strpad('PK2 in component parameter_values (mmHg_per_mL)');
    LEGEND_CONSTANTS(:,149) = strpad('PL2 in component parameter_values (L_mL_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,150) = strpad('PLDF in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,151) = strpad('PM5 in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,152) = strpad('PO2ADV in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,153) = strpad('POK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,154) = strpad('POM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,155) = strpad('POM2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,156) = strpad('PON in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,157) = strpad('POR in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,158) = strpad('POZ in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,159) = strpad('PXTP in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,160) = strpad('QAOLM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,161) = strpad('QRF in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,162) = strpad('RABSC in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,163) = strpad('RAM in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,164) = strpad('RAPRSP in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,165) = strpad('RAR in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,166) = strpad('RCDFDP in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,167) = strpad('RCDFPC in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,168) = strpad('REK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,169) = strpad('RFABKM in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,170) = strpad('RFABDM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,171) = strpad('RFABDP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,172) = strpad('RFCDFT in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,173) = strpad('RKC in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,174) = strpad('RNAGTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,175) = strpad('RNAUAD in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,176) = strpad('RPS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,177) = strpad('RTPPR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,178) = strpad('RTPPRS in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,179) = strpad('RTSPRS in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,180) = strpad('RVRS in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,181) = strpad('RVSM in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,182) = strpad('SR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,183) = strpad('SR2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,184) = strpad('SRK in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,185) = strpad('SRK2 in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,186) = strpad('STA in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,187) = strpad('TENSGN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,188) = strpad('TENSTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,189) = strpad('TIMETR in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,190) = strpad('TRNSFS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,191) = strpad('TRPL in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,192) = strpad('TSSLML in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,193) = strpad('TSSLTC in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,194) = strpad('TVDDL in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,195) = strpad('U in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,196) = strpad('VID1 in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,197) = strpad('VIDML in component parameter_values (litre2_per_monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,198) = strpad('VNTSTM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,199) = strpad('VP1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,200) = strpad('VPTISS in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,201) = strpad('VTSF in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,202) = strpad('VV9 in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,203) = strpad('X in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,204) = strpad('Z in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,205) = strpad('Z4 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,206) = strpad('Z5 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,207) = strpad('Z6 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,208) = strpad('Z7 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,209) = strpad('Z10 in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,210) = strpad('Z11 in component parameter_values (per_mmHg2)');
    LEGEND_CONSTANTS(:,211) = strpad('Z12 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,212) = strpad('Z13 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,213) = strpad('Z14 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,214) = strpad('Z16 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,215) = strpad('Z18 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,216) = strpad('Z19 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,217) = strpad('KID in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,218) = strpad('URFORM in component parameter_values (mOsm_per_minute)');
    LEGEND_CONSTANTS(:,219) = strpad('AUV in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,220) = strpad('AUY in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,221) = strpad('O2M in component parameter_values (mL_per_minute)');
    LEGEND_CONSTANTS(:,222) = strpad('NID in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,223) = strpad('ATRFBM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,224) = strpad('GBL in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,225) = strpad('RNAUGN in component parameter_values (minute_per_L)');
    LEGEND_CONSTANTS(:,226) = strpad('RNAULL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,227) = strpad('RNAUUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,228) = strpad('HSR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,229) = strpad('HSL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,230) = strpad('HMK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,231) = strpad('PO2AMB in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,232) = strpad('HKM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,233) = strpad('DR in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,234) = strpad('ANPKNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,235) = strpad('RMULT1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,236) = strpad('GLPCA in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,237) = strpad('RFN in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,238) = strpad('RFABX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,239) = strpad('ANPINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,240) = strpad('FIS in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,241) = strpad('CPPD in component parameter_values (gram_per_L)');
    LEGEND_CONSTANTS(:,242) = strpad('TRRBC in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,243) = strpad('HYL in component parameter_values (gram)');
    LEGEND_CONSTANTS(:,244) = strpad('ATRVM in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,245) = strpad('ADHC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,246) = strpad('AHY_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,247) = strpad('AMC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,248) = strpad('AMM1T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,249) = strpad('AMM2_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,250) = strpad('ANC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,251) = strpad('ANPC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,252) = strpad('ANX1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,253) = strpad('AR1T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,254) = strpad('AR2T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,255) = strpad('AR3T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,256) = strpad('AU1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,257) = strpad('AU4_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,258) = strpad('AU6_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,259) = strpad('DTKA_init in component state_variables (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,260) = strpad('HMD1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,261) = strpad('HPL_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,262) = strpad('HPR_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,263) = strpad('KTOT_init in component state_variables (monovalent_mEq)');
    LEGEND_CONSTANTS(:,264) = strpad('NAE_init in component state_variables (monovalent_mEq)');
    LEGEND_CONSTANTS(:,265) = strpad('O2VAD1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,266) = strpad('OSV_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,267) = strpad('OVA_init in component state_variables (mL_per_L)');
    LEGEND_CONSTANTS(:,268) = strpad('OVS_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,269) = strpad('PAR1_init in component state_variables (mmHg)');
    LEGEND_CONSTANTS(:,270) = strpad('PC_init in component state_variables (mmHg)');
    LEGEND_CONSTANTS(:,271) = strpad('PLUR_init in component state_variables (mOsm)');
    LEGEND_CONSTANTS(:,272) = strpad('PPR1_init in component state_variables (gram)');
    LEGEND_CONSTANTS(:,273) = strpad('PRP_init in component state_variables (gram)');
    LEGEND_CONSTANTS(:,274) = strpad('QO2T_init in component state_variables (mL)');
    LEGEND_CONSTANTS(:,275) = strpad('QOM1_init in component state_variables (mL)');
    LEGEND_CONSTANTS(:,276) = strpad('RNAUG3_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,277) = strpad('TSP_init in component state_variables (gram)');
    LEGEND_CONSTANTS(:,278) = strpad('TVD_init in component state_variables (L_per_minute)');
    LEGEND_CONSTANTS(:,279) = strpad('VAS1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,280) = strpad('VIC_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,281) = strpad('VLA1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,282) = strpad('VPA1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,283) = strpad('VPF1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,284) = strpad('VP_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,285) = strpad('VRA1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,286) = strpad('VRC_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,287) = strpad('VTS2_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,288) = strpad('VTW_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,289) = strpad('VV6_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,290) = strpad('VV7_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,291) = strpad('VVS1_init in component state_variables (litre)');
    LEGEND_VOI = strpad('time in component environment (minute)');
    LEGEND_ALGEBRAIC(:,25) = strpad('RBF in component actual_renal_blood_flow (L_per_minute)');
    LEGEND_ALGEBRAIC(:,3) = strpad('MDFLW in component proximal_tubular_and_macula_densa_flow (L_per_minute)');
    LEGEND_ALGEBRAIC(:,45) = strpad('NOD in component actual_Na_excretion_rate (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,48) = strpad('KOD in component actual_K_excretion_rate (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,56) = strpad('VUD in component actual_urine_volume (L_per_minute)');
    LEGEND_CONSTANTS(:,292) = strpad('A1K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,293) = strpad('A2K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,294) = strpad('A3K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,295) = strpad('A4K in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,296) = strpad('A4K2 in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,297) = strpad('AARK in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,298) = strpad('AARLL in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,299) = strpad('ADHINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,300) = strpad('ADHKLL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,301) = strpad('ADHKUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,302) = strpad('ADHPAM in component parameter_values (per_mmHg2)');
    LEGEND_CONSTANTS(:,303) = strpad('ADHPUL in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,304) = strpad('ADHTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,305) = strpad('ADHVLL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,306) = strpad('ADHVUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,307) = strpad('AH10 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,308) = strpad('AH11 in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,309) = strpad('AH9 in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,310) = strpad('AHMNAR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,311) = strpad('AHTHM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,312) = strpad('ALCLK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,313) = strpad('ALDINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,314) = strpad('ALDKNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,315) = strpad('ALDMM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,316) = strpad('AM1LL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,317) = strpad('AM1UL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,318) = strpad('AMCSNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,319) = strpad('AMKM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,320) = strpad('AMKMUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,321) = strpad('AMM1LM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,322) = strpad('AMM4 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,323) = strpad('AMNALL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,324) = strpad('AMNAM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,325) = strpad('AMNAUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,326) = strpad('AMT in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,327) = strpad('ANCSNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,328) = strpad('ANGINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,329) = strpad('ANGKNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,330) = strpad('ANMALD in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,331) = strpad('ANMAM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,332) = strpad('ANMARL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,333) = strpad('ANMEM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,334) = strpad('ANMKEL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,335) = strpad('ANMKEM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,336) = strpad('ANMLL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,337) = strpad('ANMNAM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,338) = strpad('ANMSLT in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,339) = strpad('ANMTM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,340) = strpad('ANMUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,341) = strpad('ANPTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,342) = strpad('ANPXAF in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,343) = strpad('ANPXUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,344) = strpad('ANT in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,345) = strpad('ANULL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,346) = strpad('ANUM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,347) = strpad('ANUVM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,348) = strpad('ANV in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,349) = strpad('ANXM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,350) = strpad('ANY in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,351) = strpad('AR1LM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,352) = strpad('AR2LM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,353) = strpad('ARF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,354) = strpad('AUC1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,355) = strpad('AUDMP in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,356) = strpad('AUK in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,357) = strpad('AUL in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,358) = strpad('AULPM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,359) = strpad('AUM1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,360) = strpad('AUM2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,361) = strpad('AUMAX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,362) = strpad('AUMIN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,363) = strpad('AUMK1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,364) = strpad('AUN1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,365) = strpad('AURG in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,366) = strpad('AUS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,367) = strpad('AUSLP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,368) = strpad('AUTO in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,369) = strpad('AUTOGN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,370) = strpad('AUTOSN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,371) = strpad('AUX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,372) = strpad('BAROTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,373) = strpad('CFC in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,374) = strpad('CKEEX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,375) = strpad('CMPTSS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,376) = strpad('CN2 in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,377) = strpad('CN7 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,378) = strpad('CNR in component parameter_values (monovalent_mEq_per_litre)');
    LEGEND_CONSTANTS(:,379) = strpad('CPF in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,380) = strpad('CPK in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,381) = strpad('CPR in component parameter_values (gram_per_L)');
    LEGEND_CONSTANTS(:,382) = strpad('CV in component parameter_values (L_per_mmHg)');
    LEGEND_CONSTANTS(:,383) = strpad('CRRFLX in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,384) = strpad('DIURET in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,385) = strpad('DHDTR in component parameter_values (per_mmHg_per_minute)');
    LEGEND_CONSTANTS(:,386) = strpad('DTNAR in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,387) = strpad('DTNARL in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,388) = strpad('EARK in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,389) = strpad('EARLL in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,390) = strpad('EFAFR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,391) = strpad('EXC in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,392) = strpad('EXCML in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,393) = strpad('EXCXP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,394) = strpad('EXCXP2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,395) = strpad('EXE in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,396) = strpad('GCOPF in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,397) = strpad('GFLC in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,398) = strpad('GFNDMP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,399) = strpad('GFNLL in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,400) = strpad('GPPD in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,401) = strpad('HM6 in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,402) = strpad('HM8 in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,403) = strpad('HTAUML in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,404) = strpad('KORGN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,405) = strpad('KORNER in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,406) = strpad('KORREN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,407) = strpad('KORTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,408) = strpad('LPDE in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,409) = strpad('LPK in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,410) = strpad('LPPR in component parameter_values (gram_per_minute)');
    LEGEND_CONSTANTS(:,411) = strpad('MDFL1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,412) = strpad('MDFLKM in component parameter_values (monovalent_mEq_per_litre)');
    LEGEND_CONSTANTS(:,413) = strpad('MDFLW2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,414) = strpad('MDFLWX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,415) = strpad('MDMP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,416) = strpad('O2A in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,417) = strpad('O2CHMO in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,418) = strpad('OMM in component parameter_values (mL_per_minute)');
    LEGEND_CONSTANTS(:,419) = strpad('PA4 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,420) = strpad('PAEX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,421) = strpad('PCE in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,422) = strpad('PCR in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,423) = strpad('PR1LL in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,424) = strpad('PGHF in component parameter_values (L_mmHg_per_gram)');
    LEGEND_CONSTANTS(:,425) = strpad('PK2 in component parameter_values (mmHg_per_mL)');
    LEGEND_CONSTANTS(:,426) = strpad('PL2 in component parameter_values (L_mL_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,427) = strpad('PLDF in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,428) = strpad('PM5 in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,429) = strpad('PO2ADV in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,430) = strpad('POK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,431) = strpad('POM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,432) = strpad('POM2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,433) = strpad('PON in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,434) = strpad('POR in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,435) = strpad('POZ in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,436) = strpad('PXTP in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,437) = strpad('QAOLM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,438) = strpad('QRF in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,439) = strpad('RABSC in component parameter_values (per_mmHg)');
    LEGEND_CONSTANTS(:,440) = strpad('RAM in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,441) = strpad('RAPRSP in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,442) = strpad('RAR in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,443) = strpad('RCDFDP in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,444) = strpad('RCDFPC in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,445) = strpad('REK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,446) = strpad('RFABKM in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,447) = strpad('RFABDM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,448) = strpad('RFABDP in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,449) = strpad('RFCDFT in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,450) = strpad('RKC in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,451) = strpad('RNAGTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,452) = strpad('RNAUAD in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,453) = strpad('RPS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,454) = strpad('RTPPR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,455) = strpad('RTPPRS in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,456) = strpad('RTSPRS in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,457) = strpad('RVRS in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,458) = strpad('RVSM in component parameter_values (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,459) = strpad('SR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,460) = strpad('SR2 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,461) = strpad('SRK in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,462) = strpad('SRK2 in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,463) = strpad('STA in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,464) = strpad('TENSGN in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,465) = strpad('TENSTC in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,466) = strpad('TIMETR in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,467) = strpad('TRNSFS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,468) = strpad('TRPL in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,469) = strpad('TSSLML in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,470) = strpad('TSSLTC in component parameter_values (per_minute)');
    LEGEND_CONSTANTS(:,471) = strpad('TVDDL in component parameter_values (minute)');
    LEGEND_CONSTANTS(:,472) = strpad('U in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,473) = strpad('VID1 in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,474) = strpad('VIDML in component parameter_values (litre2_per_monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,475) = strpad('VNTSTM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,476) = strpad('VP1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,477) = strpad('VPTISS in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,478) = strpad('VTSF in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,479) = strpad('VV9 in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,480) = strpad('X in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,481) = strpad('Z in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,482) = strpad('Z4 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,483) = strpad('Z5 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,484) = strpad('Z6 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,485) = strpad('Z7 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,486) = strpad('Z10 in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,487) = strpad('Z11 in component parameter_values (per_mmHg2)');
    LEGEND_CONSTANTS(:,488) = strpad('Z12 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,489) = strpad('Z13 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,490) = strpad('Z14 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,491) = strpad('Z16 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,492) = strpad('Z18 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,493) = strpad('Z19 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,494) = strpad('KID in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,495) = strpad('URFORM in component parameter_values (mOsm_per_minute)');
    LEGEND_CONSTANTS(:,496) = strpad('AUV in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,497) = strpad('AUY in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,498) = strpad('O2M in component parameter_values (mL_per_minute)');
    LEGEND_CONSTANTS(:,499) = strpad('NID in component parameter_values (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,500) = strpad('ATRFBM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,501) = strpad('GBL in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,502) = strpad('RNAUGN in component parameter_values (minute_per_L)');
    LEGEND_CONSTANTS(:,503) = strpad('RNAULL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,504) = strpad('RNAUUL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,505) = strpad('HSR in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,506) = strpad('HSL in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,507) = strpad('HMK in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,508) = strpad('PO2AMB in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,509) = strpad('HKM in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,510) = strpad('DR in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,511) = strpad('ANPKNS in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,512) = strpad('RMULT1 in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,513) = strpad('GLPCA in component parameter_values (mmHg)');
    LEGEND_CONSTANTS(:,514) = strpad('RFN in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,515) = strpad('RFABX in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,516) = strpad('ANPINF in component parameter_values (dimensionless)');
    LEGEND_CONSTANTS(:,517) = strpad('FIS in component parameter_values (L_per_minute_per_mmHg)');
    LEGEND_CONSTANTS(:,518) = strpad('CPPD in component parameter_values (gram_per_L)');
    LEGEND_CONSTANTS(:,519) = strpad('TRRBC in component parameter_values (L_per_minute)');
    LEGEND_CONSTANTS(:,520) = strpad('HYL in component parameter_values (gram)');
    LEGEND_CONSTANTS(:,521) = strpad('ATRVM in component parameter_values (litre)');
    LEGEND_CONSTANTS(:,522) = strpad('ADHC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,523) = strpad('AHY_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,524) = strpad('AMC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,525) = strpad('AMM1T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,526) = strpad('AMM2_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,527) = strpad('ANC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,528) = strpad('ANPC_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,529) = strpad('ANX1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,530) = strpad('AR1T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,531) = strpad('AR2T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,532) = strpad('AR3T_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,533) = strpad('AU1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,534) = strpad('AU4_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,535) = strpad('AU6_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,536) = strpad('DTKA_init in component state_variables (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,537) = strpad('HMD1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,538) = strpad('HPL_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,539) = strpad('HPR_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,540) = strpad('KTOT_init in component state_variables (monovalent_mEq)');
    LEGEND_CONSTANTS(:,541) = strpad('NAE_init in component state_variables (monovalent_mEq)');
    LEGEND_CONSTANTS(:,542) = strpad('O2VAD1_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,543) = strpad('OSV_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,544) = strpad('OVA_init in component state_variables (mL_per_L)');
    LEGEND_CONSTANTS(:,545) = strpad('OVS_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,546) = strpad('PAR1_init in component state_variables (mmHg)');
    LEGEND_CONSTANTS(:,547) = strpad('PC_init in component state_variables (mmHg)');
    LEGEND_CONSTANTS(:,548) = strpad('PLUR_init in component state_variables (mOsm)');
    LEGEND_CONSTANTS(:,549) = strpad('PPR1_init in component state_variables (gram)');
    LEGEND_CONSTANTS(:,550) = strpad('PRP_init in component state_variables (gram)');
    LEGEND_CONSTANTS(:,551) = strpad('QO2T_init in component state_variables (mL)');
    LEGEND_CONSTANTS(:,552) = strpad('QOM1_init in component state_variables (mL)');
    LEGEND_CONSTANTS(:,553) = strpad('RNAUG3_init in component state_variables (dimensionless)');
    LEGEND_CONSTANTS(:,554) = strpad('TSP_init in component state_variables (gram)');
    LEGEND_CONSTANTS(:,555) = strpad('TVD_init in component state_variables (L_per_minute)');
    LEGEND_CONSTANTS(:,556) = strpad('VAS1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,557) = strpad('VIC_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,558) = strpad('VLA1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,559) = strpad('VPA1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,560) = strpad('VPF1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,561) = strpad('VP_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,562) = strpad('VRA1_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,563) = strpad('VRC_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,564) = strpad('VTS2_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,565) = strpad('VTW_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,566) = strpad('VV6_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,567) = strpad('VV7_init in component state_variables (litre)');
    LEGEND_CONSTANTS(:,568) = strpad('VVS1_init in component state_variables (litre)');
    LEGEND_ALGEBRAIC(:,1) = strpad('PAR in component perfusion_pressure (mmHg)');
    LEGEND_STATES(:,1) = strpad('PAR1 in component perfusion_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,4) = strpad('RNAUG2 in component renal_autoregulatory_feedback_factor (dimensionless)');
    LEGEND_ALGEBRAIC(:,5) = strpad('RNAUG1 in component renal_autoregulatory_feedback_factor (dimensionless)');
    LEGEND_ALGEBRAIC(:,6) = strpad('RNAUG1T in component renal_autoregulatory_feedback_factor (dimensionless)');
    LEGEND_STATES(:,2) = strpad('RNAUG3 in component renal_autoregulatory_feedback_factor (dimensionless)');
    LEGEND_CONSTANTS(:,570) = strpad('AUMK in component autonomic_effect_on_AAR (dimensionless)');
    LEGEND_CONSTANTS(:,569) = strpad('AUMKT in component autonomic_effect_on_AAR (dimensionless)');
    LEGEND_CONSTANTS(:,572) = strpad('ANMAR in component angiotensin_effect_on_AAR (dimensionless)');
    LEGEND_CONSTANTS(:,571) = strpad('ANMAR1 in component angiotensin_effect_on_AAR (dimensionless)');
    LEGEND_ALGEBRAIC(:,7) = strpad('AAR1 in component AAR_calculation (mmHg_minute_per_L)');
    LEGEND_ALGEBRAIC(:,8) = strpad('AAR in component atrial_natriuretic_peptide_effect_on_AAR (mmHg_minute_per_L)');
    LEGEND_ALGEBRAIC(:,9) = strpad('AART in component atrial_natriuretic_peptide_effect_on_AAR (mmHg_minute_per_L)');
    LEGEND_CONSTANTS(:,573) = strpad('AUMK2 in component autonomic_effect_on_EAR (dimensionless)');
    LEGEND_CONSTANTS(:,574) = strpad('ANMER in component angiotensin_effect_on_EAR (dimensionless)');
    LEGEND_ALGEBRAIC(:,10) = strpad('RNAUG4 in component effect_of_renal_autoregulatory_feedback_on_EAR (dimensionless)');
    LEGEND_ALGEBRAIC(:,11) = strpad('EAR in component EAR_calculation (mmHg_minute_per_L)');
    LEGEND_ALGEBRAIC(:,12) = strpad('EAR1 in component EAR_calculation (mmHg_minute_per_L)');
    LEGEND_ALGEBRAIC(:,13) = strpad('RR in component total_renal_resistance (mmHg_minute_per_L)');
    LEGEND_ALGEBRAIC(:,14) = strpad('RFN in component normal_renal_blood_flow (L_per_minute)');
    LEGEND_ALGEBRAIC(:,15) = strpad('GFN in component glomerular_filtration_rate (L_per_minute)');
    LEGEND_ALGEBRAIC(:,16) = strpad('GLPC in component glomerular_colloid_osmotic_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,17) = strpad('EFAFPR in component glomerular_colloid_osmotic_pressure (dimensionless)');
    LEGEND_ALGEBRAIC(:,18) = strpad('EFAFPR1 in component glomerular_colloid_osmotic_pressure (dimensionless)');
    LEGEND_ALGEBRAIC(:,19) = strpad('GLP in component glomerular_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,20) = strpad('APD in component glomerular_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,26) = strpad('GFR in component glomerular_filtration_rate (L_per_minute)');
    LEGEND_ALGEBRAIC(:,21) = strpad('PFL in component glomerular_filtration_rate (mmHg)');
    LEGEND_ALGEBRAIC(:,22) = strpad('GFN1 in component glomerular_filtration_rate (L_per_minute)');
    LEGEND_ALGEBRAIC(:,50) = strpad('UROD in component actual_urea_excretion_rate (mOsm_per_minute)');
    LEGEND_STATES(:,3) = strpad('PLUR in component glomerular_urea_concentration (mOsm)');
    LEGEND_ALGEBRAIC(:,23) = strpad('PTFL in component proximal_tubular_and_macula_densa_flow (L_per_minute)');
    LEGEND_ALGEBRAIC(:,24) = strpad('MDFLWT in component proximal_tubular_and_macula_densa_flow (L_per_minute)');
    LEGEND_ALGEBRAIC(:,28) = strpad('RTSPPC in component renal_tissue_osmotic_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,27) = strpad('RTSPPC1 in component renal_tissue_osmotic_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,2) = strpad('PLURC in component plasma_urea_concentration (mOsm_per_litre)');
    LEGEND_ALGEBRAIC(:,29) = strpad('RCPRS in component peritubular_capillary_pressure (mmHg)');
    LEGEND_ALGEBRAIC(:,34) = strpad('RFABD in component peritubular_capillary_reabsorption_factor (dimensionless)');
    LEGEND_ALGEBRAIC(:,30) = strpad('RABSPR in component peritubular_capillary_reabsorption_factor (mmHg)');
    LEGEND_ALGEBRAIC(:,31) = strpad('RFAB1 in component peritubular_capillary_reabsorption_factor (dimensionless)');
    LEGEND_ALGEBRAIC(:,32) = strpad('RFAB in component peritubular_capillary_reabsorption_factor (dimensionless)');
    LEGEND_ALGEBRAIC(:,33) = strpad('RFABD1 in component peritubular_capillary_reabsorption_factor (dimensionless)');
    LEGEND_ALGEBRAIC(:,35) = strpad('DTNAI in component distal_tubular_Na_delivery (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,37) = strpad('DTNARA in component Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,36) = strpad('DTNARA1 in component Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,576) = strpad('DTNANG in component angiotensin_induced_Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,575) = strpad('DTNANG1 in component angiotensin_induced_Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,38) = strpad('DTKI in component distal_tubular_K_delivery (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,39) = strpad('RFABK in component effect_of_physical_forces_on_distal_K_reabsorption (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,41) = strpad('MDFLK in component effect_of_fluid_flow_on_distal_K_reabsorption (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,40) = strpad('MDFLK1 in component effect_of_fluid_flow_on_distal_K_reabsorption (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,47) = strpad('KODN in component normal_K_excretion (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,55) = strpad('VUDN in component normal_urine_volume (L_per_minute)');
    LEGEND_STATES(:,4) = strpad('DTKA in component K_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,42) = strpad('DTKSC in component K_secretion_from_distal_tubules (monovalent_mEq_per_minute)');
    LEGEND_CONSTANTS(:,577) = strpad('ANMKE1 in component K_secretion_from_distal_tubules (dimensionless)');
    LEGEND_CONSTANTS(:,578) = strpad('ANMKE in component K_secretion_from_distal_tubules (dimensionless)');
    LEGEND_ALGEBRAIC(:,44) = strpad('NODN in component normal_Na_excretion (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,43) = strpad('NODN1 in component normal_Na_excretion (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,46) = strpad('KODN1 in component normal_K_excretion (monovalent_mEq_per_minute)');
    LEGEND_ALGEBRAIC(:,49) = strpad('DTURI in component normal_urea_excretion (mOsm_per_minute)');
    LEGEND_ALGEBRAIC(:,51) = strpad('OSMOPN1 in component normal_osmolar_and_water_excretion (mOsm_per_minute)');
    LEGEND_ALGEBRAIC(:,52) = strpad('OSMOPN in component normal_osmolar_and_water_excretion (mOsm_per_minute)');
    LEGEND_ALGEBRAIC(:,53) = strpad('OSMOP1T in component normal_urine_volume (mOsm_per_minute)');
    LEGEND_ALGEBRAIC(:,54) = strpad('OSMOP1 in component normal_urine_volume (mOsm_per_minute)');
    LEGEND_RATES(:,1) = strpad('d/dt PAR1 in component perfusion_pressure (mmHg)');
    LEGEND_RATES(:,2) = strpad('d/dt RNAUG3 in component renal_autoregulatory_feedback_factor (dimensionless)');
    LEGEND_RATES(:,3) = strpad('d/dt PLUR in component glomerular_urea_concentration (mOsm)');
    LEGEND_RATES(:,4) = strpad('d/dt DTKA in component K_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)');
    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) = 103.525;
    CONSTANTS(:,2) = 1.00066;
    CONSTANTS(:,3) = 0.987545;
    CONSTANTS(:,4) = 1.0;
    CONSTANTS(:,5) = 1.0;
    CONSTANTS(:,6) = 0.39984739;
    CONSTANTS(:,7) = 29.9941;
    CONSTANTS(:,8) = 39.8952;
    CONSTANTS(:,9) = 142.035;
    CONSTANTS(:,10) = 1.0;
    CONSTANTS(:,11) = 1.0;
    CONSTANTS(:,12) = 4.44092;
    CONSTANTS(:,13) = 1.037;
    CONSTANTS(:,14) = 1.0;
    CONSTANTS(:,15) = 0.5;
    CONSTANTS(:,16) = 60;
    CONSTANTS(:,17) = 40000;
    CONSTANTS(:,18) = 0.1;
    CONSTANTS(:,19) = 40000;
    CONSTANTS(:,20) = 1;
    CONSTANTS(:,21) = 4;
    CONSTANTS(:,22) = 0;
    CONSTANTS(:,23) = 0.2;
    CONSTANTS(:,24) = 5;
    CONSTANTS(:,25) = 0.3;
    CONSTANTS(:,26) = 85;
    CONSTANTS(:,27) = 15;
    CONSTANTS(:,28) = 0.93617;
    CONSTANTS(:,29) = 2.5;
    CONSTANTS(:,30) = 0.333;
    CONSTANTS(:,31) = 1000;
    CONSTANTS(:,32) = 1;
    CONSTANTS(:,33) = 0.3;
    CONSTANTS(:,34) = 2;
    CONSTANTS(:,35) = 0.3;
    CONSTANTS(:,36) = 0;
    CONSTANTS(:,37) = 0;
    CONSTANTS(:,38) = 2.5;
    CONSTANTS(:,39) = 0;
    CONSTANTS(:,40) = 5;
    CONSTANTS(:,41) = 0.65;
    CONSTANTS(:,42) = 0.5;
    CONSTANTS(:,43) = 12;
    CONSTANTS(:,44) = 0.005;
    CONSTANTS(:,45) = 0.005;
    CONSTANTS(:,46) = 0.04;
    CONSTANTS(:,47) = 0.8;
    CONSTANTS(:,48) = 15;
    CONSTANTS(:,49) = 60;
    CONSTANTS(:,50) = 0.4;
    CONSTANTS(:,51) = 0;
    CONSTANTS(:,52) = 0;
    CONSTANTS(:,53) = 2.5;
    CONSTANTS(:,54) = 1.4;
    CONSTANTS(:,55) = 0.86;
    CONSTANTS(:,56) = 1.6;
    CONSTANTS(:,57) = 0.3;
    CONSTANTS(:,58) = 2;
    CONSTANTS(:,59) = 0.7;
    CONSTANTS(:,60) = 1;
    CONSTANTS(:,61) = 2;
    CONSTANTS(:,62) = 1.5;
    CONSTANTS(:,63) = 1.8;
    CONSTANTS(:,64) = 4;
    CONSTANTS(:,65) = 1.5;
    CONSTANTS(:,66) = 10;
    CONSTANTS(:,67) = 12;
    CONSTANTS(:,68) = 0.8;
    CONSTANTS(:,69) = 6;
    CONSTANTS(:,70) = 0;
    CONSTANTS(:,71) = 5000;
    CONSTANTS(:,72) = 0;
    CONSTANTS(:,73) = -0.2;
    CONSTANTS(:,74) = 0.005;
    CONSTANTS(:,75) = 0.005;
    CONSTANTS(:,76) = 0.5;
    CONSTANTS(:,77) = 0.3;
    CONSTANTS(:,78) = 0.3;
    CONSTANTS(:,79) = 0.004;
    CONSTANTS(:,80) = 1.5;
    CONSTANTS(:,81) = 0;
    CONSTANTS(:,82) = 3;
    CONSTANTS(:,83) = 1;
    CONSTANTS(:,84) = 5.0;
    CONSTANTS(:,85) = 0.4;
    CONSTANTS(:,86) = 0.3;
    CONSTANTS(:,87) = 0.5;
    CONSTANTS(:,88) = 1.0;
    CONSTANTS(:,89) = 1;
    CONSTANTS(:,90) = 1.5;
    CONSTANTS(:,91) = 0;
    CONSTANTS(:,92) = 7;
    CONSTANTS(:,93) = 0.9;
    CONSTANTS(:,94) = 1;
    CONSTANTS(:,95) = 0.16;
    CONSTANTS(:,96) = 0.01167;
    CONSTANTS(:,97) = 4;
    CONSTANTS(:,98) = 2;
    CONSTANTS(:,99) = 0.0212;
    CONSTANTS(:,100) = 0.2;
    CONSTANTS(:,101) = 139;
    CONSTANTS(:,102) = 0.0003;
    CONSTANTS(:,103) = 0.000253;
    CONSTANTS(:,104) = 40;
    CONSTANTS(:,105) = 0.1;
    CONSTANTS(:,106) = 0;
    CONSTANTS(:,107) = 1;
    CONSTANTS(:,108) = 0.05;
    CONSTANTS(:,109) = 0.675;
    CONSTANTS(:,110) = 1e-06;
    CONSTANTS(:,111) = 1;
    CONSTANTS(:,112) = 24;
    CONSTANTS(:,113) = 0;
    CONSTANTS(:,114) = 1;
    CONSTANTS(:,115) = 0.01;
    CONSTANTS(:,116) = 1.0;
    CONSTANTS(:,117) = 0.17;
    CONSTANTS(:,118) = 0;
    CONSTANTS(:,119) = 0.8092;
    CONSTANTS(:,120) = 0.0208333;
    CONSTANTS(:,121) = 3;
    CONSTANTS(:,122) = 0.001;
    CONSTANTS(:,123) = 1.0;
    CONSTANTS(:,124) = 1850;
    CONSTANTS(:,125) = 4.714e-08;
    CONSTANTS(:,126) = 0.4;
    CONSTANTS(:,127) = 1;
    CONSTANTS(:,128) = 0;
    CONSTANTS(:,129) = 0;
    CONSTANTS(:,130) = 10000;
    CONSTANTS(:,131) = 8;
    CONSTANTS(:,132) = 2.728e-14;
    CONSTANTS(:,133) = 0.03;
    CONSTANTS(:,134) = 10;
    CONSTANTS(:,135) = 0.667;
    CONSTANTS(:,136) = 0.005;
    CONSTANTS(:,137) = 0.01;
    CONSTANTS(:,138) = 0;
    CONSTANTS(:,139) = 0.1;
    CONSTANTS(:,140) = 0.01;
    CONSTANTS(:,141) = 57.1;
    CONSTANTS(:,142) = 1;
    CONSTANTS(:,143) = 2;
    CONSTANTS(:,144) = 1;
    CONSTANTS(:,145) = 15;
    CONSTANTS(:,146) = 0;
    CONSTANTS(:,147) = -2;
    CONSTANTS(:,148) = 0.79167;
    CONSTANTS(:,149) = 1.8;
    CONSTANTS(:,150) = 4.2;
    CONSTANTS(:,151) = 30;
    CONSTANTS(:,152) = 0.001;
    CONSTANTS(:,153) = 0.1;
    CONSTANTS(:,154) = 0.04;
    CONSTANTS(:,155) = 2;
    CONSTANTS(:,156) = 0.1;
    CONSTANTS(:,157) = 35;
    CONSTANTS(:,158) = 2;
    CONSTANTS(:,159) = 8;
    CONSTANTS(:,160) = 0.2;
    CONSTANTS(:,161) = 0.15;
    CONSTANTS(:,162) = 0.5;
    CONSTANTS(:,163) = 96.3;
    CONSTANTS(:,164) = 0;
    CONSTANTS(:,165) = 30.52;
    CONSTANTS(:,166) = 2000;
    CONSTANTS(:,167) = 0;
    CONSTANTS(:,168) = 1;
    CONSTANTS(:,169) = 0.03;
    CONSTANTS(:,170) = 0.3;
    CONSTANTS(:,171) = 1;
    CONSTANTS(:,172) = 0;
    CONSTANTS(:,173) = 5.8e-06;
    CONSTANTS(:,174) = 15;
    CONSTANTS(:,175) = 0;
    CONSTANTS(:,176) = 0;
    CONSTANTS(:,177) = 0.9;
    CONSTANTS(:,178) = 15.2;
    CONSTANTS(:,179) = 6;
    CONSTANTS(:,180) = 19.167;
    CONSTANTS(:,181) = 1;
    CONSTANTS(:,182) = 1;
    CONSTANTS(:,183) = 1;
    CONSTANTS(:,184) = 5;
    CONSTANTS(:,185) = 10000;
    CONSTANTS(:,186) = 0;
    CONSTANTS(:,187) = 0;
    CONSTANTS(:,188) = 0.05;
    CONSTANTS(:,189) = 0;
    CONSTANTS(:,190) = 0;
    CONSTANTS(:,191) = 0;
    CONSTANTS(:,192) = 0.15;
    CONSTANTS(:,193) = 0.005;
    CONSTANTS(:,194) = 30;
    CONSTANTS(:,195) = 4;
    CONSTANTS(:,196) = 0.01;
    CONSTANTS(:,197) = 0.01;
    CONSTANTS(:,198) = 1;
    CONSTANTS(:,199) = 0.01;
    CONSTANTS(:,200) = 0.0175;
    CONSTANTS(:,201) = 6;
    CONSTANTS(:,202) = 2.51;
    CONSTANTS(:,203) = 4;
    CONSTANTS(:,204) = 1;
    CONSTANTS(:,205) = 0.5;
    CONSTANTS(:,206) = 0.3;
    CONSTANTS(:,207) = 20;
    CONSTANTS(:,208) = 5;
    CONSTANTS(:,209) = 45;
    CONSTANTS(:,210) = 0.01;
    CONSTANTS(:,211) = 5;
    CONSTANTS(:,212) = 0.625;
    CONSTANTS(:,213) = 5;
    CONSTANTS(:,214) = 5;
    CONSTANTS(:,215) = 5;
    CONSTANTS(:,216) = 5;
    CONSTANTS(:,217) = 0.08;
    CONSTANTS(:,218) = 0.24;
    CONSTANTS(:,219) = 0.55;
    CONSTANTS(:,220) = 0;
    CONSTANTS(:,221) = 164;
    CONSTANTS(:,222) = 0.1;
    CONSTANTS(:,223) = 0;
    CONSTANTS(:,224) = 0;
    CONSTANTS(:,225) = 0.6;
    CONSTANTS(:,226) = 0.3;
    CONSTANTS(:,227) = 10;
    CONSTANTS(:,228) = 1;
    CONSTANTS(:,229) = 1;
    CONSTANTS(:,230) = 90;
    CONSTANTS(:,231) = 150;
    CONSTANTS(:,232) = 0.53333;
    CONSTANTS(:,233) = 0;
    CONSTANTS(:,234) = 0;
    CONSTANTS(:,235) = 1;
    CONSTANTS(:,236) = 1.0;
    CONSTANTS(:,237) = 1.22057;
    CONSTANTS(:,238) = 0.8;
    CONSTANTS(:,239) = 0;
    CONSTANTS(:,240) = 0;
    CONSTANTS(:,241) = 31.9719;
    CONSTANTS(:,242) = 0;
    CONSTANTS(:,243) = 60;
    CONSTANTS(:,244) = 0;
    CONSTANTS(:,245) = 1.0;
    CONSTANTS(:,246) = 0.301963;
    CONSTANTS(:,247) = 1.0;
    CONSTANTS(:,248) = 1.00269;
    CONSTANTS(:,249) = 1.09071;
    CONSTANTS(:,250) = 0.859476;
    CONSTANTS(:,251) = 1.0;
    CONSTANTS(:,252) = 0;
    CONSTANTS(:,253) = 1.02127;
    CONSTANTS(:,254) = 1.01179;
    CONSTANTS(:,255) = 1.1448;
    CONSTANTS(:,256) = 1.00007;
    CONSTANTS(:,257) = -0.060024;
    CONSTANTS(:,258) = 1.00132;
    CONSTANTS(:,259) = 0.0367573;
    CONSTANTS(:,260) = 1;
    CONSTANTS(:,261) = 1.00163;
    CONSTANTS(:,262) = 1.00237;
    CONSTANTS(:,263) = 3622.54;
    CONSTANTS(:,264) = 2109.91;
    CONSTANTS(:,265) = 2.368e-07;
    CONSTANTS(:,266) = 0.694163;
    CONSTANTS(:,267) = 204.497;
    CONSTANTS(:,268) = 0.699673;
    CONSTANTS(:,269) = 103.525;
    CONSTANTS(:,270) = 16.9144;
    CONSTANTS(:,271) = 159.549;
    CONSTANTS(:,272) = 0.419998;
    CONSTANTS(:,273) = 216.243;
    CONSTANTS(:,274) = 72.2362;
    CONSTANTS(:,275) = 48.0839;
    CONSTANTS(:,276) = 0;
    CONSTANTS(:,277) = 279.945;
    CONSTANTS(:,278) = 0.000980838;
    CONSTANTS(:,279) = 0.862514;
    CONSTANTS(:,280) = 25.0404;
    CONSTANTS(:,281) = 0.379883;
    CONSTANTS(:,282) = 0.38131;
    CONSTANTS(:,283) = 0.0123238;
    CONSTANTS(:,284) = 3.00449;
    CONSTANTS(:,285) = 0.100043;
    CONSTANTS(:,286) = 2.00439;
    CONSTANTS(:,287) = 0;
    CONSTANTS(:,288) = 39.8952;
    CONSTANTS(:,289) = 0.0101913;
    CONSTANTS(:,290) = 0.00366525;
    CONSTANTS(:,291) = 3.28246;
    CONSTANTS(:,292) = 0.5;
    CONSTANTS(:,293) = 60;
    CONSTANTS(:,294) = 40000;
    CONSTANTS(:,295) = 0.1;
    CONSTANTS(:,296) = 40000;
    CONSTANTS(:,297) = 1;
    CONSTANTS(:,298) = 4;
    CONSTANTS(:,299) = 0;
    CONSTANTS(:,300) = 0.2;
    CONSTANTS(:,301) = 5;
    CONSTANTS(:,302) = 0.3;
    CONSTANTS(:,303) = 85;
    CONSTANTS(:,304) = 15;
    CONSTANTS(:,305) = 0.93617;
    CONSTANTS(:,306) = 2.5;
    CONSTANTS(:,307) = 0.333;
    CONSTANTS(:,308) = 1000;
    CONSTANTS(:,309) = 1;
    CONSTANTS(:,310) = 0.3;
    CONSTANTS(:,311) = 2;
    CONSTANTS(:,312) = 0.3;
    CONSTANTS(:,313) = 0;
    CONSTANTS(:,314) = 0;
    CONSTANTS(:,315) = 2.5;
    CONSTANTS(:,316) = 0;
    CONSTANTS(:,317) = 5;
    CONSTANTS(:,318) = 0.65;
    CONSTANTS(:,319) = 0.5;
    CONSTANTS(:,320) = 12;
    CONSTANTS(:,321) = 0.005;
    CONSTANTS(:,322) = 0.005;
    CONSTANTS(:,323) = 0.04;
    CONSTANTS(:,324) = 0.8;
    CONSTANTS(:,325) = 15;
    CONSTANTS(:,326) = 60;
    CONSTANTS(:,327) = 0.4;
    CONSTANTS(:,328) = 0;
    CONSTANTS(:,329) = 0;
    CONSTANTS(:,330) = 2.5;
    CONSTANTS(:,331) = 1.4;
    CONSTANTS(:,332) = 0.86;
    CONSTANTS(:,333) = 1.6;
    CONSTANTS(:,334) = 0.3;
    CONSTANTS(:,335) = 2;
    CONSTANTS(:,336) = 0.7;
    CONSTANTS(:,337) = 1;
    CONSTANTS(:,338) = 2;
    CONSTANTS(:,339) = 1.5;
    CONSTANTS(:,340) = 1.8;
    CONSTANTS(:,341) = 4;
    CONSTANTS(:,342) = 1.5;
    CONSTANTS(:,343) = 10;
    CONSTANTS(:,344) = 12;
    CONSTANTS(:,345) = 0.8;
    CONSTANTS(:,346) = 6;
    CONSTANTS(:,347) = 0;
    CONSTANTS(:,348) = 5000;
    CONSTANTS(:,349) = 0;
    CONSTANTS(:,350) = -0.2;
    CONSTANTS(:,351) = 0.005;
    CONSTANTS(:,352) = 0.005;
    CONSTANTS(:,353) = 0.5;
    CONSTANTS(:,354) = 0.3;
    CONSTANTS(:,355) = 0.3;
    CONSTANTS(:,356) = 0.004;
    CONSTANTS(:,357) = 1.5;
    CONSTANTS(:,358) = 0;
    CONSTANTS(:,359) = 3;
    CONSTANTS(:,360) = 1;
    CONSTANTS(:,361) = 5.0;
    CONSTANTS(:,362) = 0.4;
    CONSTANTS(:,363) = 0.3;
    CONSTANTS(:,364) = 0.5;
    CONSTANTS(:,365) = 1.0;
    CONSTANTS(:,366) = 1;
    CONSTANTS(:,367) = 1.5;
    CONSTANTS(:,368) = 0;
    CONSTANTS(:,369) = 7;
    CONSTANTS(:,370) = 0.9;
    CONSTANTS(:,371) = 1;
    CONSTANTS(:,372) = 0.16;
    CONSTANTS(:,373) = 0.01167;
    CONSTANTS(:,374) = 4;
    CONSTANTS(:,375) = 2;
    CONSTANTS(:,376) = 0.0212;
    CONSTANTS(:,377) = 0.2;
    CONSTANTS(:,378) = 139;
    CONSTANTS(:,379) = 0.0003;
    CONSTANTS(:,380) = 0.000253;
    CONSTANTS(:,381) = 40;
    CONSTANTS(:,382) = 0.1;
    CONSTANTS(:,383) = 0;
    CONSTANTS(:,384) = 1;
    CONSTANTS(:,385) = 0.05;
    CONSTANTS(:,386) = 0.675;
    CONSTANTS(:,387) = 1e-06;
    CONSTANTS(:,388) = 1;
    CONSTANTS(:,389) = 24;
    CONSTANTS(:,390) = 0;
    CONSTANTS(:,391) = 1;
    CONSTANTS(:,392) = 0.01;
    CONSTANTS(:,393) = 1.0;
    CONSTANTS(:,394) = 0.17;
    CONSTANTS(:,395) = 0;
    CONSTANTS(:,396) = 0.8092;
    CONSTANTS(:,397) = 0.0208333;
    CONSTANTS(:,398) = 3;
    CONSTANTS(:,399) = 0.001;
    CONSTANTS(:,400) = 1.0;
    CONSTANTS(:,401) = 1850;
    CONSTANTS(:,402) = 4.714e-08;
    CONSTANTS(:,403) = 0.4;
    CONSTANTS(:,404) = 1;
    CONSTANTS(:,405) = 0;
    CONSTANTS(:,406) = 0;
    CONSTANTS(:,407) = 10000;
    CONSTANTS(:,408) = 8;
    CONSTANTS(:,409) = 2.728e-14;
    CONSTANTS(:,410) = 0.03;
    CONSTANTS(:,411) = 10;
    CONSTANTS(:,412) = 0.667;
    CONSTANTS(:,413) = 0.005;
    CONSTANTS(:,414) = 0.01;
    CONSTANTS(:,415) = 0;
    CONSTANTS(:,416) = 0.1;
    CONSTANTS(:,417) = 0.01;
    CONSTANTS(:,418) = 57.1;
    CONSTANTS(:,419) = 1;
    CONSTANTS(:,420) = 2;
    CONSTANTS(:,421) = 1;
    CONSTANTS(:,422) = 15;
    CONSTANTS(:,423) = 0;
    CONSTANTS(:,424) = -2;
    CONSTANTS(:,425) = 0.79167;
    CONSTANTS(:,426) = 1.8;
    CONSTANTS(:,427) = 4.2;
    CONSTANTS(:,428) = 30;
    CONSTANTS(:,429) = 0.001;
    CONSTANTS(:,430) = 0.1;
    CONSTANTS(:,431) = 0.04;
    CONSTANTS(:,432) = 2;
    CONSTANTS(:,433) = 0.1;
    CONSTANTS(:,434) = 35;
    CONSTANTS(:,435) = 2;
    CONSTANTS(:,436) = 8;
    CONSTANTS(:,437) = 0.2;
    CONSTANTS(:,438) = 0.15;
    CONSTANTS(:,439) = 0.5;
    CONSTANTS(:,440) = 96.3;
    CONSTANTS(:,441) = 0;
    CONSTANTS(:,442) = 30.52;
    CONSTANTS(:,443) = 2000;
    CONSTANTS(:,444) = 0;
    CONSTANTS(:,445) = 1;
    CONSTANTS(:,446) = 0.03;
    CONSTANTS(:,447) = 0.3;
    CONSTANTS(:,448) = 1;
    CONSTANTS(:,449) = 0;
    CONSTANTS(:,450) = 5.8e-06;
    CONSTANTS(:,451) = 15;
    CONSTANTS(:,452) = 0;
    CONSTANTS(:,453) = 0;
    CONSTANTS(:,454) = 0.9;
    CONSTANTS(:,455) = 15.2;
    CONSTANTS(:,456) = 6;
    CONSTANTS(:,457) = 19.167;
    CONSTANTS(:,458) = 1;
    CONSTANTS(:,459) = 1;
    CONSTANTS(:,460) = 1;
    CONSTANTS(:,461) = 5;
    CONSTANTS(:,462) = 10000;
    CONSTANTS(:,463) = 0;
    CONSTANTS(:,464) = 0;
    CONSTANTS(:,465) = 0.05;
    CONSTANTS(:,466) = 0;
    CONSTANTS(:,467) = 0;
    CONSTANTS(:,468) = 0;
    CONSTANTS(:,469) = 0.15;
    CONSTANTS(:,470) = 0.005;
    CONSTANTS(:,471) = 30;
    CONSTANTS(:,472) = 4;
    CONSTANTS(:,473) = 0.01;
    CONSTANTS(:,474) = 0.01;
    CONSTANTS(:,475) = 1;
    CONSTANTS(:,476) = 0.01;
    CONSTANTS(:,477) = 0.0175;
    CONSTANTS(:,478) = 6;
    CONSTANTS(:,479) = 2.51;
    CONSTANTS(:,480) = 4;
    CONSTANTS(:,481) = 1;
    CONSTANTS(:,482) = 0.5;
    CONSTANTS(:,483) = 0.3;
    CONSTANTS(:,484) = 20;
    CONSTANTS(:,485) = 5;
    CONSTANTS(:,486) = 45;
    CONSTANTS(:,487) = 0.01;
    CONSTANTS(:,488) = 5;
    CONSTANTS(:,489) = 0.625;
    CONSTANTS(:,490) = 5;
    CONSTANTS(:,491) = 5;
    CONSTANTS(:,492) = 5;
    CONSTANTS(:,493) = 5;
    CONSTANTS(:,494) = 0.08;
    CONSTANTS(:,495) = 0.24;
    CONSTANTS(:,496) = 0.55;
    CONSTANTS(:,497) = 0;
    CONSTANTS(:,498) = 164;
    CONSTANTS(:,499) = 0.1;
    CONSTANTS(:,500) = 0;
    CONSTANTS(:,501) = 0;
    CONSTANTS(:,502) = 0.6;
    CONSTANTS(:,503) = 0.3;
    CONSTANTS(:,504) = 10;
    CONSTANTS(:,505) = 1;
    CONSTANTS(:,506) = 1;
    CONSTANTS(:,507) = 90;
    CONSTANTS(:,508) = 150;
    CONSTANTS(:,509) = 0.53333;
    CONSTANTS(:,510) = 0;
    CONSTANTS(:,511) = 0;
    CONSTANTS(:,512) = 1;
    CONSTANTS(:,513) = 1.0;
    CONSTANTS(:,514) = 1.22057;
    CONSTANTS(:,515) = 0.8;
    CONSTANTS(:,516) = 0;
    CONSTANTS(:,517) = 0;
    CONSTANTS(:,518) = 31.9719;
    CONSTANTS(:,519) = 0;
    CONSTANTS(:,520) = 60;
    CONSTANTS(:,521) = 0;
    CONSTANTS(:,522) = 1.0;
    CONSTANTS(:,523) = 0.301963;
    CONSTANTS(:,524) = 1.0;
    CONSTANTS(:,525) = 1.00269;
    CONSTANTS(:,526) = 1.09071;
    CONSTANTS(:,527) = 0.859476;
    CONSTANTS(:,528) = 1.0;
    CONSTANTS(:,529) = 0;
    CONSTANTS(:,530) = 1.02127;
    CONSTANTS(:,531) = 1.01179;
    CONSTANTS(:,532) = 1.1448;
    CONSTANTS(:,533) = 1.00007;
    CONSTANTS(:,534) = -0.060024;
    CONSTANTS(:,535) = 1.00132;
    CONSTANTS(:,536) = 0.0367573;
    CONSTANTS(:,537) = 1;
    CONSTANTS(:,538) = 1.00163;
    CONSTANTS(:,539) = 1.00237;
    CONSTANTS(:,540) = 3622.54;
    CONSTANTS(:,541) = 2109.91;
    CONSTANTS(:,542) = 2.368e-07;
    CONSTANTS(:,543) = 0.694163;
    CONSTANTS(:,544) = 204.497;
    CONSTANTS(:,545) = 0.699673;
    CONSTANTS(:,546) = 103.525;
    CONSTANTS(:,547) = 16.9144;
    CONSTANTS(:,548) = 159.549;
    CONSTANTS(:,549) = 0.419998;
    CONSTANTS(:,550) = 216.243;
    CONSTANTS(:,551) = 72.2362;
    CONSTANTS(:,552) = 48.0839;
    CONSTANTS(:,553) = 0;
    CONSTANTS(:,554) = 279.945;
    CONSTANTS(:,555) = 0.000980838;
    CONSTANTS(:,556) = 0.862514;
    CONSTANTS(:,557) = 25.0404;
    CONSTANTS(:,558) = 0.379883;
    CONSTANTS(:,559) = 0.38131;
    CONSTANTS(:,560) = 0.0123238;
    CONSTANTS(:,561) = 3.00449;
    CONSTANTS(:,562) = 0.100043;
    CONSTANTS(:,563) = 2.00439;
    CONSTANTS(:,564) = 0;
    CONSTANTS(:,565) = 39.8952;
    CONSTANTS(:,566) = 0.0101913;
    CONSTANTS(:,567) = 0.00366525;
    CONSTANTS(:,568) = 3.28246;
    CONSTANTS(:,569) =  (CONSTANTS(:,2) - 1.00000).*CONSTANTS(:,353)+1.00000;
    CONSTANTS(:,570) = piecewise({CONSTANTS(:,569)<0.800000, 0.800000 }, CONSTANTS(:,569));
    CONSTANTS(:,571) =  (CONSTANTS(:,3) - 1.00000).*CONSTANTS(:,331)+1.00000;
    CONSTANTS(:,572) = piecewise({CONSTANTS(:,571)<CONSTANTS(:,332), CONSTANTS(:,332) }, CONSTANTS(:,571));
    CONSTANTS(:,573) =  (CONSTANTS(:,570) - 1.00000).*CONSTANTS(:,363)+1.00000;
    CONSTANTS(:,574) =  (CONSTANTS(:,3) - 1.00000).*CONSTANTS(:,333)+1.00000;
    CONSTANTS(:,575) =  ( (CONSTANTS(:,3) - 1.00000).*CONSTANTS(:,337)+1.00000).*0.100000;
    CONSTANTS(:,576) = piecewise({CONSTANTS(:,575)<0.00000, 0.00000 }, CONSTANTS(:,575));
    CONSTANTS(:,577) =  (CONSTANTS(:,3) - 1.00000).*CONSTANTS(:,335)+1.00000;
    CONSTANTS(:,578) = piecewise({CONSTANTS(:,577)<CONSTANTS(:,334), CONSTANTS(:,334) }, CONSTANTS(:,577));
    STATES(:,1) = CONSTANTS(:,546);
    STATES(:,2) = CONSTANTS(:,553);
    STATES(:,3) = CONSTANTS(:,548);
    STATES(:,4) = CONSTANTS(:,536);
    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(:,1) = ((100.000+ (CONSTANTS(:,1) - 100.000).*CONSTANTS(:,444)) - STATES(:,1))./CONSTANTS(:,443);
    ALGEBRAIC(:,1) = piecewise({CONSTANTS(:,441)>0.00000&CONSTANTS(:,449)<=0.00000, CONSTANTS(:,441) , CONSTANTS(:,449)>0.00000, STATES(:,1) }, CONSTANTS(:,1) - CONSTANTS(:,501));
    [CONSTANTS, STATES, ALGEBRAIC] = rootfind_0(VOI, CONSTANTS, STATES, ALGEBRAIC);
    RATES(:,2) =  (ALGEBRAIC(:,4) - 1.00000).*CONSTANTS(:,452);
    ALGEBRAIC(:,2) = STATES(:,3)./CONSTANTS(:,8);
    ALGEBRAIC(:,49) =  power(ALGEBRAIC(:,15), 2.00000).*ALGEBRAIC(:,2).*3.84000;
    ALGEBRAIC(:,50) =  ALGEBRAIC(:,49).*CONSTANTS(:,445);
    RATES(:,3) = CONSTANTS(:,495) - ALGEBRAIC(:,50);
    ALGEBRAIC(:,35) =  ALGEBRAIC(:,3).*CONSTANTS(:,9).*0.00616190;
    ALGEBRAIC(:,38) = ( ALGEBRAIC(:,35).*CONSTANTS(:,12))./CONSTANTS(:,9);
    ALGEBRAIC(:,27) =  ALGEBRAIC(:,16).*CONSTANTS(:,454) - CONSTANTS(:,455);
    ALGEBRAIC(:,28) = piecewise({ALGEBRAIC(:,27)<1.00000, 1.00000 }, ALGEBRAIC(:,27));
    ALGEBRAIC(:,29) =  ( (ALGEBRAIC(:,14) - 1.20000).*CONSTANTS(:,515)+1.20000).*CONSTANTS(:,457);
    ALGEBRAIC(:,30) = ((ALGEBRAIC(:,16)+CONSTANTS(:,456)) - ALGEBRAIC(:,29)) - ALGEBRAIC(:,28);
    ALGEBRAIC(:,31) =  ALGEBRAIC(:,30).*CONSTANTS(:,439);
    ALGEBRAIC(:,32) = ALGEBRAIC(:,31);
    ALGEBRAIC(:,33) =  (ALGEBRAIC(:,32) - 1.00000).*CONSTANTS(:,447)+1.00000;
    ALGEBRAIC(:,34) = piecewise({ALGEBRAIC(:,33)<0.000100000, 0.000100000 }, ALGEBRAIC(:,33));
    ALGEBRAIC(:,39) =  (ALGEBRAIC(:,34) - 1.00000).*CONSTANTS(:,446);
    ALGEBRAIC(:,40) =  (ALGEBRAIC(:,3) - 1.00000).*CONSTANTS(:,412)+1.00000;
    ALGEBRAIC(:,41) = piecewise({ALGEBRAIC(:,40)<0.100000, 0.100000 }, ALGEBRAIC(:,40));
    ALGEBRAIC(:,42) = ( power(CONSTANTS(:,12)./4.40000, CONSTANTS(:,374)).*CONSTANTS(:,13).*0.0800000.*ALGEBRAIC(:,41))./CONSTANTS(:,578);
    ALGEBRAIC(:,46) = ((ALGEBRAIC(:,38)+ALGEBRAIC(:,42)) - STATES(:,4)) - ALGEBRAIC(:,39);
    ALGEBRAIC(:,47) = piecewise({ALGEBRAIC(:,46)<0.00000, 0.00000 }, ALGEBRAIC(:,46));
    ALGEBRAIC(:,36) =  (( CONSTANTS(:,11).*ALGEBRAIC(:,34).*CONSTANTS(:,386))./CONSTANTS(:,384)).*( (CONSTANTS(:,10) - 1.00000).*CONSTANTS(:,310)+1.00000);
    ALGEBRAIC(:,37) = piecewise({ALGEBRAIC(:,36)<CONSTANTS(:,387), CONSTANTS(:,387) }, ALGEBRAIC(:,36));
    ALGEBRAIC(:,43) = (ALGEBRAIC(:,35) - ALGEBRAIC(:,37)) - CONSTANTS(:,576);
    ALGEBRAIC(:,44) = piecewise({ALGEBRAIC(:,43)<1.00000e-08, 1.00000e-08 }, ALGEBRAIC(:,43));
    ALGEBRAIC(:,51) = ALGEBRAIC(:,49)+ 2.00000.*(ALGEBRAIC(:,44)+ALGEBRAIC(:,47));
    ALGEBRAIC(:,52) = piecewise({ALGEBRAIC(:,51)>0.600000, 0.600000 }, ALGEBRAIC(:,51));
    ALGEBRAIC(:,53) = ALGEBRAIC(:,51) - 0.600000;
    ALGEBRAIC(:,54) = piecewise({ALGEBRAIC(:,53)<0.00000, 0.00000 }, ALGEBRAIC(:,53));
    ALGEBRAIC(:,55) = ALGEBRAIC(:,52)./( 600.000.*CONSTANTS(:,10))+ALGEBRAIC(:,54)./360.000;
    RATES(:,4) =  ( (ALGEBRAIC(:,47)./ALGEBRAIC(:,55)).*0.000451800 - STATES(:,4)).*1.00000;
   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) = piecewise({CONSTANTS(:,441)>0.00000&CONSTANTS(:,449)<=0.00000, CONSTANTS(:,441) , CONSTANTS(:,449)>0.00000, STATES(:,1) }, CONSTANTS(:,1) - CONSTANTS(:,501));
    ALGEBRAIC(:,2) = STATES(:,3)./CONSTANTS(:,8);
    ALGEBRAIC(:,49) =  power(ALGEBRAIC(:,15), 2.00000).*ALGEBRAIC(:,2).*3.84000;
    ALGEBRAIC(:,50) =  ALGEBRAIC(:,49).*CONSTANTS(:,445);
    ALGEBRAIC(:,35) =  ALGEBRAIC(:,3).*CONSTANTS(:,9).*0.00616190;
    ALGEBRAIC(:,38) = ( ALGEBRAIC(:,35).*CONSTANTS(:,12))./CONSTANTS(:,9);
    ALGEBRAIC(:,27) =  ALGEBRAIC(:,16).*CONSTANTS(:,454) - CONSTANTS(:,455);
    ALGEBRAIC(:,28) = piecewise({ALGEBRAIC(:,27)<1.00000, 1.00000 }, ALGEBRAIC(:,27));
    ALGEBRAIC(:,29) =  ( (ALGEBRAIC(:,14) - 1.20000).*CONSTANTS(:,515)+1.20000).*CONSTANTS(:,457);
    ALGEBRAIC(:,30) = ((ALGEBRAIC(:,16)+CONSTANTS(:,456)) - ALGEBRAIC(:,29)) - ALGEBRAIC(:,28);
    ALGEBRAIC(:,31) =  ALGEBRAIC(:,30).*CONSTANTS(:,439);
    ALGEBRAIC(:,32) = ALGEBRAIC(:,31);
    ALGEBRAIC(:,33) =  (ALGEBRAIC(:,32) - 1.00000).*CONSTANTS(:,447)+1.00000;
    ALGEBRAIC(:,34) = piecewise({ALGEBRAIC(:,33)<0.000100000, 0.000100000 }, ALGEBRAIC(:,33));
    ALGEBRAIC(:,39) =  (ALGEBRAIC(:,34) - 1.00000).*CONSTANTS(:,446);
    ALGEBRAIC(:,40) =  (ALGEBRAIC(:,3) - 1.00000).*CONSTANTS(:,412)+1.00000;
    ALGEBRAIC(:,41) = piecewise({ALGEBRAIC(:,40)<0.100000, 0.100000 }, ALGEBRAIC(:,40));
    ALGEBRAIC(:,42) = ( power(CONSTANTS(:,12)./4.40000, CONSTANTS(:,374)).*CONSTANTS(:,13).*0.0800000.*ALGEBRAIC(:,41))./CONSTANTS(:,578);
    ALGEBRAIC(:,46) = ((ALGEBRAIC(:,38)+ALGEBRAIC(:,42)) - STATES(:,4)) - ALGEBRAIC(:,39);
    ALGEBRAIC(:,47) = piecewise({ALGEBRAIC(:,46)<0.00000, 0.00000 }, ALGEBRAIC(:,46));
    ALGEBRAIC(:,36) =  (( CONSTANTS(:,11).*ALGEBRAIC(:,34).*CONSTANTS(:,386))./CONSTANTS(:,384)).*( (CONSTANTS(:,10) - 1.00000).*CONSTANTS(:,310)+1.00000);
    ALGEBRAIC(:,37) = piecewise({ALGEBRAIC(:,36)<CONSTANTS(:,387), CONSTANTS(:,387) }, ALGEBRAIC(:,36));
    ALGEBRAIC(:,43) = (ALGEBRAIC(:,35) - ALGEBRAIC(:,37)) - CONSTANTS(:,576);
    ALGEBRAIC(:,44) = piecewise({ALGEBRAIC(:,43)<1.00000e-08, 1.00000e-08 }, ALGEBRAIC(:,43));
    ALGEBRAIC(:,51) = ALGEBRAIC(:,49)+ 2.00000.*(ALGEBRAIC(:,44)+ALGEBRAIC(:,47));
    ALGEBRAIC(:,52) = piecewise({ALGEBRAIC(:,51)>0.600000, 0.600000 }, ALGEBRAIC(:,51));
    ALGEBRAIC(:,53) = ALGEBRAIC(:,51) - 0.600000;
    ALGEBRAIC(:,54) = piecewise({ALGEBRAIC(:,53)<0.00000, 0.00000 }, ALGEBRAIC(:,53));
    ALGEBRAIC(:,55) = ALGEBRAIC(:,52)./( 600.000.*CONSTANTS(:,10))+ALGEBRAIC(:,54)./360.000;
    ALGEBRAIC(:,25) =  CONSTANTS(:,445).*ALGEBRAIC(:,14);
    ALGEBRAIC(:,26) =  ALGEBRAIC(:,15).*CONSTANTS(:,445);
    ALGEBRAIC(:,45) =  ALGEBRAIC(:,44).*CONSTANTS(:,445);
    ALGEBRAIC(:,48) =  ALGEBRAIC(:,47).*CONSTANTS(:,445);
    ALGEBRAIC(:,56) =  ALGEBRAIC(:,55).*CONSTANTS(:,445);
end

% Functions required for solving differential algebraic equation
function [CONSTANTS, STATES, ALGEBRAIC] = rootfind_0(VOI, CONSTANTS_IN, STATES_IN, ALGEBRAIC_IN)
    ALGEBRAIC = ALGEBRAIC_IN;
    CONSTANTS = CONSTANTS_IN;
    STATES = STATES_IN;
    global initialGuess_0;
    if (length(initialGuess_0) ~= 22), initialGuess_0 = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1];, end
    options = optimset('Display', 'off', 'TolX', 1E-6);
    if length(VOI) == 1
        residualfn = @(algebraicCandidate)residualSN_0(algebraicCandidate, ALGEBRAIC, VOI, CONSTANTS, STATES);
        soln = fsolve(residualfn, initialGuess_0, options);
        initialGuess_0 = soln;
        ALGEBRAIC(:,3) = soln(1);
        ALGEBRAIC(:,4) = soln(2);
        ALGEBRAIC(:,5) = soln(3);
        ALGEBRAIC(:,6) = soln(4);
        ALGEBRAIC(:,7) = soln(5);
        ALGEBRAIC(:,8) = soln(6);
        ALGEBRAIC(:,9) = soln(7);
        ALGEBRAIC(:,10) = soln(8);
        ALGEBRAIC(:,11) = soln(9);
        ALGEBRAIC(:,12) = soln(10);
        ALGEBRAIC(:,13) = soln(11);
        ALGEBRAIC(:,14) = soln(12);
        ALGEBRAIC(:,15) = soln(13);
        ALGEBRAIC(:,16) = soln(14);
        ALGEBRAIC(:,17) = soln(15);
        ALGEBRAIC(:,18) = soln(16);
        ALGEBRAIC(:,19) = soln(17);
        ALGEBRAIC(:,20) = soln(18);
        ALGEBRAIC(:,21) = soln(19);
        ALGEBRAIC(:,22) = soln(20);
        ALGEBRAIC(:,23) = soln(21);
        ALGEBRAIC(:,24) = soln(22);
    else
        SET_ALGEBRAIC(:,3) = logical(1);
        SET_ALGEBRAIC(:,4) = logical(1);
        SET_ALGEBRAIC(:,5) = logical(1);
        SET_ALGEBRAIC(:,6) = logical(1);
        SET_ALGEBRAIC(:,7) = logical(1);
        SET_ALGEBRAIC(:,8) = logical(1);
        SET_ALGEBRAIC(:,9) = logical(1);
        SET_ALGEBRAIC(:,10) = logical(1);
        SET_ALGEBRAIC(:,11) = logical(1);
        SET_ALGEBRAIC(:,12) = logical(1);
        SET_ALGEBRAIC(:,13) = logical(1);
        SET_ALGEBRAIC(:,14) = logical(1);
        SET_ALGEBRAIC(:,15) = logical(1);
        SET_ALGEBRAIC(:,16) = logical(1);
        SET_ALGEBRAIC(:,17) = logical(1);
        SET_ALGEBRAIC(:,18) = logical(1);
        SET_ALGEBRAIC(:,19) = logical(1);
        SET_ALGEBRAIC(:,20) = logical(1);
        SET_ALGEBRAIC(:,21) = logical(1);
        SET_ALGEBRAIC(:,22) = logical(1);
        SET_ALGEBRAIC(:,23) = logical(1);
        SET_ALGEBRAIC(:,24) = logical(1);
        for i=1:length(VOI)
            residualfn = @(algebraicCandidate)residualSN_0(algebraicCandidate, ALGEBRAIC(i,:), VOI(i), CONSTANTS, STATES(i,:));
            soln = fsolve(residualfn, initialGuess_0, options);
            initialGuess_0 = soln;
            TEMP_ALGEBRAIC(:,3) = soln(1);
            TEMP_ALGEBRAIC(:,4) = soln(2);
            TEMP_ALGEBRAIC(:,5) = soln(3);
            TEMP_ALGEBRAIC(:,6) = soln(4);
            TEMP_ALGEBRAIC(:,7) = soln(5);
            TEMP_ALGEBRAIC(:,8) = soln(6);
            TEMP_ALGEBRAIC(:,9) = soln(7);
            TEMP_ALGEBRAIC(:,10) = soln(8);
            TEMP_ALGEBRAIC(:,11) = soln(9);
            TEMP_ALGEBRAIC(:,12) = soln(10);
            TEMP_ALGEBRAIC(:,13) = soln(11);
            TEMP_ALGEBRAIC(:,14) = soln(12);
            TEMP_ALGEBRAIC(:,15) = soln(13);
            TEMP_ALGEBRAIC(:,16) = soln(14);
            TEMP_ALGEBRAIC(:,17) = soln(15);
            TEMP_ALGEBRAIC(:,18) = soln(16);
            TEMP_ALGEBRAIC(:,19) = soln(17);
            TEMP_ALGEBRAIC(:,20) = soln(18);
            TEMP_ALGEBRAIC(:,21) = soln(19);
            TEMP_ALGEBRAIC(:,22) = soln(20);
            TEMP_ALGEBRAIC(:,23) = soln(21);
            TEMP_ALGEBRAIC(:,24) = soln(22);
            ALGEBRAIC(i,SET_ALGEBRAIC) = TEMP_ALGEBRAIC(SET_ALGEBRAIC);
        end
    end
end

function resid = residualSN_0(algebraicCandidate, ALGEBRAIC, VOI, CONSTANTS, STATES)
    ALGEBRAIC(:,3) = algebraicCandidate(1);
    ALGEBRAIC(:,4) = algebraicCandidate(2);
    ALGEBRAIC(:,5) = algebraicCandidate(3);
    ALGEBRAIC(:,6) = algebraicCandidate(4);
    ALGEBRAIC(:,7) = algebraicCandidate(5);
    ALGEBRAIC(:,8) = algebraicCandidate(6);
    ALGEBRAIC(:,9) = algebraicCandidate(7);
    ALGEBRAIC(:,10) = algebraicCandidate(8);
    ALGEBRAIC(:,11) = algebraicCandidate(9);
    ALGEBRAIC(:,12) = algebraicCandidate(10);
    ALGEBRAIC(:,13) = algebraicCandidate(11);
    ALGEBRAIC(:,14) = algebraicCandidate(12);
    ALGEBRAIC(:,15) = algebraicCandidate(13);
    ALGEBRAIC(:,16) = algebraicCandidate(14);
    ALGEBRAIC(:,17) = algebraicCandidate(15);
    ALGEBRAIC(:,18) = algebraicCandidate(16);
    ALGEBRAIC(:,19) = algebraicCandidate(17);
    ALGEBRAIC(:,20) = algebraicCandidate(18);
    ALGEBRAIC(:,21) = algebraicCandidate(19);
    ALGEBRAIC(:,22) = algebraicCandidate(20);
    ALGEBRAIC(:,23) = algebraicCandidate(21);
    ALGEBRAIC(:,24) = algebraicCandidate(22);
    resid(1) = ALGEBRAIC(:,6) - ( (ALGEBRAIC(:,3) - 1.00000).*CONSTANTS(:,502)+1.00000);
    resid(2) = ALGEBRAIC(:,5) - piecewise({ALGEBRAIC(:,6)<CONSTANTS(:,503), CONSTANTS(:,503) , ALGEBRAIC(:,6)>CONSTANTS(:,504), CONSTANTS(:,504) }, ALGEBRAIC(:,6));
    resid(3) = ALGEBRAIC(:,4) - (ALGEBRAIC(:,5) - STATES(:,2));
    resid(4) = ALGEBRAIC(:,7) -  CONSTANTS(:,297).*CONSTANTS(:,5).*CONSTANTS(:,570).*ALGEBRAIC(:,4).*CONSTANTS(:,572).*40.0000.*CONSTANTS(:,4);
    resid(5) = ALGEBRAIC(:,9) - ((ALGEBRAIC(:,7) -  CONSTANTS(:,14).*CONSTANTS(:,342))+CONSTANTS(:,342));
    resid(6) = ALGEBRAIC(:,8) - piecewise({ALGEBRAIC(:,9)<CONSTANTS(:,298), CONSTANTS(:,298) }, ALGEBRAIC(:,9));
    resid(7) = ALGEBRAIC(:,10) - ( (ALGEBRAIC(:,4) - 1.00000).*CONSTANTS(:,390)+1.00000);
    resid(8) = ALGEBRAIC(:,12) -  43.3330.*CONSTANTS(:,388).*CONSTANTS(:,574).*ALGEBRAIC(:,10).*CONSTANTS(:,4).*CONSTANTS(:,573);
    resid(9) = ALGEBRAIC(:,11) - piecewise({ALGEBRAIC(:,12)<CONSTANTS(:,389), CONSTANTS(:,389) }, ALGEBRAIC(:,12));
    resid(10) = ALGEBRAIC(:,13) - (ALGEBRAIC(:,8)+ALGEBRAIC(:,11));
    resid(11) = ALGEBRAIC(:,14) - ALGEBRAIC(:,1)./ALGEBRAIC(:,13);
    resid(12) = ALGEBRAIC(:,18) - ( ALGEBRAIC(:,14).*(1.00000 - CONSTANTS(:,6)))./( ALGEBRAIC(:,14).*(1.00000 - CONSTANTS(:,6)) - ALGEBRAIC(:,15));
    resid(13) = ALGEBRAIC(:,17) - piecewise({ALGEBRAIC(:,18)<1.00000, 1.00000 }, ALGEBRAIC(:,18));
    resid(14) = ALGEBRAIC(:,16) - piecewise({CONSTANTS(:,513)>0.00000,  power(ALGEBRAIC(:,17), 1.35000).*CONSTANTS(:,7).*0.980000 }, CONSTANTS(:,7)+4.00000);
    resid(15) = ALGEBRAIC(:,20) -  ALGEBRAIC(:,8).*ALGEBRAIC(:,14);
    resid(16) = ALGEBRAIC(:,19) - (ALGEBRAIC(:,1) - ALGEBRAIC(:,20));
    resid(17) = ALGEBRAIC(:,21) - ((ALGEBRAIC(:,19) - ALGEBRAIC(:,16)) - CONSTANTS(:,436));
    resid(18) = ALGEBRAIC(:,22) -  ALGEBRAIC(:,21).*CONSTANTS(:,397);
    resid(19) = ALGEBRAIC(:,15) - piecewise({ALGEBRAIC(:,22)<CONSTANTS(:,399), CONSTANTS(:,399) }, ALGEBRAIC(:,22));
    resid(20) = ALGEBRAIC(:,23) -  ALGEBRAIC(:,15).*8.00000;
    resid(21) = ALGEBRAIC(:,24) - ( (ALGEBRAIC(:,23) - 1.00000).*CONSTANTS(:,411)+1.00000);
    resid(22) = ALGEBRAIC(:,3) - piecewise({ALGEBRAIC(:,24)<0.00000, 0.00000 }, ALGEBRAIC(:,24));
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