Skip to content
RampTest.md

RampTest ​

Test passing a ramp signal to an integrator for verification purposes.

A test component that connects a Ramp signal generator to an Integrator to verify correct behavior. The ramp starts at an offset value of 0.5, remains constant until the start time (0.5s), then increases linearly by 1.0 over 0.7 seconds to reach a final value of 1.5. The integrator accumulates this signal, and the metadata specifies expected initial and final values for verification purposes.

Usage ​

BlockComponents.RampTest()

Behavior ​

[connect(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,ifelse(t<signal.duration+signal.start_time,signal.offset+signal.height(−signal.start_time+t)signal.duration,signal.height+signal.offset),signal.offset)]

Source ​

dyad
"""
Test passing a ramp signal to an integrator for verification purposes.

A test component that connects a Ramp signal generator to an Integrator to verify correct
behavior. The ramp starts at an offset value of 0.5, remains constant until the start
time (0.5s), then increases linearly by 1.0 over 0.7 seconds to reach a final value of 1.5.
The integrator accumulates this signal, and the metadata specifies expected initial and final
values for verification purposes.
"""
test component RampTest
  "Integrator component that accumulates the input signal"
  integrator = Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 20, "x2": 255, "y2": 120, "rot": 0}
      }
    }
  }
  "Ramp signal generator with configurable duration, height, start time and offset"
  signal = Ramp(duration = 0.7, height = 1.0, start_time = 0.5, offset = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      }
    }
  }
relations
  "Connects the ramp output to the integrator input"
  connect(signal.y, integrator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 3,
        "atol": {"integrator.x": 0.001},
        "expect": {
          "initial": {"signal.y": 0.5},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 1.5, "integrator.x": 3.65}
        }
      }
    }
  }
}
end
Flattened Source
dyad
"""
Test passing a ramp signal to an integrator for verification purposes.

A test component that connects a Ramp signal generator to an Integrator to verify correct
behavior. The ramp starts at an offset value of 0.5, remains constant until the start
time (0.5s), then increases linearly by 1.0 over 0.7 seconds to reach a final value of 1.5.
The integrator accumulates this signal, and the metadata specifies expected initial and final
values for verification purposes.
"""
test component RampTest
  "Integrator component that accumulates the input signal"
  integrator = Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 20, "x2": 255, "y2": 120, "rot": 0}
      }
    }
  }
  "Ramp signal generator with configurable duration, height, start time and offset"
  signal = Ramp(duration = 0.7, height = 1.0, start_time = 0.5, offset = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      }
    }
  }
relations
  "Connects the ramp output to the integrator input"
  connect(signal.y, integrator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 3,
        "atol": {"integrator.x": 0.001},
        "expect": {
          "initial": {"signal.y": 0.5},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 1.5, "integrator.x": 3.65}
        }
      }
    }
  }
}
end


Test Cases ​

Test Case case1 ​

julia
plt

julia
plt