Skip to content
VariableSinCosTest.md

VariableSinCosTest

Test component for sine and cosine generators with variable frequency and amplitude inputs.

Creates a test environment that connects amplitude and frequency input sources to sine and cosine wave generators. The amplitude source is a ramp that starts at 2 and decreases to 0 over 3 seconds, while the frequency is held constant at 2 Hz. This test setup allows visualization of how the wave generators respond to changing amplitude while maintaining a constant frequency.

Usage

VariableSinCosTest()

Behavior

amplitude_source.y(t)=sine_wave.amplitude(t)sine_wave.amplitude(t)=cos_wave.amplitude(t)frequency_source.y(t)=sine_wave.frequency(t)sine_wave.frequency(t)=cos_wave.frequency(t)dsine_wave.phi(t)dt=6.2832sine_wave.frequency(t)sine_wave.y(t)=sine_wave.offset+sine_wave.amplitude(t)sin(sine_wave.phi(t))dcos_wave.phi(t)dt=6.2832cos_wave.frequency(t)cos_wave.y(t)=cos_wave.offset+cos(cos_wave.phi(t))cos_wave.amplitude(t)amplitude_source.y(t)=ifelse(amplitude_source.start_time<t,ifelse(t<amplitude_source.duration+amplitude_source.start_time,amplitude_source.offset+amplitude_source.height(amplitude_source.start_time+t)amplitude_source.duration,amplitude_source.height+amplitude_source.offset),amplitude_source.offset)frequency_source.y(t)=frequency_source.k

Source

dyad
# Test component for sine and cosine generators with variable frequency and amplitude inputs.
#
# Creates a test environment that connects amplitude and frequency input sources to sine and cosine
# wave generators. The amplitude source is a ramp that starts at 2 and decreases to 0 over 3 seconds,
# while the frequency is held constant at 2 Hz. This test setup allows visualization of how the wave
# generators respond to changing amplitude while maintaining a constant frequency.
test component VariableSinCosTest
  # Sine wave generator with variable frequency and amplitude inputs
  sine_wave = SineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": 600, "y1": 100, "x2": 800, "y2": 300, "rot": 0}}}
  }]
  # Cosine wave generator with variable frequency and amplitude inputs
  cos_wave = CosineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": 600, "y1": 400, "x2": 800, "y2": 600, "rot": 0}}}
  }]
  # Amplitude source that starts at 2 and linearly decreases to 0 over 3 seconds
  amplitude_source = BlockComponents.Ramp(start_time=0, offset=2, duration=3, height=-2) [{
    "Dyad": {"placement": {"icon": {"x1": 0, "y1": 100, "x2": 200, "y2": 300, "rot": 0}}}
  }]
  # Frequency source providing a constant value of 2 Hz
  frequency_source = BlockComponents.Constant(k=2) [{
    "Dyad": {"placement": {"icon": {"x1": 0, "y1": 400, "x2": 200, "y2": 600, "rot": 0}}}
  }]
relations
  # Connects amplitude source to both wave generators
  connect(amplitude_source.y, sine_wave.amplitude, cos_wave.amplitude) [{
    "Dyad": {
      "edges": [
        {"S": -1, "E": 1},
        {"S": -1, "M": [{"x": 300, "y": 160}], "E": 2},
        {"S": -1, "M": [{"x": 300, "y": 460}], "E": 3}
      ],
      "junctions": [{"x": 300, "y": 200}]
    }
  }]
  # Connects frequency source to both wave generators
  connect(frequency_source.y, sine_wave.frequency, cos_wave.frequency) [{
    "Dyad": {
      "edges": [
        {"S": -1, "E": 1},
        {"S": -1, "M": [{"x": 400, "y": 240}], "E": 2},
        {"S": -1, "M": [{"x": 400, "y": 540}], "E": 3}
      ],
      "junctions": [{"x": 400, "y": 500}]
    }
  }]
metadata {
  "Dyad": {"tests": {"case1": {"stop": 10, "signals": ["sine_wave.y", "cos_wave.y"]}}}
}
end
Flattened Source
dyad
# Test component for sine and cosine generators with variable frequency and amplitude inputs.
#
# Creates a test environment that connects amplitude and frequency input sources to sine and cosine
# wave generators. The amplitude source is a ramp that starts at 2 and decreases to 0 over 3 seconds,
# while the frequency is held constant at 2 Hz. This test setup allows visualization of how the wave
# generators respond to changing amplitude while maintaining a constant frequency.
test component VariableSinCosTest
  # Sine wave generator with variable frequency and amplitude inputs
  sine_wave = SineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": 600, "y1": 100, "x2": 800, "y2": 300, "rot": 0}}}
  }]
  # Cosine wave generator with variable frequency and amplitude inputs
  cos_wave = CosineVariableFrequencyAndAmplitude() [{
    "Dyad": {"placement": {"icon": {"x1": 600, "y1": 400, "x2": 800, "y2": 600, "rot": 0}}}
  }]
  # Amplitude source that starts at 2 and linearly decreases to 0 over 3 seconds
  amplitude_source = BlockComponents.Ramp(start_time=0, offset=2, duration=3, height=-2) [{
    "Dyad": {"placement": {"icon": {"x1": 0, "y1": 100, "x2": 200, "y2": 300, "rot": 0}}}
  }]
  # Frequency source providing a constant value of 2 Hz
  frequency_source = BlockComponents.Constant(k=2) [{
    "Dyad": {"placement": {"icon": {"x1": 0, "y1": 400, "x2": 200, "y2": 600, "rot": 0}}}
  }]
relations
  # Connects amplitude source to both wave generators
  connect(amplitude_source.y, sine_wave.amplitude, cos_wave.amplitude) [{
    "Dyad": {
      "edges": [
        {"S": -1, "E": 1},
        {"S": -1, "M": [{"x": 300, "y": 160}], "E": 2},
        {"S": -1, "M": [{"x": 300, "y": 460}], "E": 3}
      ],
      "junctions": [{"x": 300, "y": 200}]
    }
  }]
  # Connects frequency source to both wave generators
  connect(frequency_source.y, sine_wave.frequency, cos_wave.frequency) [{
    "Dyad": {
      "edges": [
        {"S": -1, "E": 1},
        {"S": -1, "M": [{"x": 400, "y": 240}], "E": 2},
        {"S": -1, "M": [{"x": 400, "y": 540}], "E": 3}
      ],
      "junctions": [{"x": 400, "y": 500}]
    }
  }]
metadata {
  "Dyad": {"tests": {"case1": {"stop": 10, "signals": ["sine_wave.y", "cos_wave.y"]}}}
}
end


Test Cases

Test Case case1

Layout Switch

Adjust the layout style of VitePress to adapt to different reading needs and screens.

Expand all
The sidebar and content area occupy the entire width of the screen.
Expand sidebar with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Expand all with adjustable values
Expand sidebar width and add a new slider for user to choose and customize their desired width of the maximum width of sidebar can go, but the content area width will remain the same.
Original width
The original layout width of VitePress

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.

Spotlight

Highlight the line where the mouse is currently hovering in the content to optimize for users who may have reading and focusing difficulties.

ONOn
Turn on Spotlight.
OFFOff
Turn off Spotlight.