function out=run_equal_storage() % EQ-1.0.0. New user-authorized storage hypotheses; original science read-only. here=fileparts(mfilename('fullpath')); root=fileparts(fileparts(fileparts(fileparts(fileparts(here))))); model=fullfile(root,'reports','04_models','R23-001'); base=fullfile(root,'reports','05_simulation','R23-001','runs','SIM-R3-001-he-v2'); pub=fullfile(root,'reports','06_reports','03_endurance_simulation','SIM-R3-001'); dest=fullfile(root,'reports','05_simulation','R23-001','equal-storage-supplement'); assert(strcmp(version('-release'),'2025a'),'MATLAB R2025a required'); if ~isfolder(dest),mkdir(dest);end addpath(fullfile(model,'matlab')); addpath(fullfile(model,'supplements','mission-climb')); climbRuntime=prepare_climb_runtime(root); set(groot,'defaultFigureVisible','off'); diary(fullfile(dest,'matlab-run.log')); started=char(datetime('now','TimeZone','UTC'));timer=tic; original=jsondecode(fileread(fullfile(base,'run-receipt-all-completed.json'))); verify_original(); loaded=load(fullfile(base,'full-analysis-results.mat'),'out');old=loaded.out;clear loaded; p=r23.parameters();idx=old.mission.selected_index;b=old.integration.branches(idx); c0=r23.mission_settings(b,p);historicalBaseline=old.mission.scenarios(idx);baseline=historicalBaseline; assert(strcmp(b.design_id,'IE24_A12_P80G30_NOCHG')); assert(abs(b.M0_kg-19.746854)<1e-10); report=jsondecode(fileread(fullfile(pub,'report-data.json'))); thermalFile=fullfile(root,'reports','05_simulation','R23-001','thermal-conditioning-supplement','summary.json'); thermal=jsondecode(fileread(thermalFile));f=old.fluid.normal; T35=readtable(fullfile(model,'inputs','normal-hydrogen-35K-25to35MPa.tsv'), ... 'FileType','text','Delimiter','\t','VariableNamingRule','preserve'); rho0=T35{end,3};V=.012;Vouter=.020;T0=35;H0=rho0*V; dry0=b.empty_tank_kg+.12;wet0=dry0+b.loaded_H2_kg; noStorage=b.M0_kg-wet0; % No pressure-shell material law is applied to the user-defined dry budgets. radius=(3*V/(4*pi))^(1/3);area=4*pi*radius^2;flux=9.15;Qleak=flux*area; store=struct('fluid',f,'V_m3',V,'T0_K',T0,'Pmax_Pa',35e6,'Pfeed_Pa',200000, ... 'Qleak_W',Qleak,'recovery_cap_W',50,'recovery_fraction',.05,'heater_max_W',25,'heater_efficiency',.95); cfg=struct('same_work_s',baseline.work_s,'coarse_dt_s',10,'final_dt_s',2, ... 'work_bracket_tolerance_s',60,'work_output_grid_s',30,'work_cap_s',16*3600, ... 'initial_gross_iterations',10,'extra_control_output_W',5); inputFiles={fullfile(base,'full-analysis-results.mat'),fullfile(base,'run-receipt-all-completed.json'), ... fullfile(pub,'report-data.json'),fullfile(pub,'references.json'),fullfile(model,'all-engineering-parameters.csv'), ... fullfile(model,'inputs','normal-hydrogen-35K-25to35MPa.tsv'),thermalFile, ... fullfile(root,'reports','05_simulation','R23-001','thermal-conditioning-supplement','run-receipt.json'), ... fullfile(root,'reports','05_simulation','R23-001','upper-certificate-supplement','summary.json'), ... fullfile(root,'reports','05_simulation','R23-001','upper-certificate-supplement','run-receipt.json'), ... fullfile(root,'reports','08_collaboration','contracts','SIM-R3-002-equal-storage.md'), ... fullfile(root,'reports','08_collaboration','amendments','R23-001-undergraduate-precision.md')}; inputHashes=hash_files(inputFiles); codeFiles={fullfile(here,'run_equal_storage.m'),climbRuntime.helper_path,climbRuntime.resolved_power_function}; deps=dir(fullfile(model,'matlab','+r23','*.m')); for k=1:numel(deps),codeFiles{end+1}=fullfile(deps(k).folder,deps(k).name);end %#ok codeHashes=hash_files(codeFiles); PR={}; addpar('EQ.inner_volume',V,'m3','user design hypothesis','SIM-R3-002 contract; same 12L inner capacity'); addpar('EQ.outer_budget',Vouter,'m3','user design hypothesis','same 20L installed envelope budget'); addpar('EQ.rho0',rho0,'kg/m3','frozen NIST normal-H2 value','normal-hydrogen-35K-25to35MPa.tsv last row column3'); addpar('EQ.T0',T0,'K','frozen NIST state','35K/35MPa normal-H2'); addpar('EQ.H0',H0,'kg','derived storage inventory','rho0*V_inner'); addpar('EQ.reference_dry',dry0,'kg','baseline full replacement dry mass','B17 4.3kg + B51 .12kg'); addpar('EQ.reference_wet',wet0,'kg','baseline full replacement wet mass','B17+B18+B51; common B09/B19 retained once'); addpar('EQ.B.dry',wet0-H0,'kg','user wet-equality hypothesis, all cryogenic items included','4.704-H0; not a material shell result'); addpar('EQ.A.dry',dry0,'kg','user dry-equality hypothesis, all cryogenic items included','4.42; no second C01-C08 addition'); addpar('EQ.area_radius',radius,'m','hypothetical equivalent-sphere geometry','(3*V_inner/(4*pi))^(1/3); no Al thickness'); addpar('EQ.area',area,'m2','thermal area assumption','4*pi*equivalent_inner_radius^2; wall thickness not specified'); addpar('EQ.heat_flux',flux,'W/m2','inherited literature/engineering heat leak','original research_vessel.m/Lara scenario'); addpar('EQ.heat_leak',Qleak,'W thermal','derived for new 12L geometry','EQ.heat_flux*EQ.area; not old small-volume total'); for field=fieldnames(cfg)' addpar(['EQ.search.' field{1}],cfg.(field{1}),unit_for(field{1}),'engineering numerical setting','EQ-1.0.0; undergraduate scheme precision'); end settings=struct('version','EQ-1.0.0','model_version','R23-HE2.1.0','design_version','R2-INT-0.5.0', ... 'climb_runtime',climbRuntime, ... 'configuration',cfg,'normal_fluid_source','full-analysis-results.mat out.fluid.normal', ... 'inner_volume_m3',V,'installed_envelope_m3',Vouter,'initial_density_kg_m3',rho0, ... 'initial_H2_kg',H0,'baseline_dry_kg',dry0,'baseline_wet_kg',wet0, ... 'heat_leak_area_m2',area,'heat_leak_W',Qleak, ... 'thermal_boundary','tank heat and external warming supplied under inherited recovered-heat scenario; new external electric warming=0W; extra control counted electrically once', ... 'mass_boundary','all C01-C08 included in hypothetical dry mass; replace B17/B18/B51 only; water expelled immediately', ... 'cases',struct([])); records={};results=struct;searches=struct; % Correct only the affected reference mission; steady fits/upper bounds unchanged. cCG=c0;cCG.design_id='CG_CLIMB_CORRECTED'; cCG.search_cruise_cap_s=cfg.work_cap_s;cCG.search_dt_s=cfg.coarse_dt_s; cCG.search_iterations=cfg.initial_gross_iterations;cCG.dt_s=cfg.coarse_dt_s; referenceSame=r23.simulate_mission(cCG,b.prop,p,cfg.same_work_s,cfg.final_dt_s); [baseline,referenceSearch]=coupled_search(cCG,referenceSame); searches.CG_CLIMB_CORRECTED=referenceSearch; baselineSeries=baseline.series; writetable(baselineSeries,fullfile(dest,'CG_CLIMB_CORRECTED_MAX_WORK-mission.csv'),'Encoding','UTF-8'); referenceSmall=rmfield(baseline,'series');referenceSmall.input_settings=cCG; r23.write_json(fullfile(dest,'CG_CLIMB_CORRECTED_MAX_WORK-summary.json'),referenceSmall); save(fullfile(dest,'CG_CLIMB_CORRECTED_MAX_WORK-mission.mat'),'baseline','cCG','-v7.3'); settings.corrected_reference_settings=cCG; baseRecord=common_record('CG_CLIMB_CORRECTED',baseline,baselineSeries,cCG,dry0,b.loaded_H2_kg,V,Vouter,b.M0_kg); baseRecord.task_scope='corrected_reference_maximum_work';baseRecord.case_group='corrected_reference'; results.CG_CLIMB_CORRECTED_MAX_WORK=baseline; fprintf('CORRECTED_CG feasible=%d flight=%.2fh work=%.2fs SOC=%.4f\n',baseline.feasible,baseline.flight_s/3600,baseline.work_s,baseline.SOC_final); for hi=1:2 c=c0;c.storage=store;c.fixed_load_output_W=c0.fixed_load_output_W+cfg.extra_control_output_W; c.search_cruise_cap_s=cfg.work_cap_s;c.search_dt_s=cfg.coarse_dt_s; c.search_iterations=cfg.initial_gross_iterations;c.dt_s=cfg.coarse_dt_s; c.H0_kg=H0; if hi==1 hypothesis='B_EQUAL_COMPLETE_WET';dry=wet0-H0;c.M0_kg=b.M0_kg; else hypothesis='A_EQUAL_COMPLETE_DRY';dry=dry0;c.M0_kg=noStorage+dry+H0; end c.design_id=hypothesis; assert(abs((c.M0_kg-b.M0_kg)-(dry+H0-wet0))<1e-12); if hi==1,assert(c.M0_kg==b.M0_kg);end sf=rmfield(c.storage,'fluid');st=rmfield(c,'storage');st.storage=sf; settings.cases(hi).hypothesis_id=hypothesis;settings.cases(hi).complete_dry_storage_kg=dry; settings.cases(hi).mission_settings=st; for field=fieldnames(c)' value=c.(field{1}); if isnumeric(value)&&isscalar(value) addpar(['EQ.' hypothesis '.mission.' field{1}],value,unit_for(field{1}), ... 'inherited setting or explicit hypothesis override','r23.mission_settings; settings.json exact active scenario'); end end for field=fieldnames(sf)' addpar(['EQ.' hypothesis '.store.' field{1}],sf.(field{1}),unit_for(field{1}), ... 'active storage setting','inherited storage_analysis parameters; Qleak from new12L area'); end fprintf('START %s H0=%.8f dry=%.8f M0=%.8f Qleak=%.6fW\n',hypothesis,H0,dry,c.M0_kg,Qleak); same=r23.simulate_mission(c,b.prop,p,cfg.same_work_s,cfg.final_dt_s); records{end+1}=save_case([hypothesis '_SAME_TASK'],hypothesis,'same_reference_work',same,c,dry); %#ok [best,search]=coupled_search(c,same); searches.(hypothesis)=search; records{end+1}=save_case([hypothesis '_MAX_WORK'],hypothesis,'maximum_feasible_work_to_engineering_resolution',best,c,dry); %#ok end % Frozen old results are read and summarized, never simulated again. historicalSeries=readtable(fullfile(base,[b.design_id '-mission.csv']),'VariableNamingRule','preserve'); historicalRecord=old_record('CG_BASELINE_HE2p0',historicalBaseline,historicalSeries,c0,dry0,b.loaded_H2_kg,V,Vouter,b.M0_kg); oldCases=report.Storage.cases; oldRecords={}; for k=5:6 z=oldCases(k);S=readtable(fullfile(base,[z.design_id '-mission.csv']),'VariableNamingRule','preserve'); cc=c0;cc.H0_kg=z.vessel.H2_initial_kg;cc.M0_kg=z.complete_M0_kg;cc.fixed_load_output_W=c0.fixed_load_output_W+5; oldRecords{end+1}=old_record(z.design_id,z,S,cc,z.vessel.dry_storage_kg, ... z.vessel.H2_initial_kg,z.vessel.V_inner_m3,z.vessel.V_outer_m3,z.complete_M0_kg); %#ok end out=struct('task_id','SIM-R3-002','supplement_version','EQ-1.0.0', ... 'model_version','R23-HE2.1.0','design_version','R2-INT-0.5.0','climb_runtime',climbRuntime, ... 'baseline_source','corrected reference mission only; historical material/fit/UC/TC results retained without rerun', ... 'density_source',settings.normal_fluid_source,'settings',settings, ... 'corrected_reference',baseRecord,'new_cases',[records{:}], ... 'frozen_comparisons',[historicalRecord,oldRecords{:}], ... 'searches',searches,'all_new_maximum_cases_feasible',records{2}.feasible&&records{4}.feasible, ... 'user_hypothesis_identity','same-volume high-density storage is a user-defined capability scenario, not a commercial bottle; existing material results retained', ... 'hardware_replanning_result','A/B retain same FC, P80/G30, 12S buffer and payload; use computed power/SOC margins to determine if hardware reassignment is needed', ... 'elapsed_s',toc(timer)); r23.write_json(fullfile(dest,'settings.json'),settings); PT=cell2table(PR,'VariableNames',{'parameter_id','value','unit','identity','source_or_use'}); writetable(PT,fullfile(dest,'parameters.csv'),'Encoding','UTF-8'); copyfile(fullfile(model,'all-engineering-parameters.csv'),fullfile(dest,'inherited-1285-parameters.csv')); r23.write_json(fullfile(dest,'summary.json'),out); writetable(struct2table([baseRecord,historicalRecord,oldRecords{:},records{:}]),fullfile(dest,'comparison.csv'),'Encoding','UTF-8'); save(fullfile(dest,'equal-storage-results.mat'),'out','results','settings','searches','f','p','b','-v7.3'); make_figure(); verify_original(); for k=1:numel(inputHashes),assert(strcmp(r23.sha256_file(fullfile(root,inputHashes(k).path)),inputHashes(k).sha256));end fprintf('EQUAL_STORAGE_COMPLETED elapsed=%.2fs\n',toc(timer)); diary('off'); files=dir(fullfile(dest,'*'));outputFiles={}; for k=1:numel(files) if ~files(k).isdir&&~ismember(files(k).name,{'run-receipt.json','native-launch.log','native-stderr.log','native-launch-receipt.json'}) outputFiles{end+1}=fullfile(dest,files(k).name); %#ok end end receipt=struct('task_id','SIM-R3-002','supplement_version','EQ-1.0.0','status','completed', ... 'matlab_release',version('-release'),'matlab_version',version,'computer',computer, ... 'started_utc',started,'completed_utc',char(datetime('now','TimeZone','UTC')), ... 'script_entry','reports/04_models/R23-001/supplements/equal-storage/run_equal_storage.m', ... 'randomness','none; deterministic fixed-segment mission and bounded work-duration search', ... 'original_material_fits_UC_TC_rerun',false,'corrected_reference_mission_run',true, ... 'model_version','R23-HE2.1.0','climb_runtime',climbRuntime,'original_73_source_and_inputs_unchanged',true, ... 'source_files',codeHashes,'input_files',inputHashes,'output_files',hash_files(outputFiles), ... 'work_resolution_s',cfg.work_bracket_tolerance_s,'final_dt_s',cfg.final_dt_s); r23.write_json(fullfile(dest,'run-receipt.json'),receipt); function [best,search]=coupled_search(c,same) % The original gross-fuel routine is used only to seed an upper bracket. gross=r23.maximize_work(c,b.prop,p); lower=0;if same.feasible,lower=same.work_s;end upper=min(cfg.work_cap_s,gross.work_search_bracket_s(2)+120); history={}; [passed,fail,z]=trial(upper,cfg.coarse_dt_s); while passed&&upper end while upper-lower>cfg.work_bracket_tolerance_s middle=(lower+upper)/2; [ok,~,~]=trial(middle,cfg.coarse_dt_s); if ok,lower=middle;else,upper=middle;end end work=floor(lower/cfg.work_output_grid_s)*cfg.work_output_grid_s; [ok,~,best]=trial(work,cfg.final_dt_s); while ~ok&&work>0 work=max(work-cfg.work_output_grid_s,0);[ok,~,best]=trial(work,cfg.final_dt_s); end assert(ok); [nextOK,nextFail,nextResult]=trial(min(work+cfg.work_bracket_tolerance_s,cfg.work_cap_s),cfg.final_dt_s); while nextOK&&work+cfg.work_bracket_tolerance_s0;hOut=nan(n,1);Qwarm=hOut;ratio=hOut; preT=[c.storage.T0_K;S.tank_T_K(1:end-1)]; for j=1:n state=r23.thermo_state(preT(j),S.H2_kg(j)/c.storage.V_m3,f);hOut(j)=state.h_out; end flow=S.FC_bus_W/(c.eta_fc_bus*c.LHV_J_kg);waste=flow*c.LHV_J_kg-S.FC_bus_W; Qwarm(active)=flow(active).*max(thermal.target.enthalpy_J_kg-hOut(active),0); ratio(active)=(Qwarm(active)+S.heat_recovery_W(active))./waste(active); S.step_s=dt;S.Qwarm_external_W=Qwarm;S.minimum_total_recovery_fraction=ratio; S.conduction_loss_W=(S.propulsion_DC_W/c.bus_V).^2*c.wire_resistance_ohm; S.extra_control_bus_W=repmat(cfg.extra_control_output_W/c.eta_aux_converter,n,1); S.external_electric_warming_bus_W=zeros(n,1); result.series=S;results.(id)=result; writetable(S,fullfile(dest,[id '-mission.csv']),'Encoding','UTF-8'); save(fullfile(dest,[id '-mission.mat']),'result','c','-v7.3'); small=rmfield(result,'series');small.input_settings=rmfield(c,'storage');small.storage_settings=rmfield(c.storage,'fluid'); small.complete_dry_storage_kg=dry;small.complete_wet_storage_kg=dry+c.H0_kg; small.Qwarm_peak_W=max(Qwarm(active));small.Qwarm_Wh=sum(Qwarm(active).*dt(active))/3600; small.Qwarm_mean_FC_active_W=sum(Qwarm(active).*dt(active))/sum(dt(active)); small.minimum_total_recovery_fraction_peak=max(ratio(active)); r23.write_json(fullfile(dest,[id '-summary.json']),small); rec=common_record(id,result,S,c,dry,c.H0_kg,V,Vouter,c.M0_kg); rec.case_group=hypothesis;rec.task_scope=mode; rec.Qwarm_peak_W_thermal=small.Qwarm_peak_W;rec.Qwarm_Wh_thermal=small.Qwarm_Wh; rec.Qwarm_mean_FC_active_W_thermal=small.Qwarm_mean_FC_active_W; rec.minimum_total_recovery_fraction_peak=small.minimum_total_recovery_fraction_peak; rec.extra_control_bus_W=cfg.extra_control_output_W/c.eta_aux_converter; rec.search_limit_reason='fixed_reference_work'; if contains(mode,'maximum'),rec.search_limit_reason=searches_reason(result);end fprintf('RESULT %s feasible=%d work=%.2fs flight=%.2fh SOC=%.4f heater=%.4fWh recovered=%.4fWh\n', ... id,result.feasible,result.work_s,result.flight_s/3600,result.SOC_final,result.electric_tank_heater_Wh,result.heat_recovery_Wh); end function reason=searches_reason(result) reason='next one-minute trial fails; see search.json'; if ~result.feasible,reason=result.reason;end end function rec=old_record(id,result,S,c,dry,H,Vin,Vout,M) rec=common_record(id,result,S,c,dry,H,Vin,Vout,M); rec.task_scope='frozen_original_result_not_rerun';rec.case_group='frozen_reference'; rec.model_version='R23-HE2.0.0';rec.gain_reference_model='R23-HE2.0.0'; if result.feasible,rec.net_flight_gain_fraction=result.flight_s/historicalBaseline.flight_s-1;end if contains(id,'CcH2') rec.extra_control_bus_W=5/c.eta_aux_converter; ix=find(strcmp({thermal.cases.design_id},id)); if ~isempty(ix)&&thermal.cases(ix).valid_full_mission_thermal_target zz=thermal.cases(ix);rec.Qwarm_peak_W_thermal=zz.Qwarm_peak_W; rec.Qwarm_mean_FC_active_W_thermal=zz.Qwarm_mean_FC_active_W;rec.Qwarm_Wh_thermal=zz.Qwarm_integral_Wh; rec.minimum_total_recovery_fraction_peak=zz.minimum_total_recovery_fraction_peak; end end end function rec=common_record(id,z,S,c,dry,H,Vin,Vout,M) dt=[diff(S.time_s);z.total_profile_s-S.time_s(end)];work=S.segment==6;takeoff=S.segment==3; propHover=r23.propulsion_power(M,0,0,1,b.prop,p);propWork=r23.propulsion_power(M,5,0,1,b.prop,p); fixed=c.fixed_load_output_W/c.eta_aux_converter; wire=(S.propulsion_DC_W/c.bus_V).^2*c.wire_resistance_ohm; flight=NaN;gain=NaN;if z.feasible,flight=z.flight_s;gain=flight/baseline.flight_s-1;end rec=struct('design_id',id,'model_version','R23-HE2.1.0','gain_reference_model','R23-HE2.1.0', ... 'case_group','','task_scope','','inner_volume_m3',Vin,'installed_envelope_m3',Vout, ... 'complete_dry_storage_kg',dry,'complete_wet_storage_kg',dry+H,'H2_initial_kg',H, ... 'H2_available_before_reserve_and_purge_kg',H*(1-c.hydrogen_reserve_fraction)-c.startup_vent_H2_kg, ... 'H2_FC_used_kg',z.H2_FC_used_kg,'H2_final_kg',z.H2_final_kg,'H2_vented_kg',z.H2_vented_kg, ... 'aircraft_initial_kg',M,'aircraft_final_kg',z.final_mass_kg, ... 'takeoff_bus_peak_W',max(S.bus_load_W(takeoff)), ... 'hover_initial_bus_W',propHover+fixed+(propHover/c.bus_V)^2*c.wire_resistance_ohm, ... 'work_initial_bus_W',propWork+fixed+(propWork/c.bus_V)^2*c.wire_resistance_ohm, ... 'work_bus_mean_W',sum(S.bus_load_W(work).*dt(work))/sum(dt(work)), ... 'maximum_bus_W',max(S.bus_load_W),'continuous_motor_power_margin_W',4*c.continuous_motor_each_W-propHover, ... 'continuous_FC_hover_margin_W',c.FC_cap_W-(propHover+fixed+(propHover/c.bus_V)^2*c.wire_resistance_ohm), ... 'work_s',z.work_s,'recorded_total_profile_s',z.total_profile_s,'effective_flight_s',flight,'net_flight_gain_fraction',gain, ... 'SOC_min',z.SOC_min,'SOC_final',z.SOC_final,'feasible',logical(z.feasible), ... 'power_pass',logical(z.power_constraints_pass),'SOC_pass',logical(z.SOC_constraints_pass), ... 'H2_reserve_pass',logical(z.H2_reserve_pass),'thermal_pass',logical(z.thermal_supply_pass), ... 'termination_reason',z.reason,'search_limit_reason','frozen_original', ... 'FC_energy_Wh',z.FC_energy_Wh,'load_energy_Wh',z.load_energy_Wh, ... 'battery_storage_delta_Wh',z.battery_storage_delta_Wh, ... 'extra_control_bus_W',0,'extra_control_Wh',0,'conduction_loss_peak_W',max(wire), ... 'conduction_loss_mean_W',sum(wire.*dt)/sum(dt),'conduction_loss_Wh',sum(wire.*dt)/3600, ... 'heater_peak_W_electric_at_battery',max(S.heater_battery_W),'electric_tank_heater_Wh',z.electric_tank_heater_Wh, ... 'heat_recovery_peak_W_thermal',max(S.heat_recovery_W),'heat_recovery_Wh_thermal',z.heat_recovery_Wh, ... 'Qwarm_peak_W_thermal',NaN,'Qwarm_mean_FC_active_W_thermal',NaN,'Qwarm_Wh_thermal',NaN, ... 'minimum_total_recovery_fraction_peak',NaN,'external_electric_warming_bus_W',0, ... 'energy_balance_residual_J',z.energy_balance_residual_J,'H2_balance_residual_kg',z.H2_balance_residual_kg, ... 'SOC_energy_balance_residual_Wh',z.SOC_energy_balance_residual_Wh,'tank_energy_balance_J',z.tank_energy_balance_J); if contains(id,'EQUAL_')||contains(id,'CcH2') rec.extra_control_bus_W=cfg.extra_control_output_W/c.eta_aux_converter; rec.extra_control_Wh=rec.extra_control_bus_W*z.total_profile_s/3600; end end function make_figure() choices=[baseRecord,oldRecords{:},records{4},records{2}]; labels={'CG base','Al35 / mass','Al35 / volume','Hyp A / dry','Hyp B / wet'}; fig=figure('Position',[50 50 1500 460]);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 hardware');grid on; for ii=1:5 if isfinite(values(ii)),text(ii,values(ii),sprintf('%.2f',values(ii)),'HorizontalAlignment','center','VerticalAlignment','bottom'); else,text(ii,.25,'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('Dry mass + actual H2 inventory');grid on; nexttile;plot(baselineSeries.time_s/3600,baselineSeries.SOC,'LineWidth',1.6);hold on; AA=results.A_EQUAL_COMPLETE_DRY_MAX_WORK.series;BB=results.B_EQUAL_COMPLETE_WET_MAX_WORK.series; plot(AA.time_s/3600,AA.SOC,'LineWidth',1.6);plot(BB.time_s/3600,BB.SOC,'LineWidth',1.6); yline(c0.SOCmin,'k--');xlabel('Complete profile time (h)');ylabel('SOC');title('Nominal energy-equivalent SOC');grid on; legend('CG base','Hyp A','Hyp B','SOC min','Location','southwest'); exportgraphics(fig,fullfile(dest,'equal-storage-comparison.png'),'Resolution',160);close(fig); end function addpar(id,value,unit,identity,source) PR(end+1,:)={id,num2str(value,17),unit,identity,source}; end function unit=unit_for(name) unit='1'; if contains(name,'_J_kg'),unit='J/kg';elseif contains(name,'_kg'),unit='kg';elseif contains(name,'_m3'),unit='m3'; elseif contains(name,'_Pa'),unit='Pa';elseif contains(name,'_Wh'),unit='Wh'; elseif contains(name,'_W_s'),unit='W/s';elseif contains(name,'_W'),unit='W'; elseif contains(name,'_m_s'),unit='m/s';elseif endsWith(name,'_s'),unit='s'; elseif endsWith(name,'_V'),unit='V';elseif endsWith(name,'_A'),unit='A'; elseif endsWith(name,'_Ah'),unit='Ah';elseif endsWith(name,'_K'),unit='K'; elseif contains(name,'ohm'),unit='ohm';end end function list=hash_files(names) list=struct([]); for ii=1:numel(names) z=struct('path',strrep(erase(names{ii},[root filesep]),filesep,'/'),'sha256',r23.sha256_file(names{ii})); if isempty(list),list=z;else,list(end+1)=z;end end end function verify_original() items=[original.source_files(:);original.input_files(:)]; for ii=1:numel(items),assert(strcmp(r23.sha256_file(fullfile(root,items(ii).path)),items(ii).sha256),'Original science changed');end end end