This package contains the SPICE sources.
Note: There are differences between SPICE3 and Modelica concerning the default values of the parameter. Therefore it is recommended to specify all parameters of the source.
Extends from Modelica.Icons.SourcesPackage (Icon for packages containing sources).
Name | Description |
---|---|
V_constant | Constant independent voltage sources |
V_sin | Sinusoidal voltage source |
V_exp | Exponential voltage source |
V_pulse | Pulse voltage source |
V_pwl | Piece-wise linear voltage source |
V_sffm | Single-frequency FM voltage source |
I_constant | Constant independent current sources |
I_sin | Sinusoidal current source |
I_exp | Exponential current source |
I_pulse | Pulse current source |
I_pwl | Piece-wise linear current source |
I_sffm | Single-frequency FM current source |
The V_constant source is a source is a simple constant voltage source for an ideal constant voltage which is provided by a parameter.
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Voltage | V | 1 | Value of constant voltage [V] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model V_constant "Constant independent voltage sources" parameter SI.Voltage V=1 "Value of constant voltage"; extends Modelica.Electrical.Analog.Interfaces.OnePort; equation v = V;end V_constant;
Damped sinusoidal source
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Voltage | VO | 0.0 | Offset [V] |
Voltage | VA | 0.0 | Amplitude [V] |
Frequency | FREQ | Frequency [Hz] | |
Time | TD | 0.0 | Delay [s] |
Damping | THETA | 0.0 | Damping factor [s-1] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model V_sin "Sinusoidal voltage source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Voltage VO=0.0 "Offset"; parameter SI.Voltage VA=0.0 "Amplitude"; parameter SI.Frequency FREQ(start=1) "Frequency"; parameter SI.Time TD=0.0 "Delay"; parameter SI.Damping THETA=0.0 "Damping factor"; protected constant Real pi=Modelica.Constants.pi; equation assert(FREQ>0, "Frequency less or equal zero"); v = VO + (if time < TD then 0 else VA* Modelica.Math.exp(-(time - TD)*THETA)*Modelica.Math.sin(2*pi *FREQ*(time - TD)));end V_sin;
Rising and falling exponential source.
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Voltage | V1 | 0 | Initial value [V] |
Voltage | V2 | 0 | Pulsed value [V] |
Time | TD1 | 0.0 | Rise delay time [s] |
Time | TAU1 | 1 | Rise time constant [s] |
Time | TD2 | 1 | Fall delay time [s] |
Time | TAU2 | 1 | Fall time constant [s] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model V_exp "Exponential voltage source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Voltage V1=0 "Initial value"; parameter SI.Voltage V2=0 "Pulsed value"; parameter SI.Time TD1=0.0 "Rise delay time"; parameter SI.Time TAU1=1 "Rise time constant"; parameter SI.Time TD2=1 "Fall delay time"; parameter SI.Time TAU2=1 "Fall time constant"; equation v = V1 + (if (time < TD1) then 0 else if (time < (TD2)) then (V2-V1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) else (V2-V1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) + (V1-V2)*(1 - Modelica.Math.exp(-(time - TD2)/TAU2)));end V_exp;
Periodic pulse source with not limited number of periods.
A single pulse is described by the following table:
time |
value |
0 |
V1 |
TD |
V1 |
TD+TR |
V2 |
TD+TR+PW |
V2 |
TD+TR+PW+TF |
V1 |
TSTOP |
V1 |
Intermediate points are determined by linear interpolation.
A pulse it looks like a saw tooth, use this parameters e.g.:
Parameter |
Value |
V1 |
0 |
V2 |
1 |
TD |
0 |
TR |
1 |
TF |
1 |
PW |
2 |
PER |
1 |
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Voltage | V1 | 0 | Initial value [V] |
Voltage | V2 | 0 | Pulsed value [V] |
Time | TD | 0.0 | Delay time [s] |
Time | TR | Rise time [s] | |
Time | TF | TR | Fall time [s] |
Time | PW | Modelica.Constants.inf | Pulse width [s] |
Time | PER | Modelica.Constants.inf | Period [s] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model V_pulse "Pulse voltage source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Voltage V1 = 0 "Initial value"; parameter SI.Voltage V2 = 0 "Pulsed value"; parameter SI.Time TD = 0.0 "Delay time"; parameter SI.Time TR(start=1) "Rise time"; parameter SI.Time TF = TR "Fall time"; parameter SI.Time PW = Modelica.Constants.inf "Pulse width"; parameter SI.Time PER= Modelica.Constants.inf "Period"; protected parameter SI.Time Trising=TR "End time of rising phase within one period"; parameter SI.Time Twidth=Trising + PW "End time of width phase within one period"; parameter SI.Time Tfalling=Twidth + TF "End time of falling phase within one period"; SI.Time T0(final start=TD) "Start time of current period"; Integer counter(start=-1) "Period counter"; Integer counter2(start=-1); equation when pre(counter2) <> 0 and sample(TD, PER) then T0 = time; counter2 = pre(counter); counter = pre(counter) - (if pre(counter) > 0 then 1 else 0); end when; v = V1 + (if (time < TD or counter2 == 0 or time >= T0 + Tfalling) then 0 else if (time < T0 + Trising) then (time - T0)* (V2-V1)/Trising else if (time < T0 + Twidth) then V2-V1 else (T0 + Tfalling - time)*(V2-V1)/(Tfalling - Twidth));end V_pulse;
This model generates a voltage by linear interpolation in a given table. The time points and voltage values are stored in a matrix table[i,j], where the first column table[:,1] contains the time points and the second column contains the voltage to be interpolated. The table interpolation has the following proporties:
Example:
table = [0 0 1 0 1 1 2 4 3 9 4 16] If, e.g., time = 1.0, the voltage v = 0.0 (before event), 1.0 (after event) e.g., time = 1.5, the voltage v = 2.5, e.g., time = 2.0, the voltage v = 4.0, e.g., time = 5.0, the voltage v = 23.0 (i.e., extrapolation).
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Real | table[:, :] | [0, 0; 1, 1; 2, 4] | Table matrix (time = first column, voltage = second column) |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model V_pwl "Piece-wise linear voltage source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter Real table[:, :]=[0, 0; 1, 1; 2, 4] "Table matrix (time = first column, voltage = second column)"; Modelica.Blocks.Sources.TimeTable tab(table=table); equation v = tab.y;end V_pwl;
The single-frequency frequency modulation source generates a carrier signal of the frequency FC. This signal is modulated by the signal frequency FS. See the formula in the modelica text.
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Voltage | VO | 0 | Offset [V] |
Voltage | VA | 0 | Amplitude [V] |
Frequency | FC | Carrier frequency [Hz] | |
Real | MDI | 0 | Modulation index |
Frequency | FS | FC | Singnal frequency [Hz] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model V_sffm "Single-frequency FM voltage source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Voltage VO = 0 "Offset"; parameter SI.Voltage VA = 0 "Amplitude"; parameter SI.Frequency FC( start=0) "Carrier frequency"; parameter Real MDI=0 "Modulation index"; parameter SI.Frequency FS= FC "Singnal frequency"; protected constant Real pi=Modelica.Constants.pi; equation v = VO + VA *Modelica.Math.sin( 2 *pi * FC *time + MDI *Modelica.Math.sin(2 *pi *FS *time));end V_sffm;
The I_constant source is a simple constant current source for an ideal constant current which is provided by a parameter.
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Current | I | 1 | Value of constant voltage [A] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model I_constant "Constant independent current sources" parameter SI.Current I=1 "Value of constant voltage"; extends Modelica.Electrical.Analog.Interfaces.OnePort; equation i = I;end I_constant;
Damped sinusoidal source
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Current | IO | 0 | Offset [A] |
Current | IA | 0 | Amplitude [A] |
Frequency | FREQ | Frequency [Hz] | |
Time | TD | 0.0 | Delay [s] |
Damping | THETA | 0.0 | Damping factor [s-1] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model I_sin "Sinusoidal current source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Current IO=0 "Offset"; parameter SI.Current IA=0 "Amplitude"; parameter SI.Frequency FREQ(start=1) "Frequency"; parameter SI.Time TD=0.0 "Delay"; parameter SI.Damping THETA=0.0 "Damping factor"; protected constant Real pi=Modelica.Constants.pi; equation assert(FREQ>0, "Frequency less or equal zero"); i = IO + (if time < TD then 0 else IA* Modelica.Math.exp(-(time - TD)*THETA)*Modelica.Math.sin(2*pi *FREQ*(time - TD)));end I_sin;
Rising and falling exponential source.
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Current | I1 | 0 | Initial value [A] |
Current | I2 | 0 | Pulsed value [A] |
Time | TD1 | 0.0 | Rise delay time [s] |
Time | TAU1 | 1 | Rise time constant [s] |
Time | TD2 | 2 | Fall delay time [s] |
Time | TAU2 | 1 | Fall time constant [s] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model I_exp "Exponential current source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Current I1=0 "Initial value"; parameter SI.Current I2=0 "Pulsed value"; parameter SI.Time TD1=0.0 "Rise delay time"; parameter SI.Time TAU1=1 "Rise time constant"; parameter SI.Time TD2=2 "Fall delay time"; parameter SI.Time TAU2=1 "Fall time constant"; equation i = I1 + (if (time < TD1) then 0 else if (time < (TD2)) then (I2-I1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) else (I2-I1)*(1 - Modelica.Math.exp(-(time - TD1)/TAU1)) + (I1-I2)*(1 - Modelica.Math.exp(-(time - TD2)/TAU2)));end I_exp;
Periodic pulse source with not limited number of periods.
A single pulse is described by the following table:
time |
value |
0 |
I1 |
TD |
I1 |
TD+TR |
I2 |
TD+TR+PW |
I2 |
TD+TR+PW+TF |
I1 |
TSTOP |
I1 |
Intermediate points are determined by linear interpolation.
A pulse it looks like a saw tooth, use this parameters e.g.:
Parameter |
Value |
I1 |
0 |
I2 |
1 |
TD |
0 |
TR |
1 |
TF |
1 |
PW |
2 |
PER |
1 |
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Current | I1 | 0 | Initial value [A] |
Current | I2 | 0 | Pulsed value [A] |
Time | TD | 0.0 | Delay time [s] |
Time | TR | Rise time [s] | |
Time | TF | TR | Fall time [s] |
Time | PW | Modelica.Constants.inf | Pulse width [s] |
Time | PER | Modelica.Constants.inf | Period [s] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model I_pulse "Pulse current source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Current I1 = 0 "Initial value"; parameter SI.Current I2 = 0 "Pulsed value"; parameter SI.Time TD = 0.0 "Delay time"; parameter SI.Time TR(start=1) "Rise time"; parameter SI.Time TF = TR "Fall time"; parameter SI.Time PW = Modelica.Constants.inf "Pulse width"; parameter SI.Time PER= Modelica.Constants.inf "Period"; protected parameter SI.Time Trising=TR "End time of rising phase within one period"; parameter SI.Time Twidth=Trising + PW "End time of width phase within one period"; parameter SI.Time Tfalling=Twidth + TF "End time of falling phase within one period"; SI.Time T0(final start=TD) "Start time of current period"; Integer counter(start=-1) "Period counter"; Integer counter2(start=-1); equation when pre(counter2) <> 0 and sample(TD, PER) then T0 = time; counter2 = pre(counter); counter = pre(counter) - (if pre(counter) > 0 then 1 else 0); end when; i = I1 + (if (time < TD or counter2 == 0 or time >= T0 + Tfalling) then 0 else if (time < T0 + Trising) then (time - T0)* (I2-I1)/Trising else if (time < T0 + Twidth) then I2-I1 else (T0 + Tfalling - time)*(I2-I1)/(Tfalling - Twidth));end I_pulse;
This model generates a current by linear interpolation in a given table. The time points and current values are stored in a matrix table[i,j], where the first column table[:,1] contains the time points and the second column contains the current to be interpolated. The table interpolation has the following proporties:
Example:
table = [0 0 1 0 1 1 2 4 3 9 4 16] If, e.g., time = 1.0, the current i = 0.0 (before event), 1.0 (after event) e.g., time = 1.5, the current i = 2.5, e.g., time = 2.0, the current i = 4.0, e.g., time = 5.0, the current i = 23.0 (i.e., extrapolation).
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Real | table[:, :] | [0, 0; 1, 1; 2, 4] | Table matrix (time = first column, voltage = second column) |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model I_pwl "Piece-wise linear current source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter Real table[:, :]=[0, 0; 1, 1; 2, 4] "Table matrix (time = first column, voltage = second column)"; Modelica.Blocks.Sources.TimeTable tab(table=table); equation i = tab.y;end I_pwl;
The single-frequency frequency modulation source generates a carrier signal of the frequency FC. This signal is modulated by the signal frequency FS. See the formula in the modelica text.
Extends from Modelica.Electrical.Analog.Interfaces.OnePort (Component with two electrical pins p and n and current i from p to n).
Type | Name | Default | Description |
---|---|---|---|
Current | IO | 0 | Offset [A] |
Current | IA | 0 | Amplitude [A] |
Frequency | FC | Carrier frequency [Hz] | |
Real | MDI | 0 | Modulation index |
Frequency | FS | FC | Singnal frequency [Hz] |
Type | Name | Description |
---|---|---|
PositivePin | p | Positive pin (potential p.v > n.v for positive voltage drop v) |
NegativePin | n | Negative pin |
model I_sffm "Single-frequency FM current source" extends Modelica.Electrical.Analog.Interfaces.OnePort; parameter SI.Current IO = 0 "Offset"; parameter SI.Current IA = 0 "Amplitude"; parameter SI.Frequency FC( start=0) "Carrier frequency"; parameter Real MDI=0 "Modulation index"; parameter SI.Frequency FS= FC "Singnal frequency"; protected constant Real pi=Modelica.Constants.pi; equation i = IO + IA *Modelica.Math.sin( 2 *pi * FC *time + MDI *Modelica.Math.sin(2 *pi *FS *time));end I_sffm;