Skip to content

Commit 64433f2

Browse files
committed
Additional plots for 3level converter quantities
1 parent fa02b20 commit 64433f2

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

motulator/grid/utils/_plots.py

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def plot(sim, base=None, plot_pcc_voltage=True, plot_w=False, t_span=None):
164164
ax3.set_xlabel("Time (s)")
165165

166166
fig.align_ylabels()
167-
plt.tight_layout()
168-
plt.grid()
167+
#plt.tight_layout()
168+
#plt.grid()
169169
ax3.grid()
170170
#plt.show()
171171

@@ -270,9 +270,54 @@ def plot(sim, base=None, plot_pcc_voltage=True, plot_w=False, t_span=None):
270270
ax3.set_xlabel("Time (s)")
271271

272272
fig.align_ylabels()
273+
ax3.grid()
274+
275+
# %%
276+
# Third figure (only if three-level converter is used)
277+
try:
278+
i_o = mdl.converter.data.i_o
279+
280+
fig, (ax1, ax2) = plt.subplots(2, 1)
281+
282+
# Subplot 1: Capacitor voltages
283+
ax1.plot(
284+
mdl.converter.data.t,
285+
mdl.converter.data.u_dc1/base.u,
286+
label=r"$u_\mathrm{dc1}$")
287+
ax1.plot(
288+
mdl.converter.data.t,
289+
mdl.converter.data.u_dc2/base.u,
290+
label=r"$u_\mathrm{dc2}$")
291+
ax1.legend()
292+
ax1.set_xlim(t_span)
293+
ax1.set_xticklabels([])
294+
295+
# Subplot 2: Converter dc-side currents
296+
ax2.plot(
297+
mdl.converter.data.t,
298+
mdl.converter.data.i_P/base.i,
299+
label=r"$i_\mathrm{P}$")
300+
ax2.plot(mdl.converter.data.t, i_o/base.i, label=r"$i_\mathrm{o}$")
301+
ax2.legend()
302+
ax2.set_xlim(t_span)
303+
304+
# Add axis labels
305+
if pu_vals:
306+
ax1.set_ylabel("Voltage (p.u.)")
307+
ax2.set_ylabel("Current (p.u.)")
308+
else:
309+
ax1.set_ylabel("Voltage (V)")
310+
ax2.set_ylabel("Current (A)")
311+
ax2.set_xlabel("Time (s)")
312+
313+
fig.align_ylabels()
314+
ax2.grid()
315+
316+
except AttributeError:
317+
pass
318+
273319
plt.tight_layout()
274320
plt.grid()
275-
ax3.grid()
276321
plt.show()
277322

278323

0 commit comments

Comments
 (0)