VoltageSource
Ideal voltage source whose output voltage is determined by a real input signal and a scaling parameter.
This component models an ideal voltage source. The voltage v
across its positive and negative pins (inherited from the TwoPin
base component) is determined by an external real input signal connected to its V
input port, and a unit parameter uV
. The signal at input V
is treated as a dimensionless value, which is then multiplied by the parameter uV
(which has units of Voltage) to produce the actual output voltage v
across the pins. The relationship is given by:
Where V
is the value of the signal at the RealInput
port.
This component extends from OnePort
Usage
VoltageSource(uV=1.0)
Connectors
p
- (Pin
)n
- (Pin
)V
- This connector represents a real signal as an input to a component (RealInput
)
Variables
Name | Description | Units |
---|---|---|
v | Voltage across the component (between pin p and pin n). | V |
i | Current flowing through the component (from pin p to pin n). | A |
Behavior
Source
# Ideal voltage source whose output voltage is determined by a real input signal and a scaling parameter.
#
# This component models an ideal voltage source. The voltage `v` across its positive and
# negative pins (inherited from the `TwoPin` base component) is determined by an
# external real input signal connected to its `V` input port, and a unit
# parameter `uV`. The signal at input `V` is treated as a dimensionless value,
# which is then multiplied by the parameter `uV` (which has units of Voltage)
# to produce the actual output voltage `v` across the pins.
# The relationship is given by:
# ```math
# v = V uV
# ```
# Where `V` is the value of the signal at the `RealInput` port.
component VoltageSource
extends OnePort
# External real input signal that provides the base value for the source voltage.
V = RealInput() [{
"Dyad": {"placement": {"icon": {"x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 90}}}
}]
# Unit parameter to balance units in voltage relation.
final parameter uV::Voltage = 1.0
relations
v = V*uV
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://ElectricalComponents/Voltage.svg"}
}
}
end
Flattened Source
# Ideal voltage source whose output voltage is determined by a real input signal and a scaling parameter.
#
# This component models an ideal voltage source. The voltage `v` across its positive and
# negative pins (inherited from the `TwoPin` base component) is determined by an
# external real input signal connected to its `V` input port, and a unit
# parameter `uV`. The signal at input `V` is treated as a dimensionless value,
# which is then multiplied by the parameter `uV` (which has units of Voltage)
# to produce the actual output voltage `v` across the pins.
# The relationship is given by:
# ```math
# v = V uV
# ```
# Where `V` is the value of the signal at the `RealInput` port.
component VoltageSource
# Positive electrical pin.
p = Pin() [{
"Dyad": {
"placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
}
}]
# Negative electrical pin.
n = Pin() [{
"Dyad": {
"placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
}
}]
# Voltage across the component (between pin p and pin n).
variable v::Voltage
# Current flowing through the component (from pin p to pin n).
variable i::Current
# External real input signal that provides the base value for the source voltage.
V = RealInput() [{
"Dyad": {"placement": {"icon": {"x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 90}}}
}]
# Unit parameter to balance units in voltage relation.
final parameter uV::Voltage = 1.0
relations
v = p.v-n.v
i = p.i
p.i+n.i = 0
v = V*uV
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://ElectricalComponents/Voltage.svg"}
}
}
end
Test Cases
This is setup code, that must be run before each test case.
using ElectricalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames
snapshotsdir = joinpath(dirname(dirname(pathof(ElectricalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/ElectricalComponents/bmmPM/test/snapshots"
Related
Examples
Experiments
Analyses
Tests