Skip to content

Commit

Permalink
Testing slightly different variant
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMeisrimelModelon committed Dec 1, 2023
1 parent 38235b9 commit a5a62ed
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/pyfmi/fmi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8363,26 +8363,18 @@ 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))
eps_pt[i] = max((N.nextafter(abs(v_pt[i]), N.inf)-abs(v_pt[i]))/RUROUND, RUROUND*2**(-9))
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] *= N.sign(v_pt[i])
temp = v_pt[i] + eps_pt[i]
eps_pt[i] = temp - v_pt[i]
else:
for i in range(len_v):
eps_pt[i] = RUROUND*(max(abs(v_pt[i]), RRUROUND))
eps_pt[i] = max((N.nextafter(abs(v_pt[i]), N.inf)-abs(v_pt[i]))/RUROUND, RUROUND*2**(-9))
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] *= N.sign(v_pt[i])
temp = v_pt[i] + eps_pt[i]
eps_pt[i] = temp - v_pt[i]


if group is not None:
Expand Down Expand Up @@ -8960,4 +8952,4 @@ cdef class WorkerClass2:
elif index == 3:
ret = <FMIL.fmi2_value_reference_t*>PyArray_DATA(self._tmp4_ref)

return ret
return ret

0 comments on commit a5a62ed

Please sign in to comment.