def _evaluate(args): """Runs model according to provided problem file.""" try: api.evaluate_problem(args.conf_file, args.force) except FastFileExistsError as exc: if _query_yes_no( 'Output file "%s" already exists. Do you want to overwrite it?' % exc.args[1]): api.evaluate_problem(args.conf_file, True) else: print("Computation not run.")
def test_api_eval_mission(cleanup): results_folder_path = pth.join(RESULTS_FOLDER_PATH, "api_eval_mission") configuration_file_path = pth.join(results_folder_path, "oad_process.yml") api._PROBLEM_CONFIGURATOR = MissionConfigurator() # Generation of configuration file ---------------------------------------- api.generate_configuration_file(configuration_file_path, True) # Generation of inputs ---------------------------------------------------- # We get the same inputs as in tutorial notebook source_xml = pth.join( root_folder_path, "src", "fastoad", "notebooks", "01_tutorial", "data", "CeRAS01_baseline.xml", ) api.generate_inputs(configuration_file_path, source_xml, overwrite=True) # Run model --------------------------------------------------------------- problem = api.evaluate_problem(configuration_file_path, True) api._PROBLEM_CONFIGURATOR = None # Check that weight-performances loop correctly converged _check_weight_performance_loop(problem) assert_allclose(problem["data:handling_qualities:static_margin"], 0.05, atol=1e-2) assert_allclose(problem["data:geometry:wing:MAC:at25percent:x"], 17.149, atol=1e-2) assert_allclose(problem["data:weight:aircraft:MTOW"], 74846, atol=1) assert_allclose(problem["data:geometry:wing:area"], 126.581, atol=1e-2) assert_allclose(problem["data:geometry:vertical_tail:area"], 27.535, atol=1e-2) assert_allclose(problem["data:geometry:horizontal_tail:area"], 35.848, atol=1e-2) assert_allclose(problem["data:mission:sizing:needed_block_fuel"], 19495, atol=1)
def test_api_eval_breguet(cleanup): results_folder_path = pth.join(RESULTS_FOLDER_PATH, "api_eval_breguet") configuration_file_path = pth.join(results_folder_path, "oad_process.yml") # Generation of configuration file ---------------------------------------- api.generate_configuration_file(configuration_file_path, True) # Generation of inputs ---------------------------------------------------- # We get the same inputs as in tutorial notebook source_xml = pth.join(DATA_FOLDER_PATH, "CeRAS01_notebooks.xml") api.generate_inputs(configuration_file_path, source_xml, overwrite=True) # Run model --------------------------------------------------------------- problem = api.evaluate_problem(configuration_file_path, True) # Check that weight-performances loop correctly converged _check_weight_performance_loop(problem) assert_allclose(problem["data:handling_qualities:static_margin"], 0.05, atol=1e-2) assert_allclose(problem["data:geometry:wing:MAC:at25percent:x"], 17.149, atol=1e-2) assert_allclose(problem["data:weight:aircraft:MTOW"], 74892, atol=1) assert_allclose(problem["data:geometry:wing:area"], 126.732, atol=1e-2) assert_allclose(problem["data:geometry:vertical_tail:area"], 27.565, atol=1e-2) assert_allclose(problem["data:geometry:horizontal_tail:area"], 35.884, atol=1e-2) assert_allclose(problem["data:mission:sizing:needed_block_fuel"], 19527, atol=1)