Commit cb8c438b authored by Bichen Li's avatar Bichen Li

- Update the dockerfile, add the pull of py4mod package

parent 836bc55b
# ignore results # ignore results
*.csv *.csv
*.mat *.mat
# ignore symbolic links # ignore symbolic links
*.egg-info *.egg-info
*.eggs *.eggs
# ignore compiled python files # ignore compiled python files
*.pyc *.pyc
# ignore logging files # ignore logging files
*.log *.log
# ignore generated dymola files # ignore generated dymola files
buildlog.txt buildlog.txt
dsfinal.txt dsfinal.txt
dsin.txt dsin.txt
dslog.txt dslog.txt
dsmodel* dsmodel*
dymosim* dymosim*
# ignore matlab dumping file # ignore matlab dumping file
*.mdmp *.mdmp
# ignore spyder project # ignore spyder project
.spyderproject .spyderproject
.spyproject .spyproject
# ignore pycharm files # ignore pycharm files
.idea .idea
__pycache__ __pycache__
# ignore jupyter notebook files # ignore jupyter notebook files
.ipynb_checkpoints .ipynb_checkpoints
Test.py Test.py
\ No newline at end of file
# Dataprocessing toolkit for RWTH ACS simulators # Dataprocessing toolkit for RWTH ACS simulators
## Copyright ## Copyright
2017, Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University 2017, Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
## License ## License
This project is released under the terms of the [GPL version 3](COPYING.md). This project is released under the terms of the [GPL version 3](COPYING.md).
``` ```
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
any later version. any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
``` ```
For other licensing options please consult [Prof. Antonello Monti](mailto:amonti@eonerc.rwth-aachen.de). For other licensing options please consult [Prof. Antonello Monti](mailto:amonti@eonerc.rwth-aachen.de).
## Contact ## Contact
[![EONERC ACS Logo](doc/eonerc_logo.png)](http://www.acs.eonerc.rwth-aachen.de) [![EONERC ACS Logo](doc/eonerc_logo.png)](http://www.acs.eonerc.rwth-aachen.de)
- Markus Mirz <mmirz@eonerc.rwth-aachen.de> - Markus Mirz <mmirz@eonerc.rwth-aachen.de>
- Jan Dinkelbach <JDinkelbach@eonerc.rwth-aachen.de> - Jan Dinkelbach <JDinkelbach@eonerc.rwth-aachen.de>
- Steffen Vogel <stvogel@eonerc.rwth-aachen.de> - Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
[Institute for Automation of Complex Power Systems (ACS)](http://www.acs.eonerc.rwth-aachen.de) [Institute for Automation of Complex Power Systems (ACS)](http://www.acs.eonerc.rwth-aachen.de)
[EON Energy Research Center (EONERC)](http://www.eonerc.rwth-aachen.de) [EON Energy Research Center (EONERC)](http://www.eonerc.rwth-aachen.de)
[RWTH University Aachen, Germany](http://www.rwth-aachen.de) [RWTH University Aachen, Germany](http://www.rwth-aachen.de)
from dataprocessing.readtools import * from dataprocessing.readtools import *
from dataprocessing.timeseries import * from dataprocessing.timeseries import *
def get_node_voltage_phasors(dpsim_timeseries_list): def get_node_voltage_phasors(dpsim_timeseries_list):
"""Calculate voltage phasors of all nodes """Calculate voltage phasors of all nodes
:param dpsim_timeseries_list: timeseries list retrieved from dpsim results :param dpsim_timeseries_list: timeseries list retrieved from dpsim results
:return: :return:
""" """
voltage_phasor_list = {} voltage_phasor_list = {}
for ts in dpsim_timeseries_list: for ts in dpsim_timeseries_list:
ts_abs = ts.abs(ts.name + '_abs') ts_abs = ts.abs(ts.name + '_abs')
ts_phase = ts.phase(ts.name + '_phase') ts_phase = ts.phase(ts.name + '_phase')
ts_phasor = {} ts_phasor = {}
ts_phasor['abs'] = ts_abs ts_phasor['abs'] = ts_abs
ts_phasor['phase'] = ts_phase ts_phasor['phase'] = ts_phase
voltage_phasor_list[ts.name] = ts_phasor voltage_phasor_list[ts.name] = ts_phasor
return voltage_phasor_list return voltage_phasor_list
def get_node_emt_voltages(timeseries_list, freq): def get_node_emt_voltages(timeseries_list, freq):
"""Calculate voltage phasors of all nodes """Calculate voltage phasors of all nodes
:param timeseries_list: timeseries list retrieved from dpsim results :param timeseries_list: timeseries list retrieved from dpsim results
:return: :return:
""" """
voltages_list = {} voltages_list = {}
for ts in timeseries_list: for ts in timeseries_list:
ts_emt = ts.dynphasor_shift_to_emt(ts.name, freq) ts_emt = ts.dynphasor_shift_to_emt(ts.name, freq)
voltages_list[ts.name] = ts_emt voltages_list[ts.name] = ts_emt
return voltages_list return voltages_list
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from .timeseries import * from .timeseries import *
def plot_timeseries(figure_id, timeseries, plt_linestyle='-', plt_linewidth=2, plt_color=None, plt_legend_loc='lower right'): def plot_timeseries(figure_id, timeseries, plt_linestyle='-', plt_linewidth=2, plt_color=None, plt_legend_loc='lower right'):
""" """
This function plots either a single timeseries or several timeseries in the figure defined by figure_id. This function plots either a single timeseries or several timeseries in the figure defined by figure_id.
Several timeseries (handed over in a list) are plotted in several subplots. Several timeseries (handed over in a list) are plotted in several subplots.
In order to plot several timeseries in one plot, the function is to be called several times (hold is activated). In order to plot several timeseries in one plot, the function is to be called several times (hold is activated).
""" """
plt.figure(figure_id) plt.figure(figure_id)
if not isinstance(timeseries, list): if not isinstance(timeseries, list):
if plt_color: if plt_color:
plt.plot(timeseries.time, timeseries.values, linestyle=plt_linestyle, label=timeseries.label, linewidth=plt_linewidth, color=plt_color) plt.plot(timeseries.time, timeseries.values, linestyle=plt_linestyle, label=timeseries.label, linewidth=plt_linewidth, color=plt_color)
else: else:
plt.plot(timeseries.time, timeseries.values, linestyle=plt_linestyle, label=timeseries.label, linewidth=plt_linewidth) plt.plot(timeseries.time, timeseries.values, linestyle=plt_linestyle, label=timeseries.label, linewidth=plt_linewidth)
plt.gca().autoscale(axis='x', tight=True) plt.gca().autoscale(axis='x', tight=True)
plt.legend(loc=plt_legend_loc) plt.legend(loc=plt_legend_loc)
else: else:
for ts in timeseries: for ts in timeseries:
plt.subplot(len(timeseries), 1, timeseries.index(ts) + 1) plt.subplot(len(timeseries), 1, timeseries.index(ts) + 1)
if plt_color: if plt_color:
plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label, linewidth=plt_linewidth, color=plt_color) plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label, linewidth=plt_linewidth, color=plt_color)
else: else:
plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label, linewidth=plt_linewidth) plt.plot(ts.time, ts.values, linestyle=plt_linestyle, label=ts.label, linewidth=plt_linewidth)
plt.gca().autoscale(axis='x', tight=True) plt.gca().autoscale(axis='x', tight=True)
plt.legend() plt.legend()
def set_timeseries_labels(timeseries, timeseries_labels): def set_timeseries_labels(timeseries, timeseries_labels):
""" """
Sets label attribute of timeseries, later used in plotting functions. Sets label attribute of timeseries, later used in plotting functions.
Suitable for single timeseries as well as for several timeseries (handed over in a list). Suitable for single timeseries as well as for several timeseries (handed over in a list).
""" """
if not isinstance(timeseries, list): if not isinstance(timeseries, list):
timeseries.label = timeseries_labels timeseries.label = timeseries_labels
else: else:
for ts in timeseries: for ts in timeseries:
ts.label = timeseries_labels[timeseries.index(ts)] ts.label = timeseries_labels[timeseries.index(ts)]
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import re import re
import os import os
import sys import sys
sys.path.append(r"D:\HIWI\Git\data-processing\dataprocessing") sys.path.append(r".\data-processing\dataprocessing")
sys.path.append(r"D:\HIWI\Git\python-for-modelica-dev_interface\Py4Mod\py4mod") sys.path.append(r".\python-for-modelica-dev_interface\Py4Mod\py4mod")
from ModelicaModel import ModelicaModel from ModelicaModel import ModelicaModel
from validationtools import * from validationtools import *
from readtools import * from readtools import *
os.chdir(r"D:\HIWI\Git") os.chdir(r"D:\HIWI\Git")
def simulate_modelica(model_name, model_path): def simulate_modelica(model_name, model_path):
interface = ModelicaModel(model_name, model_path) interface = ModelicaModel(model_name, model_path)
# Initialization # Initialization
interface.createInterface("OPENMODELICA") interface.createInterface("OPENMODELICA")
interface.loadFile(model_path + '\ModPowerSystems\package.mo') interface.loadFile(model_path + '\ModPowerSystems\package.mo')
# Redirection # Redirection
cwd = os.getcwd() cwd = os.getcwd()
wd = os.path.join(cwd, 'test') wd = os.path.join(cwd, 'test')
if not os.path.exists(wd): if not os.path.exists(wd):
os.makedirs(wd) os.makedirs(wd)
interface.changeWorkingDirectory(wd.replace("\\", "/")) interface.changeWorkingDirectory(wd.replace("\\", "/"))
# Build & Run # Build & Run
interface.buildModel() interface.buildModel()
interface.simulate() interface.simulate()
print("Test Start") print("Test Start")
# We need to extract all the result files from git now # We need to extract all the result files from git now
for files in os.listdir( for files in os.listdir(
os.path.abspath("reference-results/Neplan/BasicGrids")): os.path.abspath("reference-results/Neplan/BasicGrids")):
# Assert the result, model result path read from cmd line # Assert the result, model result path read from cmd line
validate_modelica_res(os.path.splitext(files)[0], validate_modelica_res(os.path.splitext(files)[0],
os.path.abspath("reference-results/Modelica/BasicGrids/" + os.path.abspath("reference-results/Modelica/BasicGrids/" +
os.path.splitext(files)[0] + ".mat"), os.path.splitext(files)[0] + ".mat"),
os.path.abspath("reference-results/Neplan/BasicGrids/" + os.path.abspath("reference-results/Neplan/BasicGrids/" +
os.path.splitext(files)[0] + ".rlf")) os.path.splitext(files)[0] + ".rlf"))
print("Test End") print("Test End")
from dataprocessing.readtools import * from dataprocessing.readtools import *
from dataprocessing.plottools import * from dataprocessing.plottools import *
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from plottingtools.config import * from plottingtools.config import *
current_emt_mod = read_timeseries_Modelica(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\EMT\UnitTest_Kundur_FullModel_Euler_1us.mat", ["synchronousGenerator_Park.i[1]"]) # Note: both results include only one damper winding in q axis current_emt_mod = read_timeseries_Modelica(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\EMT\UnitTest_Kundur_FullModel_Euler_1us.mat", ["synchronousGenerator_Park.i[1]"]) # Note: both results include only one damper winding in q axis
current_emt_dpsim = read_timeseries_dpsim_real(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\EMT\DPsim\UnitTest_FullModel_Trap_1us\data_j.csv")[0] current_emt_dpsim = read_timeseries_dpsim_real(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\EMT\DPsim\UnitTest_FullModel_Trap_1us\data_j.csv")[0]
current_emt_dpsim.values = -current_emt_dpsim.values current_emt_dpsim.values = -current_emt_dpsim.values
# Comparison EMT # Comparison EMT
figure_id = 1 figure_id = 1
plt.figure(figure_id, figsize=(12,8)) plt.figure(figure_id, figsize=(12,8))
set_timeseries_labels(current_emt_mod, ["EMT Modelica"]) set_timeseries_labels(current_emt_mod, ["EMT Modelica"])
plot_timeseries(figure_id, current_emt_mod) plot_timeseries(figure_id, current_emt_mod)
set_timeseries_labels(current_emt_dpsim, "EMT DPsim") # TODO: modelica timeseries needs list element, dpsim timeseries needs string set_timeseries_labels(current_emt_dpsim, "EMT DPsim") # TODO: modelica timeseries needs list element, dpsim timeseries needs string
plot_timeseries(figure_id, current_emt_dpsim, plt_linestyle=':') plot_timeseries(figure_id, current_emt_dpsim, plt_linestyle=':')
plt.xlabel('Zeit [s]') plt.xlabel('Zeit [s]')
plt.ylabel('Strom [A]') plt.ylabel('Strom [A]')
plt.show(block=False) plt.show(block=False)
# Comparison DP # Comparison DP
current_dp_mod = read_timeseries_Modelica(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\DP\UnitTest_Kundur_FullModel_Euler_1us.mat", ["synchronousGenerator_Park.I[1]"]) # Note: both results include only one damper winding in q axis current_dp_mod = read_timeseries_Modelica(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\DP\UnitTest_Kundur_FullModel_Euler_1us.mat", ["synchronousGenerator_Park.I[1]"]) # Note: both results include only one damper winding in q axis
current_dp_dpsim = read_timeseries_dpsim_cmpl(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\DP\DPsim\UnitTest_FullModel_Trap_1us\data_j.csv")[0] current_dp_dpsim = read_timeseries_dpsim_cmpl(r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\SynchronousGenerator\DP\DPsim\UnitTest_FullModel_Trap_1us\data_j.csv")[0]
current_dp_dpsim.values = -current_dp_dpsim.values current_dp_dpsim.values = -current_dp_dpsim.values
current_dpabs_dpsim = current_dp_dpsim.abs(current_dp_dpsim.name + ' abs') current_dpabs_dpsim = current_dp_dpsim.abs(current_dp_dpsim.name + ' abs')
figure_id = 2 figure_id = 2
plt.figure(figure_id, figsize=(12,8)) plt.figure(figure_id, figsize=(12,8))
set_timeseries_labels(current_dp_mod, ["DP Modelica"]) set_timeseries_labels(current_dp_mod, ["DP Modelica"])
plot_timeseries(figure_id, current_dp_mod) plot_timeseries(figure_id, current_dp_mod)
set_timeseries_labels(current_dpabs_dpsim, "DP DPsim") # TODO: modelica timeseries needs list element, dpsim timeseries needs string set_timeseries_labels(current_dpabs_dpsim, "DP DPsim") # TODO: modelica timeseries needs list element, dpsim timeseries needs string
plot_timeseries(figure_id, current_dpabs_dpsim, plt_linestyle=':') plot_timeseries(figure_id, current_dpabs_dpsim, plt_linestyle=':')
plt.xlabel('Zeit [s]') plt.xlabel('Zeit [s]')
plt.ylabel('Strom [A]') plt.ylabel('Strom [A]')
plt.show(block=True) plt.show(block=True)
from dataprocessing.readtools import * from dataprocessing.readtools import *
from dataprocessing.plottools import * from dataprocessing.plottools import *
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
results_path = r'\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\InductionMachine\results' results_path = r'\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\InductionMachine\results'
### --- Read in section --- ### ### --- Read in section --- ###
# Stator currents # Stator currents
stator_currents_mo = read_time_series_Modelica(results_path + r'\Modelica3hpMachineRRFs.mat', ['inductionMachineSquirrelCage.i[1]', 'inductionMachineSquirrelCage.i[2]', 'inductionMachineSquirrelCage.i[3]']) stator_currents_mo = read_time_series_Modelica(results_path + r'\Modelica3hpMachineRRFs.mat', ['inductionMachineSquirrelCage.i[1]', 'inductionMachineSquirrelCage.i[2]', 'inductionMachineSquirrelCage.i[3]'])
stator_currents_pls = read_time_series_PLECS(results_path + r'\PLECS3hpMachineStatorCurrents.csv') stator_currents_pls = read_time_series_PLECS(results_path + r'\PLECS3hpMachineStatorCurrents.csv')
# Rotor currents # Rotor currents
rotor_currents_mo = read_time_series_Modelica(results_path + r'\Modelica3hpMachineRRFs.mat', ['inductionMachineSquirrelCage.i_qd0r[1]', 'inductionMachineSquirrelCage.i_qd0r[2]']) rotor_currents_mo = read_time_series_Modelica(results_path + r'\Modelica3hpMachineRRFs.mat', ['inductionMachineSquirrelCage.i_qd0r[1]', 'inductionMachineSquirrelCage.i_qd0r[2]'])
rotor_currents_pls = read_time_series_PLECS(results_path + r'\PLECS3hpMachineRotorCurrentsDqRRFs.csv') rotor_currents_pls = read_time_series_PLECS(results_path + r'\PLECS3hpMachineRotorCurrentsDqRRFs.csv')
rotor_currents_pls[1].values = -rotor_currents_pls[1].values # transformation DQ0->QD0 rotor_currents_pls[1].values = -rotor_currents_pls[1].values # transformation DQ0->QD0
# Torque and speed # Torque and speed
torque_speed_mo = read_time_series_Modelica(results_path + r'\Modelica3hpMachineRRFs.mat', ['inductionMachineSquirrelCage.T_e', 'inductionMachineSquirrelCage.omega_rm']) torque_speed_mo = read_time_series_Modelica(results_path + r'\Modelica3hpMachineRRFs.mat', ['inductionMachineSquirrelCage.T_e', 'inductionMachineSquirrelCage.omega_rm'])
torque_speed_pls = read_time_series_PLECS(results_path + r'\PLECS3hpMachineTorqueSpeed.csv') torque_speed_pls = read_time_series_PLECS(results_path + r'\PLECS3hpMachineTorqueSpeed.csv')
torque_speed_mo[1].values = torque_speed_mo[1].values/2/np.pi*60 # transformation to r/min torque_speed_mo[1].values = torque_speed_mo[1].values/2/np.pi*60 # transformation to r/min
### --- Plot section --- ### ### --- Plot section --- ###
# Stator currents # Stator currents
figure_id = 1 figure_id = 1
plt.figure(figure_id) plt.figure(figure_id)
plt.title("Stator currents") plt.title("Stator currents")
set_time_series_labels(stator_currents_mo, ['Modelica: Ias [A]', 'Modelica: Ibs [A]', 'Modelica: Ics [A]']) set_time_series_labels(stator_currents_mo, ['Modelica: Ias [A]', 'Modelica: Ibs [A]', 'Modelica: Ics [A]'])
plot_in_subplots(figure_id, stator_currents_mo) plot_in_subplots(figure_id, stator_currents_mo)
set_time_series_labels(stator_currents_pls, ['PLECS: Ias [A]', 'PLECS: Ibs [A]', 'PLECS: Ics [A]']) set_time_series_labels(stator_currents_pls, ['PLECS: Ias [A]', 'PLECS: Ibs [A]', 'PLECS: Ics [A]'])
plot_in_subplots(figure_id, stator_currents_pls, plt_linestyle='--') plot_in_subplots(figure_id, stator_currents_pls, plt_linestyle='--')
plt.xlabel('Time [s]') plt.xlabel('Time [s]')
plt.show(block=False) plt.show(block=False)
# Rotor currents # Rotor currents
figure_id = 2 figure_id = 2
plt.figure(figure_id) plt.figure(figure_id)
plt.title("Rotor currents (in synchronously rotating reference frame)") plt.title("Rotor currents (in synchronously rotating reference frame)")
set_time_series_labels(rotor_currents_mo, ['Modelica: Iqr\' [A]', 'Modelica: Idr\' [A]']) set_time_series_labels(rotor_currents_mo, ['Modelica: Iqr\' [A]', 'Modelica: Idr\' [A]'])
plot_in_subplots(figure_id, rotor_currents_mo) plot_in_subplots(figure_id, rotor_currents_mo)
set_time_series_labels(rotor_currents_pls, ['PLECS: Iqr\' [A]', 'PLECS: Idr\' [A]']) set_time_series_labels(rotor_currents_pls, ['PLECS: Iqr\' [A]', 'PLECS: Idr\' [A]'])
plot_in_subplots(figure_id, rotor_currents_pls, plt_linestyle='--') plot_in_subplots(figure_id, rotor_currents_pls, plt_linestyle='--')
plt.xlabel('Time [s]') plt.xlabel('Time [s]')
plt.show(block=False) plt.show(block=False)
# Torque and speed # Torque and speed
figure_id = 3 figure_id = 3
plt.figure(figure_id) plt.figure(figure_id)
plt.title("Rotor currents (in synchronously rotating reference frame)") plt.title("Rotor currents (in synchronously rotating reference frame)")
set_time_series_labels(torque_speed_mo, ['Modelica: Torque [Nm]', 'Modelica: Speed [r/min]']) set_time_series_labels(torque_speed_mo, ['Modelica: Torque [Nm]', 'Modelica: Speed [r/min]'])
plot_in_subplots(figure_id, torque_speed_mo) plot_in_subplots(figure_id, torque_speed_mo)
set_time_series_labels(torque_speed_pls, ['PLECS: Torque [Nm]', 'PLECS: Speed [r/min]']) set_time_series_labels(torque_speed_pls, ['PLECS: Torque [Nm]', 'PLECS: Speed [r/min]'])
plot_in_subplots(figure_id, torque_speed_pls, plt_linestyle='--') plot_in_subplots(figure_id, torque_speed_pls, plt_linestyle='--')
plt.xlabel('Time [s]') plt.xlabel('Time [s]')
plt.show() plt.show()
\ No newline at end of file
from dataprocessing.readtools import * from dataprocessing.readtools import *
from dataprocessing.timeseries import * from dataprocessing.timeseries import *
path = 'C:\\Users\\mmi\\git\\PowerSystemSimulation\\DPsim\\VisualStudio\\DPsimVS2017\\' path = 'C:\\Users\\mmi\\git\\PowerSystemSimulation\\DPsim\\VisualStudio\\DPsimVS2017\\'
logName = 'lvector-cim'; logName = 'lvector-cim';
dataType = '.csv'; dataType = '.csv';
logFilename = path + logName + dataType; logFilename = path + logName + dataType;
ts_dpsim = read_timeseries_dpsim_cmpl(logFilename) ts_dpsim = read_timeseries_dpsim_cmpl(logFilename)
for ts in ts_dpsim: for ts in ts_dpsim:
ts_abs = ts.abs(ts.name + ' abs') ts_abs = ts.abs(ts.name + ' abs')
ts_phase = ts.phase(ts.name + ' phase') ts_phase = ts.phase(ts.name + ' phase')
print(ts.name + ': ' + str(ts_abs.values[0]) + '<' + str(ts_phase.values[0] * 180/np.pi)) print(ts.name + ': ' + str(ts_abs.values[0]) + '<' + str(ts_phase.values[0] * 180/np.pi))
from dataprocessing.dpsim import * from dataprocessing.dpsim import *
from dataprocessing.plottools import * from dataprocessing.plottools import *
path = 'D:\\path\\to\\logs\\' path = 'D:\\path\\to\\logs\\'
logName = 'simulation_name_LeftVector' logName = 'simulation_name_LeftVector'
logFilename = path + logName + '.csv' logFilename = path + logName + '.csv'
ts_dpsim = read_timeseries_dpsim_cmpl(logFilename) ts_dpsim = read_timeseries_dpsim_cmpl(logFilename)
phasors = get_node_voltage_phasors(ts_dpsim) phasors = get_node_voltage_phasors(ts_dpsim)
print('Print phasors for all nodes at first time step:') print('Print phasors for all nodes at first time step:')
for node, phasor in phasors.items(): for node, phasor in phasors.items():
print(node + ': ' + str(phasor['abs'].values[0]) + '<' + str(phasor['phase'].values[0])) print(node + ': ' + str(phasor['abs'].values[0]) + '<' + str(phasor['phase'].values[0]))
print('Print phasors for all nodes at last time step:') print('Print phasors for all nodes at last time step:')
for node, phasor in phasors.items(): for node, phasor in phasors.items():
print(node + ': ' + str(phasor['abs'].values[-1]) + '<' + str(phasor['phase'].values[-1])) print(node + ': ' + str(phasor['abs'].values[-1]) + '<' + str(phasor['phase'].values[-1]))
emt_voltages = get_node_emt_voltages(ts_dpsim, 50) emt_voltages = get_node_emt_voltages(ts_dpsim, 50)
print('Print EMT voltages for all nodes at last time step:') print('Print EMT voltages for all nodes at last time step:')
for node, voltage in emt_voltages.items(): for node, voltage in emt_voltages.items():
print(node + ': ' + str(voltage.values[-1])) print(node + ': ' + str(voltage.values[-1]))
# Change node number to fit example # Change node number to fit example
#plot_timeseries(1, phasors['n2']['abs']) #plot_timeseries(1, phasors['n2']['abs'])
plot_timeseries(2, emt_voltages['n2']) plot_timeseries(2, emt_voltages['n2'])
plt.show() plt.show()
from dataprocessing.readtools import * from dataprocessing.readtools import *
from dataprocessing.plottools import * from dataprocessing.plottools import *
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
# Example 1: read in single variable included in the Modelica results file # Example 1: read in single variable included in the Modelica results file
voltage_node126 = read_timeseries_Modelica( voltage_node126 = read_timeseries_Modelica(
r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat", r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat",
timeseries_names="N126.Vrel") timeseries_names="N126.Vrel")
plt.figure(1, figsize=(12,8)) plt.figure(1, figsize=(12,8))
set_timeseries_labels(voltage_node126, "voltage N126") set_timeseries_labels(voltage_node126, "voltage N126")
plt.plot(voltage_node126.time/3600, voltage_node126.values, label=voltage_node126.label) plt.plot(voltage_node126.time/3600, voltage_node126.values, label=voltage_node126.label)
plt.legend() plt.legend()
plt.show(block=True) plt.show(block=True)
# Example 2: read in multiple variables defined in a list # Example 2: read in multiple variables defined in a list
voltage_two_nodes = read_timeseries_Modelica( voltage_two_nodes = read_timeseries_Modelica(
r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat", r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat",
timeseries_names=["N127.Vrel", "N128.Vrel"]) timeseries_names=["N127.Vrel", "N128.Vrel"])
plt.figure(2, figsize=(12,8)) plt.figure(2, figsize=(12,8))
plt.plot(voltage_two_nodes[0].time/3600, voltage_two_nodes[0].values, label=voltage_two_nodes[0].label) plt.plot(voltage_two_nodes[0].time/3600, voltage_two_nodes[0].values, label=voltage_two_nodes[0].label)
plt.plot(voltage_two_nodes[1].time/3600, voltage_two_nodes[1].values, label=voltage_two_nodes[1].label) plt.plot(voltage_two_nodes[1].time/3600, voltage_two_nodes[1].values, label=voltage_two_nodes[1].label)
plt.legend() plt.legend()
plt.show(block=True) plt.show(block=True)
# Example 3: read in all voltages using regular expressions # Example 3: read in all voltages using regular expressions
voltages_all_nodes = read_timeseries_Modelica( voltages_all_nodes = read_timeseries_Modelica(
r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat", r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat",
timeseries_names='^[^.]*.Vrel$', is_regex=True) timeseries_names='^[^.]*.Vrel$', is_regex=True)
plt.figure(3, figsize=(12, 8)) plt.figure(3, figsize=(12, 8))
for i in range(len(voltages_all_nodes)): for i in range(len(voltages_all_nodes)):
plt.plot(voltages_all_nodes[i].time / 3600, voltages_all_nodes[i].values, label=voltages_all_nodes[i].label) plt.plot(voltages_all_nodes[i].time / 3600, voltages_all_nodes[i].values, label=voltages_all_nodes[i].label)
plt.legend() plt.legend()
plt.show(block=True) plt.show(block=True)
# Example 4: read in all variables # Example 4: read in all variables
variables_all = read_timeseries_Modelica( variables_all = read_timeseries_Modelica(
r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat") r"\\tsclient\N\Research\German Public\ACS0049_SINERGIEN_bsc\Data\WorkData\SimulationResults\IEEE European\Single_scenario_fixed_PV\IEEEEuropean_60.mat")
dict_variables_all = {} dict_variables_all = {}
for ts in variables_all: for ts in variables_all:
dict_variables_all[ts.name] = ts dict_variables_all[ts.name] = ts
plt.figure(4, figsize=(12, 8)) plt.figure(4, figsize=(12, 8))
plt.plot(dict_variables_all["L12.Irel"].time/3600, dict_variables_all["L12.Irel"].values, label=dict_variables_all["L12.Irel"].label) plt.plot(dict_variables_all["L12.Irel"].time/3600, dict_variables_all["L12.Irel"].values, label=dict_variables_all["L12.Irel"].label)
plt.legend() plt.legend()
plt.show(block=True) plt.show(block=True)
\ No newline at end of file