Skip to content
LIBRARY
Sources.Sine.md

Sources.Sine ​

Generates a sine wave signal with configurable parameters.

The component produces a sinusoidal output according to:

y=offset+amplitude⋅sin⁡(2π⋅frequency⋅(time−start_time)+phase)

When time is less than start_time, the output equals the offset value.

This component extends from BlockComponents.Interfaces.Signal

Usage ​

BlockComponents.Sources.Sine(start_time=0.0, offset=0.0, amplitude, frequency, phase=0.0)

Parameters: ​

NameDescriptionUnitsDefault value
start_timeTime at which the signal starts changing from its offset values0
offsetConstant value added to the signal output–0
amplitudePeak value of the sine wave–
frequencyNumber of cycles per time unitHz
phaseAngular displacement of the sine wave at start timerad0

Connectors ​

  • y - This connector represents a real signal as an output from a component (RealOutput)

Behavior ​

julia
using BlockComponents #hide
using ModelingToolkit #hide
@variables start_time #hide
@variables offset #hide
@variables amplitude #hide
@variables frequency #hide
@variables phase #hide
@named sys = BlockComponents.Sources.Sine(start_time=start_time, offset=offset, amplitude=amplitude, frequency=frequency, phase=phase) #hide
full_equations(sys) #hide
<< @example-block not executed in draft mode >>

Source ​

dyad
"""
Generates a sine wave signal with configurable parameters.

The component produces a sinusoidal output according to:

math y = \text{offset} + \text{amplitude} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{start_time}) + \text{phase})


When time is less than `start_time`, the output equals the `offset` value.
"""
component Sine
  extends BlockComponents.Interfaces.Signal
  "Peak value of the sine wave"
  parameter amplitude::Real
  "Number of cycles per time unit"
  parameter frequency::Frequency
  "Angular displacement of the sine wave at start time"
  parameter phase::Angle = 0.0
relations
  "Output equation that generates the sine wave when time exceeds start_time"
  y = offset + amplitude * ifelse(time >= start_time, sin(2 * π * frequency * (time - start_time) + phase), sin(phase))
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Sine.svg"}
  }
}
end
Flattened Source
dyad
"""
Generates a sine wave signal with configurable parameters.

The component produces a sinusoidal output according to:

math y = \text{offset} + \text{amplitude} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{start_time}) + \text{phase})


When time is less than `start_time`, the output equals the `offset` value.
"""
component Sine
  "Real-valued output connector for the component"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Time at which the signal starts changing from its offset value"
  parameter start_time::Time = 0.0
  "Constant value added to the signal output"
  parameter offset::Real = 0.0
  "Peak value of the sine wave"
  parameter amplitude::Real
  "Number of cycles per time unit"
  parameter frequency::Frequency
  "Angular displacement of the sine wave at start time"
  parameter phase::Angle = 0.0
relations
  "Output equation that generates the sine wave when time exceeds start_time"
  y = offset + amplitude * ifelse(time >= start_time, sin(2 * π * frequency * (time - start_time) + phase), sin(phase))
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Sine.svg"}
  }
}
end


Test Cases ​

No test cases defined.