def test_work_flow_me2(self): """Tests the work flow of write_header, write_point, write_finalize.""" model = Dummy_FMUModelME2([], "bouncingBall.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME2.0"), _connect_dll=False) model.setup_experiment() model.initialize() bouncingBall = ResultHandlerFile(model) bouncingBall.set_options(model.simulate_options()) bouncingBall.simulation_start() bouncingBall.initialize_complete() bouncingBall.integration_point() bouncingBall.simulation_end() res = ResultDymolaTextual('bouncingBall_result.txt') h = res.get_variable_data('h') derh = res.get_variable_data('der(h)') g = res.get_variable_data('g') nose.tools.assert_almost_equal(h.x, 1.000000, 5) nose.tools.assert_almost_equal(derh.x, 0.000000, 5)
def test_get_description(self): model = Dummy_FMUModelME1([], "CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME1.0"), _connect_dll=False) model.initialize() result_writer = ResultHandlerFile(model) result_writer.set_options(model.simulate_options()) result_writer.simulation_start() result_writer.initialize_complete() result_writer.integration_point() result_writer.simulation_end() res = ResultDymolaTextual('CoupledClutches_result.txt') assert res.description[res.get_variable_index("J1.phi")] == "Absolute rotation angle of component"
def test_get_description_unicode(self): model = Dummy_FMUModelME1([], "Description.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME1.0"), _connect_dll=False) model.initialize() result_writer = ResultHandlerFile(model) result_writer.set_options(model.simulate_options()) result_writer.simulation_start() result_writer.initialize_complete() result_writer.integration_point() result_writer.simulation_end() res = ResultDymolaTextual('Description_result.txt') desc = res.description[res.get_variable_index("x")] assert desc == u"Test symbols '' ‘’"
def test_description_not_stored(self): model = Dummy_FMUModelME1([], "CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME1.0"), _connect_dll=False) model.initialize() opts = model.simulate_options() opts["result_store_variable_description"] = False result_writer = ResultHandlerFile(model) result_writer.set_options(opts) result_writer.simulation_start() result_writer.initialize_complete() result_writer.integration_point() result_writer.simulation_end() res = ResultDymolaTextual('CoupledClutches_result.txt') assert res.description[res.get_variable_index("J1.phi")] == "", "Description is not empty, " + res.description[res.get_variable_index("J1.phi")]