def _get_problem_inputs( self, problem: FASTOADProblem) -> Tuple[om.IndepVarComp, VariableList]: """ Reads input file for the configure problem. Needed variables are returned as an IndepVarComp instance while unused variables are returned as a VariableList instance. :param problem: problem with missing inputs. setup() must have been run. :return: IVC of needed input variables, VariableList with unused variables. """ mandatory, optional = get_unconnected_input_names(problem, promoted_names=True) needed_variable_names = mandatory + optional input_variables = DataFile(self.input_file_path) unused_variables = VariableList([ var for var in input_variables if var.name not in needed_variable_names ]) for name in unused_variables.names(): del input_variables[name] nan_variable_names = [ var.name for var in input_variables if np.all(np.isnan(var.value)) ] if nan_variable_names: raise FASTConfigurationNanInInputFile(self.input_file_path, nan_variable_names) input_ivc = input_variables.to_ivc() return input_ivc, unused_variables
def test_mission_group_with_loop(cleanup): 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, "test_looped_mission_group.csv"), use_initializer_iteration=True, mission_file_path=pth.join(DATA_FOLDER_PATH, "test_mission.yml"), mission_name="operational", add_solver=True, ), 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"], 5682.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 )