Professional Documents
Culture Documents
Time_series_ex
Time_series_ex
Time_series_ex
import numpy as np
import pandas as pd
import tempfile
import random
import pandapower as pp
random.seed(10)
def simple_test_net():
"""
b4 sgen
"""
net = pp.create_empty_network()
b1 = pp.create_bus(net, 110)
b2 = pp.create_bus(net, 20)
b3 = pp.create_bus(net, 20)
b4 = pp.create_bus(net, 20)
pp.create_ext_grid(net, b0)
return net
net = simple_test_net()
#print(net)
#############################
def timeseries_example(output_dir):
net = simple_test_net()
n_timesteps = 10
profiles, ds = create_data_source(n_timesteps)
# 3. create controllers (to control P values of the load and the sgen)
create_controllers(net, ds)
# time steps to be calculated. Could also be a list with non-consecutive time steps
run_timeseries(net, time_steps)
print(net.res_line.loading_percent)
#############The DFData(profiles) converts the Dataframe to the required format for the controllers.
def create_data_source(n_timesteps=24):
profiles = pd.DataFrame()
ds = DFData(profiles)
return profiles, ds
#print(profiles.head())
########create the controllers by telling the function which element_index belongs to which profile.
data_source=ds, profile_name=["load1_p"])
data_source=ds, profile_name=["sgen1_p"])
####### create the output writer. Instead of saving the whole net (which takes a lot of time), we extract
only pre defined outputs
# these variables are saved to the harddisk after / during the time series loop
ow.log_variable('res_load', 'p_mw')
ow.log_variable('res_bus', 'vm_pu')
ow.log_variable('res_line', 'loading_percent')
ow.log_variable('res_line', 'i_ka')
return ow
if not os.path.exists(output_dir):
os.mkdir(output_dir)
timeseries_example(output_dir)