function out=thermo_analysis(paths) normal=r23.build_fluid(paths,'Hydrogen');para=r23.build_fluid(paths,'ParaHydrogen'); files=dir(fullfile(paths.inputs,'normal-hydrogen*.tsv')); rows=[]; for k=1:numel(files) T=readtable(fullfile(files(k).folder,files(k).name),'FileType','text','Delimiter','\t','VariableNamingRule','preserve'); vals=table2array(T(:,1:6)); for i=1:size(vals,1) e=r23.eos(vals(i,1),vals(i,3),normal); rows(end+1,:)=[vals(i,1),vals(i,2)*1e6,vals(i,3),e.p_Pa,e.u_J_kg,vals(i,5)*1000,e.h_J_kg,vals(i,6)*1000, ... (e.p_Pa/vals(i,2)/1e6-1),e.u_J_kg-vals(i,5)*1000,e.h_J_kg-vals(i,6)*1000]; end end tab=array2table(rows,'VariableNames',{'T_K','NIST_P_Pa','NIST_rho_kg_m3','MATLAB_P_Pa','MATLAB_u_J_kg','NIST_u_J_kg','MATLAB_h_J_kg','NIST_h_J_kg','relative_pressure_error','u_difference_J_kg','h_difference_J_kg'}); writetable(tab,fullfile(paths.run,'EOS-NIST-independent-check.csv')); assert(max(abs(rows(:,9)))<1e-4,'EOS failed independent NIST pressure checks.'); assert(max(abs(rows(:,10:11)),[],'all')<10,'EOS failed NIST energy reference checks.'); para=r23.with_saturation(para,paths);normal=r23.with_saturation(normal,paths); out=struct('normal',normal,'para',para,'validation',tab,'max_relative_pressure_error',max(abs(rows(:,9))), ... 'max_energy_difference_J_kg',max(abs(rows(:,10:11)),[],'all'),'calculation_engine','native MATLAB R2025a Helmholtz derivatives', ... 'source','Leachman2009; pinned CoolProp coefficient JSON; independent NIST raw normal-H2 states', ... 'EOS_not_ideal_gas',true,'L05_para_not_replaced_by_normal',true); save(fullfile(paths.run,'validated-fluid-models.mat'),'out'); r23.write_json(fullfile(paths.run,'EOS-validation-summary.json'),rmfield(out,{'normal','para','validation'})); fprintf('EOS_NIST_CHECK_PASSED maxRelP=%.6g maxEnergyDelta=%.6g J/kg\n',out.max_relative_pressure_error,out.max_energy_difference_J_kg); end