TestWrapToZero TestWrapToZero Icon

TestWrapToZero

Usage

PrimitiveComponents.TestWrapToZero()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( source_{+}y(t), wrap_{+}u(t) \right) \\ \mathtt{source.y}\left( t \right) = ifelse\left( \mathtt{source.start\_time} < t, ifelse\left( t < \mathtt{source.duration} + \mathtt{source.start\_time}, \mathtt{source.offset} + \frac{\mathtt{source.height} \left( - \mathtt{source.start\_time} + t \right)}{\mathtt{source.duration}}, \mathtt{source.height} + \mathtt{source.offset} \right), \mathtt{source.offset} \right) \\ \mathtt{wrap.y}\left( t \right) = ifelse\left( \mathtt{wrap.u}\left( t \right) > \mathtt{wrap.threshold}, 0, \mathtt{wrap.u}\left( t \right) \right) \\ \end{array} \right] \end{equation} \]

Source

test component TestWrapToZero
  "Ramp input that crosses threshold"
  source = BlockComponents.Ramp(height = 4.0, duration = 4.0, offset = -2.0) {}
  "WrapToZero component under test"
  wrap = PrimitiveComponents.Discontinuous.WrapToZero(threshold = 1.0) {}
relations
  connect(source.y, wrap.u) {}
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["wrap.y"]}
      }
    },
    "_links": {
      "source": {
        "Dyad": {
          "placement": {
            "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
          },
          "tags": []
        }
      },
      "wrap": {
        "Dyad": {
          "placement": {
            "diagram": {"iconName": "default", "x1": 150, "y1": 20, "x2": 250, "y2": 120, "rot": 0}
          },
          "tags": []
        }
      },
      "id3": {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
    }
  }
}
end
Flattened Source
test component TestWrapToZero
  "Ramp input that crosses threshold"
  source = BlockComponents.Ramp(height = 4.0, duration = 4.0, offset = -2.0) {}
  "WrapToZero component under test"
  wrap = PrimitiveComponents.Discontinuous.WrapToZero(threshold = 1.0) {}
relations
  connect(source.y, wrap.u) {}
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["wrap.y"]}
      }
    },
    "_links": {
      "source": {
        "Dyad": {
          "placement": {
            "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
          },
          "tags": []
        }
      },
      "wrap": {
        "Dyad": {
          "placement": {
            "diagram": {"iconName": "default", "x1": 150, "y1": 20, "x2": 250, "y2": 120, "rot": 0}
          },
          "tags": []
        }
      },
      "id3": {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output