From a5a62ed4427e2a7576b2cde844c6a3863945c6eb Mon Sep 17 00:00:00 2001 From: PeterMeisrimelModelon <92585725+PeterMeisrimelModelon@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:49:46 +0100 Subject: [PATCH] Testing slightly different variant --- src/pyfmi/fmi.pyx | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/pyfmi/fmi.pyx b/src/pyfmi/fmi.pyx index 5204cbd0..f582de7d 100644 --- a/src/pyfmi/fmi.pyx +++ b/src/pyfmi/fmi.pyx @@ -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: @@ -8960,4 +8952,4 @@ cdef class WorkerClass2: elif index == 3: ret = PyArray_DATA(self._tmp4_ref) - return ret + return ret \ No newline at end of file