function out=l05_reconstruction(para,paths) % Thermodynamic reconstruction at published case geometry/power; not new sizing. cases={'L05_baseline',.020,.280e6,292,48;'L05_Case1',.0153,3.2e6,292,58.7;'L05_Case2',.0190,5e6,315.6,68.7}; summary=struct([]);hist=cell(3,1); rho0=66.3;P0=225400;eta=.5197;LHV=119.96e6;r=.2673/2;flux=9.15; T0=fzero(@(T)initialP(T),[para.Tmin+.002,50]); for i=1:3 V=cases{i,2};Pmax=cases{i,3};power=cases{i,4};M0=rho0*V; L=(V-4*pi*r^3/3)/(pi*r^2);area=4*pi*r^2+2*pi*r*L; k=struct('fluid',para,'V_m3',V,'Pmax_Pa',Pmax,'Pfeed_Pa',200000,'Qleak_W',flux*area, ... 'recovery_cap_W',0,'recovery_fraction',0,'heater_max_W',0,'heater_efficiency',1); ss=r23.thermo_state(T0,rho0,para);st=struct('m',M0,'U',M0*ss.u_J_kg,'U0',M0*ss.u_J_kg,'s',ss,'Qin_J',0,'out_enthalpy_J',0,'balance_J',0); time=0;used=0;vented=0;dt=60;rows=[]; while time<100*3600&&st.m>1e-5 dm=power/(eta*LHV)*dt; if dm>=st.m,break;end [st,v,~,~,ok]=r23.advance_tank(st,dm,dt,k,power,eta); time=time+dt;used=used+dm;vented=vented+v; rows(end+1,:)=[time/3600,st.m,st.s.p_Pa/1000,st.s.T_K,used,vented,st.balance_J]; if ~ok||st.s.p_Pa<200000,break;end end hist{i}=rows;writetable(array2table(rows,'VariableNames',{'time_h','H2_remaining_kg','P_kPa','T_K','H2_FC_used_kg','H2_vented_kg','thermal_balance_J'}),fullfile(paths.run,[cases{i,1} '-thermo.csv'])); s=struct('case_id',cases{i,1},'V_inner_m3',V,'Pmax_Pa',Pmax,'power_W',power,'initial_T_K',T0,'Qleak_W',flux*area, ... 'predicted_time_h',time/3600,'paper_time_h',cases{i,5},'relative_time_difference',time/3600/cases{i,5}-1, ... 'H2_initial_kg',M0,'FC_utilization',used/M0,'vent_fraction',vented/M0,'H2_remaining_kg',st.m,'tank_energy_residual_J',st.balance_J, ... 'comparison_scope','published V/P/power scenario reconstruction; approximate cylindrical area; no claim that structural optimum was independently reproduced'); if isempty(summary),summary=s;else,summary(end+1)=s;end fprintf('L05_RECON %s %.8gh vs%.8g utilization%.8g\n',s.case_id,s.predicted_time_h,s.paper_time_h,s.FC_utilization); end out=struct('fluid','pure parahydrogen','eta_FC',eta,'LHV_J_kg',LHV,'rho0_kg_m3',rho0,'P0_Pa',P0,'Qflux_W_m2',flux,'cases',summary,'not_new_UAV_flight_validation',true); r23.write_json(fullfile(paths.report,'L05-reconstruction-summary.json'),out); fig=figure('Position',[100 100 1040 440]);tiledlayout(1,2,'Padding','compact'); nexttile;hold on;for i=1:3,plot(hist{i}(:,1),hist{i}(:,2));end;grid on;xlabel('Time (h)');ylabel('Hydrogen inventory (kg)');legend(cases(:,1),'Interpreter','none');title('Published-case thermodynamic reconstruction'); nexttile;hold on;for i=1:3,plot(hist{i}(:,1),hist{i}(:,3));end;grid on;xlabel('Time (h)');ylabel('Pressure (kPa)');title('Real para-H2 EOS, venting and 200kPa termination'); r23.save_figure(fig,paths,'L05-thermodynamic-reconstruction');close(fig); function v=initialP(T) s=r23.thermo_state(T,rho0,para);v=s.p_Pa-P0; end end