def test_equal_eval_name_warning_and_costs(): net = nw.case5() pp.create_pwl_cost(net, 0, "sgen", [[0, 20, 1], [20, 30, 2]]) pp.create_pwl_cost(net, 0, "gen", [[0, 20, 1], [20, 30, 2]]) pp.create_pwl_cost(net, 1, "gen", [[0, 20, 1], [20, 30, 2]]) pp.create_pwl_cost(net, 2, "gen", [[0, 20, 1], [20, 30, 2]]) df = pd.DataFrame({ 0: [200, 300, 400, 500], 1: [400, 300, 100, 50], 2: [100, 300, 200, 100] }) ds = ts.DFData(df.astype(np.float64)) _ = ct.ConstControl(net, "load", "p_mw", net.load.index, profile_name=net.load.index, data_source=ds) ow = ts.OutputWriter(net, output_path=None) ow.log_variable("res_sgen", "p_mw", None, np.max, 'warnme') ow.log_variable("res_load", "p_mw", None, np.max, 'warnme') ow.log_variable("pwl_cost", "points", eval_function=cost_logging) ow.remove_log_variable("res_bus", "vm_pu") ow.remove_log_variable("res_line", "loading_percent") ts.run_timeseries(net, verbose=False) p_sgen = ow.output["res_sgen.p_mw"] p_load = ow.output["res_load.p_mw"] cost = ow.output["pwl_cost.points"] assert not np.all(p_sgen.values == p_load.values) assert cost.shape == (4, 4) assert len(ow.np_results) == 3
def prod_regulee(net, index, df_scale, pmax): df = pd.DataFrame() df['prod'] = df_scale['scale'].values * pmax ds = pt.DFData(df) ProdQRegulatedControl(net, gid = index, data_source=ds, pmax = pmax)
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_EV_QReg(net, bus, df, pers): ev = pp.create_storage(net, bus, p_mw = 0, max_e_mwh = pers.cap_bat, name = "ev bus"+str(bus), soc_percent=0.5) ds = pt.DFData(df) EVQRegControl(net, gid = ev, data_source=ds, efficiency = pers.efficiency)
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