Test_Logical_OR Test_Logical_OR Icon

Test_Logical_OR

Usage

PrimitiveComponents.Test_Logical_OR()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( u1_{+}y(t), or_{logical\_1_{+}u1(t)} \right) \\ \mathrm{connect}\left( u2_{+}y(t), or_{logical\_1_{+}u2(t)} \right) \\ \mathrm{connect}\left( u3_{+}y(t), or_{logical\_2_{+}u1(t)} \right) \\ \mathrm{connect}\left( u4_{+}y(t), or_{logical\_2_{+}u2(t)} \right) \\ \mathrm{connect}\left( u5_{+}y(t), or_{logical\_3_{+}u1(t)} \right) \\ \mathrm{connect}\left( u6_{+}y(t), or_{logical\_3_{+}u2(t)} \right) \\ \mathrm{connect}\left( u7_{+}y(t), or_{logical\_4_{+}u1(t)} \right) \\ \mathrm{connect}\left( u8_{+}y(t), or_{logical\_4_{+}u2(t)} \right) \\ \mathtt{u1.y}\left( t \right) = \mathtt{u1.k} \\ \mathtt{u2.y}\left( t \right) = \mathtt{u2.k} \\ \mathtt{u3.y}\left( t \right) = \mathtt{u3.k} \\ \mathtt{u4.y}\left( t \right) = \mathtt{u4.k} \\ \mathtt{u5.y}\left( t \right) = \mathtt{u5.k} \\ \mathtt{u6.y}\left( t \right) = \mathtt{u6.k} \\ \mathtt{u7.y}\left( t \right) = \mathtt{u7.k} \\ \mathtt{u8.y}\left( t \right) = \mathtt{u8.k} \\ \mathtt{or\_logical\_1.c1}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_1.u1}\left( t \right), \mathtt{or\_logical\_1.target\_value}, \mathtt{or\_logical\_1.abs\_tol} \right) \\ \mathtt{or\_logical\_1.c2}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_1.u2}\left( t \right), \mathtt{or\_logical\_1.target\_value}, \mathtt{or\_logical\_1.abs\_tol} \right) \\ \mathtt{or\_logical\_1.y}\left( t \right) = ifelse\left( \neg \mathtt{or\_logical\_1.c1}\left( t \right) \vee \neg \mathtt{or\_logical\_1.c2}\left( t \right), 1, 0 \right) \\ \mathtt{or\_logical\_2.c1}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_2.u1}\left( t \right), \mathtt{or\_logical\_2.target\_value}, \mathtt{or\_logical\_2.abs\_tol} \right) \\ \mathtt{or\_logical\_2.c2}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_2.u2}\left( t \right), \mathtt{or\_logical\_2.target\_value}, \mathtt{or\_logical\_2.abs\_tol} \right) \\ \mathtt{or\_logical\_2.y}\left( t \right) = ifelse\left( \neg \mathtt{or\_logical\_2.c1}\left( t \right) \vee \neg \mathtt{or\_logical\_2.c2}\left( t \right), 1, 0 \right) \\ \mathtt{or\_logical\_3.c1}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_3.u1}\left( t \right), \mathtt{or\_logical\_3.target\_value}, \mathtt{or\_logical\_3.abs\_tol} \right) \\ \mathtt{or\_logical\_3.c2}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_3.u2}\left( t \right), \mathtt{or\_logical\_3.target\_value}, \mathtt{or\_logical\_3.abs\_tol} \right) \\ \mathtt{or\_logical\_3.y}\left( t \right) = ifelse\left( \neg \mathtt{or\_logical\_3.c1}\left( t \right) \vee \neg \mathtt{or\_logical\_3.c2}\left( t \right), 1, 0 \right) \\ \mathtt{or\_logical\_4.c1}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_4.u1}\left( t \right), \mathtt{or\_logical\_4.target\_value}, \mathtt{or\_logical\_4.abs\_tol} \right) \\ \mathtt{or\_logical\_4.c2}\left( t \right) = check\_with\_target\_value\left( \mathtt{or\_logical\_4.u2}\left( t \right), \mathtt{or\_logical\_4.target\_value}, \mathtt{or\_logical\_4.abs\_tol} \right) \\ \mathtt{or\_logical\_4.y}\left( t \right) = ifelse\left( \neg \mathtt{or\_logical\_4.c1}\left( t \right) \vee \neg \mathtt{or\_logical\_4.c2}\left( t \right), 1, 0 \right) \\ \end{array} \right] \end{equation} \]

