Skip to content
SineTest.md

SineTest

Test component that integrates a sine wave with specific parameters.

This component connects a configurable sine wave generator to an integrator and verifies correct numerical behavior through the test case in metadata. The sine wave has an amplitude of 1, frequency of 2 Hz, start time of 0.5s, offset of 0.5, and phase shift of 1.57 radians. The integrator accumulates the sine wave signal over time, and the test case verifies both signals meet expected values.

Usage

SineTest()

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.offset+signal.amplitudesin(signal.phase+6.2832signal.frequency(signal.start_time+t)),signal.offset)

Source

dyad
# Test component that integrates a sine wave with specific parameters.
#
# This component connects a configurable sine wave generator to an integrator and
# verifies correct numerical behavior through the test case in metadata. The sine
# wave has an amplitude of 1, frequency of 2 Hz, start time of 0.5s, offset of 0.5,
# and phase shift of 1.57 radians. The integrator accumulates the sine wave signal
# over time, and the test case verifies both signals meet expected values.
test component SineTest
  # Integrator that accumulates the sine wave input
  integrator = Integrator()
  # Sine wave generator with specific parameters for testing
  signal = Sine(amplitude=1, frequency=2, start_time=0.5, offset=0.5, phase=1.57)
relations
  # Connects the sine wave output to the integrator input
  connect(signal.y, integrator.u)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {"signal.y": 0.001, "integrator.x": 0.001},
        "expect": {
          "initial": {"signal.y": 0.5},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 1.49999, "integrator.x": 2.54036}
        }
      }
    }
  }
}
end
Flattened Source
dyad
# Test component that integrates a sine wave with specific parameters.
#
# This component connects a configurable sine wave generator to an integrator and
# verifies correct numerical behavior through the test case in metadata. The sine
# wave has an amplitude of 1, frequency of 2 Hz, start time of 0.5s, offset of 0.5,
# and phase shift of 1.57 radians. The integrator accumulates the sine wave signal
# over time, and the test case verifies both signals meet expected values.
test component SineTest
  # Integrator that accumulates the sine wave input
  integrator = Integrator()
  # Sine wave generator with specific parameters for testing
  signal = Sine(amplitude=1, frequency=2, start_time=0.5, offset=0.5, phase=1.57)
relations
  # Connects the sine wave output to the integrator input
  connect(signal.y, integrator.u)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 5,
        "atol": {"signal.y": 0.001, "integrator.x": 0.001},
        "expect": {
          "initial": {"signal.y": 0.5},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 1.49999, "integrator.x": 2.54036}
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt