Skip to content

Commit

Permalink
Revert Jacobian changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMeisrimelModelon committed Nov 17, 2023
1 parent 35aa55b commit d306424
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/pyfmi/fmi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8304,7 +8304,6 @@ cdef class FMUModelME2(FMUModelBase2):
cdef double tmp_nominal, fac, tmp
cdef int method = FORWARD_DIFFERENCE if self.force_finite_differences is True or self.force_finite_differences == 0 else CENTRAL_DIFFERENCE
cdef double RUROUND = FORWARD_DIFFERENCE_EPS if method == FORWARD_DIFFERENCE else CENTRAL_DIFFERENCE_EPS
cdef double RRUROUND = (RUROUND)**(0.5)
cdef N.ndarray[FMIL.fmi2_real_t, ndim=1, mode='c'] dfpert, df, eps, nominals
cdef N.ndarray[FMIL.fmi2_value_reference_t, ndim=1, mode='c'] v_ref = N.array(var_ref, copy=False, dtype = N.uint32)
cdef N.ndarray[FMIL.fmi2_value_reference_t, ndim=1, mode='c'] z_ref = N.array(func_ref, copy=False, dtype = N.uint32)
Expand Down Expand Up @@ -8363,27 +8362,11 @@ cdef class FMUModelME2(FMUModelBase2):
nominals_pt[i] = self.get_variable_nominal(valueref = v_ref_pt[i])

for i in range(len_v):
eps_pt[i] = RUROUND*(max(abs(v_pt[i]), RRUROUND))
if N.sign(v_pt[i]):
eps_pt[i] *= N.sign(v_pt[i])
if abs(v_pt[i])/2 <= abs(v_pt[i] + eps_pt[i]) <= 2*abs(v_pt[i]):
temp = v_pt[i] + eps_pt[i]
eps_pt[i] = temp - v_pt[i]
elif abs(v_pt[i])/2 <= abs(v_pt[i] - eps_pt[i]) <= 2*abs(v_pt[i]):
temp = v_pt[i] - eps_pt[i]
eps_pt[i] = temp - v_pt[i]
eps_pt[i] = RUROUND*(max(abs(v_pt[i]), nominals_pt[i]))
else:
for i in range(len_v):
eps_pt[i] = RUROUND*(max(abs(v_pt[i]), RRUROUND))
if N.sign(v_pt[i]):
eps_pt[i] *= N.sign(v_pt[i])
if abs(v_pt[i])/2 <= abs(v_pt[i] + eps_pt[i]) <= 2*abs(v_pt[i]):
temp = v_pt[i] + eps_pt[i]
eps_pt[i] = temp - v_pt[i]
elif abs(v_pt[i])/2 <= abs(v_pt[i] - eps_pt[i]) <= 2*abs(v_pt[i]):
temp = v_pt[i] - eps_pt[i]
eps_pt[i] = temp - v_pt[i]

tmp_nominal = self.get_variable_nominal(valueref = v_ref_pt[i])
eps_pt[i] = RUROUND*(max(abs(v_pt[i]), tmp_nominal))

if group is not None:
if output_matrix is not None:
Expand Down

0 comments on commit d306424

Please sign in to comment.