コード例 #1
0
    def test_ode_simulation_distlib(self):

        m_distlib1 = FMUModel2('DISTLib_Examples_Simulation.fmu')
        m_distlib2 = FMUModel2('DISTLib_Examples_Simulation.fmu')

        opts = m_distlib1.simulate_options()
        opts['with_jacobian'] = True
        res = m_distlib1.simulate(final_time=70, options=opts)
        res = m_distlib2.simulate(final_time=70)

        A, B, C, D, n_err1 = m_distlib1.check_jacobians()

        A, B, C, D, n_err2 = m_distlib2.check_jacobians()
        nose.tools.assert_equals(n_err1 + n_err2, 0)
コード例 #2
0
    def test_ode_simulation_distlib(self):

        m_block = FMUModel2('BlockOdeJacTest.fmu')
        m_block.initialize()

        A, B, C, D, n_err = m_block.check_jacobians()
        nose.tools.assert_equals(n_err, 0)
コード例 #3
0
 def test_IfExpressionSim1(self):
     cname = "JacGenTests.JacTestIfExpression3"
     fn = compile_fmu(cname,
                      self.fname,
                      compiler_options={
                          'generate_ode_jacobian': True,
                          'eliminate_alias_variables': False
                      },
                      version="2.0alpha")
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     Afd, Bfd, Cfd, Dfd, n_errs = m.check_jacobians(delta_rel=1e-6,
                                                    delta_abs=1e-3,
                                                    tol=1e-5)
     assert n_errs == 0
     m.simulate(final_time=2)
     Afd, Bfd, Cfd, Dfd, n_errs = m.check_jacobians(delta_rel=1e-6,
                                                    delta_abs=1e-3,
                                                    tol=1e-5)
     assert n_errs == 0
     m.simulate(final_time=4, options={'initialize': False})
     Afd, Bfd, Cfd, Dfd, n_errs = m.check_jacobians(delta_rel=1e-6,
                                                    delta_abs=1e-3,
                                                    tol=1e-5)
     assert n_errs == 0
コード例 #4
0
    def test_ode_simulation_NonLinear(self):
        m_nonlin = FMUModel2('NonLinear_MultiSystems.fmu')

        m_nonlin.initialize()

        A, B, C, D, n_err = m_nonlin.check_jacobians()
        nose.tools.assert_equals(n_err, 0)
コード例 #5
0
 def test_multiplication(self):
     cname = "JacGenTests.JacTestMult"
     fn = compile_fmu(cname,self.fname,compiler_options={'generate_ode_jacobian':True,'eliminate_alias_variables':False,'fmi_version':2.0})
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0 
コード例 #6
0
 def test_exponentiation(self):
     cname = "JacGenTests.JacTestPow"
     fn = compile_fmu(cname,self.fname,compiler_options={'generate_ode_jacobian':True,'eliminate_alias_variables':False}, version="2.0alpha")
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0 
コード例 #7
0
 def test_Unsolved_blocks6(self):
     cname = "JacGenTests.Unsolved_blocks6"
     fn = compile_fmu(cname,self.fname,compiler_options={'generate_ode_jacobian':True,\
       'eliminate_alias_variables':False}, version="2.0alpha")
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     m.initialize(relativeTolerance=1e-11)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0       
コード例 #8
0
 def test_DiscreteFunction1(self):
     cname = "JacGenTests.JacTestDiscreteFunction1"
     fn = compile_fmu(cname,self.fname,compiler_options={'generate_ode_jacobian':True, \
     'eliminate_alias_variables':False,'fmi_version':2.0})
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     m.initialize(relativeTolerance=1e-11)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0
コード例 #9
0
 def test_local_loop_1(self):
     cname = "TearingTests.TearingTest1"
     fn = compile_fmu(cname,os.path.join(path_to_mofiles,'TearingTests.mo'),compiler_options={'automatic_tearing':True,
         'equation_sorting':True,'eliminate_alias_variables':False,
         'generate_ode_jacobian':True, "local_iteration_in_tearing":"all"},version="2.0alpha")
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     m.initialize(relativeTolerance=1e-11)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0       
コード例 #10
0
 def test_Unsolved_blocks_torn_2(self):
     cname = "JacGenTests.Unsolved_blocks_torn_2"
     fn = compile_fmu(cname,self.fname,compiler_options={'automatic_tearing':True,
         'equation_sorting':True,'eliminate_alias_variables':False,
         'generate_ode_jacobian':True,'fmi_version':2.0})
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     m.initialize(relativeTolerance=1e-11)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0       
コード例 #11
0
    def test_ode_simulation_NonLinearIO(self):
        m_nonlinIO = FMUModel2('NonLinear_TwoSystems_wIO.fmu')

        m_nonlinIO.set('u', 1)
        m_nonlinIO.set('u1', 10000)
        m_nonlinIO.set('u2', 1)
        m_nonlinIO.set('u3', 10000)

        m_nonlinIO.initialize()

        A, B, C, D, n_err = m_nonlinIO.check_jacobians()
        nose.tools.assert_equals(n_err, 0)
コード例 #12
0
 def test_Input(self):
     cname = "JacGenTests.JacTestInput"
     fn = compile_fmu(cname,self.fname,compiler_options={'generate_ode_jacobian':True, \
     'eliminate_alias_variables':False}, version="2.0alpha")
     m = FMUModel2(fn)
     m.set_debug_logging(True)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0
     t = N.linspace(0.,5.0,100) 
     u_traj = N.transpose(N.vstack((t,t)))
     input_object = ('u', u_traj)
     m.simulate(final_time = 10, input = input_object)
     Afd,Bfd,Cfd,Dfd,n_errs= m.check_jacobians(delta_rel=1e-6,delta_abs=1e-3,tol=1e-5)
     assert n_errs ==0
コード例 #13
0
    def test_ode_simulation_furuta(self):

        m_furuta = FMUModel2('Furuta.fmu')

        print "Starting simulation"

        opts = m_furuta.simulate_options()
        opts['with_jacobian'] = True
        res = m_furuta.simulate(final_time=100, options=opts)

        A, B, C, D, n_err1 = m_furuta.check_jacobians()

        opts['with_jacobian'] = False
        opts['initialize'] = False
        res = m_furuta.simulate(final_time=100, options=opts)

        A, B, C, D, n_err2 = m_furuta.check_jacobians()
        nose.tools.assert_equals(n_err1 + n_err2, 0)