Cosine
Generates a cosine wave with configurable parameters.
A signal generator that produces a cosine wave with the equation
when time exceeds start_time, otherwise outputs the offset value. The component allows setting the wave's amplitude, frequency, phase shift and vertical offset.
This component extends from Signal
Usage
BlockComponents.Cosine(start_time=0.0, offset=0.0, amplitude, frequency, phase=0.0)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
start_time | Time at which the signal starts changing from its offset value | s | 0 |
offset | Constant value added to the signal output | – | 0 |
amplitude | The peak value of the cosine wave | – | |
frequency | The number of cycles per second | Hz | |
phase | The phase shift of the cosine wave in radians | rad | 0 |
Connectors
y- This connector represents a real signal as an output from a component (RealOutput)
Behavior
Source
dyad
"""
Generates a cosine wave with configurable parameters.
A signal generator that produces a cosine wave with the equationmath y(t) = offset + amplitude \cdot \cos(2\pi \cdot frequency \cdot (t-start_time) + phase)
when time exceeds start_time, otherwise outputs the offset value. The component allows setting
the wave's amplitude, frequency, phase shift and vertical offset.
"""
component Cosine
extends Signal
"The peak value of the cosine wave"
parameter amplitude::Real
"The number of cycles per second"
parameter frequency::Frequency
"The phase shift of the cosine wave in radians"
parameter phase::Angle = 0.0
relations
y = offset + amplitude * ifelse(time >= start_time, cos(2 * π * frequency * (time - start_time) + phase), cos(phase))
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/Cosine.svg"}
}
}
endFlattened Source
dyad
"""
Generates a cosine wave with configurable parameters.
A signal generator that produces a cosine wave with the equationmath y(t) = offset + amplitude \cdot \cos(2\pi \cdot frequency \cdot (t-start_time) + phase)
when time exceeds start_time, otherwise outputs the offset value. The component allows setting
the wave's amplitude, frequency, phase shift and vertical offset.
"""
component Cosine
"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
"The peak value of the cosine wave"
parameter amplitude::Real
"The number of cycles per second"
parameter frequency::Frequency
"The phase shift of the cosine wave in radians"
parameter phase::Angle = 0.0
relations
y = offset + amplitude * ifelse(time >= start_time, cos(2 * π * frequency * (time - start_time) + phase), cos(phase))
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/Cosine.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests