Skip to content

Commit adff32c

Browse files
authored
Simplification in the code and comments, renaming a few files and classes. Deleting some extra features in grid converter control. Implementation of the frequency converter with diode bridge is partly reverted to the earlier version for its simpler usage. (#138)
1 parent 75aef83 commit adff32c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+657
-1205
lines changed

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
"../../examples/obs_vhz",
7474
"../../examples/flux_vector",
7575
"../../examples/signal_inj",
76+
"../../examples/grid_following",
77+
"../../examples/grid_forming",
7678
]),
7779
}
7880

docs/source/model/converters.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
Converters
22
==========
33

4-
Inverter
5-
--------
4+
Voltage-Source Converter
5+
------------------------
66

7-
The figure below shows a three-phase two-level inverter and its equivalent model, where ideal switches are assumed. In the equivalent model, each changeover switch is connected to either negative or positive potential of the DC bus. The switching phenomena are assumed to be infinitely fast. The inverter model is provided in the class :class:`motulator.drive.model.Inverter`.
7+
The figure below shows a three-phase two-level voltage-source converter and its equivalent model, where ideal switches are assumed. This converter can operate both as an inverter and a rectifier, depending on the direction of the power flow. In the equivalent model, each changeover switch is connected to either negative or positive potential of the DC bus. The switching phenomena are assumed to be infinitely fast. The converter model is provided in the class :class:`motulator.drive.model.VoltageSourceConverter`.
88

99

1010
.. figure:: figs/inverter.svg
1111
:width: 100%
1212
:align: center
13-
:alt: Three-phase two-level inverter
13+
:alt: Three-phase two-level voltage-source converter
1414
:target: .
1515

16-
Three-phase two-level inverter: (left) main circuit; (right) equivalent model. The DC-bus voltage and currents are :math:`u_\mathrm{dc}` and :math:`i_\mathrm{dc}`, respectively.
16+
Three-phase two-level voltage-source converter: (left) main circuit; (right) equivalent model. The DC-bus voltage and currents are :math:`u_\mathrm{dc}` and :math:`i_\mathrm{dc}`, respectively.
1717

1818
Six-Pulse Diode Bridge
1919
----------------------
@@ -31,12 +31,12 @@ The figure below shows a six-pulse diode bridge rectifier, where the inductor :m
3131
Carrier Comparison
3232
------------------
3333

34-
The figure below shows an inverter equipped with a generic three-phase load. In pulse-width modulation (PWM), carrier comparison is commonly used to generate instantaneous switching state signals :math:`q_\mathrm{a}`, :math:`q_\mathrm{b}`, and :math:`q_\mathrm{c}` from duty ratios :math:`d_\mathrm{a}`, :math:`d_\mathrm{b}`, and :math:`d_\mathrm{c}`. The duty ratios are continuous signals in the range [0, 1} while the switching states are either 0 or 1.
34+
The figure below shows a converter equipped with a generic three-phase load. In pulse-width modulation (PWM), carrier comparison is commonly used to generate instantaneous switching state signals :math:`q_\mathrm{a}`, :math:`q_\mathrm{b}`, and :math:`q_\mathrm{c}` from duty ratios :math:`d_\mathrm{a}`, :math:`d_\mathrm{b}`, and :math:`d_\mathrm{c}`. The duty ratios are continuous signals in the range [0, 1} while the switching states are either 0 or 1.
3535

3636
.. figure:: figs/pwm_inverter.svg
3737
:width: 100%
3838
:align: center
39-
:alt: Inverter and carrier comparison
39+
:alt: Voltage-source converter and carrier comparison
4040
:target: .
4141

4242
Instantaneous switching states are defined by the carrier comparison. In this example, the switching states are :math:`q_\mathrm{a}=1`, :math:`q_\mathrm{b}=0`, and :math:`q_\mathrm{c}=0`.

docs/source/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ After :doc:`installation`, *motulator* can be used by creating a continuous-time
1111
from motulator.drive.utils import plot # Example plotting functions
1212
1313
# Continuous-time model for the drive system
14-
converter = model.Inverter(u_dc=540)
14+
converter = model.VoltageSourceConverter(u_dc=540)
1515
machine = model.InductionMachineInvGamma(
1616
R_s=3.7, R_R=2.1, L_sgm=.021, L_M=.224, n_p=2)
1717
mechanics = model.StiffMechanicalSystem(J=.015)

examples/flux_vector/plot_flux_vector_pmsm_2kw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
n_p=3, R_s=3.6, L_d=.036, L_q=.051, psi_f=.545)
2626
machine = model.SynchronousMachine(mdl_par)
2727
mechanics = model.StiffMechanicalSystem(J=.015)
28-
converter = model.Inverter(u_dc=540)
28+
converter = model.VoltageSourceConverter(u_dc=540)
2929
mdl = model.Drive(converter, machine, mechanics)
3030

3131
# %%

examples/flux_vector/plot_flux_vector_pmsyrm_5kw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def i_s(psi_s):
152152
# n_p=2, R_s=.63, L_d=18e-3, L_q=110e-3, psi_f=.47)
153153
# machine = model.SynchronousMachine(mdl_par)
154154
mechanics = model.StiffMechanicalSystem(J=.015)
155-
converter = model.Inverter(u_dc=540)
155+
converter = model.VoltageSourceConverter(u_dc=540)
156156
mdl = model.Drive(converter, machine, mechanics)
157157

158158
# %%

examples/flux_vector/plot_flux_vector_syrm_7kw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def i_s(psi_s):
5656
# n_p=2, R_s=.54, L_d=37e-3, L_q=6.2e-3, psi_f=0)
5757
# machine = model.SynchronousMachine(mdl_par)
5858
mechanics = model.StiffMechanicalSystem(J=.015)
59-
converter = model.Inverter(u_dc=540)
59+
converter = model.VoltageSourceConverter(u_dc=540)
6060
mdl = model.Drive(converter, machine, mechanics)
6161

