CosineVariableFrequencyAndAmplitude
Cosine voltage source with variable frequency and amplitude
Variable cosine generator with externally controlled amplitude and frequency inputs. The component generates a cosine waveform based on integration of the frequency input:
+––––––+ | amplitude | +––-+–––+ | v +––––––+ | | | Cosine +––> y | Generator | | | +––––––+ ^ | +––-+–––+ | frequency | +––––––+
Usage
BlockComponents.CosineVariableFrequencyAndAmplitude(phi0=0, offset=0)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
phi0 | Initial phase of the cosine wave | – | 0 |
offset | Offset of the cosine wave | – | 0 |
Connectors
amplitude- This connector represents a real signal as an input to a component (RealInput)frequency- This connector represents a real signal as an input to a component (RealInput)y- This connector represents a real signal as an output from a component (RealOutput)
Variables
| Name | Description | Units |
|---|---|---|
phi | Phase of the cosine wave | rad |
Behavior
Source
dyad
# Cosine voltage source with variable frequency and amplitude
#
# Variable cosine generator with externally controlled amplitude and frequency inputs.
# The component generates a cosine waveform based on integration of the frequency input:
#
# +------------+
# | amplitude |
# +-----+------+
# |
# v
# +------------+
# | |
# | Cosine +----> y
# | Generator |
# | |
# +------------+
# ^
# |
# +-----+------+
# | frequency |
# +------------+
#
# ```math
# \frac{d\phi}{dt} = 2\pi \cdot frequency
# ```
#
# ```math
# y = offset + amplitude \cdot \cos(\phi)
# ```
component CosineVariableFrequencyAndAmplitude
# Input port for the amplitude of the cosine wave
amplitude = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 190, "x2": 0, "y2": 290, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 190, "x2": 0, "y2": 290, "rot": 0}
}
}
}
# Input port for the frequency of the cosine wave in Hz
frequency = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0}
}
}
}
# Output port for the resulting cosine waveform
y = RealOutput() {
"Dyad": {
"placement": {
"icon": {
"iconName": "default",
"x1": 1100,
"y1": 450,
"x2": 1000,
"y2": 550,
"rot": 180
},
"diagram": {
"iconName": "default",
"x1": 1100,
"y1": 450,
"x2": 1000,
"y2": 550,
"rot": 180
}
}
}
}
# Initial phase of the cosine wave
parameter phi0::Real = 0
# Offset of the cosine wave
parameter offset::Real = 0
# Phase of the cosine wave
variable phi::Angle
relations
initial phi = phi0
der(phi) = 2 * π * frequency
y = offset + amplitude * cos(phi)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/CosineVariableFrequencyAndAmplitude.svg"}
}
}
endFlattened Source
dyad
# Cosine voltage source with variable frequency and amplitude
#
# Variable cosine generator with externally controlled amplitude and frequency inputs.
# The component generates a cosine waveform based on integration of the frequency input:
#
# +------------+
# | amplitude |
# +-----+------+
# |
# v
# +------------+
# | |
# | Cosine +----> y
# | Generator |
# | |
# +------------+
# ^
# |
# +-----+------+
# | frequency |
# +------------+
#
# ```math
# \frac{d\phi}{dt} = 2\pi \cdot frequency
# ```
#
# ```math
# y = offset + amplitude \cdot \cos(\phi)
# ```
component CosineVariableFrequencyAndAmplitude
# Input port for the amplitude of the cosine wave
amplitude = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 190, "x2": 0, "y2": 290, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 190, "x2": 0, "y2": 290, "rot": 0}
}
}
}
# Input port for the frequency of the cosine wave in Hz
frequency = RealInput() {
"Dyad": {
"placement": {
"icon": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0},
"diagram": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0}
}
}
}
# Output port for the resulting cosine waveform
y = RealOutput() {
"Dyad": {
"placement": {
"icon": {
"iconName": "default",
"x1": 1100,
"y1": 450,
"x2": 1000,
"y2": 550,
"rot": 180
},
"diagram": {
"iconName": "default",
"x1": 1100,
"y1": 450,
"x2": 1000,
"y2": 550,
"rot": 180
}
}
}
}
# Initial phase of the cosine wave
parameter phi0::Real = 0
# Offset of the cosine wave
parameter offset::Real = 0
# Phase of the cosine wave
variable phi::Angle
relations
initial phi = phi0
der(phi) = 2 * π * frequency
y = offset + amplitude * cos(phi)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://BlockComponents/CosineVariableFrequencyAndAmplitude.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests