Test_GreaterEqual_Logical Test_GreaterEqual_Logical Icon

Test_GreaterEqual_Logical

Usage

PrimitiveComponents.Test_GreaterEqual_Logical()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( u1_{+}y(t), greaterequal_{logical_{+}u1(t)} \right) \\ \mathrm{connect}\left( u2_{+}y(t), greaterequal_{logical_{+}u2(t)} \right) \\ \mathtt{u1.y}\left( t \right) = ifelse\left( t \geq \mathtt{u1.start\_time}, \mathtt{u1.height} + \mathtt{u1.offset}, \mathtt{u1.offset} \right) \\ \mathtt{u2.y}\left( t \right) = ifelse\left( t \geq \mathtt{u2.start\_time}, \mathtt{u2.height} + \mathtt{u2.offset}, \mathtt{u2.offset} \right) \\ \mathtt{greaterequal\_logical.y}\left( t \right) = ifelse\left( \mathtt{greaterequal\_logical.u1}\left( t \right) \geq \mathtt{greaterequal\_logical.u2}\left( t \right), 1, 0 \right) \\ \end{array} \right] \end{equation} \]

Source

# This test demonstrates the behavior of the `GreaterEqual_Logical` component 
# when comparing two time-varying input signals generated by step functions.
#
# Two `Step` blocks provide real-valued signals:
#   - u1 starts at 5 and steps down by 3 at time = 3s → transitions from 5 → 2
#   - u2 starts at 3 and steps down by 2 at time = 5s → transitions from 3 → 2
#
# The `GreaterEqual_Logical` component evaluates whether u1 ≥ u2 at each instant:
#   - Initially (t < 3): u1 = 5, u2 = 3 → y = 1.0  (true)
#   - Between 3 ≤ t < 5: u1 = 2, u2 = 3 → y = 0.0  (false)
#   - After t ≥ 5:       u1 = 2, u2 = 2 → y = 1.0  (true)
component Test_GreaterEqual_Logical
  u1 = BlockComponents.Step(start_time = 3, offset = 5, height = -3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 330, "x2": 300, "y2": 430, "rot": 0}
      }
    }
  }
  u2 = BlockComponents.Step(offset = 3, start_time = 5, height = -1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 210, "y1": 640, "x2": 310, "y2": 740, "rot": 0}
      }
    }
  }
  greaterequal_logical = PrimitiveComponents.Compare.GreaterOrEqual() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 450, "x2": 560, "y2": 550, "rot": 0}
      }
    }
  }
relations
  connect(greaterequal_logical.u1, u1.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 379, "y": 469}, {"x": 379, "y": 380}], "E": 2}]}
  }
  connect(greaterequal_logical.u2, u2.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 384, "y": 523}, {"x": 384, "y": 690}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_GreaterEqual_Logical_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["greaterequal_logical.y"]}
      }
    }
  }
}
end
Flattened Source
component Test_GreaterEqual_Logical
  u1 = BlockComponents.Step(start_time = 3, offset = 5, height = -3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 200, "y1": 330, "x2": 300, "y2": 430, "rot": 0}
      }
    }
  }
  u2 = BlockComponents.Step(offset = 3, start_time = 5, height = -1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 210, "y1": 640, "x2": 310, "y2": 740, "rot": 0}
      }
    }
  }
  greaterequal_logical = PrimitiveComponents.Compare.GreaterOrEqual() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 450, "x2": 560, "y2": 550, "rot": 0}
      }
    }
  }
relations
  connect(greaterequal_logical.u1, u1.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 379, "y": 469}, {"x": 379, "y": 380}], "E": 2}]}
  }
  connect(greaterequal_logical.u2, u2.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 384, "y": 523}, {"x": 384, "y": 690}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_GreaterEqual_Logical_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["greaterequal_logical.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
  • Examples
  • Experiments
  • Analyses