Skip to content
ContinuousClockTest.md

ContinuousClockTest

Test that evaluates a continuous clock signal integrated over time.

This test component connects a continuous clock signal to an integrator to validate the clock's behavior. The continuous clock starts at time 0.5 with an offset of 1.0, generating a signal that increases linearly with time (y = t + offset when t ≥ start_time). The integrator accumulates this signal, resulting in a quadratic response. The test verifies both the clock output and the integrated value against expected results at t=5.

Usage

ContinuousClockTest()

Behavior

signal.y(t)=integrator.u(t)dintegrator.x(t)dt=integrator.kintegrator.u(t)integrator.y(t)=integrator.x(t)signal.y(t)=ifelse(signal.start_time<t,signal.offsetsignal.start_time+t,signal.offset)

Source

dyad
# Test that evaluates a continuous clock signal integrated over time.
#
# This test component connects a continuous clock signal to an integrator to validate the
# clock's behavior. The continuous clock starts at time 0.5 with an offset of 1.0, generating
# a signal that increases linearly with time (y = t + offset when t ≥ start_time). The integrator
# accumulates this signal, resulting in a quadratic response. The test verifies both the clock
# output and the integrated value against expected results at t=5.
test component ContinuousClockTest
  # Integrator that accumulates the clock signal
  integrator = Integrator()
  # Continuous clock with 0.5 start time and 1.0 offset
  signal = ContinuousClock(start_time=0.5, offset=1.0)
relations
  # Connects the clock output to the integrator input
  connect(signal.y, integrator.u)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {"integrator.x": 0.001},
        "expect": {
          "initial": {"signal.y": 1},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 5.5, "integrator.x": 15.11887}
        }
      }
    }
  }
}
end
Flattened Source
dyad
# Test that evaluates a continuous clock signal integrated over time.
#
# This test component connects a continuous clock signal to an integrator to validate the
# clock's behavior. The continuous clock starts at time 0.5 with an offset of 1.0, generating
# a signal that increases linearly with time (y = t + offset when t ≥ start_time). The integrator
# accumulates this signal, resulting in a quadratic response. The test verifies both the clock
# output and the integrated value against expected results at t=5.
test component ContinuousClockTest
  # Integrator that accumulates the clock signal
  integrator = Integrator()
  # Continuous clock with 0.5 start time and 1.0 offset
  signal = ContinuousClock(start_time=0.5, offset=1.0)
relations
  # Connects the clock output to the integrator input
  connect(signal.y, integrator.u)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {"integrator.x": 0.001},
        "expect": {
          "initial": {"signal.y": 1},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 5.5, "integrator.x": 15.11887}
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt