Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"autoapi",
"Awan",
"axhline",
"axlim",
"Baldor",
"Blanco",
"Böcker",
Expand All @@ -36,6 +37,7 @@
"Capecchi",
"Capponi",
"Claypool",
"cmap",
"Degner",
"dejavuserif",
"docstrings",
Expand Down Expand Up @@ -154,11 +156,13 @@
"vartheta",
"Verghese",
"viridis",
"xdata",
"xlabel",
"xlim",
"xtick",
"xticklabels",
"xticks",
"ydata",
"Yepes",
"ylabel",
"ylabels",
Expand All @@ -167,6 +171,7 @@
"yticks",
"Zigliotto",
"zlabel",
"zlim"
"zlim",
"zticks"
],
}
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
author = "Aalto Electric Drives"

# The full version, including alpha/beta/rc tags
release = "0.6.1"
release = "0.6.2"

# -- General configuration -------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@
# Plot also the stator voltage and currents as well as the DC-bus and grid-side
# quantities.

utils.plot_extra(res, base, t_span=(0.8, 0.825))
utils.plot_stator_waveforms(res, base, t_lims=(0.8, 0.825))
utils.plot_dc_bus_waveforms(res, base, t_lims=(0.8, 0.825))
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
# Get the path of the MATLAB file and load the FEM data
p = Path(__file__).resolve().parent if "__file__" in globals() else Path.cwd()
fem_flux_map = utils.import_syre_data(str(p / "THOR.mat"))
utils.plot_maps(fem_flux_map, base, x_lims=(-2, 2), y_lims=(-2, 2))
utils.plot_map(fem_flux_map, "d", base, x_lims=(-2, 2), y_lims=(-2, 2))
utils.plot_map(fem_flux_map, "q", base, x_lims=(-2, 2), y_lims=(-2, 2))

# %%
# Configure the system model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
fem_flux_map = utils.import_syre_data(str(p / "THOR.mat"))

# %%
# Plot the maps in per-unit values
# Plot the maps in per-unit values.

# sphinx_gallery_thumbnail_number = 3
utils.plot_maps(fem_flux_map, base, x_lims=(-2, 2), y_lims=(-2, 2))
utils.plot_map(fem_flux_map, "d", base, x_lims=(-2, 2), y_lims=(-2, 2))
utils.plot_map(fem_flux_map, "q", base, x_lims=(-2, 2), y_lims=(-2, 2))

# %%
# Two-dimensional presentation of flux maps.
Expand Down
39 changes: 28 additions & 11 deletions examples/drive/flux_vector/plot_flux_vector_pmsyrm_5kw_sat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
5.5-kW PM-SyRM, saturated
5.6-kW PM-SyRM, saturated
=========================

This example simulates sensorless stator-flux-vector control of a 5.5-kW PM-SyRM (Baldor
This example simulates sensorless stator-flux-vector control of a 5.6-kW PM-SyRM (Baldor
ECS101M0H7EF4) drive. The machine model is parametrized using the flux map data,
measured using the constant-speed test. The control system is parametrized using the
algebraic saturation model from [#Lel2024]_, fitted to the measured data. This
Expand All @@ -15,7 +15,6 @@

from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
from scipy.io import loadmat

Expand All @@ -25,7 +24,7 @@
# %%
# Compute base values based on the nominal values (just for figures).

nom = utils.NominalValues(U=370, I=8.8, f=60, P=5.5e3, tau=29.2)
nom = utils.NominalValues(U=460, I=8.8, f=60, P=5.6e3, tau=29.7)
base = utils.BaseValues.from_nominal(nom, n_p=2)

# %%
Expand All @@ -45,7 +44,7 @@

# Plot the measured data
# sphinx_gallery_thumbnail_number = 4
utils.plot_flux_vs_current(meas_flux_map, base, lims=(-1.5, 1.5))
utils.plot_flux_vs_current(meas_flux_map, base, x_lims=(-1.5, 1.5))

# %%
# Create a saturation model, which will be used in the control system.
Expand All @@ -72,14 +71,33 @@

# Generate the flux map using the saturation model
est_curr_map = i_s_dq_fcn.as_magnetic_model(
d_range=np.linspace(-0.1, 1.3 * base.psi, 256),
q_range=np.linspace(-1.7 * base.psi, 1.7 * base.psi, 256),
d_range=np.linspace(-0.1, base.psi, 256),
q_range=np.linspace(-1.4 * base.psi, 1.4 * base.psi, 256),
)
est_flux_map = est_curr_map.invert()

# Plot the saturation model (surface) and the measured data (points)
utils.plot_maps(
est_flux_map, base, x_lims=(-1.8, 1.8), y_lims=(-2.15, 2.15), raw_data=meas_flux_map
utils.plot_map(
est_flux_map,
"d",
base,
x_lims=(-2, 2),
y_lims=(-2, 2),
z_lims=(0, 1),
x_ticks=[-2, -1, 0, 1, 2],
y_ticks=[-2, -1, 0, 1, 2],
raw_data=meas_flux_map,
)
utils.plot_map(
est_flux_map,
"q",
base,
x_lims=(-2, 2),
y_lims=(-2, 2),
z_lims=(-1.5, 1.5),
x_ticks=[-2, -1, 0, 1, 2],
y_ticks=[-2, -1, 0, 1, 2],
raw_data=meas_flux_map,
)

# %%
Expand Down Expand Up @@ -113,7 +131,6 @@
mc.plot_current_vs_torque(i_s_vals, base)
mc.plot_current_loci(i_s_vals, base)
mc.plot_flux_loci(i_s_vals, base)
plt.show()

# %%
# Set the speed reference and the external load torque.
Expand All @@ -125,7 +142,7 @@
# Create the simulation object, simulate, and plot the results in per-unit values.

sim = model.Simulation(mdl, ctrl)
res = sim.simulate(t_stop=1.5)
res = sim.simulate(t_stop=1.4)
utils.plot(res, base)

# %%
Expand Down
5 changes: 3 additions & 2 deletions examples/drive/flux_vector/plot_flux_vector_syrm_7kw_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
psi_q_range = np.linspace(-0.5 * base.psi, 0.5 * base.psi, 256)
flux_map = curr_map.as_magnetic_model(psi_d_range, psi_q_range).invert()

# Plot the flux map
utils.plot_maps(flux_map, base)
# Plot the flux maps
utils.plot_map(flux_map, "d", base)
utils.plot_map(flux_map, "q", base)

# Parameter estimates
est_par = control.SaturatedSynchronousMachinePars(
Expand Down
6 changes: 3 additions & 3 deletions examples/drive/vhz/plot_obs_vhz_pmsm_2kw_two_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
# %%
# Plot the load speed and the twist angle.

t_span = (0, 1.2)
t_lims = (0, 1.2)
_, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 5))
ax1.plot(res.mdl.t, res.mdl.mechanics.w_M, label=r"$\omega_\mathrm{M}$")
ax1.plot(res.mdl.t, res.mdl.mechanics.w_L, label=r"$\omega_\mathrm{L}$")
ax2.plot(res.mdl.t, res.mdl.mechanics.theta_ML * 180 / np.pi)
ax1.set_xlim(t_span)
ax2.set_xlim(t_span)
ax1.set_xlim(t_lims)
ax2.set_xlim(t_lims)
ax1.set_xticklabels([])
ax1.legend()
ax1.set_ylabel(r"$\omega_\mathrm{M}$, $\omega_\mathrm{L}$ (rad/s)")
Expand Down
4 changes: 3 additions & 1 deletion examples/drive/vhz/plot_vhz_im_2kw.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
res = sim.simulate(t_stop=1.4)
# sphinx_gallery_thumbnail_number = 2
utils.plot(res, base)
utils.plot_extra(res, base, t_span=(1.1, 1.125))
utils.plot_stator_waveforms(res, base, t_lims=(1.1, 1.125))
utils.plot_dc_bus_waveforms(res, base, t_lims=(1.1, 1.125))


# %%
# .. note::
Expand Down
6 changes: 3 additions & 3 deletions examples/drive/vhz/plot_vhz_im_2kw_lc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@
# %%
# Plot additional waveforms.

t_span = (1.1, 1.125) # Time span for the zoomed-in plot
t_lims = (1.1, 1.125) # Time span for the zoomed-in plot

# Plot the converter and stator voltages (phase a)
fig1, (ax1, ax2) = plt.subplots(2, 1)
ax1.plot(res.mdl.t, res.mdl.converter.u_c_ab.real / base.u, label=r"$u_\mathrm{ca}$")
ax1.plot(res.mdl.t, res.mdl.machine.u_s_ab.real / base.u, label=r"$u_\mathrm{sa}$")
ax1.set_xlim(t_span)
ax1.set_xlim(t_lims)
ax1.legend()
ax1.set_xticklabels([])
ax1.set_ylabel("Voltage (p.u.)")
# Plot the converter and stator currents (phase a)
ax2.plot(res.mdl.t, res.mdl.converter.i_c_ab.real / base.i, label=r"$i_\mathrm{ca}$")
ax2.plot(res.mdl.t, res.mdl.machine.i_s_ab.real / base.i, label=r"$i_\mathrm{sa}$")
ax2.set_xlim(t_span)
ax2.set_xlim(t_lims)
ax2.legend()
ax2.set_ylabel("Current (p.u.)")
ax2.set_xlabel("Time (s)")
Expand Down
4 changes: 3 additions & 1 deletion examples/grid/grid_following/plot_gfl_10kva.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@

sim = model.Simulation(mdl, ctrl)
res = sim.simulate(t_stop=0.08)
utils.plot(res, base, plot_pcc_voltage=False)
utils.plot_control_signals(res, base)
utils.plot_grid_waveforms(res, base, plot_pcc_voltage=False)


# Uncomment line below to plot locus of the grid voltage space vector
# utils.plot_voltage_vector(res, base)
3 changes: 2 additions & 1 deletion examples/grid/grid_following/plot_gfl_dc_bus_10kva.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@

sim = model.Simulation(mdl, ctrl)
res = sim.simulate(t_stop=0.1)
utils.plot(res, base)
utils.plot_control_signals(res, base)
utils.plot_grid_waveforms(res, base)
5 changes: 3 additions & 2 deletions examples/grid/grid_following/plot_gfl_lcl_10kva.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This example simulates a grid-following-controlled converter connected to a strong grid
through an LCL filter. The control system includes a phase-locked loop (PLL) to
synchronize with the grid, a current reference generator, and a PI-type current
controller. The LCL filter dynamics are not taken into account in the control system.
controller. The LCL-filter dynamics are not taken into account in the control system.

"""

Expand Down Expand Up @@ -53,4 +53,5 @@
# %%
# Plot the results.

utils.plot(res, base)
utils.plot_control_signals(res, base)
utils.plot_grid_waveforms(res, base)
3 changes: 2 additions & 1 deletion examples/grid/grid_forming/plot_gfm_obs_13kva.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@

sim = model.Simulation(mdl, ctrl)
res = sim.simulate(t_stop=1.4)
utils.plot(res, base)
utils.plot_control_signals(res, base)
utils.plot_grid_waveforms(res, base)
7 changes: 4 additions & 3 deletions examples/grid/grid_forming/plot_gfm_rfpsc_13kva.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
12.5-kVA converter, RFPSC
=========================

This example simulates reference-feedforward power-synchronization control
(RFPSC) of a converter connected to a weak grid.
This example simulates reference-feedforward power-synchronization control (RFPSC) of a
converter connected to a weak grid.

"""

Expand Down Expand Up @@ -49,4 +49,5 @@

sim = model.Simulation(mdl, ctrl)
res = sim.simulate(t_stop=1.4)
utils.plot(res, base)
utils.plot_control_signals(res, base)
utils.plot_grid_waveforms(res, base)
2 changes: 1 addition & 1 deletion motulator/common/model/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import numpy as np

from motulator.common.model._base import Subsystem
from motulator.common.utils import abc2complex, complex2abc, empty_array
from motulator.common.utils._utils import abc2complex, complex2abc, empty_array


# %%
Expand Down
17 changes: 1 addition & 16 deletions motulator/common/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,7 @@
SequenceGenerator,
Step,
abc2complex,
clip,
complex2abc,
empty_array,
get_value,
sign,
wrap,
)

__all__ = [
"SequenceGenerator",
"Step",
"abc2complex",
"complex2abc",
"clip",
"empty_array",
"get_value",
"sign",
"wrap",
]
__all__ = ["SequenceGenerator", "Step", "abc2complex", "complex2abc"]
Loading