Analog.Basic.VariableCapacitor
Ideal linear electrical capacitor with variable capacitance.
The capacitance value C is provided as an external input signal. A lower bound Cmin prevents the effective capacitance from reaching zero, which would cause a variable index change:
The branch current follows from the time derivative of charge:
This charge-based formulation correctly accounts for time-varying capacitance, producing i = C \dot{v} + \dot{C} v.
Corresponds to Modelica.Electrical.Analog.Basic.VariableCapacitor.
This component extends from ElectricalComponents.Analog.Interfaces.OnePort
Usage
ElectricalComponents.Analog.Basic.VariableCapacitor(Cmin=1e-16)
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
Cmin | Lower bound for variable capacitance | F | 1e-16 |
Connectors
p- This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)n- This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. (Pin)C- 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 |
Q | Electric charge stored in the capacitor | C |
Behavior
Source
"""
Ideal linear electrical capacitor with variable capacitance.
The capacitance value `C` is provided as an external input signal.
A lower bound `Cmin` prevents the effective capacitance from reaching
zero, which would cause a variable index change:math Q = \max(C, C_{min}) \cdot v
The branch current follows from the time derivative of charge:math i = \frac{dQ}
This charge-based formulation correctly accounts for time-varying
capacitance, producing `i = C \dot{v} + \dot{C} v`.
Corresponds to `Modelica.Electrical.Analog.Basic.VariableCapacitor`.
"""
component VariableCapacitor
extends ElectricalComponents.Analog.Interfaces.OnePort
"Capacitance input signal"
C = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": -100, "x2": 550, "y2": 0, "rot": 90}
},
"tags": []
}
}
"Lower bound for variable capacitance"
parameter Cmin::Capacitance = 1e-16
"Electric charge stored in the capacitor"
variable Q::ElectricCharge
relations
assert(C >= 0, "Capacitance C has to be >= 0!")
Q = max(C, Cmin) * v
i = der(Q)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://ElectricalComponents/Capacitor.svg"}
}
}
endFlattened Source
"""
Ideal linear electrical capacitor with variable capacitance.
The capacitance value `C` is provided as an external input signal.
A lower bound `Cmin` prevents the effective capacitance from reaching
zero, which would cause a variable index change:math Q = \max(C, C_{min}) \cdot v
The branch current follows from the time derivative of charge:math i = \frac{dQ}
This charge-based formulation correctly accounts for time-varying
capacitance, producing `i = C \dot{v} + \dot{C} v`.
Corresponds to `Modelica.Electrical.Analog.Basic.VariableCapacitor`.
"""
component VariableCapacitor
"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
"Capacitance input signal"
C = RealInput() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 450, "y1": -100, "x2": 550, "y2": 0, "rot": 90}
},
"tags": []
}
}
"Lower bound for variable capacitance"
parameter Cmin::Capacitance = 1e-16
"Electric charge stored in the capacitor"
variable Q::ElectricCharge
relations
v = p.v - n.v
i = p.i
p.i + n.i = 0
assert(C >= 0, "Capacitance C has to be >= 0!")
Q = max(C, Cmin) * v
i = der(Q)
metadata {
"Dyad": {
"labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
"icons": {"default": "dyad://ElectricalComponents/Capacitor.svg"}
}
}
endTest Cases
No test cases defined.
Related
Examples
Experiments
Analyses
Tests