def test_const_control(simple_test_net): net = simple_test_net profiles, ds = create_data_source() time_steps = range(0, 10) ow = setup_output_writer(net, time_steps) ConstControl(net, 'load', 'p_mw', element_index=0, data_source=ds, profile_name='load1', scale_factor=0.85) ConstControl(net, 'ext_grid', 'vm_pu', element_index=0, data_source=ds, profile_name='slack_v') run_timeseries(net, time_steps, output_writer=ow, verbose=False) assert np.alltrue(profiles['load1'].values * 0.85 == ow.output['load.p_mw'][0].values) assert np.alltrue( profiles['slack_v'].values == ow.output['res_bus.vm_pu'][0].values)
def create_controllers(net, ds): ConstControl(net, element='load', variable='p_mw', element_index=[1], data_source=ds, profile_name=["load1_p"]) ConstControl(net, element='load', variable='p_mw', element_index=[2], data_source=ds, profile_name=["load2_p"]) ConstControl(net, element='load', variable='p_mw', element_index=[3], data_source=ds, profile_name=["load3_p"]) ConstControl(net, element='load', variable='p_mw', element_index=[4], data_source=ds, profile_name=["load4_p"]) ConstControl(net, element='load', variable='p_mw', element_index=[5], data_source=ds, profile_name=["load5_p"]) # ConstControl(net, element='sgen', variable='p_mw', element_index=[0], # data_source=ds, profile_name=["sgen1_p"]) return net
def create_controllers(net, ds, state='NS'): ConstControl(net, element='load', variable='p_mw', element_index=[0], data_source=ds, profile_name=["load1_p"]) ConstControl(net, element='load', variable='p_mw', element_index=[1], data_source=ds, profile_name=["load2_p"]) ConstControl(net, element='load', variable='p_mw', element_index=[2], data_source=ds, profile_name=["load3_p"]) ConstControl(net, element='sgen', variable='p_mw', element_index=[0], data_source=ds, profile_name=["sgen1_p"]) if state in ['NS', 'HL', 'LL', 'LD']: ConstControl(net, element='sgen', variable='p_mw', element_index=[1], data_source=ds, profile_name=["sgen2_p"])
def create_controllers(net, ds): load1= pp.get_element_index(net, "load", 'load1') sgen1 = pp.get_element_index(net, "sgen", 'sgen1') ConstControl(net, element='load', variable='p_mw', element_index=[load1], data_source=ds, profile_name=["load1_p"]) ConstControl(net, element='sgen', variable='p_mw', element_index=[sgen1], data_source=ds, profile_name=["sgen1_p"]) return net
def create_controllers(net, ds): ConstControl(net, element='load', variable='p_mw', element_index=[14], data_source=ds, profile_name=["load1_p"]) ConstControl(net, element='sgen', variable='p_mw', element_index=[5], data_source=ds, profile_name=["sgen1_p"])
def create_controllers(net, ds): for load in range(len(net.load)): ConstControl(net, element='load', variable='p_mw', element_index=load, data_source=ds, profile_name=["load1_p"]) for PV in range(len(net.sgen)): ConstControl(net, element='sgen', variable='p_mw', element_index=PV, data_source=ds, profile_name=["sgen1_p"])
def test_output_dump_after_time(simple_test_net): net = simple_test_net n_timesteps = 100 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) time_steps = range(0, n_timesteps) # write output after 0.1 minutes to disk ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), output_file_type=".json", write_time=0.05) 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') run_timeseries(net, time_steps, output_writer=ow, verbose=False)
def create_controllers(net, ds): for i in range(len(net.load)): ConstControl(net, element='load', variable='p_mw', element_index=[i], data_source=ds, profile_name=['load{}_P'.format(str(i))]) ConstControl(net, element='load', variable='q_mvar', element_index=[i], data_source=ds, profile_name=['load{}_Q'.format(str(i))]) return net
def test_store_and_load(simple_test_net): net = simple_test_net n_timesteps = 2 profiles, ds = create_data_source(n_timesteps) ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) dirname = tempfile.gettempdir() ow = OutputWriter(net, output_path=dirname, output_file_type=".json") ow.remove_log_variable("res_bus") tmp_file = os.path.join(dirname, "net.json") pp.to_json(net, tmp_file) del net del ow res_line_file = os.path.join(dirname, "res_line", "loading_percent.json") # del result file is one is present if os.path.isfile(res_line_file): os.remove(res_line_file) net = pp.from_json(tmp_file) ow = net.output_writer.iat[0, 0] assert len(ow.log_variables) == 1 assert ow.output_path == dirname time_steps = range(0, n_timesteps) run_timeseries(net, time_steps=time_steps, verbose=False) # check if results were written assert os.path.isfile(res_line_file)
def test_timeseries_results(simple_test_net): # This test compares output writer results with input # test net net = simple_test_net net.user_pf_options = dict() n_timesteps = 5 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"], scale_factor=0.5) time_steps = range(0, n_timesteps) ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), output_file_type=".json") 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') run_timeseries(net, time_steps, output_writer=ow, verbose=False) assert np.allclose( ow.output['res_load.p_mw'].sum().values * 2, profiles[["load1", "load2_mv_p", "load3_hv_p"]].sum().values) # 3load - @Rieke What is this test for compared to the first one? # @Flo in / out of service testen ... ow.log_variable('res_load', 'p_mw') net.controller.in_service = False # set the first controller out of service ConstControl(net, 'load', 'p_mw', element_index=0, data_source=ds, profile_name='load1') run_timeseries(net, time_steps, output_writer=ow, verbose=False) assert np.allclose(ow.output['res_load.p_mw'][0].sum(), profiles["load1"].sum())
def create_controllers(self, ds): # Change the load in the pandapower network based on the provided data source for i in range(len(self.net.load)): ConstControl(self.net, element='load', variable='p_mw', element_index=[i], data_source=ds, profile_name=['load_{}_p'.format(str(i))]) ConstControl(self.net, element='load', variable='q_mvar', element_index=[i], data_source=ds, profile_name=['load_{}_q'.format(str(i))]) return self.net
def test_timeseries_var_func(simple_test_net): # This test checks if the output writer works with a user defined function # test net net = simple_test_net n_timesteps = 5 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"], scale_factor=0.5) time_steps = range(0, n_timesteps) ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_load', 'p_mw', eval_function=np.max) ow.log_variable('res_bus', 'vm_pu', eval_function=np.min) ow.log_variable('res_bus', 'q_mvar', eval_function=np.sum) run_timeseries(net, time_steps, output_writer=ow, verbose=False) # asserts if last value of output_writers output is the minimum value assert net["res_load"]["p_mw"].max( ) == ow.output["res_load.p_mw"].iloc[-1].values assert net["res_bus"]["vm_pu"].min() == ow.output["res_bus.vm_pu"].iloc[-1, -1] assert net["res_bus"]["q_mvar"].sum( ) == ow.output["res_bus.q_mvar"].iloc[-1].values # get minimum voltage of all hv busses mask = (net.bus.vn_kv > 70.0) & (net.bus.vn_kv < 380.0) hv_busses_index = net.bus.loc[mask].index mask = (net.bus.vn_kv > 1.0) & (net.bus.vn_kv < 70.0) mv_busses_index = net.bus.loc[mask].index ow.log_variable('res_bus', 'vm_pu', index=hv_busses_index, eval_function=np.min, eval_name="hv_bus_min") ow.log_variable('res_bus', 'vm_pu', index=mv_busses_index, eval_function=np.min, eval_name="mv_bus_min") run_timeseries(net, time_steps, output_writer=ow, verbose=False) assert net["res_bus"].loc[hv_busses_index, "vm_pu"].min() == ow.output["res_bus.vm_pu"].loc[ time_steps[-1], "hv_bus_min"] assert net["res_bus"].loc[mv_busses_index, "vm_pu"].min() == ow.output["res_bus.vm_pu"].loc[ time_steps[-1], "mv_bus_min"]
def apply_const_controllers(net, absolute_profiles_values): """ Applys ConstControl instances to the net. As a result, one can easily run timeseries with given power values of e.g. loads, sgens, storages or gens. INPUT: **net** - pandapower net **absolute_profiles_values** - dict of Dataframes with absolute values for the profiles, keys should be tuples of length 2 (element and parameter), DataFrame size is timesteps x number of elements """ n_time_steps = dict() for (elm, param), values in absolute_profiles_values.items(): if values.shape[1]: # check DataFrame shape[0] == time_steps if elm in n_time_steps.keys(): if n_time_steps[elm] != values.shape[0]: logger.warning( "There are two profiles for %ss which have different " % elm + "amount of time steps.") else: n_time_steps[elm] = values.shape[0] # check DataFrame shape[1] == net[elm].index unknown_idx = values.columns.difference(net[elm].index) if len(unknown_idx): logger.warning( "In absolute_profiles_values[%s][%s], " % (elm, param) + "there are indices additional & unknown to net[%s].index" % elm + str(["%i" % i for i in unknown_idx])) missing_idx = net[elm].index.difference(values.columns) if len(missing_idx): logger.warning( "In absolute_profiles_values[%s][%s], " % (elm, param) + "these indices are missing compared to net[%s].index" % elm + str(["%i" % i for i in missing_idx])) # apply const controllers idx = list(net[elm].index.intersection(values.columns)) ConstControl(net, element=elm, variable=param, element_index=idx, profile_name=idx, data_source=DFData( absolute_profiles_values[(elm, param)][idx])) # compare all DataFrame shape[0] == time_steps if len(set(n_time_steps.values())) > 1: logger.warning("The profiles have different amount of time steps:") logger.warning(n_time_steps)
def test_const_control_write_to_object_attribute(simple_test_net): net = simple_test_net profiles, ds = create_data_source() time_steps = range(0, 10) ow = setup_output_writer(net, time_steps) ContinuousTapControl(net, 0, 1., level=1, check_tap_bounds=False) ConstControl(net, 'load', 'p_mw', element_index=0, data_source=ds, profile_name='load1', scale_factor=0.85) ConstControl(net, 'ext_grid', 'vm_pu', element_index=0, data_source=ds, profile_name='slack_v') ConstControl(net, 'controller', 'object.vm_set_pu', element_index=0, data_source=ds, profile_name='trafo_v') run_timeseries(net, time_steps, output_writer=ow, verbose=False) assert np.alltrue(profiles['load1'].values * 0.85 == ow.output['load.p_mw'][0].values) assert np.alltrue( profiles['slack_v'].values == ow.output['res_bus.vm_pu'][0].values) assert np.allclose( profiles['trafo_v'].values, ow.output['res_bus.vm_pu'][net.trafo.at[0, 'lv_bus']].values, atol=1e-3, rtol=0)
def test_output_writer_multiple_index_definition(simple_test_net): net = simple_test_net n_timesteps = 1 profiles, ds = create_data_source(n_timesteps) ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) time_steps = range(0, n_timesteps) ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_bus', 'vm_pu', net.load.bus[[0, 1]]) ow.log_variable('res_bus', 'vm_pu', index=[1, 2]) ow.log_variable('res_bus', 'vm_pu', index=[3, 2, 1]) ow.log_variable('res_bus', 'vm_pu', net.load.bus) ow.log_variable('res_bus', 'vm_pu', index=[3, 4]) ow.log_variable('res_bus', 'vm_pu', net.bus.index) ow.log_variable('res_bus', 'vm_pu', 0) run_timeseries(net, time_steps) backup_result = copy.deepcopy( ow.output["res_bus.vm_pu"].loc[:, net.bus.index]) del ow ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_bus', 'vm_pu', net.bus.index) # run_timeseries(net, time_steps) run_timeseries(net, time_steps) # assert all are considered assert len(ow.output["res_bus.vm_pu"].columns) == len(net.bus.index) # assert correct order of values assert np.allclose(backup_result, ow.output["res_bus.vm_pu"].loc[:, net.bus.index])
def test_default_output_writer(simple_test_net): net = simple_test_net n_timesteps = 5 profiles, ds = create_data_source(n_timesteps) ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) time_steps = range(0, n_timesteps) run_timeseries(net, time_steps, verbose=False) ow = net.output_writer.iloc[0, 0] loading_percent = ow.output["res_line.loading_percent"] vm_pu = ow.output["res_bus.vm_pu"] assert loading_percent.shape[0] == n_timesteps and loading_percent.shape[ 1] == len(net.line) assert vm_pu.shape[0] == n_timesteps and vm_pu.shape[1] == len(net.bus)
def test_time_steps(simple_test_net): net = simple_test_net n_timesteps = 11 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) # correct run_timeseries(net, time_steps=range(0, n_timesteps), verbose=False) # also correct run_timeseries(net, time_steps=[0, 2, 4, 8, 9], verbose=False) # ok. missing time_step list -> should check the datasource run_timeseries(net, verbose=False) # depricated run_timeseries(net, time_steps=(0, 10), verbose=False)
def test_output_writer_eval_simple(simple_test_net): net = simple_test_net n_timesteps = 1 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) time_steps = range(0, n_timesteps) ow = OutputWriter(net, time_steps, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_bus', 'vm_pu', eval_function=max, eval_name="max") run_timeseries(net, time_steps, verbose=False) assert len(ow.output["res_bus.vm_pu"]["max"]) == n_timesteps
def test_output_writer_without_timesteps_set(simple_test_net): net = simple_test_net n_timesteps = 5 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) time_steps = range(0, n_timesteps) ow = OutputWriter(net, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_bus', 'vm_pu') ow.log_variable('res_line', 'i_ka') run_timeseries(net, time_steps) assert len(ow.output["res_bus.vm_pu"]) == n_timesteps assert len(ow.output["res_line.i_ka"]) == n_timesteps
def test_ppc_log(simple_test_net): net = simple_test_net n_timesteps = 5 profiles, ds = create_data_source(n_timesteps) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"], recycle=True) time_steps = range(0, n_timesteps) ow = OutputWriter(net, output_path=tempfile.gettempdir(), output_file_type=".json", log_variables=list()) ow.log_variable('ppc_bus', 'vm') ow.log_variable('ppc_bus', 'va') pp.runpp(net, only_v_results=True, recycle={ "bus_pq": True, "gen": False, "trafo": False }) run_timeseries(net, time_steps, recycle={ "bus_pq": True, "gen": False, "trafo": False }, only_v_results=True, verbose=False) assert len(ow.output["ppc_bus.vm"]) == n_timesteps assert len(ow.output["ppc_bus.va"]) == n_timesteps
def test_output_writer_short_data_source(simple_test_net): net = simple_test_net # outputwriter should fail if data source is shorter than time steps n_timesteps = 10 profiles, ds = create_data_source(5) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) time_steps = range(0, n_timesteps) ow = OutputWriter(net, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_bus', 'vm_pu') ow.log_variable('res_line', 'i_ka') with pytest.raises(KeyError): run_timeseries(net, time_steps, verbose=False)
def test_output_writer_without_timesteps_set_repeat(simple_test_net): net = simple_test_net # the same outputwriter should be able to run repeated time series time_steps_to_check = [8, 5, 10] profiles, ds = create_data_source(max(time_steps_to_check)) # 1load ConstControl(net, element='load', variable='p_mw', element_index=[0, 1, 2], data_source=ds, profile_name=["load1", "load2_mv_p", "load3_hv_p"]) ow = OutputWriter(net, output_path=tempfile.gettempdir(), output_file_type=".json") ow.log_variable('res_bus', 'vm_pu') ow.log_variable('res_line', 'i_ka') for n_timesteps in time_steps_to_check: time_steps = range(0, n_timesteps) run_timeseries(net, time_steps, verbose=False) assert len(ow.output["res_bus.vm_pu"].index) == n_timesteps
def simulate_network(scenario, installations_percent, cooperation_percent, installation_buses, cooperating_buses, individual_buses): scenario_name = get_scenario_name(scenario) full_dir_path = "data/results/{}/03-simulation/{}_installations/{}_cooperative".format( scenario_name, installations_percent, cooperation_percent) if os.path.exists(full_dir_path) and SKIP_EXISTING: if PRINT_SKIPPING_LINES: print("[{}] [{}%] [{}%] Simulating network... [skipping]".format( scenario_name, installations_percent, cooperation_percent)) return False print("[{}] [{}%] [{}%] Simulating network...".format( scenario_name, installations_percent, cooperation_percent)) net = ieee_european_lv_asymmetric('on_peak_566') for index, _ in net.asymmetric_load.iterrows(): net.asymmetric_load.in_service.at[index] = False pandapower.runpp(net) for original_index, row in buses.iterrows(): load_index = pandapower.create_load(net, bus=row.bus, p_mw=0) load_profile_raw = pandas.read_csv( "data/source/load_profiles/Load_profile_{}.csv".format( original_index + 1), sep=",", decimal=".") load_profile_raw['mult'] = load_profile_raw['mult'].apply( convertkWToMW).iloc[::10].reset_index(drop=True) load_profile = frame_data.DFData(pandas.DataFrame(load_profile_raw)) load_controller = ConstControl(net, element='load', element_index=load_index, variable='p_mw', data_source=load_profile, profile_name='mult', recycle=False) for original_index, row in installation_buses.iterrows(): if scenario.get('EV') == True: ev_index = pandapower.create_load(net, bus=row.bus, p_mw=0) ev_profile_raw = pandas.read_csv( "data/source/ev_profiles/EV_home_profiles_{}.csv".format( original_index + 1), sep=";", decimal=",") ev_profile_raw['load'] = ev_profile_raw['load'].apply( convert10minkWhTokW).apply(convertkWToMW) ev_profile = frame_data.DFData(pandas.DataFrame(ev_profile_raw)) ev_controller = ConstControl(net, element='load', element_index=ev_index, variable='p_mw', data_source=ev_profile, profile_name='load', recycle=False) if scenario.get('PV') == True: sgen_index = pandapower.create_sgen(net, bus=row.bus, p_mw=0, sn_mva=0, type='PV') pv_profile_raw = pandas.read_csv("data/source/PVProfile1440.csv", sep=";", decimal=".") pv_profile_raw['pv_output_power_kw'] = pv_profile_raw[ 'pv_output_power_kw'].apply( convertkWToMW).iloc[::10].reset_index(drop=True) pv_profile = frame_data.DFData(pandas.DataFrame(pv_profile_raw)) sgen_controller = ConstControl(net, element='sgen', element_index=sgen_index, variable='p_mw', data_source=pv_profile, profile_name='pv_output_power_kw', recycle=False) for original_index, row in cooperating_buses.iterrows(): storage_index = pandapower.create_storage( net, bus=row.bus, p_mw=0, max_e_mwh=BATTERY_ENERGY_MAX / 1000.0, soc_percent=(INITIAL_BATTERY_CHARGE / BATTERY_ENERGY_MAX) * 100.0, max_p_mw=RATED_P / 1000.0, min_p_mw=-RATED_P / 1000.0) storage_profile_raw = pandas.read_csv( "data/results/{}/02-collective/{}_installations/{}_cooperation/Storage_profile_{}.csv" .format(scenario_name, installations_percent, cooperation_percent, original_index + 1), sep=",", decimal=".") storage_profile_raw['power_kW'] = storage_profile_raw[ 'power_kW'].apply(convertkWToMW).apply(convertStorage) storage_profile = frame_data.DFData( pandas.DataFrame(storage_profile_raw)) storage_controller = ConstControl(net, element='storage', element_index=storage_index, variable='p_mw', data_source=storage_profile, profile_name='power_kW', recycle=False) for original_index, row in individual_buses.iterrows(): storage_index = pandapower.create_storage( net, bus=row.bus, p_mw=0, max_e_mwh=BATTERY_ENERGY_MAX / 1000.0, soc_percent=(INITIAL_BATTERY_CHARGE / BATTERY_ENERGY_MAX) * 100.0, max_p_mw=RATED_P / 1000.0, min_p_mw=-RATED_P / 1000.0) storage_profile_raw = pandas.read_csv( "data/results/{}/01-individual/storage-profiles/Storage_profile_{}.csv" .format(scenario_name, original_index + 1), sep=",", decimal=".") storage_profile_raw['power_kW'] = storage_profile_raw[ 'power_kW'].apply(convertkWToMW).apply(convertStorage) storage_profile = frame_data.DFData( pandas.DataFrame(storage_profile_raw)) storage_controller = ConstControl(net, element='storage', element_index=storage_index, variable='p_mw', data_source=storage_profile, profile_name='power_kW', recycle=False) time_steps = range(0, T) ow = OutputWriter(net, output_path=full_dir_path, output_file_type=".csv", log_variables=[]) ow.log_variable("load", "p_mw") ow.log_variable("res_bus", "vm_pu", index=buses_nodes) ow.log_variable("res_line", "p_to_mw", index=line_nodes) ow.log_variable("res_trafo", "vm_lv_pu") ow.log_variable("res_trafo", "p_lv_mw") if scenario.get('PV') == True: ow.log_variable("sgen", "p_mw") if cooperating_buses.size > 0 or individual_buses.size > 0: ow.log_variable("storage", "p_mw") run_timeseries(net, time_steps, continue_on_divergence=True, verbose=False) return True
def coupled_g2p_const_control(multinet, element_index_power, element_index_gas, g2p_efficiency=0.6, name_power_net='power', name_gas_net='gas', element_type_power="sgen", profile_name=None, data_source=None, scale_factor=1.0, power_led=False, in_service=True, order=(0, 1), level=0, drop_same_existing_ctrl=False, matching_params=None, initial_run=False, **kwargs): """ Creates a ConstController (gas consumption) and a G2P Controller (corresponding power output). The ConstController updates gas consumption values of a given sink element in accordance to the profile given in the datasource. The G2PControlMultiEnergy-controller couples a gas network (from pandapipes) and a power network (from pandapower). It reads the gas consumption values that were updated by the ConstController, applies the efficiency factor and unit conversions and writes the resulting power output to 'sgen' or 'gen' elements in the power net. The ConstController is stored in the gas net inside the multinet. The G2PControlMultiEnergy is stored in the controller-DataFrame of the multinet itself (multinet.controller). Both controllers are run by run_control_multinet.run_control() or within run_time_series_multinet.run_timeseries(). :param multinet: pandapipes-Mulitnet that includes the power and gas network with load and source elements :type multinet: attrdict (pandapipes.MultiNet) :param element_index_power: Index of one or more sgen/gen elements in the power net to which the power generation values from the data source will be written :type element_index_power: int or iterable of integers :param element_index_gas: Index of one or more sink elements in the gas net to which the corresponding calculated mass flow will be written :param g2p_efficiency: constant efficiency factor (default: based on HHV) :type g2p_efficiency: float :param name_power_net: Key name to find the power net in multinet['nets'] :type name_power_net: str :param name_gas_net: Key name to find the gas net in multinet['nets'] :type name_gas_net: str :param element_type_power: type of the corresponding power generation units, either 'sgen' or 'gen' :type element_type_power: str :param profile_name: The profile names of the elements in the data source :type profile_name: str :param data_source: The data source that provides profile data :type data_source: object :param scale_factor: Scaling factor for time series input values :type scale_factor: real :param in_service: Indicates if the controllers are currently in_service :type in_service: bool :param order: within the same level, controllers with lower order are called before controllers with numerical higher order. Default: (0, 1) -> ConstController updates values before G2P controller calculates power output :type order: tuple of integers :param level: level to which the controllers belong. Low level is called before higher level. Respective run function for the nets are called at least once per level. :type level: real :param drop_same_existing_ctrl: Indicates if already existing controllers of the same type and with the same matching parameters (e.g. at same element) should be dropped :type drop_same_existing_ctrl: bool :param matching_params: is required to check if same controller already exists (dropping or logging) :type matching_params: dict :param initial_run: Whether a power and pipe flow should be run before the control step is applied or not :type initial_run: bool :param kwargs: optional additional controller arguments that were implemented by users :type kwargs: :return: (ID of the ConstController, ID of G2P controller) :rtype: """ if power_led: net_power = multinet['nets'][name_power_net] const = ConstControl(net_power, element='sgen', variable='p_mw', element_index=element_index_power, profile_name=profile_name, data_source=data_source, scale_factor=scale_factor, in_service=in_service, order=order[0], level=level, drop_same_existing_ctrl=drop_same_existing_ctrl, matching_params=matching_params, initial_run=initial_run, **kwargs) else: net_gas = multinet['nets'][name_gas_net] const = ConstControl(net_gas, element='sink', variable='mdot_kg_per_s', element_index=element_index_gas, profile_name=profile_name, data_source=data_source, scale_factor=scale_factor, in_service=in_service, order=order[0], level=level, drop_same_existing_ctrl=drop_same_existing_ctrl, matching_params=matching_params, initial_run=initial_run, **kwargs) g2p = G2PControlMultiEnergy( multinet, element_index_power, element_index_gas, g2p_efficiency, name_power_net, name_gas_net, element_type_power, in_service, order[1], level, drop_same_existing_ctrl=drop_same_existing_ctrl, initial_run=initial_run, calc_gas_from_power=power_led, **kwargs) return const, g2p
for _, row in consumer_bus_indices.iterrows(): # initialize loads load_index = pp.create_load(net, bus=row.bus, p_mw=0) load_profile_raw = pd.read_csv( "European_LV_Test_Feeder_v2/European_LV_CSV/Load Profiles/"+row.load_profile_filename, sep=",", decimal=".") load_profile_raw['mult'] = load_profile_raw['mult'].apply( convertkWToMW).iloc[::10].reset_index(drop=True) load_profile = fd.DFData(pd.DataFrame(load_profile_raw)) load_controller = ConstControl( net, element='load', element_index=load_index, variable='p_mw', data_source=load_profile, profile_name='mult', recycle=False ) # initialize PV generation sgen_index = pp.create_sgen(net, bus=row.bus, p_mw=0, sn_mva=0, type='PV') pv_profile_raw = pd.read_csv("PVProfile1440.csv", sep=";", decimal=".") pv_profile_raw['pv_output_power_kw'] = pv_profile_raw['pv_output_power_kw'].apply( convertkWToMW).iloc[::10].reset_index(drop=True) pv_profile = fd.DFData(pd.DataFrame(pv_profile_raw)) sgen_controller = ConstControl( net, element='sgen', element_index=sgen_index, variable='p_mw',
def def_prod(net, index, df_scale, pmax): df = pd.DataFrame() df['prod'] = df_scale['scale'].values * pmax ds = pt.DFData(df) ConstControl(net, element="sgen", variable = 'p_mw', element_index = index, data_source = ds, profile_name="prod")
def def_charge(net, index, df_scale, Pmax): df = pd.DataFrame() df['charge'] = df_scale['scale'].values * Pmax ds = pt.DFData(df) ConstControl(net, element="load", variable = 'p_mw', element_index = index, data_source = ds, set_q_from_cosphi = False, profile_name="charge") return net