Changeset 13739


Ignore:
Timestamp:
Oct 13, 2019 12:43:12 PM (4 weeks ago)
Author:
Christian Andersson
Message:

Updated JM trunk to point to the new PyFMI release and updated tests. Related to ticket:5854

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:externals
      •  

        old new  
        11https://svn.jmodelica.org/assimulo/tags/Assimulo-3.0@875 external/Assimulo
        2 https://svn.jmodelica.org/PyFMI/tags/PyFMI-2.5.4/src/common@13387 Python/src/common
         2https://svn.jmodelica.org/PyFMI/tags/PyFMI-2.5.5/src/common@13738 Python/src/common
        33https://github.com/chria/casadi/branches/tested_mod@11366 ThirdParty/CasADi/CasADi
        44https://svn.jmodelica.org/FMILibrary/trunk@10948 external/FMILibrary/FMILibrary
        5 https://svn.jmodelica.org/PyFMI/tags/PyFMI-2.5.4@13387 external/PyFMI
         5https://svn.jmodelica.org/PyFMI/tags/PyFMI-2.5.5@13738 external/PyFMI
    • Property svn:mergeinfo changed
      /branches/dev-cw-pyfmi (added)merged: 13734-13736
  • trunk/Python/src/pyjmi/examples/cstr_mpc_casadi.py

    r8187 r13739  
    8686    sim_model.set('_start_T', T_0_A)
    8787    sim_model.set('Tc', 280)
    88     init_res = sim_model.simulate(start_time=0., final_time=150)
     88   
     89    opts = sim_model.simulate_options()
     90    opts["CVode_options"]["maxh"] = 0.0
     91    opts["ncp"] = 0
     92   
     93    init_res = sim_model.simulate(start_time=0., final_time=150, options=opts)
    8994
    9095    ### 2. Define the optimal control problem and solve it using the MPC class
     
    159164        sim_res = sim_model.simulate(start_time=k*sample_period,
    160165                                     final_time=(k+1)*sample_period,
    161                                      input=u_k)
     166                                     input=u_k, options=opts)
    162167
    163168        # Extract state at end of sample_period from sim_res and add Gaussian
  • trunk/Python/src/pyjmi/examples/if_example_2.py

    r4648 r13739  
    4949    t = res['time']
    5050   
    51     assert N.abs(res.final('x') - 3.5297217)    < 1e-3
    52     assert N.abs(res.final('u') - (-0.2836621)) < 1e-3
     51    assert N.abs(res.final('x') - 3.5297217)    < 1e-2, N.abs(res.final('x') - 3.5297217)
     52    assert N.abs(res.final('u') - (-0.2836621)) < 1e-2, N.abs(res.final('u') - (-0.2836621))
    5353
    5454    if with_plots:
  • trunk/Python/src/pyjmi/ukf.py

    r10171 r13739  
    368368                opt['CVode_options']['atol'] = 1e-8
    369369                opt['CVode_options']['rtol'] = 1e-6
     370                opt['CVode_options']['maxh'] = 0.0
     371                opt['ncp'] = 0
    370372                print 'Simulating sigma-point '+str(i+1)+' out of '+str(sigma.shape[1])+' :'
    371373                try:
  • trunk/Python/src/tests_jmodelica/general/base_simul.py

    r10446 r13739  
    286286       
    287287        if not cvode_options:
    288             cvode_options = {'atol':self.abs_tol,'rtol':self.rel_tol}
     288            cvode_options = {'atol':self.abs_tol,'rtol':self.rel_tol, 'maxh':0.0}
     289        else:
     290            if not 'maxh' in cvode_options:
     291                cvode_options['maxh'] = 0.0
    289292       
    290293        if isinstance(self.model, FMUModelME1) or isinstance(self.model, FMUModelME2):
  • trunk/Python/src/tests_jmodelica/optimization/test_casadi_collocation.py

    r13401 r13739  
    366366        opts["CVode_options"]["rtol"] = 1e-6
    367367        opts["CVode_options"]["atol"] = 1e-8 * model.nominal_continuous_states
     368        opts["CVode_options"]["maxh"] = 0.0
     369        opts["ncp"] = 0
    368370        init_res = model.simulate(final_time=300, input=('Tc', u_traj),
    369371                                  options=opts)
     
    21252127        opts["CVode_options"]["rtol"] = 1e-6
    21262128        opts["CVode_options"]["atol"] = 1e-8 * model.nominal_continuous_states
     2129        opts["CVode_options"]["maxh"] = 0.0
     2130        opts["ncp"] = 0
    21272131        res = model.simulate(start_time=0., final_time=150., input=opt_input,
    21282132                             options=opts)
  • trunk/Python/src/tests_jmodelica/optimization/test_realtime_mpc.py

    r13492 r13739  
    3535def check_result(results, ref):
    3636    for key in ref:
    37         assert abs(ref[key] - results[key][-1]) < 1e-3, abs(ref[key] - results[key][-1])
     37        assert abs(ref[key] - results[key][-1]) < 1e-2, abs(ref[key] - results[key][-1])
    3838       
    3939
  • trunk/Python/src/tests_jmodelica/simulation/test_assimulo_interface_fmi.py

    r13366 r13739  
    20022002        opts["CVode_options"]["rtol"] = 1e-4
    20032003        opts["CVode_options"]["atol"] = 1e-6
     2004        opts["CVode_options"]["maxh"] = 0.0
     2005        opts["ncp"] = 0
    20042006        res = bounce.simulate(start_time=2.,final_time=5.,options=opts)
    20052007
     
    20202022        opts["CVode_options"]["rtol"] = 1e-4
    20212023        opts["CVode_options"]["atol"] = 1e-6
     2024        opts["CVode_options"]["maxh"] = 0.0
     2025        opts["ncp"] = 0
    20222026        res = bounce.simulate(final_time=3., options=opts)
    20232027       
     
    20332037        opt["CVode_options"]["rtol"] = 1e-4
    20342038        opt["CVode_options"]["atol"] = 1e-6
     2039        opt["CVode_options"]["maxh"] = 0.0
     2040        opt["ncp"] = 0
    20352041        res = bounce.simulate(final_time=3., options=opt)
    20362042       
     
    20592065        opts["CVode_options"]["rtol"] = 1e-4
    20602066        opts["CVode_options"]["atol"] = 1e-6
     2067        opts["CVode_options"]["maxh"] = 0.0
     2068        opts["ncp"] = 0
    20612069        res = bounce.simulate(final_time=3., options=opts)
    20622070
     
    20702078        #Writing continuous
    20712079        bounce = load_fmu('bouncingBall.fmu', path_to_fmus_me1)
    2072         #bounce.initialize(options={'initialize':False})
    20732080        res = bounce.simulate(final_time=3.,
    2074             options={'initialize':True,'CVode_options':{'iter':'FixedPoint','rtol':1e-6,'atol':1e-6}})
     2081            options={'initialize':True,'ncp':0, 'CVode_options':{'maxh':0.0, 'iter':'FixedPoint','rtol':1e-6,'atol':1e-6}})
    20752082   
    20762083        nose.tools.assert_almost_equal(res.solver.rtol, 0.00000100, 7)
     
    20922099        opts["CVode_options"]["rtol"] = 1e-4
    20932100        opts["CVode_options"]["atol"] = 1e-6
    2094         #bounce.initialize()
     2101        opts["CVode_options"]["maxh"] = 0.0
     2102        opts["ncp"] = 0
    20952103        res = bounce.simulate(final_time=3., options=opts)
    20962104       
     
    20992107       
    21002108        bounce.reset()
    2101         #bounce.initialize()
    2102        
     2109
    21032110        nose.tools.assert_almost_equal(bounce.get('h'), 1.00000,5)
    21042111       
  • trunk/Python/src/tests_jmodelica/test_delay.py

    r10318 r13739  
    3838def simulate(fmu, final_time, maxh = None):
    3939    opts = fmu.simulate_options()     
    40     opts['solver'] = 'CVode'           
     40    opts['solver'] = 'CVode'
     41    opts['ncp'] = 0
     42    opts['CVode_options']['maxh'] = 0.0
    4143    if maxh is not None:
    4244        opts['CVode_options']['maxh'] = maxh
  • trunk/Python/src/tests_jmodelica/test_fmi_2.py

    r13338 r13739  
    988988        assert opts['initialize']
    989989        assert opts['with_jacobian'] == "Default"
    990         assert opts['ncp'] == 0
    991990
    992991        #Test the result file
  • trunk/Python/src/tests_jmodelica/test_fmi_coupled.py

    r13338 r13739  
    8282        nose.tools.assert_almost_equal(res.final("time"),1.5)
    8383        nose.tools.assert_almost_equal(res.final("First.J1.w"),res.final("Second.J1.w"))
    84         nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places=3)
     84        nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places=2)
    8585       
    8686        coupled.reset()
     
    9090        nose.tools.assert_almost_equal(res.final("time"),1.5)
    9191        nose.tools.assert_almost_equal(res.final("First.J1.w"),res.final("Second.J1.w"))
    92         nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places=3)
     92        nose.tools.assert_almost_equal(res.final("First.J1.w"), 3.2501079, places=2)
    9393
    9494    @testattr(stddist_full = True)
Note: See TracChangeset for help on using the changeset viewer.