Source

# This test demonstrates the behavior of the `Logical_OR` component.
#
# Eight constant input signals are used to test four separate `Logical_OR` blocks:
#   - u1 = 0.0, u2 = 1.0
#   - u3 = 10,  u4 = 5
#   - u5 = -0.002, u6 = 1
#   - u7 = -0.0002, u8 = 0.0001
#
# The `Logical_OR` component treats each input as:
#   - Approximately 0 (within default tolerance 1e-3) → false
#   - Any other value → true
#
# Expected behavior in this test:
#   - or_logical_1: u1 = 0 (false), u2 = 1 (true) → y = 1.0
#   - or_logical_2: u3 = 10 (true), u4 = 5 (true) → y = 1.0
#   - or_logical_3: u5 = -0.002 (true), u6 = 1 (true) → y = 1.0
#   - or_logical_4: u7 = -0.0002 (false within tolerance), u8 = 0.0001 (false within tolerance) → y = 0.0
test component Test_Logical_OR
  u1 = BlockComponents.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 60, "y1": 80, "x2": 160, "y2": 180, "rot": 0}
      }
    }
  }
  u2 = BlockComponents.Constant(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 80, "y1": 270, "x2": 180, "y2": 370, "rot": 0}
      }
    }
  }
  u3 = BlockComponents.Constant(k = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 80, "x2": 670, "y2": 180, "rot": 0}
      }
    }
  }
  u4 = BlockComponents.Constant(k = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 590, "y1": 250, "x2": 690, "y2": 350, "rot": 0}
      }
    }
  }
  u5 = BlockComponents.Constant(k = -0.002) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 90, "y1": 560, "x2": 190, "y2": 660, "rot": 0}
      }
    }
  }
  u6 = BlockComponents.Constant(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 100, "y1": 810, "x2": 200, "y2": 910, "rot": 0}
      }
    }
  }
  u7 = BlockComponents.Constant(k = -0.0002) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 570, "x2": 670, "y2": 670, "rot": 0}
      }
    }
  }
  u8 = BlockComponents.Constant(k = 0.0001) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 580, "y1": 790, "x2": 680, "y2": 890, "rot": 0}
      }
    }
  }
  or_logical_1 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 290, "y1": 180, "x2": 390, "y2": 280, "rot": 0}
      }
    }
  }
  or_logical_2 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 820, "y1": 170, "x2": 920, "y2": 270, "rot": 0}
      }
    }
  }
  or_logical_3 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 280, "y1": 700, "x2": 380, "y2": 800, "rot": 0}
      }
    }
  }
  or_logical_4 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 820, "y1": 710, "x2": 920, "y2": 810, "rot": 0}
      }
    }
  }
