def test_mission_group_without_loop(cleanup, with_dummy_plugin_2): input_file_path = pth.join(DATA_FOLDER_PATH, "test_mission.xml") ivc = DataFile(input_file_path).to_ivc() with pytest.raises(FastMissionFileMissingMissionNameError): run_system( Mission( propulsion_id="test.wrapper.propulsion.dummy_engine", out_file=pth.join(RESULTS_FOLDER_PATH, "unlooped_mission_group.csv"), use_initializer_iteration=False, mission_file_path=pth.join(DATA_FOLDER_PATH, "test_mission.yml"), adjust_fuel=False, reference_area_variable="data:geometry:aircraft:reference_area", ), ivc, ) problem = run_system( Mission( propulsion_id="test.wrapper.propulsion.dummy_engine", out_file=pth.join(RESULTS_FOLDER_PATH, "unlooped_mission_group.csv"), use_initializer_iteration=False, mission_file_path=pth.join(DATA_FOLDER_PATH, "test_mission.yml"), mission_name="operational", adjust_fuel=False, reference_area_variable="data:geometry:aircraft:reference_area", ), ivc, ) assert_allclose(problem["data:mission:operational:needed_block_fuel"], 6589.0, atol=1.0) assert_allclose(problem["data:mission:operational:block_fuel"], 15195.0, atol=1.0)
def test_sizing_breguet(cleanup, with_dummy_plugin_2): ivc = om.IndepVarComp() ivc.add_output("data:mission:sizing:main_route:cruise:altitude", 35000, units="ft") ivc.add_output("data:TLAR:cruise_mach", 0.78) ivc.add_output("data:TLAR:range", 2000, units="NM") ivc.add_output("data:mission:sizing:TOW", 74000, units="kg") ivc.add_output("settings:mission:sizing:breguet:climb:mass_ratio", 0.97) ivc.add_output("settings:mission:sizing:breguet:descent:mass_ratio", 0.98) ivc.add_output("settings:mission:sizing:breguet:reserve:mass_ratio", 0.06) ivc.add_output("data:mission:sizing:takeoff:altitude", 0.0) ivc.add_output("data:mission:sizing:takeoff:V2", 0.0, units="m/s") ivc.add_output("data:mission:sizing:takeoff:fuel", 0.0, units="kg") ivc.add_output("data:mission:sizing:taxi_out:thrust_rate", 0) ivc.add_output("data:mission:sizing:taxi_out:duration", 0, units="s") ivc.add_output("data:geometry:wing:area", 0.0, units="m**2") # Ensure L/D ratio == 16.0 ivc.add_output("data:aerodynamics:aircraft:cruise:CL", np.linspace(0, 1.5, 150)) ivc.add_output("data:aerodynamics:aircraft:cruise:CD", np.linspace(0, 1.5, 150) / 16.0) # With direct call to rubber engine problem = run_system( Mission( propulsion_id="test.wrapper.propulsion.dummy_engine", out_file=pth.join(RESULTS_FOLDER_PATH, "sizing_breguet.csv"), use_initializer_iteration=False, mission_file_path="::sizing_breguet", adjust_fuel=False, ), ivc, ) assert_allclose(problem["data:mission:sizing:taxi_out:fuel"], 0.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_out:duration"], 0.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_out:distance"], 0.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:climb:fuel"], 2220.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:climb:duration"], 0.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:climb:distance"], 250000.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:cruise:fuel"], 5210.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:cruise:duration"], 13852.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:cruise:distance"], 3204000.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:descent:fuel"], 1331.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:descent:duration"], 0.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:descent:distance"], 250000.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:fuel"], 8761.0, atol=1) assert_allclose(problem["data:mission:sizing:fuel"], 12454.0, atol=1) assert_allclose(problem["data:mission:sizing:needed_block_fuel"], 12454.0, atol=1) assert_allclose(problem["data:mission:sizing:global_reserve:fuel"], 3693.0, atol=1)
def test_mission_component(cleanup, with_dummy_plugin_2): input_file_path = pth.join(DATA_FOLDER_PATH, "test_mission.xml") ivc = DataFile(input_file_path).to_ivc() problem = run_system( MissionComponent( propulsion_id="test.wrapper.propulsion.dummy_engine", out_file=pth.join(RESULTS_FOLDER_PATH, "mission.csv"), use_initializer_iteration=False, mission_wrapper=MissionWrapper(pth.join(DATA_FOLDER_PATH, "test_mission.yml")), mission_name="operational", reference_area_variable="data:geometry:aircraft:reference_area", ), ivc, ) # plot_flight(problem.model.component.flight_points, "test_mission.png") assert_allclose(problem["data:mission:operational:needed_block_fuel"], 6590.0, atol=1.0) assert_allclose( problem["data:mission:operational:main_route:initial_climb:duration"], 34.0, atol=1.0 ) assert_allclose( problem["data:mission:operational:main_route:initial_climb:fuel"], 121.0, atol=1.0 ) assert_allclose( problem["data:mission:operational:main_route:initial_climb:distance"], 3600.0, atol=1.0 ) assert_allclose(problem["data:mission:operational:main_route:climb:duration"], 236.0, atol=1.0) assert_allclose(problem["data:mission:operational:main_route:climb:fuel"], 727.0, atol=1.0) assert_allclose( problem["data:mission:operational:main_route:climb:distance"], 43065.0, atol=1.0 ) assert_allclose( problem["data:mission:operational:main_route:cruise:duration"], 14734.0, atol=1.0 ) assert_allclose(problem["data:mission:operational:main_route:cruise:fuel"], 5167.0, atol=1.0) assert_allclose( problem["data:mission:operational:main_route:cruise:distance"], 3392590.0, atol=1.0 ) assert_allclose( problem["data:mission:operational:main_route:descent:duration"], 1424.0, atol=1.0 ) assert_allclose(problem["data:mission:operational:main_route:descent:fuel"], 192.0, atol=1.0) assert_allclose( problem["data:mission:operational:main_route:descent:distance"], 264451.0, atol=1.0 )
def test_mission_group_breguet_with_loop(cleanup, with_dummy_plugin_2): input_file_path = pth.join(DATA_FOLDER_PATH, "test_mission.xml") vars = DataFile(input_file_path) del vars["data:mission:operational:TOW"] ivc = vars.to_ivc() problem = run_system( Mission( propulsion_id="test.wrapper.propulsion.dummy_engine", out_file=pth.join(RESULTS_FOLDER_PATH, "looped_breguet_mission_group.csv"), use_initializer_iteration=True, mission_file_path=pth.join(DATA_FOLDER_PATH, "test_breguet.yml"), add_solver=True, reference_area_variable="data:geometry:aircraft:reference_area", ), ivc, ) # check loop assert_allclose( problem["data:mission:operational:TOW"], problem["data:mission:operational:OWE"] + problem["data:mission:operational:payload"] + problem["data:mission:operational:onboard_fuel_at_takeoff"], atol=1.0, ) assert_allclose( problem["data:mission:operational:needed_onboard_fuel_at_takeoff"], problem["data:mission:operational:onboard_fuel_at_takeoff"], atol=1.0, ) assert_allclose( problem["data:mission:operational:needed_block_fuel"], problem["data:mission:operational:needed_onboard_fuel_at_takeoff"] + problem["data:mission:operational:taxi_out:fuel"] + problem["data:mission:operational:takeoff:fuel"], atol=1.0, ) assert_allclose(problem["data:mission:operational:needed_block_fuel"], 5626.0, atol=1.0) assert_allclose( problem["data:mission:operational:needed_onboard_fuel_at_takeoff"], 5430.0, atol=1.0 )
def test_sizing_mission(cleanup, with_dummy_plugin_2): ivc = om.IndepVarComp() ivc.add_output("data:mission:sizing:main_route:cruise:altitude", 35000, units="ft") ivc.add_output("data:TLAR:cruise_mach", 0.78) ivc.add_output("data:TLAR:range", 2000, units="NM") ivc.add_output("data:mission:sizing:TOW", 74000, units="kg") ivc.add_output("data:mission:sizing:takeoff:altitude", 0.0) ivc.add_output("data:mission:sizing:takeoff:V2", 80.0, units="m/s") ivc.add_output("data:mission:sizing:takeoff:fuel", 80.0, units="kg") ivc.add_output("data:mission:sizing:taxi_out:thrust_rate", 0.3) ivc.add_output("data:mission:sizing:climb:thrust_rate", 0.9) ivc.add_output("data:mission:sizing:descent:thrust_rate", 0.05) ivc.add_output("data:mission:sizing:taxi_out:duration", 500, units="s") ivc.add_output("data:mission:sizing:taxi_in:thrust_rate", 0.3) ivc.add_output("data:mission:sizing:taxi_in:duration", 500, units="s") ivc.add_output("data:mission:sizing:holding:duration", 30, units="min") ivc.add_output("data:mission:sizing:diversion:distance", 200, units="NM") ivc.add_output("data:geometry:wing:area", 100.0, units="m**2") # Ensure L/D ratio == 16.0 ivc.add_output("data:aerodynamics:aircraft:cruise:CL", np.linspace(0, 1.5, 150)) ivc.add_output("data:aerodynamics:aircraft:cruise:CD", np.linspace(0, 1.5, 150) / 16.0) ivc.add_output("data:aerodynamics:aircraft:takeoff:CL", np.linspace(0, 1.5, 150) + 0.5) ivc.add_output("data:aerodynamics:aircraft:takeoff:CD", np.linspace(0, 1.5, 150) / 16.0) # With direct call to rubber engine problem = run_system( Mission( propulsion_id="test.wrapper.propulsion.dummy_engine", out_file=pth.join(RESULTS_FOLDER_PATH, "sizing_mission.csv"), use_initializer_iteration=False, mission_file_path="::sizing_mission", adjust_fuel=False, ), ivc, ) assert_allclose(problem["data:mission:sizing:taxi_out:fuel"], 351.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_out:duration"], 500.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_out:distance"], 0.0, atol=1) assert_allclose( problem["data:mission:sizing:main_route:initial_climb:fuel"], 108.0, atol=1) assert_allclose( problem["data:mission:sizing:main_route:initial_climb:duration"], 30.0, atol=1) assert_allclose( problem["data:mission:sizing:main_route:initial_climb:distance"], 3168.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:climb:fuel"], 992.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:climb:duration"], 322.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:climb:distance"], 61782.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:cruise:fuel"], 5454.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:cruise:duration"], 14344.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:cruise:distance"], 3301322.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:descent:fuel"], 161.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:descent:duration"], 1705.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:descent:distance"], 337731.0, atol=1) assert_allclose( problem["data:mission:sizing:diversion:diversion_climb:fuel"], 471.0, atol=1) assert_allclose( problem["data:mission:sizing:diversion:diversion_climb:duration"], 153.0, atol=1) assert_allclose( problem["data:mission:sizing:diversion:diversion_climb:distance"], 24747.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:cruise:fuel"], 316.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:cruise:duration"], 880.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:cruise:distance"], 192547.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:descent:fuel"], 86.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:descent:duration"], 908.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:descent:distance"], 153105.0, atol=1) assert_allclose(problem["data:mission:sizing:holding:fuel"], 639.0, atol=1) assert_allclose(problem.get_val("data:mission:sizing:holding:duration", "s"), 1800.0, atol=1) assert_allclose(problem["data:mission:sizing:holding:distance"], 236664.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_in:fuel"], 351.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_in:duration"], 500.0, atol=1) assert_allclose(problem["data:mission:sizing:taxi_in:distance"], 0.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:fuel"], 6715.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:duration"], 16401.0, atol=1) assert_allclose(problem["data:mission:sizing:main_route:distance"], 3704004.0, atol=10) assert_allclose(problem["data:mission:sizing:diversion:fuel"], 873.0, atol=1) assert_allclose(problem["data:mission:sizing:diversion:duration"], 1941.0, atol=1) assert_allclose(problem.get_val("data:mission:sizing:diversion:distance", "m"), 370400.0, atol=10) assert_allclose( problem["data:mission:sizing:fuel"] + problem["data:mission:sizing:taxi_out:fuel"] + problem["data:mission:sizing:takeoff:fuel"], 9009.0, atol=1, ) assert_allclose(problem["data:mission:sizing:duration"], 20643.0, atol=1) assert_allclose(problem["data:mission:sizing:distance"], 4311067.0, atol=10) assert_allclose(problem["data:mission:sizing:reserve:fuel"], 201.0, atol=1) assert_allclose(problem["data:mission:sizing:needed_block_fuel"], 9210.0, atol=1)