function out=storage_analysis(integration,mission,peak,fluid,p,paths) f=fluid.normal;b=integration.branches(mission.selected_index);c0=r23.mission_settings(b,p); base=mission.scenarios(mission.selected_index); % Only tankB17, gross inventoryB18 and high-pressure safety allowanceB51 replaced. baseWithoutStorage=b.M0_kg-b.empty_tank_kg-b.loaded_H2_kg-.12; massBudget=b.empty_tank_kg+b.loaded_H2_kg+.12; Vbay=.020;VinnerCap=b.cylinder_water_volume_L/1000; T35=readtable(fullfile(paths.inputs,'normal-hydrogen-35K-25to35MPa.tsv'),'FileType','text','Delimiter','\t','VariableNamingRule','preserve'); rhoCC=T35{end,3};rhoLow=66.3; Pinitial=225400;Tlow=fzero(@initP,[f.Tmin+.002,50]); routes={'LH2_low_pressure',rhoLow,.280e6,Tlow;'CcH2_pressure_retention',rhoLow,5e6,Tlow;'CcH2_high_density',rhoCC,35e6,35}; out=struct('model_version','R23-HE2.0.0','normal_hydrogen_only_for_UAV_comparison',true, ... 'cryo_budget_revision','CRYO-BUDGET-1.2.0','revision_boundary','independent internalMLI, internal low-conduction supports, resistive heater hardware and new warm pressure-regulation budgets; R2 CG inputs unchanged', ... 'baseline_design_id',b.design_id,'baseline_catalogue_H2_kg',b.loaded_H2_kg,'baseline_flight_h',base.flight_s/3600, ... 'replacement_BOM_ids',{{'B17','B18','B51'}},'common_installed_storage_mass_budget_kg',massBudget, ... 'common_outer_bay_budget_m3',Vbay,'common_max_inner_volume_m3',VinnerCap, ... 'geometry_status','common20Lcompleteouterenvelope andselectedcatalogueinternalvolume cap;12LbodyOD200mm,length536mmverifiedbyR2;2Linterfacesbudget;packingandmountingnotqualified', ... 'L05_percent_gain_multiplied_into_UAV',false,'cases',struct([])); out.CG_body_geometry=struct('outer_diameter_m',.200,'body_length_m',.536,'bounding_cylinder_m3',pi*.200^2/4*.536, ... 'common_interfaces_volume_budget_m3',.002,'complete_volume_budget_m3',Vbay,'source','R2v0.5manufacturer12Lcylinderbodydimensions;interfacesandpackingareexplicitresearchbudgets'); for ri=1:3 name=routes{ri,1};rho=routes{ri,2};Pmax=routes{ri,3};T0=routes{ri,4}; for mode=1:2 if mode==1 % Maximize stored H2 under common complete mass and geometry limits. vl=1e-5;vh=VinnerCap; for it=1:45 vm=(vl+vh)/2;v=r23.research_vessel(vm,Pmax,rho); if v.dry_storage_kg+v.H2_initial_kg<=massBudget&&v.V_outer_m3<=Vbay,vl=vm;else,vh=vm;end end V=vl;label='mass_limited_with_common_geometry'; else vl=1e-5;vh=VinnerCap; for it=1:45 vm=(vl+vh)/2;v=r23.research_vessel(vm,Pmax,rho); if v.V_outer_m3<=Vbay,vl=vm;else,vh=vm;end end V=vl;label='volume_limited_full_mass_reported'; end vessel=r23.research_vessel(V,Pmax,rho); c=c0;c.design_id=[name '__' label];c.H0_kg=vessel.H2_initial_kg;c.M0_kg=baseWithoutStorage+vessel.dry_storage_kg+c.H0_kg; c.fixed_load_output_W=c.fixed_load_output_W+5; % additional cryogenic state/control allowance c.search_dt_s=4;c.search_iterations=12;c.dt_s=2; rough=r23.maximize_work(c,b.prop,p); store=struct('fluid',f,'V_m3',V,'T0_K',T0,'Pmax_Pa',Pmax,'Pfeed_Pa',200000, ... 'Qleak_W',vessel.Qleak_W,'recovery_cap_W',50,'recovery_fraction',.05,'heater_max_W',25,'heater_efficiency',.95); result=rough; if rough.completed_profile&&rough.power_constraints_pass&&rough.SOC_constraints_pass c.storage=store; result=r23.simulate_mission(c,b.prop,p,rough.work_s,2); % Extra vent loss is resolved by one conservative duration correction, not hidden. if ~result.H2_reserve_pass&&result.H2_vented_kg>c.startup_vent_H2_kg reduction=(result.H2_vented_kg-c.startup_vent_H2_kg)*c.eta_fc_bus*c.LHV_J_kg/max(mean(result.series.FC_bus_W),1); result=r23.simulate_mission(c,b.prop,p,max(rough.work_s-reduction-5,0),2); end end series=result.series;small=rmfield(result,'series'); small.work_search_bracket_s=[NaN NaN];if isfield(rough,'work_search_bracket_s'),small.work_search_bracket_s=rough.work_search_bracket_s;end small.route=name;small.constraint_case=label;small.vessel=vessel;small.complete_M0_kg=c.M0_kg; small.delta_complete_mass_vs_CG_kg=c.M0_kg-b.M0_kg; small.net_flight_gain_fraction=NaN;if result.feasible,small.net_flight_gain_fraction=result.flight_s/base.flight_s-1;end small.source_state=struct('composition','normalH2 fixed75%ortho/25%para','T0_K',T0,'rho0_kg_m3',rho, ... 'initial_state_identity','35K35MPaNIST forhighdensity;66.3kg/m3at225.4kParesearchinitialconditionforLH2/retention,normalEOSderivedT'); small.limits='Research vessel only; source literature para aircraft gains not copied; valve/HX/structure/thermal qualification unresolved'; if isempty(out.cases),out.cases=small;else,out.cases(end+1)=small;end writetable(series,fullfile(paths.run,[c.design_id '-mission.csv'])); r23.write_json(fullfile(paths.run,[c.design_id '-summary.json']),small); fprintf('STORAGE %s M=%.7gkg H0=%.7gkg feasible=%d flight=%.7gh gain=%.7g\n',c.design_id,c.M0_kg,c.H0_kg,result.feasible,result.flight_s/3600,small.net_flight_gain_fraction); end end out.C01_C08_mass_boundary='All eight dry-storage categories explicitly summed in each vessel.C01_C08_mass_map; common B09 cradle retained once; B19 HFLW mass conservatively retained without asserting low-pressure compatibility, new warm regulation explicitly added; replacing only B17/B18/B51.'; % Threshold map separates potential density gain from allowed installed penalty. Vthreshold=min(VinnerCap,.009);Hhigh=rhoCC*Vthreshold;dry=linspace(.5,12,100);aux=linspace(0,500,80);gains=nan(numel(aux),numel(dry)); Pbase=r23.propulsion_power(b.M0_kg,5,0,1,b.prop,p);Pbase=Pbase+b.bus_fixed_load_W+(Pbase/50)^2*.013; for i=1:numel(dry) M=baseWithoutStorage+dry(i)+Hhigh; [pp,mp]=r23.propulsion_power(M,5,0,1,b.prop,p); for j=1:numel(aux) pb=pp+b.bus_fixed_load_W+(pp/50)^2*.013+aux(j); if mp.in_domain&&pp<=4*b.motor_continuous_each_budget_W&&pb<=2280 gains(j,i)=(Hhigh*.95*p.LHV*.5/pb/3600)/(b.loaded_H2_kg*.95*p.LHV*.5/Pbase/3600)-1; end end end writematrix([NaN,dry;aux',gains],fullfile(paths.run,'CcH2-dry-mass-aux-steady-gain-map.csv')); out.threshold_map=struct('H2_high_density_kg',Hhigh,'V_inner_m3',Vthreshold,'dry_mass_grid_kg',dry,'extra_aux_grid_W',aux, ... 'comparison','same5m/ssteadynew versus same5m/sCGdiagnostic; mainnetclaimsusefullmissioncases', ... 'note','NaN where continuouspowerorstaticmapconstraintfails; not95%physicalguarantee'); Mcap=peak.fixed_hardware_summary(mission.selected_index).combined_power_screen_MTOW_kg; targetPower=Pbase*Hhigh/b.loaded_H2_kg; mb=[4*min([b.prop.bench_points.thrust_g])/1000,4*max([b.prop.bench_points.thrust_g])/1000]; Menergy=fzero(@(M)steady_bus(M)-targetPower,mb); dryPower=Mcap-baseWithoutStorage-Hhigh;dryEnergy=Menergy-baseWithoutStorage-Hhigh; requiredStress=fzero(@stress_residual,[121e6,1.5e9]); stressVessel=r23.research_vessel(Vthreshold,35e6,rhoCC,requiredStress); dryExample=2;Mexample=baseWithoutStorage+dryExample+Hhigh; auxPowerLimit=2280-steady_bus(Mexample);auxEnergyLimit=targetPower-steady_bus(Mexample); out.thresholds=struct('comparison_steady_speed_m_s',5,'power_screen_MTOW_kg',Mcap, ... 'maximum_complete_dry_storage_for_power_kg',dryPower,'energy_only_dry_mass_break_even_kg',dryEnergy, ... 'energy_only_break_even_total_mass_kg',Menergy,'energy_only_break_even_outside_continuous_power_domain',Menergy>Mcap, ... 'required_allowable_stress_at_Al_density_Pa',requiredStress,'hypothetical_material_identity','strengththresholdat2700kg/m3;notclaimed6061orcommercialcompositeproperty', ... 'stress_threshold_external_volume_m3',stressVessel.V_outer_m3,'stress_threshold_common_bay_pass',stressVessel.V_outer_m3<=Vbay, ... 'example_dry_storage_kg',dryExample,'example_extra_aux_power_limit_W',auxPowerLimit,'example_energy_only_aux_break_even_W',auxEnergyLimit, ... 'governing_first_constraint','continuousFC/motorpowerbeforesteadynetzeroenergygain','zero_gain_contour_in_feasible_map',any(gains(:)<=0)); r23.write_json(fullfile(paths.report,'storage-summary.json'),out); save(fullfile(paths.run,'storage-results.mat'),'out'); fig=figure('Position',[100 100 1280 500]);tiledlayout(1,2,'Padding','compact'); nexttile;contourf(dry,aux,100*gains,20,'LineColor','none');colorbar;hold on; if any(gains(:)<=0),contour(dry,aux,gains,[0 0],'k','LineWidth',2);end grid on; xlabel('Complete dry cryogenic storage (kg)');ylabel('Additional electrical auxiliary load (W)');title('High-density potential and continuous-power feasible region (%)'); nexttile;labels=["LH2 / mass","LH2 / volume","CcH2 5MPa / mass","CcH2 5MPa / volume","CcH2 35MPa / mass","CcH2 35MPa / volume"]; values=[out.cases.net_flight_gain_fraction]*100;barh(values);yticks(1:numel(labels));yticklabels(strrep(labels,'_',' '));xlabel('Full-mission flight-time gain vs CG (%)');grid on;title('Unqualified vessel research cases; infeasible cases blank'); r23.save_figure(fig,paths,'storage-net-gain-and-penalty-threshold');close(fig); function v=initP(T) s=r23.thermo_state(T,rhoLow,f);v=s.p_Pa-Pinitial; end function P=steady_bus(M) pp=r23.propulsion_power(M,5,0,1,b.prop,p);P=pp+b.bus_fixed_load_W+(pp/50)^2*.013; end function value=stress_residual(S) vv=r23.research_vessel(Vthreshold,35e6,rhoCC,S);value=vv.dry_storage_kg-dryPower; end end