Changeset 13729


Ignore:
Timestamp:
Oct 10, 2019 8:49:05 PM (5 weeks ago)
Author:
Christian Andersson
Message:

Merged latest trunk changes to release branch. Related to ticket:5854

Location:
PyFMI/branches/PyFMI-2.5.x
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • PyFMI/branches/PyFMI-2.5.x

  • PyFMI/branches/PyFMI-2.5.x/CHANGELOG

    r13690 r13729  
    22
    33--- PyFMI-2.5.5 ---
     4    * Changed default value of maxh to be computed based on ncp, start
     5      and stop time according to, maxh=(stop-start)/ncp (ticket:5858)
     6    * Changed default ncp value from '0' to '500' (ticket:5857)
    47    * Changed default value for the sparse solver in CVode (if the
    58      systemsize is >100 and the non-zero pattern is less than 15% then
  • PyFMI/branches/PyFMI-2.5.x/doc/sphinx/source/changelog.rst

    r13690 r13729  
    55
    66--- PyFMI-2.5.5 ---
     7    * Changed default value of maxh to be computed based on ncp, start
     8      and stop time according to, maxh=(stop-start)/ncp (ticket:5858)
     9    * Changed default ncp value from '0' to '500' (ticket:5857)
    710    * Changed default value for the sparse solver in CVode (if the
    811      systemsize is >100 and the non-zero pattern is less than 15% then
  • PyFMI/branches/PyFMI-2.5.x/src/pyfmi

  • PyFMI/branches/PyFMI-2.5.x/src/pyfmi/fmi_algorithm_drivers.py

    r13690 r13729  
    6565            Number of communication points. If ncp is zero, the solver will
    6666            return the internal steps taken.
    67             Default: '0'
     67            Default: '500'
    6868
    6969        initialize --
     
    156156        maxh    --
    157157            The maximum step-size allowed to be used by the solver.
    158             Default: 0.0 (i.e. no limit on the step-size)
     158            Default: "Default" (max step-size computed based on (final_time-start_time)/ncp)
    159159
    160160        discr   --
     
    169169        _defaults= {
    170170            'solver': 'CVode',
    171             'ncp':0,
     171            'ncp':500,
    172172            'initialize':True,
    173173            'sensitivities':None,
     
    183183            'extra_equations':None,
    184184            'CVode_options':{'discr':'BDF','iter':'Newton',
    185                             'atol':"Default",'rtol':"Default","maxh":0.0,'external_event_detection':False},
    186             'Radau5ODE_options':{'atol':"Default",'rtol':"Default","maxh":0.0},
     185                            'atol':"Default",'rtol':"Default","maxh":"Default",'external_event_detection':False},
     186            'Radau5ODE_options':{'atol':"Default",'rtol':"Default","maxh":"Default"},
    187187            'RungeKutta34_options':{'atol':"Default",'rtol':"Default"},
    188             'Dopri5_options':{'atol':"Default",'rtol':"Default"},
    189             'RodasODE_options':{'atol':"Default",'rtol':"Default"},
    190             'LSODAR_options':{'atol':"Default",'rtol':"Default"},
     188            'Dopri5_options':{'atol':"Default",'rtol':"Default", "maxh":"Default"},
     189            'RodasODE_options':{'atol':"Default",'rtol':"Default", "maxh":"Default"},
     190            'LSODAR_options':{'atol':"Default",'rtol':"Default", "maxh":"Default"},
    191191            'ExplicitEuler_options':{},
    192192            'ImplicitEuler_options':{}
     
    516516        if "usejac" in solver_options and fnbr == 0:
    517517            solver_options["usejac"] = False
     518           
     519        if "maxh" in solver_options and solver_options["maxh"] == "Default":
     520            if self.options["ncp"] == 0:
     521                solver_options["maxh"] = 0.0
     522            else:
     523                solver_options["maxh"] = float(self.final_time - self.start_time) / float(self.options["ncp"])
    518524
    519525        #loop solver_args and set properties of solver
  • PyFMI/branches/PyFMI-2.5.x/tests/test_fmi.py

    r13690 r13729  
    522522            run_case(True, "SPARSE", PYFMI_JACOBIAN_SPARSE_SIZE_LIMIT+1, {"Dep": [1]*PYFMI_JACOBIAN_SPARSE_SIZE_LIMIT})
    523523            run_case(True, "SPARSE", PYFMI_JACOBIAN_SPARSE_SIZE_LIMIT+1, {"Dep": [1]*PYFMI_JACOBIAN_SPARSE_SIZE_LIMIT}, True)
     524       
     525        @testattr(stddist = True)
     526        def test_ncp_option(self):
     527            model = Dummy_FMUModelME2([], "NoState.Example1.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME2.0"), _connect_dll=False)
     528            opts = model.simulate_options()
     529            assert opts["ncp"] == 500, opts["ncp"]
     530       
     531        @testattr(stddist = True)
     532        def test_maxh_option(self):
     533            model = Dummy_FMUModelME2([], "NoState.Example1.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME2.0"), _connect_dll=False)
     534            opts = model.simulate_options()
     535            opts["result_handling"] = "none"
     536           
     537            from pyfmi.fmi_algorithm_drivers import AssimuloFMIAlg
     538           
     539            class TempAlg(AssimuloFMIAlg):
     540                def solve(self):
     541                    pass
     542           
     543            def run_case(tstart, tstop, solver, ncp="Default"):
     544                model.reset()
     545               
     546                opts["solver"] = solver
     547               
     548                if ncp != "Default":
     549                    opts["ncp"] = ncp
     550               
     551                if opts["ncp"] == 0:
     552                    expected = 0.0
     553                else:
     554                    expected = (float(tstop)-float(tstart))/float(opts["ncp"])
     555               
     556                res = model.simulate(start_time=tstart, final_time=tstop,options=opts, algorithm=TempAlg)
     557                assert res.solver.maxh == expected, res.solver.maxh
     558                assert res.options[solver+"_options"]["maxh"] == "Default", res.options[solver+"_options"]["maxh"]
     559               
     560            run_case(0,1,"CVode")
     561            run_case(0,1,"CVode", 0)
     562            run_case(0,1,"Radau5ODE")
     563            run_case(0,1,"Dopri5")
     564            run_case(0,1,"RodasODE")
     565            run_case(0,1,"LSODAR")
     566            run_case(0,1,"LSODAR")
     567
    524568           
    525569class Test_FMUModelME2:
  • PyFMI/branches/PyFMI-2.5.x/tests/test_fmi_coupled.py

    r12966 r13729  
    7777            coupled = CoupledFMUModelME2(models, connections=connections)
    7878
    79             opts = {"CVode_options": {"rtol":1e-6, "atol":1e-6}}
     79            opts = {"CVode_options": {"rtol":1e-6, "atol":1e-6}, "ncp":0}
    8080
    8181            res = coupled.simulate(options=opts)
Note: See TracChangeset for help on using the changeset viewer.