Exemple #1
0
def runpm_tnep(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="ACPPowerModel",
               pm_solver="juniper",
               correct_pm_network_data=True,
               silence=True,
               pm_nl_solver="ipopt",
               pm_mip_solver="cbc",
               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 transmission network extension planning (tnep) optimization from PowerModels.jl via PandaModels.jl
    """
    ac = True if "DC" not in pm_model else False
    if pm_solver is None:
        if pm_model == "DCPPowerModel":
            pm_solver = "ipopt"
        else:
            pm_solver = "juniper"

    if "ne_line" not in net:
        raise ValueError(
            "ne_line DataFrame missing in net. Please define to run tnep")
    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_tnep",
                     pm_model=pm_model,
                     pm_solver=pm_solver,
                     correct_pm_network_data=correct_pm_network_data,
                     silence=silence,
                     pm_nl_solver=pm_nl_solver,
                     pm_mip_solver=pm_mip_solver,
                     pm_time_limits=pm_time_limits,
                     pm_log_level=pm_log_level,
                     opf_flow_lim=opf_flow_lim,
                     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_tnep_results(net)
Exemple #2
0
def runpm_tnep(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=None,
               correct_pm_network_data=True,
               pm_nl_solver="ipopt",
               pm_mip_solver="cbc",
               pm_time_limits=None,
               pm_log_level=0,
               opf_flow_lim="S",
               **kwargs):  # pragma: no cover
    """
    Runs a non-linear transmission network extension planning (tnep) 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_tnep.jl')
    ac = True if "DC" not in pm_model else False
    if pm_solver is None:
        if pm_model == "DCPPowerModel":
            pm_solver = "gurobi"
        else:
            pm_solver = "juniper"

    if "ne_line" not in net:
        raise ValueError(
            "ne_line DataFrame missing in net. Please define to run tnep")
    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_nl_solver=pm_nl_solver,
                     pm_mip_solver=pm_mip_solver,
                     pm_time_limits=pm_time_limits,
                     pm_log_level=pm_log_level,
                     opf_flow_lim=opf_flow_lim)
    _runpm(net)
    read_tnep_results(net)