Logical_AND Logical_AND Icon

LogicGates.Logical_AND

Logical_AND(; name, abs_tol=1e-3, target_value=0.0)

A logical AND operation component for two real-valued input signals.

Parameters

  • abs_tol: Absolute tolerance for comparing inputs to target value (default: 1e-3)
  • target_value: Reference value for comparison (default: 0.0)

Variables

  • u1(t): First input signal (placement: left side, upper)
  • u2(t): Second input signal (placement: left side, lower)
  • y(t): Output signal (placement: right side)

Description

Compares each input (u1 and u2) against the targetvalue within a tolerance defined by abstol, treating the inputs as Boolean-like conditions based on whether they are close to the target. The output y is set to 0.0 (true) only when both inputs are close to the target value, and 1.0 (false) otherwise. This component is useful for creating logical conditions or control decisions in hybrid or signal-based models where continuous real inputs need to be evaluated as logical states.

Usage

PrimitiveComponents.LogicGates.Logical_AND(abs_tol=1e-3, target_value=0.0)

Parameters:

NameDescriptionUnitsDefault value
abs_tol0.001
target_value0

Connectors

  • u1 - This connector represents a real signal as an input to a component (RealInput)
  • y - This connector represents a real signal as an output from a component (RealOutput)
  • u2 - This connector represents a real signal as an input to a component (RealInput)

Variables

NameDescriptionUnits
c1
c2

Behavior

\[ \begin{align} \mathtt{c1}\left( t \right) &= check\_with\_target\_value\left( \mathtt{u1}\left( t \right), \mathtt{target\_value}, \mathtt{abs\_tol} \right) \\ \mathtt{c2}\left( t \right) &= check\_with\_target\_value\left( \mathtt{u2}\left( t \right), \mathtt{target\_value}, \mathtt{abs\_tol} \right) \\ y\left( t \right) &= ifelse\left( \neg \mathtt{c1}\left( t \right) \wedge \neg \mathtt{c2}\left( t \right), 1, 0 \right) \end{align} \]

Source

"""
    Logical_AND(; name, abs_tol=1e-3, target_value=0.0)

A logical AND operation component for two real-valued input signals.

# Parameters
- `abs_tol`: Absolute tolerance for comparing inputs to target value (default: 1e-3)
- `target_value`: Reference value for comparison (default: 0.0)

# Variables
- `u1(t)`: First input signal (placement: left side, upper)
- `u2(t)`: Second input signal (placement: left side, lower)
- `y(t)`: Output signal (placement: right side)

# Description
Compares each input (u1 and u2) against the target_value within a tolerance defined by abs_tol,
treating the inputs as Boolean-like conditions based on whether they are close to the target.
The output y is set to 0.0 (true) only when both inputs are close to the target value,
and 1.0 (false) otherwise. This component is useful for creating logical conditions or control
decisions in hybrid or signal-based models where continuous real inputs need to be evaluated
as logical states.
"""
component Logical_AND
  u1 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  y = Dyad.RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  u2 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  # Absolute tolerance — the maximum allowed difference |x - target_value| for them to be considered approximately equal. Defaults to 1e-3
  parameter abs_tol::Real() = 1e-3
  # The reference value against which x is compared for closeness. Defaults to 0.0.
  parameter target_value::Real() = 0.0
  variable c1::Boolean
  variable c2::Boolean
relations
  c1 = check_with_target_value(u1, target_value, abs_tol)
  c2 = check_with_target_value(u2, target_value, abs_tol)
  y = ifelse(!c1 and !c2, float_sym(1.0), float_sym(0.0))
metadata {"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/AND.svg"}}}
end
Flattened Source
"""
    Logical_AND(; name, abs_tol=1e-3, target_value=0.0)

A logical AND operation component for two real-valued input signals.

# Parameters
- `abs_tol`: Absolute tolerance for comparing inputs to target value (default: 1e-3)
- `target_value`: Reference value for comparison (default: 0.0)

# Variables
- `u1(t)`: First input signal (placement: left side, upper)
- `u2(t)`: Second input signal (placement: left side, lower)
- `y(t)`: Output signal (placement: right side)

# Description
Compares each input (u1 and u2) against the target_value within a tolerance defined by abs_tol,
treating the inputs as Boolean-like conditions based on whether they are close to the target.
The output y is set to 0.0 (true) only when both inputs are close to the target value,
and 1.0 (false) otherwise. This component is useful for creating logical conditions or control
decisions in hybrid or signal-based models where continuous real inputs need to be evaluated
as logical states.
"""
component Logical_AND
  u1 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 250, "y2": 290, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  y = Dyad.RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": 1000, "x2": 1040, "y1": 480, "y2": 520, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  u2 = Dyad.RealInput() {
    "Dyad": {
      "placement": {
        "diagram": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0},
        "icon": {"x1": -40, "x2": 0, "y1": 700, "y2": 740, "sh": 0.04, "sw": 0.04, "rot": 0}
      }
    }
  }
  # Absolute tolerance — the maximum allowed difference |x - target_value| for them to be considered approximately equal. Defaults to 1e-3
  parameter abs_tol::Real() = 1e-3
  # The reference value against which x is compared for closeness. Defaults to 0.0.
  parameter target_value::Real() = 0.0
  variable c1::Boolean
  variable c2::Boolean
relations
  c1 = check_with_target_value(u1, target_value, abs_tol)
  c2 = check_with_target_value(u2, target_value, abs_tol)
  y = ifelse(!c1 and !c2, float_sym(1.0), float_sym(0.0))
metadata {"Dyad": {"icons": {"default": "dyad://PrimitiveComponents/AND.svg"}}}
end


Test Cases

No test cases defined.

  • Examples
  • Experiments
  • Analyses