Example #1
0
def runpm_ots(net,
              julia_file=None,
              pp_to_pm_callback=None,
              calculate_voltage_angles=True,
              trafo_model="t",
              delta=1e-8,
              trafo3w_losses="hv",
              check_connectivity=True,
              pm_model="DCPPowerModel",
              pm_solver="juniper",
              pm_nl_solver="ipopt",
              pm_mip_solver="cbc",
              correct_pm_network_data=True,
              silence=True,
              pm_time_limits=None,
              pm_log_level=0,
              delete_buffer_file=True,
              pm_file_path=None,
              opf_flow_lim="S",
              pm_tol=1e-8,
              pdm_dev_mode=False,
              **kwargs):
    """
    Runs optimal transmission switching (OTS) optimization from PowerModels.jl via PandaModels.jl
    """
    ac = True if "DC" not in pm_model else False
    if pm_solver is None:
        pm_solver = "juniper"

    net._options = {}
    _add_ppc_options(net,
                     calculate_voltage_angles=calculate_voltage_angles,
                     trafo_model=trafo_model,
                     check_connectivity=check_connectivity,
                     mode="opf",
                     switch_rx_ratio=2,
                     init_vm_pu="flat",
                     init_va_degree="flat",
                     enforce_q_lims=True,
                     recycle=dict(_is_elements=False, ppc=False, Ybus=False),
                     voltage_depend_loads=False,
                     delta=delta,
                     trafo3w_losses=trafo3w_losses)
    _add_opf_options(net,
                     trafo_loading='power',
                     ac=ac,
                     init="flat",
                     numba=True,
                     pp_to_pm_callback=pp_to_pm_callback,
                     julia_file="run_powermodels_ots",
                     pm_model=pm_model,
                     pm_solver=pm_solver,
                     correct_pm_network_data=correct_pm_network_data,
                     silence=silence,
                     pm_mip_solver=pm_mip_solver,
                     pm_nl_solver=pm_nl_solver,
                     pm_time_limits=pm_time_limits,
                     pm_log_level=pm_log_level,
                     opf_flow_lim="S",
                     pm_tol=pm_tol)

    _runpm(net,
           delete_buffer_file=delete_buffer_file,
           pm_file_path=pm_file_path,
           pdm_dev_mode=pdm_dev_mode)
    read_ots_results(net)
Example #2
0
def runpm_ots(net,
              pp_to_pm_callback=None,
              calculate_voltage_angles=True,
              trafo_model="t",
              delta=1e-8,
              trafo3w_losses="hv",
              check_connectivity=True,
              pm_model="DCPPowerModel",
              pm_solver="juniper",
              pm_nl_solver="ipopt",
              pm_mip_solver="cbc",
              correct_pm_network_data=True,
              pm_time_limits=None,
              pm_log_level=0,
              **kwargs):  # pragma: no cover
    """
    Runs a non-linear optimal transmission switching (OTS) optimization using PowerModels.jl.

    OPTIONAL:
        **julia_file** (str, None) - path to a custom julia optimization file

        **pp_to_pm_callback** (function, None) - callback function to add data to the PowerModels data structure

        **correct_pm_network_data** (bool, True) - checks if network data is correct. If not tries to correct it

        **pm_model** (str, "ACPPowerModel") - The PowerModels.jl model to use

        **pm_solver** (str, "juniper") - The "main" power models solver

        **pm_mip_solver** (str, "cbc") - The mixed integer solver (when "main" solver == juniper)

        **pm_nl_solver** (str, "ipopt") - The nonlinear solver (when "main" solver == juniper)

        **pm_time_limits** (Dict, None) - Time limits in seconds for power models interface. To be set as a dict like
                                          {"pm_time_limit": 300., "pm_nl_time_limit": 300., "pm_mip_time_limit": 300.}

        **pm_log_level** (int, 0) - solver log level in power models


     """
    julia_file = os.path.join(pp_dir, "opf", 'run_powermodels_ots.jl')
    ac = True if "DC" not in pm_model else False
    if pm_solver is None:
        pm_solver = "juniper"

    net._options = {}
    _add_ppc_options(net,
                     calculate_voltage_angles=calculate_voltage_angles,
                     trafo_model=trafo_model,
                     check_connectivity=check_connectivity,
                     mode="opf",
                     switch_rx_ratio=2,
                     init_vm_pu="flat",
                     init_va_degree="flat",
                     enforce_q_lims=True,
                     recycle=dict(_is_elements=False, ppc=False, Ybus=False),
                     voltage_depend_loads=False,
                     delta=delta,
                     trafo3w_losses=trafo3w_losses)
    _add_opf_options(net,
                     trafo_loading='power',
                     ac=ac,
                     init="flat",
                     numba=True,
                     pp_to_pm_callback=pp_to_pm_callback,
                     julia_file=julia_file,
                     pm_model=pm_model,
                     pm_solver=pm_solver,
                     correct_pm_network_data=correct_pm_network_data,
                     pm_mip_solver=pm_mip_solver,
                     pm_nl_solver=pm_nl_solver,
                     pm_time_limits=pm_time_limits,
                     pm_log_level=pm_log_level,
                     opf_flow_lim="S")
    _runpm(net)
    read_ots_results(net)