def test_oad_process(cleanup): """ Test for the overall aircraft design process. """ problem = FASTOADProblemConfigurator(pth.join(INPUT_FOLDER_PATH, "oad_process.toml")).get_problem() problem.model.aicraft.set_input_defaults('data:geometry:horizontal_tail:sweep_25', val=10., units='deg') ref_inputs = pth.join(INPUT_FOLDER_PATH, XML_NAME) get_problem_after_setup(problem).write_needed_inputs(ref_inputs, VariableXmlStandardFormatter()) problem.read_inputs() print('\n') problem.setup(check=True) problem.set_solver_print(level=2) with Timer(name="Mass-performance loop:"): problem.run_model() problem.write_outputs() if not pth.exists(RESULTS_FOLDER_PATH): os.mkdir(RESULTS_FOLDER_PATH) om.view_connections( problem, outfile=pth.join(RESULTS_FOLDER_PATH, "connections.html"), show_browser=False ) om.n2(problem, outfile=pth.join(RESULTS_FOLDER_PATH, "n2.html"), show_browser=False) # Check that weight-performances loop correctly converged assert_allclose( problem["data:weight:aircraft:OWE"], problem["data:weight:airframe:mass"] + problem["data:weight:propulsion:mass"] + problem["data:weight:systems:mass"] + problem["data:weight:furniture:mass"], rtol=5e-2, ) assert_allclose( problem["data:weight:aircraft:MZFW"], problem["data:weight:aircraft:OWE"] + problem["data:weight:aircraft:max_payload"], rtol=5e-2, ) assert_allclose( problem["data:weight:aircraft:MTOW"], problem["data:weight:aircraft:OWE"] + problem["data:weight:aircraft:max_payload"] + problem["data:mission:sizing:fuel"], rtol=5e-2, ) assert_allclose(problem.get_val("data:mission:sizing:fuel", units="kg"), 203.65, atol=1) # noinspection PyTypeChecker assert_allclose(problem.get_val("data:weight:aircraft:max_payload", units="kg"), 400.0, atol=1) # noinspection PyTypeChecker assert_allclose(problem["data:handling_qualities:static_margin"], 0.08515, atol=1e-2) # noinspection PyTypeChecker assert_allclose(problem.get_val("data:weight:aircraft:MTOW", units="kg"), 1650.24, atol=1) # noinspection PyTypeChecker assert_allclose(problem.get_val("data:weight:aircraft:payload", units="kg"), 360., atol=1) # noinspection PyTypeChecker assert_allclose(problem.get_val("data:weight:aircraft:OWE", units="kg"), 1046.61, atol=1) # noinspection PyTypeChecker assert_allclose(problem.get_val("data:mission:sizing:main_route:cruise:fuel", units="kg"), 166.405, atol=1)
def test_oad_process(cleanup): """ Test for the overall aircraft design process. """ problem = FASTOADProblemConfigurator( pth.join(DATA_FOLDER_PATH, "oad_process.toml")).get_problem() ref_inputs = pth.join(DATA_FOLDER_PATH, "beechcraft_76.xml") get_problem_after_setup(problem).write_needed_inputs( ref_inputs, VariableXmlStandardFormatter()) problem.read_inputs() print('\n') problem.setup(check=True) problem.set_solver_print(level=2) problem.run_model() problem.write_outputs() if not pth.exists(RESULTS_FOLDER_PATH): os.mkdir(RESULTS_FOLDER_PATH) om.view_connections(problem, outfile=pth.join(RESULTS_FOLDER_PATH, "connections.html"), show_browser=False) om.n2(problem, outfile=pth.join(RESULTS_FOLDER_PATH, "n2.html"), show_browser=False) # Check that weight-performances loop correctly converged assert_allclose( problem["data:weight:aircraft:OWE"], problem["data:weight:airframe:mass"] + problem["data:weight:propulsion:mass"] + problem["data:weight:systems:mass"] + problem["data:weight:furniture:mass"], rtol=5e-2, ) assert_allclose( problem["data:weight:aircraft:MZFW"], problem["data:weight:aircraft:OWE"] + problem["data:weight:aircraft:max_payload"], rtol=5e-2, ) assert_allclose( problem["data:weight:aircraft:MTOW"], problem["data:weight:aircraft:OWE"] + problem["data:weight:aircraft:max_payload"] + problem["data:mission:sizing:fuel"], rtol=5e-2, )