relations
  connect(u1.y, or_logical_1.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 224, "y": 130}, {"x": 224, "y": 207}], "E": 2}]}
  }
  connect(or_logical_1.u2, u2.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 234, "y": 252}, {"x": 234, "y": 320}], "E": 2}]}
  }
  connect(u3.y, or_logical_2.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 744, "y": 130}, {"x": 744, "y": 197}], "E": 2}]}
  }
  connect(or_logical_2.u2, u4.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 749, "y": 242}, {"x": 749, "y": 300}], "E": 2}]}
  }
  connect(u5.y, or_logical_3.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 234, "y": 610}, {"x": 234, "y": 727}], "E": 2}]}
  }
  connect(or_logical_3.u2, u6.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 239, "y": 772}, {"x": 239, "y": 860}], "E": 2}]}
  }
  connect(u7.y, or_logical_4.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 744, "y": 620}, {"x": 744, "y": 737}], "E": 2}]}
  }
  connect(or_logical_4.u2, u8.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 749, "y": 782}, {"x": 749, "y": 840}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_Logical_OR_": {"stop": 2}},
    "tests": {
      "case1": {
        "stop": 2,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {
          "signals": ["or_logical_1.y", "or_logical_2.y", "or_logical_3.y", "or_logical_4.y"]
        }
      }
    }
  }
}
end
Flattened Source
test component Test_Logical_OR
  u1 = BlockComponents.Constant(k = 0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 60, "y1": 80, "x2": 160, "y2": 180, "rot": 0}
      }
    }
  }
  u2 = BlockComponents.Constant(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 80, "y1": 270, "x2": 180, "y2": 370, "rot": 0}
      }
    }
  }
  u3 = BlockComponents.Constant(k = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 80, "x2": 670, "y2": 180, "rot": 0}
      }
    }
  }
  u4 = BlockComponents.Constant(k = 5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 590, "y1": 250, "x2": 690, "y2": 350, "rot": 0}
      }
    }
  }
  u5 = BlockComponents.Constant(k = -0.002) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 90, "y1": 560, "x2": 190, "y2": 660, "rot": 0}
      }
    }
  }
  u6 = BlockComponents.Constant(k = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 100, "y1": 810, "x2": 200, "y2": 910, "rot": 0}
      }
    }
  }
  u7 = BlockComponents.Constant(k = -0.0002) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 570, "x2": 670, "y2": 670, "rot": 0}
      }
    }
  }
  u8 = BlockComponents.Constant(k = 0.0001) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 580, "y1": 790, "x2": 680, "y2": 890, "rot": 0}
      }
    }
  }
  or_logical_1 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 290, "y1": 180, "x2": 390, "y2": 280, "rot": 0}
      }
    }
  }
  or_logical_2 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 820, "y1": 170, "x2": 920, "y2": 270, "rot": 0}
      }
    }
  }
  or_logical_3 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 280, "y1": 700, "x2": 380, "y2": 800, "rot": 0}
      }
    }
  }
  or_logical_4 = PrimitiveComponents.LogicGates.Logical_OR() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 820, "y1": 710, "x2": 920, "y2": 810, "rot": 0}
      }
    }
  }
relations
  connect(u1.y, or_logical_1.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 224, "y": 130}, {"x": 224, "y": 207}], "E": 2}]}
  }
  connect(or_logical_1.u2, u2.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 234, "y": 252}, {"x": 234, "y": 320}], "E": 2}]}
  }
  connect(u3.y, or_logical_2.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 744, "y": 130}, {"x": 744, "y": 197}], "E": 2}]}
  }
  connect(or_logical_2.u2, u4.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 749, "y": 242}, {"x": 749, "y": 300}], "E": 2}]}
  }
  connect(u5.y, or_logical_3.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 234, "y": 610}, {"x": 234, "y": 727}], "E": 2}]}
  }
  connect(or_logical_3.u2, u6.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 239, "y": 772}, {"x": 239, "y": 860}], "E": 2}]}
  }
  connect(u7.y, or_logical_4.u1) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 744, "y": 620}, {"x": 744, "y": 737}], "E": 2}]}
  }
  connect(or_logical_4.u2, u8.y) {
    "Dyad": {"edges": [{"S": 1, "M": [{"x": 749, "y": 782}, {"x": 749, "y": 840}], "E": 2}]}
  }
metadata {
  "Dyad": {
    "experiments": {"Test_Logical_OR_": {"stop": 2}},
    "tests": {
      "case1": {
        "stop": 2,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {
          "signals": ["or_logical_1.y", "or_logical_2.y", "or_logical_3.y", "or_logical_4.y"]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
plt
Example block output
plt
Example block output
plt
Example block output