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:
This component extends from Signal
Usage
ExpSine(start_time=0.0, offset=0.0, amplitude, damping, frequency, phase)
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 | 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 |
Connectors
y
- This connector represents a real signal as an output from a component (RealOutput
)
Behavior
Source
dyad
# 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(t) = \text{offset} + \text{amplitude} \cdot e^{-\text{damping}\cdot(t-t_{\text{start}})} \cdot \sin(2\pi \cdot \text{frequency} \cdot (t-t_{\text{start}}) + \text{phase})
# ```
component ExpSine
extends 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
relations
y = if start_time<time then offset+amplitude*exp(-damping*(time-start_time))*sin(2*π*frequency*(time-start_time)+phase) else offset
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/ExpSine.svg"}}}
end
Flattened Source
dyad
# 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(t) = \text{offset} + \text{amplitude} \cdot e^{-\text{damping}\cdot(t-t_{\text{start}})} \cdot \sin(2\pi \cdot \text{frequency} \cdot (t-t_{\text{start}}) + \text{phase})
# ```
component ExpSine
# Real-valued output connector for the component
y = RealOutput() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
# 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
relations
y = if start_time<time then offset+amplitude*exp(-damping*(time-start_time))*sin(2*π*frequency*(time-start_time)+phase) else offset
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/ExpSine.svg"}}}
end
Test Cases
This is setup code, that must be run before each test case.
julia
using BlockComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames
snapshotsdir = joinpath(dirname(dirname(pathof(BlockComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/BlockComponents/77kIK/test/snapshots"
Related
Examples
Experiments
Analyses
Tests