def rundcopp(net, verbose=False, check_connectivity=True, suppress_warnings=True, r_switch=0.0, delta=1e-10, trafo3w_losses="hv", **kwargs): """ Runs the pandapower Optimal Power Flow. Flexibilities, constraints and cost parameters are defined in the pandapower element tables. Flexibilities for generators can be defined in net.sgen / net.gen. net.sgen.controllable / net.gen.controllable signals if a generator is controllable. If False, the active and reactive power are assigned as in a normal power flow. If yes, the following flexibilities apply: - net.sgen.min_p_kw / net.sgen.max_p_kw - net.gen.min_p_kw / net.gen.max_p_kw - net.load.min_p_kw / net.load.max_p_kw Network constraints can be defined for buses, lines and transformers the elements in the following columns: - net.line.max_loading_percent - net.trafo.max_loading_percent - net.trafo3w.max_loading_percent INPUT: **net** - The pandapower format network OPTIONAL: **verbose** (bool, False) - If True, some basic information is printed **suppress_warnings** (bool, True) - suppress warnings in pypower If set to True, warnings are disabled during the loadflow. Because of the way data is processed in pypower, ComplexWarnings are raised during the loadflow. These warnings are suppressed by this option, however keep in mind all other pypower warnings are suppressed, too. """ if (not net.sgen.empty) & (not "controllable" in net.sgen.columns): logger.warning('Warning: Please specify sgen["controllable"]\n') if (not net.load.empty) & (not "controllable" in net.load.columns): logger.warning('Warning: Please specify load["controllable"]\n') mode = "opf" ac = False init = "flat" copy_constraints_to_ppc = True trafo_model = "t" trafo_loading = 'current' calculate_voltage_angles = True enforce_q_lims = True recycle = dict(_is_elements=False, ppc=False, Ybus=False) # net.__internal_options = {} net._options = {} _add_ppc_options(net, calculate_voltage_angles=calculate_voltage_angles, trafo_model=trafo_model, check_connectivity=check_connectivity, mode=mode, copy_constraints_to_ppc=copy_constraints_to_ppc, r_switch=r_switch, init=init, enforce_q_lims=enforce_q_lims, recycle=recycle, voltage_depend_loads=False, delta=delta, trafo3w_losses=trafo3w_losses) _add_opf_options(net, trafo_loading=trafo_loading, ac=ac) _check_bus_index_and_print_warning_if_high(net) _check_gen_index_and_print_warning_if_high(net) _optimal_powerflow(net, verbose, suppress_warnings, **kwargs)
def rundcopp(net, verbose=False, check_connectivity=True, suppress_warnings=True, switch_rx_ratio=0.5, delta=1e-10, trafo3w_losses="hv", **kwargs): """ Runs the pandapower Optimal Power Flow. Flexibilities, constraints and cost parameters are defined in the pandapower element tables. Flexibilities for generators can be defined in net.sgen / net.gen. net.sgen.controllable / net.gen.controllable signals if a generator is controllable. If False, the active and reactive power are assigned as in a normal power flow. If yes, the following flexibilities apply: - net.sgen.min_p_mw / net.sgen.max_p_mw - net.gen.min_p_mw / net.gen.max_p_mw - net.load.min_p_mw / net.load.max_p_mw Network constraints can be defined for buses, lines and transformers the elements in the following columns: - net.line.max_loading_percent - net.trafo.max_loading_percent - net.trafo3w.max_loading_percent INPUT: **net** - The pandapower format network OPTIONAL: **verbose** (bool, False) - If True, some basic information is printed **suppress_warnings** (bool, True) - suppress warnings in pypower If set to True, warnings are disabled during the loadflow. Because of the way data is processed in pypower, ComplexWarnings are raised during the loadflow. These warnings are suppressed by this option, however keep in mind all other pypower warnings are suppressed, too. **delta** (float, 1e-10) - power tolerance **trafo3w_losses** (str, "hv") - defines where open loop losses of three-winding transformers are considered. Valid options are "hv", "mv", "lv" for HV/MV/LV side or "star" for the star point. """ if (not net.sgen.empty) & ("controllable" not in net.sgen.columns): logger.warning('Warning: Please specify sgen["controllable"]\n') if (not net.load.empty) & ("controllable" not in net.load.columns): logger.warning('Warning: Please specify load["controllable"]\n') _init_rundcopp_options(net, check_connectivity=check_connectivity, switch_rx_ratio=switch_rx_ratio, delta=delta, trafo3w_losses=trafo3w_losses, **kwargs) _check_bus_index_and_print_warning_if_high(net) _check_gen_index_and_print_warning_if_high(net) _optimal_powerflow(net, verbose, suppress_warnings, **kwargs)
def runopp(net, verbose=False, calculate_voltage_angles=False, check_connectivity=False, suppress_warnings=True, r_switch=0.0, delta=1e-10, init="flat", numba=True, trafo3w_losses="hv", **kwargs): """ Runs the pandapower Optimal Power Flow. Flexibilities, constraints and cost parameters are defined in the pandapower element tables. Flexibilities can be defined in net.sgen / net.gen /net.load net.sgen.controllable if a static generator is controllable. If False, the active and reactive power are assigned as in a normal power flow. If True, the following flexibilities apply: - net.sgen.min_p_kw / net.sgen.max_p_kw - net.sgen.min_q_kvar / net.sgen.max_q_kvar - net.load.min_p_kw / net.load.max_p_kw - net.load.min_q_kvar / net.load.max_q_kvar - net.gen.min_p_kw / net.gen.max_p_kw - net.gen.min_q_kvar / net.gen.max_q_kvar - net.ext_grid.min_p_kw / net.ext_grid.max_p_kw - net.ext_grid.min_q_kvar / net.ext_grid.max_q_kvar - net.dcline.min_q_to_kvar / net.dcline.max_q_to_kvar / net.dcline.min_q_from_kvar / net.dcline.max_q_from_kvar Controllable loads behave just like controllable static generators. It must be stated if they are controllable. Otherwise, they are not respected as flexibilities. Dc lines are controllable per default Network constraints can be defined for buses, lines and transformers the elements in the following columns: - net.bus.min_vm_pu / net.bus.max_vm_pu - net.line.max_loading_percent - net.trafo.max_loading_percent - net.trafo3w.max_loading_percent How these costs are combined into a cost function depends on the cost_function parameter. INPUT: **net** - The pandapower format network OPTIONAL: **verbose** (bool, False) - If True, some basic information is printed **suppress_warnings** (bool, True) - suppress warnings in pypower If set to True, warnings are disabled during the loadflow. Because of the way data is processed in pypower, ComplexWarnings are raised during the loadflow. These warnings are suppressed by this option, however keep in mind all other pypower warnings are suppressed, too. **init** (str, "flat") - init of starting opf vector. Options are "flat" or "pf" Starting solution vector (x0) for opf calculations is determined by this flag. Options are: "flat" (default): starting vector is (upper bound - lower bound) / 2 "pf": a power flow is executed prior to the opf and the pf solution is the starting vector. This may improve convergence, but takes a longer runtime (which are probably neglectible for opf calculations) """ logger.warning( "The OPF cost definition has changed! Please check out the tutorial 'opf_changes-may18.ipynb' or the documentation!" ) _check_necessary_opf_parameters(net, logger) if numba: numba = _check_if_numba_is_installed(numba) mode = "opf" ac = True copy_constraints_to_ppc = True trafo_model = "t" trafo_loading = 'current' enforce_q_lims = True recycle = dict(_is_elements=False, ppc=False, Ybus=False) net._options = {} _add_ppc_options(net, calculate_voltage_angles=calculate_voltage_angles, trafo_model=trafo_model, check_connectivity=check_connectivity, mode=mode, copy_constraints_to_ppc=copy_constraints_to_ppc, r_switch=r_switch, init_vm_pu=init, init_va_degree=init, enforce_q_lims=enforce_q_lims, recycle=recycle, voltage_depend_loads=False, delta=delta, trafo3w_losses=trafo3w_losses) _add_opf_options(net, trafo_loading=trafo_loading, ac=ac, init=init, numba=numba) _check_bus_index_and_print_warning_if_high(net) _check_gen_index_and_print_warning_if_high(net) _optimal_powerflow(net, verbose, suppress_warnings, **kwargs)
def runopp(net, verbose=False, calculate_voltage_angles=True, check_connectivity=True, suppress_warnings=True, switch_rx_ratio=2, delta=1e-10, init="flat", numba=True, trafo3w_losses="hv", consider_line_temperature=False, **kwargs): """ Runs the pandapower Optimal Power Flow. Flexibilities, constraints and cost parameters are defined in the pandapower element tables. Flexibilities can be defined in net.sgen / net.gen /net.load / net.storage /net.ext_grid net.sgen.controllable if a static generator is controllable. If False, the active and reactive power are assigned as in a normal power flow. If True, the following flexibilities apply: - net.gen.min_p_mw / net.gen.max_p_mw - net.gen.min_q_mvar / net.gen.max_q_mvar - net.sgen.min_p_mw / net.sgen.max_p_mw - net.sgen.min_q_mvar / net.sgen.max_q_mvar - net.dcline.max_p_mw - net.dcline.min_q_to_mvar / net.dcline.max_q_to_mvar / net.dcline.min_q_from_mvar / net.dcline.max_q_from_mvar - net.ext_grid.min_p_mw / net.ext_grid.max_p_mw - net.ext_grid.min_q_mvar / net.ext_grid.max_q_mvar - net.load.min_p_mw / net.load.max_p_mw - net.load.min_q_mvar / net.load.max_q_mvar - net.storage.min_p_mw / net.storage.max_p_mw - net.storage.min_q_mvar / net.storage.max_q_mvar Controllable loads behave just like controllable static generators. It must be stated if they are controllable. Otherwise, they are not respected as flexibilities. Dc lines are controllable per default Network constraints can be defined for buses, lines and transformers the elements in the following columns: - net.bus.min_vm_pu / net.bus.max_vm_pu - net.line.max_loading_percent - net.trafo.max_loading_percent - net.trafo3w.max_loading_percent If the external grid ist controllable, the voltage setpoint of the external grid can be optimized within the voltage constraints by the OPF. The same applies to the voltage setpoints of the controllable generator elements. How these costs are combined into a cost function depends on the cost_function parameter. INPUT: **net** - The pandapower format network OPTIONAL: **verbose** (bool, False) - If True, some basic information is printed **suppress_warnings** (bool, True) - suppress warnings in pypower If set to True, warnings are disabled during the loadflow. Because of the way data is processed in pypower, ComplexWarnings are raised during the loadflow. These warnings are suppressed by this option, however keep in mind all other pypower warnings are suppressed, too. **init** (str, "flat") - init of starting opf vector. Options are "flat", "pf" or "results" Starting solution vector (x0) for opf calculations is determined by this flag. Options are: "flat" (default): starting vector is (upper bound - lower bound) / 2 "pf": a power flow is executed prior to the opf and the pf solution is the starting vector. This may improve convergence, but takes a longer runtime (which are probably neglectible for opf calculations) "results": voltage magnitude vector is taken from result table **delta** (float, 1e-10) - power tolerance **trafo3w_losses** (str, "hv") - defines where open loop losses of three-winding transformers are considered. Valid options are "hv", "mv", "lv" for HV/MV/LV side or "star" for the star point. **consider_line_temperature** (bool, False) - adjustment of line impedance based on provided\ line temperature. If True, net.line must contain a column "temperature_degree_celsius".\ The temperature dependency coefficient alpha must be provided in the net.line.alpha\ column, otherwise the default value of 0.004 is used **kwargs** - Pypower / Matpower keyword arguments: - OPF_VIOLATION (5e-6) constraint violation tolerance - PDIPM_COSTTOL (1e-6) optimality tolerance - PDIPM_GRADTOL (1e-6) gradient tolerance - PDIPM_COMPTOL (1e-6) complementarity condition (inequality) tolerance - PDIPM_FEASTOL (set to OPF_VIOLATION if not specified) feasibiliy (equality) tolerance - PDIPM_MAX_IT (150) maximum number of iterations - SCPDIPM_RED_IT(20) maximum number of step size reductions per iteration """ _check_necessary_opf_parameters(net, logger) _init_runopp_options(net, calculate_voltage_angles=calculate_voltage_angles, check_connectivity=check_connectivity, switch_rx_ratio=switch_rx_ratio, delta=delta, init=init, numba=numba, trafo3w_losses=trafo3w_losses, consider_line_temperature=consider_line_temperature, **kwargs) _check_bus_index_and_print_warning_if_high(net) _check_gen_index_and_print_warning_if_high(net) _optimal_powerflow(net, verbose, suppress_warnings, **kwargs)
def runopp(net, verbose=False, calculate_voltage_angles=False, check_connectivity=False, suppress_warnings=True, r_switch=0.0, delta = 1e-10, **kwargs): """ Runs the pandapower Optimal Power Flow. Flexibilities, constraints and cost parameters are defined in the pandapower element tables. Flexibilities can be defined in net.sgen / net.gen /net.load net.sgen.controllable if a static generator is controllable. If False, the active and reactive power are assigned as in a normal power flow. If True, the following flexibilities apply: - net.sgen.min_p_kw / net.sgen.max_p_kw - net.sgen.min_q_kvar / net.sgen.max_q_kvar - net.load.min_p_kw / net.load.max_p_kw - net.load.min_q_kvar / net.load.max_q_kvar - net.gen.min_p_kw / net.gen.max_p_kw - net.gen.min_q_kvar / net.gen.max_q_kvar - net.ext_grid.min_p_kw / net.ext_grid.max_p_kw - net.ext_grid.min_q_kvar / net.ext_grid.max_q_kvar - net.dcline.min_q_to_kvar / net.dcline.max_q_to_kvar / net.dcline.min_q_from_kvar / net.dcline.max_q_from_kvar Controllable loads behave just like controllable static generators. It must be stated if they are controllable. Otherwise, they are not respected as flexibilities. Dc lines are controllable per default Network constraints can be defined for buses, lines and transformers the elements in the following columns: - net.bus.min_vm_pu / net.bus.max_vm_pu - net.line.max_loading_percent - net.trafo.max_loading_percent - net.trafo3w.max_loading_percent How these costs are combined into a cost function depends on the cost_function parameter. INPUT: **net** - The pandapower format network OPTIONAL: **verbose** (bool, False) - If True, some basic information is printed **suppress_warnings** (bool, True) - suppress warnings in pypower If set to True, warnings are disabled during the loadflow. Because of the way data is processed in pypower, ComplexWarnings are raised during the loadflow. These warnings are suppressed by this option, however keep in mind all other pypower warnings are suppressed, too. """ # Check if all necessary parameters are given: if (not net.gen.empty) and (("min_p_kw" not in net.gen.columns) or ("max_p_kw" not in net.gen.columns) or ( "max_q_kvar" not in net.gen.columns) or ("min_q_kvar" not in net.gen.columns)): raise UserWarning('Warning: Please specify operational constraints for controllable gens') if (not net.dcline.empty) and (("min_q_to_kvar" not in net.dcline.columns) or ("max_q_to_kvar" not in net.dcline.columns) or ( "min_q_from_kvar" not in net.dcline.columns) or ("max_q_from_kvar" not in net.dcline.columns)): raise UserWarning('Warning: Please specify operational constraints for dclines') if "controllable" in net.sgen.columns: if net.sgen.controllable.any(): if ("min_p_kw" not in net.sgen.columns) or ("max_p_kw" not in net.sgen.columns) or ( "max_q_kvar" not in net.sgen.columns) or ("min_q_kvar" not in net.sgen.columns): raise UserWarning('Warning: Please specify operational constraints for controllable sgens') else: logger.debug('No controllable sgens found') if "controllable" in net.load.columns: if net.load.controllable.any(): if ("min_p_kw" not in net.load.columns) or ("max_p_kw" not in net.load.columns) or ( "max_q_kvar" not in net.load.columns) or ("min_q_kvar" not in net.load.columns): raise UserWarning('Warning: Please specify operational constraints for controllable loads') else: logger.debug('No controllable loads found') mode = "opf" ac = True copy_constraints_to_ppc = True trafo_model = "t" trafo_loading = 'current' init = "flat" enforce_q_lims = True recycle = dict(_is_elements=False, ppc=False, Ybus=False) net._options = {} _add_ppc_options(net, calculate_voltage_angles=calculate_voltage_angles, trafo_model=trafo_model, check_connectivity=check_connectivity, mode=mode, copy_constraints_to_ppc=copy_constraints_to_ppc, r_switch=r_switch, init=init, enforce_q_lims=enforce_q_lims, recycle=recycle, voltage_depend_loads=False, delta=delta) _add_opf_options(net, trafo_loading=trafo_loading, ac=ac) _optimal_powerflow(net, verbose, suppress_warnings, **kwargs)
def runopp(net, verbose=False, calculate_voltage_angles=False, check_connectivity=True, suppress_warnings=True, r_switch=0.0, delta=1e-10, **kwargs): """ Runs the pandapower Optimal Power Flow. Flexibilities, constraints and cost parameters are defined in the pandapower element tables. Flexibilities for generators can be defined in net.sgen / net.gen. net.sgen.controllable / net.gen.controllable signals if a generator is controllable. If False, the active and reactive power are assigned as in a normal power flow. If yes, the following flexibilities apply: - net.sgen.min_p_kw / net.sgen.max_p_kw - net.sgen.min_q_kvar / net.sgen.max_q_kvar - net.gen.min_p_kw / net.gen.max_p_kw - net.gen.min_q_kvar / net.gen.max_q_kvar - net.ext_grid.min_p_kw / net.ext_grid.max_p_kw - net.ext_grid.min_q_kvar / net.ext_grid.max_q_kvar - net.dcline.min_q_to_kvar / net.dcline.max_q_to_kvar / net.dcline.min_q_from_kvar / net.dcline.max_q_from_kvar Network constraints can be defined for buses, lines and transformers the elements in the following columns: - net.bus.min_vm_pu / net.bus.max_vm_pu - net.line.max_loading_percent - net.trafo.max_loading_percent - net.trafo3w.max_loading_percent How these costs are combined into a cost function depends on the cost_function parameter. INPUT: **net** - The pandapower format network OPTIONAL: **verbose** (bool, False) - If True, some basic information is printed **suppress_warnings** (bool, True) - suppress warnings in pypower If set to True, warnings are disabled during the loadflow. Because of the way data is processed in pypower, ComplexWarnings are raised during the loadflow. These warnings are suppressed by this option, however keep in mind all other pypower warnings are suppressed, too. """ mode = "opf" ac = True copy_constraints_to_ppc = True trafo_model = "t" trafo_loading = 'current' init = "flat" enforce_q_lims = True recycle = dict(_is_elements=False, ppc=False, Ybus=False) net._options = {} _add_ppc_options(net, calculate_voltage_angles=calculate_voltage_angles, trafo_model=trafo_model, check_connectivity=check_connectivity, mode=mode, copy_constraints_to_ppc=copy_constraints_to_ppc, r_switch=r_switch, init=init, enforce_q_lims=enforce_q_lims, recycle=recycle, voltage_depend_loads=False, delta=delta) _add_opf_options(net, trafo_loading=trafo_loading, ac=ac) _optimal_powerflow(net, verbose, suppress_warnings, **kwargs)