示例#1
0
    def check_eq(self):
        """
        Check the variables and equations and set the limiter flags.
        """
        self.zu[:] = np.greater(self.u.v, self.upper.v)
        self.zl[:] = np.less(self.u.v, self.lower.v)
        self.zi[:] = np.logical_not(np.logical_or(self.zu, self.zl))

        self.zu[:] = np.logical_and(self.zu, np.greater(self.state.e, 0)).astype(np.float64)
        self.zl[:] = np.logical_and(self.zl, np.less(self.state.e, 0)).astype(np.float64)
        self.zi[:] = np.logical_not(
            np.logical_or(self.zu.astype(np.bool),
                          self.zl.astype(np.bool))).astype(np.float64)
示例#2
0
    def __init__(self,
                 u,
                 value=0.0,
                 flag=1,
                 equal=False,
                 name=None,
                 tex_name=None,
                 info=None,
                 cache=True):

        self.value = dummify(value)
        self.equal = equal

        if self.equal is True:
            self.func = lambda x: np.greater_equal(x, self.value.v)
        else:
            self.func = lambda x: np.greater(x, self.value.v)

        FlagCondition.__init__(
            self,
            u,
            func=self.func,
            flag=flag,
            name=name,
            tex_name=tex_name,
            info=info,
            cache=cache,
        )
示例#3
0
    def check_var(self):
        """
        Updates five flags: zi, zu, zl; zur, and zlr based on the following rules:

        zu:
          1 if u > upper; 0 otherwise.

        zl:
          1 if u < lower; 0 otherwise.
        zi:
          not(zu or zl);

        zur:
         - set to 1 when (previous zu + present zi == 2)
         - hold when (previous zi == zi)
         - clear otherwise

        zlr:
         - set to 1 when (previous zl + present zi == 2)
         - hold when (previous zi == zi)
         - clear otherwise
        """
        if not self.enable:
            return
        zu = np.greater(self.u.v, self.upper.v)
        zl = np.less(self.u.v, self.lower.v)
        zi = np.logical_not(np.logical_or(zu, zl))

        # square return dead band
        self.zur[:] = np.equal(self.zu + zi, 2) + self.zur * np.equal(zi, self.zi)
        self.zlr[:] = np.equal(self.zl + zi, 2) + self.zlr * np.equal(zi, self.zi)

        self.zu[:] = zu.astype(np.float64)
        self.zl[:] = zl.astype(np.float64)
        self.zi[:] = zi.astype(np.float64)
示例#4
0
    def check_var(self, *args, **kwargs):
        """
        Evaluate the flags.
        """
        if not self.enable:
            return

        if not self.no_upper:
            if self.equal:
                self.zu[:] = np.greater_equal(self.u.v, self.upper.v)
            else:
                self.zu[:] = np.greater(self.u.v, self.upper.v)

        if not self.no_lower:
            if self.equal:
                self.zl[:] = np.less_equal(self.u.v, self.lower.v)
            else:
                self.zl[:] = np.less(self.u.v, self.lower.v)

        self.zi[:] = np.logical_not(np.logical_or(self.zu, self.zl))
示例#5
0
    def check_eq(self):
        if not self.enable:
            return

        if not self.rate_no_lower:
            self.zlr[:] = np.less(
                self.u.e, self.rate_lower.v)  # 1 if at the lower rate limit

            if self.rate_lower_cond is not None:
                self.zlr[:] = self.zlr * self.rate_lower_cond.v  # 1 if both at the lower rate limit and enabled

            # for where `zlr == 1`, set the equation value to the lower limit
            self.u.e[np.where(self.zlr)] = self.rate_lower.v

        if not self.rate_no_upper:
            self.zur[:] = np.greater(self.u.e, self.rate_upper.v)

            if self.rate_upper_cond is not None:
                self.zur[:] = self.zur * self.rate_upper_cond.v

            self.u.e[np.where(self.zur)] = self.rate_upper.v