6262
# %%
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
10-kVA grid-following converter, power control
3-
==============================================
2+
10-kVA converter
3+
================
44
55
This example simulates a grid-following-controlled converter connected to a
66
strong grid. The control system includes a phase-locked loop (PLL) to
@@ -10,20 +10,14 @@
1010
"""
1111

1212
# %%
13-
import numpy as np
14-
15-
from motulator.common.model import (
16-
CarrierComparison,
17-
Inverter,
18-
Simulation,
19-
)
20-
from motulator.common.utils import (
21-
BaseValues,
22-
NominalValues,
23-
)
13+
from motulator.common.model import VoltageSourceConverter, Simulation
14+
from motulator.common.utils import BaseValues, NominalValues
2415
from motulator.grid import model
2516
import motulator.grid.control.grid_following as control
26-
from motulator.grid.utils import FilterPars, GridPars, plot_grid, plot_voltage_vector
17+
from motulator.grid.utils import FilterPars, GridPars, plot_grid
18+
# from motulator.grid.utils import plot_voltage_vector
19+
# from motulator.common.model import CarrierComparison
20+
# import numpy as np
2721

2822
# %%
2923
# Compute base values based on the nominal values.
@@ -38,32 +32,30 @@
3832
grid_par = GridPars(u_gN=base.u, w_gN=base.w)
3933

4034
# Filter parameters
41-
filter_par = FilterPars(L_fc=0.2*base.L)
35+
filter_par = FilterPars(L_fc=.2*base.L)
4236

4337
# Create AC filter with given parameters
44-
grid_filter = model.GridFilter(filter_par, grid_par)
38+
ac_filter = model.ACFilter(filter_par, grid_par)
4539

4640
# AC grid model with constant voltage magnitude and frequency
47-
grid_model = model.StiffSource(w_g=grid_par.w_gN, e_g_abs=grid_par.u_gN)
41+
grid_model = model.ThreePhaseVoltageSource(
42+
w_g=grid_par.w_gN, abs_e_g=grid_par.u_gN)
4843

4944
# Inverter with constant DC voltage
50-
converter = Inverter(u_dc=650)
45+
converter = VoltageSourceConverter(u_dc=650)
5146

5247
# Create system model
53-
mdl = model.GridConverterSystem(converter, grid_filter, grid_model)
48+
mdl = model.GridConverterSystem(converter, ac_filter, grid_model)
5449

5550
# Uncomment line below to enable the PWM model
56-
#mdl.pwm = CarrierComparison()
51+
# mdl.pwm = CarrierComparison()
5752

5853
# %%
5954
# Configure the control system.
6055

6156
# Control configuration parameters
6257
cfg = control.GFLControlCfg(
63-
grid_par=grid_par,
64-
filter_par=filter_par,
65-
i_max=1.5*base.i,
66-
)
58+
grid_par=grid_par, filter_par=filter_par, max_i=1.5*base.i)
6759

6860
# Create the control system
6961
ctrl = control.GFLControl(cfg)
@@ -72,13 +64,13 @@
7264
# Set the time-dependent reference and disturbance signals.
7365

7466
# Set the active and reactive power references
75-
ctrl.ref.p_g = lambda t: (t > 0.02)*(5e3)
76-
ctrl.ref.q_g = lambda t: (t > 0.04)*(4e3)
67+
ctrl.ref.p_g = lambda t: (t > .02)*5e3
68+
ctrl.ref.q_g = lambda t: (t > .04)*4e3
7769

78-
# Uncomment lines below to simulate a nonsymmetric fault (add negative sequence)
79-
#mdl.grid_model.par.e_g_abs = 0.75*base.u
80-
#mdl.grid_model.par.e_g_neg_abs = 0.25*base.u
81-
#mdl.grid_model.par.phi_neg = -np.pi/3
70+
# Uncomment lines below to simulate a unbalanced fault (add negative sequence)
71+
# mdl.grid_model.par.abs_e_g = 0.75*base.u
72+
# mdl.grid_model.par.abs_e_g_neg = 0.25*base.u
73+
# mdl.grid_model.par.phi_neg = -np.pi/3
8274

8375
# %%
8476
# Create the simulation object and simulate it.
@@ -93,6 +85,5 @@
9385
# `base` you can plot the results in SI units.
9486

9587
# Uncomment line below to plot locus of the grid voltage space vector
96-
#plot_voltage_vector(sim=sim, base=base)
97-
98-
plot_grid(sim=sim, base=base, plot_pcc_voltage=True)
88+
# plot_voltage_vector(sim, base)
89+
plot_grid(sim, base, plot_pcc_voltage=True)
Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
"""
2-
10-kVA grid-following converter, DC-bus voltage control
3-
=======================================================
2+
10-kVA converter, DC-bus voltage
3+
================================
44
55
This example simulates a grid-following-controlled converter connected to a
6-
strong grid and regulating the DC-bus voltage at the same time. The control
7-
system includes a DC-bus voltage controller, a phase-locked loop (PLL) to
8-
synchronize with the grid, a current reference generator, and a PI-based
9-
current controller.
6+
strong grid and regulating the DC-bus voltage. The control system includes a
7+
DC-bus voltage controller, a phase-locked loop (PLL) to synchronize with the
8+
grid, a current reference generator, and a PI-type current controller.
109
1110
"""
1211

1312
# %%
14-
from motulator.common.model import (
15-
CarrierComparison,
16-
Inverter,
17-
Simulation,
18-
)
19-
from motulator.common.utils import (
20-
BaseValues,
21-
NominalValues,
22-
)
13+
from motulator.common.model import VoltageSourceConverter, Simulation
14+
from motulator.common.utils import BaseValues, NominalValues
2315
from motulator.grid import model
2416
import motulator.grid.control.grid_following as control
2517
from motulator.grid.control import DCBusVoltageController
@@ -38,35 +30,33 @@
3830
grid_par = GridPars(u_gN=base.u, w_gN=base.w)
3931

4032
# Filter parameters
41-
filter_par = FilterPars(L_fc=0.2*base.L)
33+
filter_par = FilterPars(L_fc=.2*base.L)
4234

4335
# Create AC filter with given parameters
44-
grid_filter = model.GridFilter(filter_par, grid_par)
36+
ac_filter = model.ACFilter(filter_par, grid_par)
4537

4638
# AC-voltage magnitude (to simulate voltage dips or short-circuits)
47-
e_g_abs_var = lambda t: base.u
39+
abs_e_g_var = lambda t: base.u
4840

4941
# AC grid model with constant voltage magnitude and frequency
50-
grid_model = model.StiffSource(w_g=grid_par.w_gN, e_g_abs=e_g_abs_var)
51-
52-
# DC-bus parameters
53-
C_dc = 1e-3
42+
grid_model = model.ThreePhaseVoltageSource(
43+
w_g=grid_par.w_gN, abs_e_g=abs_e_g_var)
5444

5545
# Inverter model with DC-bus dynamics included
56-
converter = Inverter(u_dc=600, C_dc=C_dc)
46+
converter = VoltageSourceConverter(u_dc=600, C_dc=1e-3)
5747

5848
# Create system model
59-
mdl = model.GridConverterSystem(converter, grid_filter, grid_model)
49+
mdl = model.GridConverterSystem(converter, ac_filter, grid_model)
6050

6151
# %%
6252
# Configure the control system.
6353

6454
# Control parameters
6555
cfg = control.GFLControlCfg(
6656
grid_par=grid_par,
67-
C_dc=C_dc,
57+
C_dc=1e-3,
6858
filter_par=filter_par,
69-
i_max=1.5*base.i,
59+
max_i=1.5*base.i,
7060
)
7161
# Create the control system
7262
ctrl = control.GFLControl(cfg)
@@ -78,11 +68,11 @@
7868
# Set the time-dependent reference and disturbance signals.
7969

8070
# Set the references for DC-bus voltage and reactive power
81-
ctrl.ref.u_dc = lambda t: 600 + (t > .02)*(50)
82-
ctrl.ref.q_g = lambda t: (t > .04)*(4e3)
71+
ctrl.ref.u_dc = lambda t: 600 + (t > .02)*50
72+
ctrl.ref.q_g = lambda t: (t > .04)*4e3
8373

8474
# Set the external DC-bus current
85-
mdl.converter.i_ext = lambda t: (t > .06)*(10)
75+
mdl.converter.i_ext = lambda t: (t > .06)*10
8676

8777
# %%
8878
# Create the simulation object and simulate it.
Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
"""
2-
10-kVA grid-following converter with LCL filter, power control
3-
==============================================================
2+
10-kVA converter, LCL filter
3+
============================
44
55
This example simulates a grid-following-controlled converter connected to a
66
strong grid through an LCL filter. The control system includes a phase-locked
77
loop (PLL) to synchronize with the grid, a current reference generator, and a
8-
PI-based current controller.
8+
PI-type current controller.
99
1010
"""
1111

1212
# %%
13-
from motulator.common.model import (
14-
CarrierComparison,
15-
Inverter,
16-
Simulation,
17-
)
18-
from motulator.common.utils import (
19-
BaseValues,
20-
NominalValues,
21-
)
13+
from motulator.common.model import VoltageSourceConverter, Simulation
14+
from motulator.common.utils import BaseValues, NominalValues
2215
from motulator.grid import model
2316
import motulator.grid.control.grid_following as control
2417
from motulator.grid.utils import FilterPars, GridPars, plot_grid
@@ -32,40 +25,35 @@
3225
# %%
3326
# Configure the system model.
3427

35-
# Grid parameters
28+
# Grid and filter parameters
3629
grid_par = GridPars(u_gN=base.u, w_gN=base.w)
37-
38-
# Filter parameters
39-
filter_par = FilterPars(L_fc=0.073*base.L, L_fg=0.073*base.L, C_f=0.043*base.C)
30+
filter_par = FilterPars(L_fc=.073*base.L, L_fg=.073*base.L, C_f=.043*base.C)
4031

4132
# DC-bus parameters
42-
grid_filter = model.GridFilter(filter_par, grid_par)
33+
ac_filter = model.ACFilter(filter_par, grid_par)
4334

4435
# AC-voltage magnitude (to simulate voltage dips or short-circuits)
45-
e_g_abs_var = lambda t: grid_par.u_gN
36+
abs_e_g_var = lambda t: grid_par.u_gN
4637

4738
# AC grid model with constant voltage magnitude and frequency
48-
grid_model = model.StiffSource(w_g=grid_par.w_gN, e_g_abs=e_g_abs_var)
39+
grid_model = model.ThreePhaseVoltageSource(
40+
w_g=grid_par.w_gN, abs_e_g=abs_e_g_var)
4941

5042
# Inverter model with constant DC voltage
51-
converter = Inverter(u_dc=650)
43+
converter = VoltageSourceConverter(u_dc=650)
5244

5345
# Create system model
54-
mdl = model.GridConverterSystem(converter, grid_filter, grid_model)
46+
mdl = model.GridConverterSystem(converter, ac_filter, grid_model)
5547

5648
# Uncomment line below to enable the PWM model
5749
#mdl.pwm = CarrierComparison()
5850

5951
# %%
6052
# Configure the control system.
6153

62-
# # Control parameters
54+
# Control parameters
6355
cfg = control.GFLControlCfg(
64-
grid_par=grid_par,
65-
filter_par=filter_par,
66-
on_u_cap=True,
67-
i_max=1.5*base.i,
68-
)
56+
grid_par=grid_par, filter_par=filter_par, max_i=1.5*base.i)
6957

7058
# Create the control system
7159
ctrl = control.GFLControl(cfg)
@@ -74,8 +62,8 @@
7462
# Set the time-dependent reference and disturbance signals.
7563

7664
# Set the active and reactive power references
77-
ctrl.ref.p_g = lambda t: (t > .02)*(5e3)
78-
ctrl.ref.q_g = lambda t: (t > .04)*(4e3)
65+
ctrl.ref.p_g = lambda t: (t > .02)*5e3
66+
ctrl.ref.q_g = lambda t: (t > .04)*4e3
7967

8068
# %%
8169
# Create the simulation object and simulate it.

0 commit comments

Comments
 (0)