Commit e24e25bd authored by Jan Dinkelbach's avatar Jan Dinkelbach
Browse files

Fix CI

parent d02a0ae9
%% Cell type:markdown id: tags:
# EMT Simulation of CIGRE MV with PV Inverters
%% Cell type:markdown id: tags:
### Run simulation
%% Cell type:code id: tags:
``` python
%%bash
TOP=${TOP:-$(git rev-parse --show-toplevel)}
PATH=${TOP}/build/Examples/Cxx
EMT_CIGRE_MV_withDG --timestep=0.1e-3 --duration=3 ${TOP}/build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_noLoad1_LeftFeeder_With_LoadFlow_Results/*.xml
EMT_CIGRE_MV_withDG --timestep=1e-3 --duration=3 ${TOP}/build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_noLoad1_LeftFeeder_With_LoadFlow_Results/*.xml
```
%% Cell type:markdown id: tags:
## Powerflow
%% Cell type:markdown id: tags:
### Read results
%% Cell type:code id: tags:
``` python
time_step = 0.001
num_steps_window = int(0.02/time_step)
from villas.dataprocessing.readtools import *
from villas.dataprocessing.timeseries import *
import matplotlib.pyplot as plt
import re
# %matplotlib widget
modelName = 'EMT_CIGRE_MV_withDG_Powerflow'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim_powerflow = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
### Plot results
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,8))
for ts_name, ts_obj in ts_dpsim_powerflow.items():
if ts_name != 'N0.V':
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### Node voltages
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim_powerflow.items():
print(ts_name + ': ' + str(ts_obj.abs().values[0]) + ', ' + str(ts_obj.phase().values[0]))
```
%% Cell type:markdown id: tags:
## EMT
%% Cell type:markdown id: tags:
### Read results
%% Cell type:code id: tags:
``` python
modelName = 'EMT_CIGRE_MV_withDG'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
### Plot results
%% Cell type:markdown id: tags:
### All node voltages
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,12))
subplot_number = 1
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-3:] == 'V_0' and ts_name[:-2] != 'N0.V':
plt.subplot(4,3,subplot_number)
subplot_number += 1
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
plt.legend(loc='upper right')
plt.xlim([-0.03,1])
plt.show()
```
%% Cell type:markdown id: tags:
## Voltages at first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-3:] == 'V_0':
print(ts_name + ': ' + str(ts_obj.values[0]))
```
%% Cell type:markdown id: tags:
## Maximum voltage in last 20ms window
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-3:] == 'V_0':
print(ts_name + ': ' + str(max(ts_obj.values[-num_steps_window:])))
```
%% Cell type:markdown id: tags:
## PV inverter
%% Cell type:markdown id: tags:
### States - Powers
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-7:]=='state_p' or ts_name[-7:]=='state_q':
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### States - Others
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-7:]!='state_p' and ts_name[-7:]!='state_q' and 'state' in ts_name:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### States at first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'state' in ts_name:
print(ts_name + ': ' + str(ts_obj.abs().values[0]) + ', ' + str(ts_obj.phase().values[0]))
```
%% Cell type:markdown id: tags:
### States at last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'state' in ts_name:
print(ts_name + ': ' + str(ts_obj.abs().values[-1]) + ', ' + str(ts_obj.phase().values[-1]))
```
%% Cell type:markdown id: tags:
### Plot inputs
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if 'input' in ts_name:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### Inputs at first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'input' in ts_name:
print(ts_name + ': ' + str(ts_obj.abs().values[0]) + ', ' + str(ts_obj.phase().values[0]))
```
%% Cell type:markdown id: tags:
### Inputs at last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'input' in ts_name:
print(ts_name + ': ' + str(ts_obj.abs().values[-1]) + ', ' + str(ts_obj.phase().values[-1]))
```
%% Cell type:markdown id: tags:
### Plot outputs
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if 'output' in ts_name:
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### Outputs at first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'output' in ts_name:
print(ts_name + ': ' + str(ts_obj.abs().values[0]) + ', ' + str(ts_obj.phase().values[0]))
```
%% Cell type:markdown id: tags:
### Outputs at last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'output' in ts_name:
print(ts_name + ': ' + str(ts_obj.abs().values[-1]) + ', ' + str(ts_obj.phase().values[-1]))
```
%% Cell type:markdown id: tags:
### Plot interface vars
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
subplot_number = 1
for ts_name, ts_obj in ts_dpsim.items():
if 'intf' in ts_name:
plt.subplot(2,3,subplot_number)
subplot_number += 1
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
plt.legend(loc='upper right')
plt.show()
```
%% Cell type:markdown id: tags:
## Plot derived power
%% Cell type:code id: tags:
``` python
pv_N11_p_inst_intf = ts_dpsim['pv_N11_v_intf_0'].values*ts_dpsim['pv_N11_i_intf_0'].values+ts_dpsim['pv_N11_v_intf_1'].values*ts_dpsim['pv_N11_i_intf_1'].values+ts_dpsim['pv_N11_v_intf_2'].values*ts_dpsim['pv_N11_i_intf_2'].values
plt.figure(figsize=(12,6))
plt.plot(ts_dpsim['pv_N11_v_intf_0'].time, pv_N11_p_inst_intf, label='pv_N11_p_inst_intf')
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### Interface vars at first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'intf' in ts_name:
print(ts_name + ': ' + str(ts_obj.values[0]))
print('pv_N11_p_inst_intf' + ': ' + str(pv_N11_p_inst_intf[0]))
```
%% Cell type:markdown id: tags:
### Interface vars at last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if 'intf' in ts_name:
print(ts_name + ': ' + str(ts_obj.values[-1]))
print('pv_N11_p_inst_intf' + ': ' + str(pv_N11_p_inst_intf[-1:]))
```
......
%% Cell type:markdown id: tags:
# EMT Simulation of CIGRE MV with PV Inverters and Load Step
%% Cell type:markdown id: tags:
### Run simulation
%% Cell type:code id: tags:
``` python
%%bash
TOP=${TOP:-$(git rev-parse --show-toplevel)}
PATH=${TOP}/build/Examples/Cxx
EMT_CIGRE_MV_withDG_withLoadStep --timestep=0.1e-3 --duration=3 ${TOP}/build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_noLoad1_LeftFeeder_With_LoadFlow_Results/*.xml
EMT_CIGRE_MV_withDG_withLoadStep --timestep=1e-3 --duration=3 ${TOP}/build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_noLoad1_LeftFeeder_With_LoadFlow_Results/*.xml
```
%% Cell type:markdown id: tags:
## Powerflow
%% Cell type:markdown id: tags:
### Read results
%% Cell type:code id: tags:
``` python
from villas.dataprocessing.readtools import *
from villas.dataprocessing.timeseries import *
import matplotlib.pyplot as plt
import re
modelName = 'EMT_CIGRE_MV_withDG_withLoadStep_Powerflow'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
### Plot results
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name != 'N0.V':
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
## EMT
%% Cell type:code id: tags:
``` python
modelName = 'EMT_CIGRE_MV_withDG_withLoadStep'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
### Plot results
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-2:] == '_0' and ts_name[:-2] != 'N0.V':
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
## Voltages at first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-2:] == '_0':
print(ts_name + ': ' + str(ts_obj.values[0]))
```
%% Cell type:markdown id: tags:
### Plot zoomed to Load Step
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-2:] == '_0' and ts_name[:-2] != 'N0.V':
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
#plt.ylim([19000,21000])
plt.xlim([1.999,2.015])
plt.legend()
plt.show()
```
......
%% Cell type:markdown id: tags:
# EMT Simulation of CIGRE MV without PV Inverters
%% Cell type:markdown id: tags:
### Run simulation
%% Cell type:code id: tags:
``` python
%%bash
TOP=${TOP:-$(git rev-parse --show-toplevel)}
PATH=${TOP}/build/Examples/Cxx
EMT_CIGRE_MV_withoutDG --timestep=0.1e-3 --duration=1 ${TOP}/build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_noLoad1_LeftFeeder_With_LoadFlow_Results/*.xml
EMT_CIGRE_MV_withoutDG --timestep=1e-3 --duration=1 ${TOP}/build/_deps/cim-data-src/CIGRE_MV/NEPLAN/CIGRE_MV_no_tapchanger_noLoad1_LeftFeeder_With_LoadFlow_Results/*.xml
```
%% Cell type:markdown id: tags:
## Powerflow
%% Cell type:markdown id: tags:
### Read results
%% Cell type:code id: tags:
``` python
from villas.dataprocessing.readtools import *
from villas.dataprocessing.timeseries import *
import matplotlib.pyplot as plt
import re
# %matplotlib widget
modelName = 'EMT_CIGRE_MV_withoutDG_Powerflow'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim_powerflow = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
### Plot results
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim_powerflow.items():
if ts_name != 'N0.V':
plt.plot(ts_obj.time, ts_obj.abs().values, label=ts_name)
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
## EMT
%% Cell type:markdown id: tags:
### Read results
%% Cell type:code id: tags:
``` python
modelName = 'EMT_CIGRE_MV_withoutDG'
path = 'logs/' + modelName + '/'
dpsim_result_file = path + modelName + '.csv'
ts_dpsim = read_timeseries_csv(dpsim_result_file)
```
%% Cell type:markdown id: tags:
### Plot Node voltages
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-3:] == 'V_0' and ts_name[:-2] != 'N0.V':
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
plt.plot(ts_dpsim_powerflow[ts_name[:-2]].time, np.sqrt(2/3)*ts_dpsim_powerflow[ts_name[:-2]].abs().values, label=ts_name[:-2])
plt.xlim([0,0.1])
plt.legend()
plt.show()
```
%% Cell type:markdown id: tags:
### At first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.V_0':
print(ts_name + ': ' + str(ts_obj.values[0]))
```
%% Cell type:markdown id: tags:
### At last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.V_0':
print(ts_name + ': ' + str(ts_obj.values[-1:]))
```
%% Cell type:markdown id: tags:
## Load currents
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.I_0' and ts_name[:4]=='LOAD':
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
#plt.xlim([0,0.1])
plt.legend(loc='upper right')
plt.show()
```
%% Cell type:markdown id: tags:
### At first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.I_0' and ts_name[:4]=='LOAD':
print(ts_name + ': ' + str(ts_obj.values[0]))
```
%% Cell type:markdown id: tags:
### At last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.I_0' and ts_name[:4]=='LOAD':
print(ts_name + ': ' + str(ts_obj.values[-1]))
```
%% Cell type:markdown id: tags:
### Load Power Calculations
%% Cell type:code id: tags:
``` python
# load_I_3_p ref from CIM: P=225250, Q=139597
# load_H_11_p ref from CIM: P=329800, Q=82656
load_I_3_p = ts_dpsim['N3.V_0'].values*ts_dpsim['LOAD-I-3.I_0'].values+ts_dpsim['N3.V_1'].values*ts_dpsim['LOAD-I-3.I_1'].values+ts_dpsim['N3.V_2'].values*ts_dpsim['LOAD-I-3.I_2'].values
load_H_11_p = ts_dpsim['N11.V_0'].values*ts_dpsim['LOAD-H-11.I_0'].values+ts_dpsim['N11.V_1'].values*ts_dpsim['LOAD-H-11.I_1'].values+ts_dpsim['N11.V_2'].values*ts_dpsim['LOAD-H-11.I_2'].values
```
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
plt.plot(ts_dpsim['N3.V_0'].time, load_I_3_p, label='load_I_3_p')
plt.plot(ts_dpsim['N11.V_0'].time, load_H_11_p, label='load_H_11_p')
#plt.xlim([0,0.01])
plt.legend(loc='upper right')
plt.show()
```
%% Cell type:markdown id: tags:
### At first timestep
%% Cell type:code id: tags:
``` python
print('Load-I-3.p' + ': ' + str(load_I_3_p[0]))
print('Load-H-11.p' + ': ' + str(load_H_11_p[0]))
```
%% Cell type:markdown id: tags:
### At last timestep
%% Cell type:code id: tags:
``` python
print('Load-I-3.p' + ': ' + str(load_I_3_p[-1]))
print('Load-H-11.p' + ': ' + str(load_H_11_p[-1]))
```
%% Cell type:markdown id: tags:
## Line currents
%% Cell type:code id: tags:
``` python
plt.figure(figsize=(12,6))
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.I_0' and ts_name[:4]!='LOAD':
plt.plot(ts_obj.time, ts_obj.values, label=ts_name)
#plt.xlim([0,0.1])
plt.legend(loc='upper right')
plt.show()
```
%% Cell type:markdown id: tags:
### At first timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.I_0' and ts_name[:4]!='LOAD':
print(ts_name + ': ' + str(ts_obj.values[0]))
```
%% Cell type:markdown id: tags:
### At last timestep
%% Cell type:code id: tags:
``` python
for ts_name, ts_obj in ts_dpsim.items():
if ts_name[-4:] == '.I_0' and ts_name[:4]!='LOAD':
print(ts_name + ': ' + str(ts_obj.values[-1]))
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment