TestPolynomial TestPolynomial Icon

TestPolynomial

Usage

PrimitiveComponents.TestPolynomial()

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathrm{connect}\left( source_{+}y(t), poly_{+}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{poly.y}\left( t \right) = \mathtt{poly.c0} + \mathtt{poly.c1} \mathtt{poly.u}\left( t \right) + \left( \mathtt{poly.u}\left( t \right) \right)^{2} \mathtt{poly.c2} + \left( \mathtt{poly.u}\left( t \right) \right)^{3} \mathtt{poly.c3} \\ \end{array} \right] \end{equation} \]

Source

test component TestPolynomial
  "Ramp input from -2 to 2"
  source = BlockComponents.Ramp(height = 4.0, duration = 2.0, offset = -2.0) {}
  "Polynomial component: y = 1 + 2*u - 0.5*u^2"
  poly = PrimitiveComponents.Mathematical.Polynomial(c0 = 1.0, c1 = 2.0, c2 = -0.5) {}
relations
  connect(source.y, poly.u) {}
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["poly.y"]}
      }
    },
    "_links": {
      "source": {
        "Dyad": {
          "placement": {
            "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
          },
          "tags": []
        }
      },
      "poly": {
        "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 TestPolynomial
  "Ramp input from -2 to 2"
  source = BlockComponents.Ramp(height = 4.0, duration = 2.0, offset = -2.0) {}
  "Polynomial component: y = 1 + 2*u - 0.5*u^2"
  poly = PrimitiveComponents.Mathematical.Polynomial(c0 = 1.0, c1 = 2.0, c2 = -0.5) {}
relations
  connect(source.y, poly.u) {}
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "stop": 10,
        "abstol": 0.00001,
        "reltol": 0.00001,
        "expect": {"signals": ["poly.y"]}
      }
    },
    "_links": {
      "source": {
        "Dyad": {
          "placement": {
            "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
          },
          "tags": []
        }
      },
      "poly": {
        "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