function render_equal_storage_final() % Publication-only plots from completed MAT data. No physical model runs. here=fileparts(mfilename('fullpath')); root=fileparts(fileparts(fileparts(fileparts(fileparts(here))))); model=fullfile(root,'reports','04_models','R23-001');addpath(fullfile(model,'matlab')); dest=fullfile(root,'reports','05_simulation','R23-001','equal-storage-supplement'); source=fullfile(dest,'equal-storage-results.mat');before=r23.sha256_file(source); d=load(source,'out','results','settings');out=d.out;res=d.results; baseline=res.CG_CLIMB_CORRECTED_MAX_WORK;S=baseline.series;c=d.settings.corrected_reference_settings; set(groot,'defaultFigureVisible','off','defaultAxesFontName','Arial','defaultAxesFontSize',11); set(groot,'defaultAxesColorOrder',[.08 .35 .65;.85 .30 .10;.10 .50 .25]); figures=struct('figures',dest); fig=figure('Position',[80 80 1100 720]);tiledlayout(2,2,'Padding','compact'); nexttile;plot(S.time_s/60,[S.bus_load_W,S.FC_bus_W,S.battery_bus_signed_W]/1000,'LineWidth',1.4); grid on;xlabel('Complete profile time (min)');ylabel('Power (kW)');legend('Bus load','FC net','Battery bus','Location','best'); title('R23-HE2.1.0 reference: power');xtickformat('%.2f');ytickformat('%.2f'); nexttile;plot(S.time_s/60,100*S.SOC,'LineWidth',1.4);hold on;yline(100*c.SOCmin,'k--'); grid on;xlabel('Complete profile time (min)');ylabel('Energy-equivalent SOC (%)');xtickformat('%.2f');ytickformat('%.2f'); nexttile;plot(S.time_s/60,S.H2_kg*1000,'LineWidth',1.4);hold on;yline(c.H0_kg*c.hydrogen_reserve_fraction*1000,'k--'); grid on;xlabel('Complete profile time (min)');ylabel('Hydrogen inventory (g)');xtickformat('%.2f');ytickformat('%.2f'); nexttile;plot(S.time_s/60,S.aircraft_mass_kg,'LineWidth',1.4);grid on; xlabel('Complete profile time (min)');ylabel('Aircraft mass (kg)');xtickformat('%.2f');ytickformat('%.2f'); sgtitle(sprintf('Corrected mission | flight %.2f h | final SOC %.2f',baseline.flight_s/3600,baseline.SOC_final)); r23.save_figure(fig,figures,'corrected-CG-mission-publication');close(fig); fig=figure('Position',[80 80 1100 450]);tiledlayout(1,2,'Padding','compact');sel=S.time_s<=240; nexttile;plot(S.time_s(sel),[S.bus_load_W(sel),S.FC_bus_W(sel),S.battery_bus_signed_W(sel)],'LineWidth',1.4); hold on;yline(c.FC_cap_W,'k--');grid on;xlabel('Time (s)');ylabel('Power (W)'); legend('Bus load','FC net','Battery bus','FC cap','Location','best');title('Startup / takeoff / corrected climb'); xtickformat('%.2f');ytickformat('%.2f'); nexttile;yyaxis left;plot(S.time_s(sel),S.propulsion_DC_W(sel)/4,'LineWidth',1.4);hold on; yline(c.continuous_motor_each_W,'k--');ylabel('Each-motor DC input (W)'); yyaxis right;plot(S.time_s(sel),100*S.SOC(sel),'LineWidth',1.4);ylabel('SOC (%)');ylim([floor(100*min(S.SOC(sel)))-.05,ceil(100*max(S.SOC(sel)))+.05]);grid on;xlabel('Time (s)'); title('Continuous input budget and SOC');xtickformat('%.2f');yyaxis left;ytickformat('%.2f');yyaxis right;ytickformat('%.2f'); ax=gca;ax.YAxis(1).Color='k';ax.YAxis(2).Color='k'; r23.save_figure(fig,figures,'corrected-CG-startup-publication');close(fig); B=out.new_cases(2);A=out.new_cases(4); choices=[out.corrected_reference,out.frozen_comparisons(2:3),A,B]; labels={'CG reference','Al35 / mass','Al35 / volume','Hyp A / dry','Hyp B / wet'}; fig=figure('Position',[50 50 1500 500]);tiledlayout(1,3,'Padding','compact','TileSpacing','compact'); nexttile;values=[choices.effective_flight_s]/3600;bar(values);xticks(1:5);xticklabels(labels);xtickangle(25); ylabel('Feasible flight time (h)');title('Full mission, same propulsion hardware');grid on;ytickformat('%.2f'); for k=1:5 if isfinite(values(k)),text(k,values(k),sprintf('%.2f',values(k)),'HorizontalAlignment','center','VerticalAlignment','bottom'); else,text(k,.3,'Infeasible','HorizontalAlignment','center','Rotation',90);end end nexttile;bar([[choices.complete_dry_storage_kg]',[choices.H2_initial_kg]'],'stacked'); xticks(1:5);xticklabels(labels);xtickangle(25);ylabel('Storage replacement mass (kg)'); legend('Complete dry storage','Initial H2','Location','northwest');title('Complete dry mass + initial H2');grid on;ylim([0,1.15*max([choices.complete_wet_storage_kg])]);ytickformat('%.2f'); for k=1:5,text(k,choices(k).complete_wet_storage_kg,sprintf('%.2f',choices(k).complete_wet_storage_kg),'HorizontalAlignment','center','VerticalAlignment','bottom');end nexttile;plot(S.time_s/3600,100*S.SOC,'LineWidth',1.5);hold on; AA=res.A_EQUAL_COMPLETE_DRY_MAX_WORK.series;BB=res.B_EQUAL_COMPLETE_WET_MAX_WORK.series; plot(AA.time_s/3600,100*AA.SOC,'LineWidth',1.5);plot(BB.time_s/3600,100*BB.SOC,'LineWidth',1.5); yline(100*c.SOCmin,'k--');xlabel('Complete profile time (h)');ylabel('SOC (%)');title('Nominal energy-equivalent SOC');grid on; legend('CG reference','Hyp A','Hyp B','SOC min','Location','southwest');xtickformat('%.2f');ytickformat('%.2f'); r23.save_figure(fig,figures,'equal-storage-comparison-publication');close(fig); assert(strcmp(r23.sha256_file(source),before)); names={'corrected-CG-mission-publication','corrected-CG-startup-publication','equal-storage-comparison-publication'}; outputs=struct([]); for k=1:numel(names) for ext={'.png','.svg'} file=[names{k} ext{1}];item=struct('path',['reports/05_simulation/R23-001/equal-storage-supplement/' file], ... 'sha256',r23.sha256_file(fullfile(dest,file))); if isempty(outputs),outputs=item;else,outputs(end+1)=item;end %#ok end end receipt=struct('operation','publication_plotting_from_completed_MAT_only','physical_model_rerun',false,'new_physical_calculations',false, ... 'MATLAB_release',version('-release'),'source_sha256',r23.sha256_file([mfilename('fullpath') '.m']), ... 'input','reports/05_simulation/R23-001/equal-storage-supplement/equal-storage-results.mat', ... 'input_sha256',before,'outputs',outputs); r23.write_json(fullfile(dest,'final-publication-figures-receipt.json'),receipt); fprintf('EQUAL_STORAGE_FINAL_PUBLICATION_FIGURES_COMPLETED\n'); end