Changeset 13434


Ignore:
Timestamp:
Sep 9, 2019 8:37:08 PM (3 months ago)
Author:
Christian Andersson
Message:

Fixed issue with the estimation method. Related to ticket:5836

Location:
PyFMI/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • PyFMI/trunk/CHANGELOG

    r13361 r13434  
    11--- CHANGELOG ---
     2
     3--- PyFMI-trunk ---
     4    * Fixed issue with estimating directional derivatives when the
     5      structure info is not used and the matrix has zero dim (ticket:5836)
    26
    37--- PyFMI-2.5.4 ---
  • PyFMI/trunk/setup.py

    r13033 r13434  
    156156    if not x.find('--version'):
    157157        VERSION = x[10:]
     158        copy_args.remove(x)
     159    if not x.find('--debug'):
     160        static = x[8:]
     161        if x[8:].upper() == "TRUE":
     162            debug_flag = True
     163        else:
     164            debug_flag = False
    158165        copy_args.remove(x)
    159166   
  • PyFMI/trunk/src/pyfmi/fmi.pyx

    r13364 r13434  
    78027802                A = output_matrix
    78037803           
     7804            if len_v == 0 or len_f == 0:
     7805                return A
     7806           
    78047807            dfpert = N.zeros(len_f, dtype = N.double)
    78057808            for i in range(len_v):
  • PyFMI/trunk/tests/test_fmi.py

    r13364 r13434  
    458458           
    459459class Test_FMUModelME2:
     460   
     461    @testattr(stddist = True)
     462    def test_estimate_directional_derivatives_bouncing_ball(self):
     463        full_path = os.path.join(file_path, "files", "FMUs", "XML", "ME2.0", "BouncingBall.fmu")
     464        model = Dummy_FMUModelME2([], full_path, _connect_dll=False)
     465       
     466        def f(*args, **kwargs):
     467            derh = model.values[model.variables["v"].value_reference]
     468            derv = -9.81
     469            model.values[model.variables["der(h)"].value_reference] = derh
     470            return np.array([derh, derv])
     471        model.get_derivatives = f
     472       
     473        model.initialize()
     474        model.event_update()
     475        model.enter_continuous_time_mode()
     476       
     477        [As, Bs, Cs, Ds] = model.get_state_space_representation(use_structure_info=False)
     478        [A, B, C, D] = model.get_state_space_representation()
     479       
     480        assert As.shape == A.shape
     481        assert Bs.shape == B.shape
     482        assert Cs.shape == C.shape
     483        assert Ds.shape == D.shape
     484       
     485        np.allclose(As, A.toarray())
     486        np.allclose(Bs, B.toarray())
     487        np.allclose(Cs, C.toarray())
     488        np.allclose(Ds, D.toarray())
     489   
    460490    @testattr(stddist = True)
    461491    def test_estimate_directional_derivatives_BCD(self):
Note: See TracChangeset for help on using the changeset viewer.