Example #1
0
    def test_work_flow_me2(self):
        model = Dummy_FMUModelME2([],
                                  "bouncingBall.fmu",
                                  os.path.join(file_path, "files", "FMUs",
                                               "XML", "ME2.0"),
                                  _connect_dll=False)
        model.setup_experiment()
        model.initialize()

        bouncingBall = ResultHandlerBinaryFile(model)

        bouncingBall.set_options(model.simulate_options())
        bouncingBall.simulation_start()
        bouncingBall.initialize_complete()
        bouncingBall.integration_point()
        bouncingBall.simulation_end()

        res = ResultDymolaBinary('bouncingBall_result.mat')

        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)
Example #2
0
 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 = ResultHandlerBinaryFile(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 = ResultDymolaBinary('CoupledClutches_result.mat')
     
     assert res.description[res.get_variable_index("J1.phi")] == "Absolute rotation angle of component"
Example #3
0
 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 = ResultHandlerBinaryFile(model)
     result_writer.set_options(opts)
     result_writer.simulation_start()
     result_writer.initialize_complete()
     result_writer.integration_point()
     result_writer.simulation_end()
     
     res = ResultDymolaBinary('CoupledClutches_result.mat')
     
     assert res.description[res.get_variable_index("J1.phi")] == "", "Description is not empty, " + res.description[res.get_variable_index("J1.phi")]
Example #4
0
 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 = ResultHandlerBinaryFile(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 = ResultDymolaBinary('Description_result.mat')
     
     desc = res.description[res.get_variable_index("x")]
     #This handling should in the future be nativly handled by the IO module        
     desc = desc.encode("latin_1", "replace").decode("utf-8", "replace")
     
     assert desc == u"Test symbols '' ‘’"
Example #5
0
    def test_filter_no_variables(self):
        model = Dummy_FMUModelME2([],
                                  "bouncingBall.fmu",
                                  os.path.join(file_path, "files", "FMUs",
                                               "XML", "ME2.0"),
                                  _connect_dll=False)
        model.setup_experiment()
        model.initialize()
        model.time = 1.0
        opts = model.simulate_options()
        opts["filter"] = "NoMatchingVariables"

        bouncingBall = ResultHandlerBinaryFile(model)

        bouncingBall.set_options(opts)
        bouncingBall.simulation_start()
        bouncingBall.initialize_complete()
        bouncingBall.integration_point()
        bouncingBall.simulation_end()

        res = ResultDymolaBinary('bouncingBall_result.mat')

        t = res.get_variable_data('time')
        nose.tools.assert_almost_equal(t.x[-1], 1.000000, 5)