Skip to content
SecondOrderTest.md

SecondOrderTest

Second-order system test with constant input.

Tests a second-order dynamic system by applying a constant input and verifying the expected step response. The second-order system is configured with a gain of 1.0, natural frequency of 1.0, and damping ratio of 0.5, which produces a slightly under-damped response. The system should eventually reach the steady-state output value matching the input constant.

Usage

SecondOrderTest()

Behavior

c.y(t)=pt2.u(t)c.y(t)=c.kdpt2.x(t)dt=pt2.xd(t)dpt2.xd(t)dt=(2pt2.dpt2.xd(t)+(pt2.x(t)+pt2.kpt2.u(t))pt2.w)pt2.wpt2.y(t)=pt2.x(t)

Source

dyad
# Second-order system test with constant input.
#
# Tests a second-order dynamic system by applying a constant input and verifying the expected
# step response. The second-order system is configured with a gain of 1.0, natural frequency
# of 1.0, and damping ratio of 0.5, which produces a slightly under-damped response. The system
# should eventually reach the steady-state output value matching the input constant.
test component SecondOrderTest
  # Constant source block that provides a fixed value of 1 as input
  c = Constant(k=1)
  # Second-order transfer function block with specified dynamics parameters
  pt2 = SecondOrder(k=1.0, w=1.0, d=0.5)
relations
  # Connects the constant output to the input of the second-order system
  connect(c.y, pt2.u)
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "stop": 10,
        "initial": {"pt2.xd": 0},
        "atol": {"pt2.y": 0.01},
        "expect": {"final": {"pt2.y": 1}, "signals": ["pt2.y"]}
      }
    }
  }
}
end
Flattened Source
dyad
# Second-order system test with constant input.
#
# Tests a second-order dynamic system by applying a constant input and verifying the expected
# step response. The second-order system is configured with a gain of 1.0, natural frequency
# of 1.0, and damping ratio of 0.5, which produces a slightly under-damped response. The system
# should eventually reach the steady-state output value matching the input constant.
test component SecondOrderTest
  # Constant source block that provides a fixed value of 1 as input
  c = Constant(k=1)
  # Second-order transfer function block with specified dynamics parameters
  pt2 = SecondOrder(k=1.0, w=1.0, d=0.5)
relations
  # Connects the constant output to the input of the second-order system
  connect(c.y, pt2.u)
metadata {
  "Dyad": {
    "experiments": {},
    "tests": {
      "case1": {
        "stop": 10,
        "initial": {"pt2.xd": 0},
        "atol": {"pt2.y": 0.01},
        "expect": {"final": {"pt2.y": 1}, "signals": ["pt2.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt