Sources.ExpSine
Exponentially damped sine wave with configurable amplitude, frequency, and damping.
Generates a sinusoidal signal that exponentially decays over time based on the damping coefficient. The signal remains at the offset value until the start time is reached, after which it follows the equation:
When time < start_time, the output depends on the continuous parameter:
continuous = true(default): output equals the value the signal would have atstart_time, ensuring value continuity (backwards compatible)continuous = false: output equalsoffset
By default shift_time = start_time (backwards compatible). Set shift_time = 0 for absolute time reference where phase has its exact physical meaning.
Note: the exponential damping envelope always uses (time - start_time) since damping is relative to when the signal activates, not the waveform time origin.
This component extends from BlockComponents.Interfaces.Signal
Usage
BlockComponents.Sources.ExpSine(start_time=0.0, offset=0.0, amplitude, damping, frequency, phase, shift_time=start_time, continuous=true)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
start_time | Time at which the signal starts changing from its offset value | s | 0.0 |
offset | Constant value added to the signal output | – | 0.0 |
amplitude | Maximum amplitude of the sine wave | – | |
damping | Coefficient controlling how quickly the sine wave decays | s-1 | |
frequency | Frequency of the sine wave oscillation | Hz | |
phase | Phase angle offset of the sine wave in radians | rad | |
shift_time | Time origin for the waveform (default: start_time for backwards compatibility; set to 0 for absolute time reference) | s | start_time |
continuous | If true, output is continuous at start_time by holding at the start value; if false, output is offset before start_time | – | true |
Connectors
y- This connector represents a real signal as an output from a component (RealOutput)
Behavior
Source
"""
Exponentially damped sine wave with configurable amplitude, frequency, and damping.
Generates a sinusoidal signal that exponentially decays over time based on the damping coefficient.
The signal remains at the offset value until the start time is reached, after which it follows the
equation:
```math
y = \text{offset} + \text{amplitude} \cdot e^{-\text{damping}\cdot(\text{time}-\text{start\_time})} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{shift\_time}) + \text{phase})
```
When `time < start_time`, the output depends on the `continuous` parameter:
- `continuous = true` (default): output equals the value the signal would have at `start_time`, ensuring value continuity (backwards compatible)
- `continuous = false`: output equals `offset`
By default `shift_time = start_time` (backwards compatible). Set `shift_time = 0` for
absolute time reference where `phase` has its exact physical meaning.
Note: the exponential damping envelope always uses `(time - start_time)` since damping
is relative to when the signal activates, not the waveform time origin.
"""
component ExpSine
extends BlockComponents.Interfaces.Signal
"Maximum amplitude of the sine wave"
parameter amplitude::Real
"Coefficient controlling how quickly the sine wave decays"
parameter damping::DampingCoefficient
"Frequency of the sine wave oscillation"
parameter frequency::Frequency
"Phase angle offset of the sine wave in radians"
parameter phase::Angle
"Time origin for the waveform (default: start_time for backwards compatibility; set to 0 for absolute time reference)"
parameter shift_time::Time = start_time
"If true, output is continuous at start_time by holding at the start value; if false, output is offset before start_time"
parameter continuous::Boolean = true
relations
y = offset + ifelse(continuous, amplitude * ifelse(time >= start_time, exp(-damping * (time - start_time)) * sin(2 * π * frequency * (time - shift_time) + phase), sin(2 * π * frequency * (start_time - shift_time) + phase)), ifelse(time >= start_time, amplitude * exp(-damping * (time - start_time)) * sin(2 * π * frequency * (time - shift_time) + phase), 0.0))
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/ExpSine.svg"}
}
}
endFlattened Source
"""
Exponentially damped sine wave with configurable amplitude, frequency, and damping.
Generates a sinusoidal signal that exponentially decays over time based on the damping coefficient.
The signal remains at the offset value until the start time is reached, after which it follows the
equation:
```math
y = \text{offset} + \text{amplitude} \cdot e^{-\text{damping}\cdot(\text{time}-\text{start\_time})} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{shift\_time}) + \text{phase})
```
When `time < start_time`, the output depends on the `continuous` parameter:
- `continuous = true` (default): output equals the value the signal would have at `start_time`, ensuring value continuity (backwards compatible)
- `continuous = false`: output equals `offset`
By default `shift_time = start_time` (backwards compatible). Set `shift_time = 0` for
absolute time reference where `phase` has its exact physical meaning.
Note: the exponential damping envelope always uses `(time - start_time)` since damping
is relative to when the signal activates, not the waveform time origin.
"""
component ExpSine
"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
"Maximum amplitude of the sine wave"
parameter amplitude::Real
"Coefficient controlling how quickly the sine wave decays"
parameter damping::DampingCoefficient
"Frequency of the sine wave oscillation"
parameter frequency::Frequency
"Phase angle offset of the sine wave in radians"
parameter phase::Angle
"Time origin for the waveform (default: start_time for backwards compatibility; set to 0 for absolute time reference)"
parameter shift_time::Time = start_time
"If true, output is continuous at start_time by holding at the start value; if false, output is offset before start_time"
parameter continuous::Boolean = true
relations
y = offset + ifelse(continuous, amplitude * ifelse(time >= start_time, exp(-damping * (time - start_time)) * sin(2 * π * frequency * (time - shift_time) + phase), sin(2 * π * frequency * (start_time - shift_time) + phase)), ifelse(time >= start_time, amplitude * exp(-damping * (time - start_time)) * sin(2 * π * frequency * (time - shift_time) + phase), 0.0))
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/ExpSine.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests