Test_GreaterThreshold Test_GreaterThreshold Icon

Test_GreaterThreshold

Usage

PrimitiveComponents.Test_GreaterThreshold()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( step_{1_{+}y(t)}, greaterthreshold_{1_{+}u(t)} \right) \\ \mathrm{connect}\left( step_{2_{+}y(t)}, greaterthreshold_{2_{+}u(t)} \right) \\ \mathtt{greaterthreshold\_1.y}\left( t \right) = ifelse\left( \mathtt{greaterthreshold\_1.u}\left( t \right) > \mathtt{greaterthreshold\_1.threshold}, 1, 0 \right) \\ \mathtt{greaterthreshold\_2.y}\left( t \right) = ifelse\left( \mathtt{greaterthreshold\_2.u}\left( t \right) > \mathtt{greaterthreshold\_2.threshold}, 1, 0 \right) \\ \mathtt{step\_1.y}\left( t \right) = ifelse\left( t \geq \mathtt{step\_1.start\_time}, \mathtt{step\_1.height} + \mathtt{step\_1.offset}, \mathtt{step\_1.offset} \right) \\ \mathtt{step\_2.y}\left( t \right) = ifelse\left( t \geq \mathtt{step\_2.start\_time}, \mathtt{step\_2.height} + \mathtt{step\_2.offset}, \mathtt{step\_2.offset} \right) \\ \end{array} \right] \end{equation} \]

Source

# This test validates the `GreaterThreshold` component when comparing time-varying input signals against a fixed threshold value.
#
# Two `Step` blocks generate real-valued input signals:
#   - step_1 starts at 3 and increases by 4 at time = 5s → transitions from 3 → 7
#   - step_2 starts at 5 and decreases by 2 at time = 5s → transitions from 5 → 3
#
# Each signal is connected to a separate `GreaterThreshold` block (threshold = 5),
# which outputs 1.0 when the input is strictly greater than the threshold, and 0.0 otherwise.
#
# The `GreaterThreshold` component evaluates whether u > threshold at each instant:
#   - For step_1:
#       • Initially (t < 5): u = 3 → y = 0.0 (false)
#       • After t ≥ 5:       u = 7 → y = 1.0 (true)
#   - For step_2:
#       • Initially (t < 5): u = 5 → y = 0.0 (false, equal to threshold is not greater)
#       • After t ≥ 5:       u = 3 → y = 0.0 (false)
component Test_GreaterThreshold
  greaterthreshold_1 = PrimitiveComponents.Compare.GreaterThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      }
    }
  }
  greaterthreshold_2 = PrimitiveComponents.Compare.GreaterThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 590, "x2": 560, "y2": 690, "rot": 0}
      }
    }
  }
  step_1 = BlockComponents.Step(offset = 3, start_time = 5, height = 4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 230, "x2": 230, "y2": 330, "rot": 0}
      }
    }
  }
  step_2 = BlockComponents.Step(offset = 5, start_time = 5, height = -2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 590, "x2": 230, "y2": 690, "rot": 0}
      }
    }
  }
relations
  connect(greaterthreshold_1.u, step_1.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(greaterthreshold_2.u, step_2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_GreaterThreshold_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["greaterthreshold_1.y", "greaterthreshold_2.y"]}
      }
    }
  }
}
end
Flattened Source
component Test_GreaterThreshold
  greaterthreshold_1 = PrimitiveComponents.Compare.GreaterThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 230, "x2": 550, "y2": 330, "rot": 0}
      }
    }
  }
  greaterthreshold_2 = PrimitiveComponents.Compare.GreaterThreshold(threshold = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 460, "y1": 590, "x2": 560, "y2": 690, "rot": 0}
      }
    }
  }
  step_1 = BlockComponents.Step(offset = 3, start_time = 5, height = 4) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 230, "x2": 230, "y2": 330, "rot": 0}
      }
    }
  }
  step_2 = BlockComponents.Step(offset = 5, start_time = 5, height = -2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 130, "y1": 590, "x2": 230, "y2": 690, "rot": 0}
      }
    }
  }
relations
  connect(greaterthreshold_1.u, step_1.y) {"Dyad": {"edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(greaterthreshold_2.u, step_2.y) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}]}}
metadata {
  "Dyad": {
    "experiments": {"Test_GreaterThreshold_": {"stop": 10}},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["greaterthreshold_1.y", "greaterthreshold_2.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
plt
Example block output
  • Examples
  • Experiments
  • Analyses