add high voltage connections as links in the lossy transport model (see Neumann et al)

Parameters:
  • network (Network) –

    description

  • config (dict) –

    description

  • n_years (int) –

    description

Raises:
  • ValueError

    description

Source code in workflow/scripts/prepare_network_common.py
def add_HV_links(network: pypsa.Network, config: dict, n_years: int):
    """add high voltage connections as links in the lossy transport model (see Neumann et al)

    Args:
        network (pypsa.Network): _description_
        config (dict): _description_
        n_years (int): _description_

    Raises:
        ValueError: _description_
    """

    edge_path = config["edge_paths"].get(config["scenario"]["topology"], None)
    if edge_path is None:
        raise ValueError(f"No grid found for topology {config['scenario']['topology']}")
    else:
        edges = pd.read_csv(
            edge_path, sep=",", header=None, names=["bus0", "bus1", "p_nom"]
        ).fillna(0)

    # fix this to use map with x.y
    lengths = NON_LIN_PATH_SCALING * np.array(
        [
            haversine(
                [network.buses.at[bus0, "x"], network.buses.at[bus0, "y"]],
                [network.buses.at[bus1, "x"], network.buses.at[bus1, "y"]],
            )
            for bus0, bus1 in edges[["bus0", "bus1"]].values
        ]
    )

    cc = (
        (config["line_cost_factor"] * lengths * [HVAC_cost_curve(len_) for len_ in lengths])
        * LINE_SECURITY_MARGIN
        * FOM_LINES
        * n_years
        * annuity(ECON_LIFETIME_LINES, config["costs"]["discountrate"])
    )

    network.add(
        "Link",
        edges["bus0"] + "-" + edges["bus1"],
        p_nom=edges["p_nom"].values,
        p_nom_min=edges["p_nom"].values,
        bus0=edges["bus0"].values,
        bus1=edges["bus1"].values,
        p_nom_extendable=True,
        p_min_pu=-1,
        length=lengths,
        capital_cost=cc,
    )

calc_renewable_pu_avail(renewable_ds, planning_year, snapshots)

calaculate the renewable per unit availability

Parameters:
  • renewable_ds (Dataset) –

    the renewable dataset from build_renewable_potential

  • planning_year (int) –

    the investment year

  • snapshots (Index) –

    the network snapshots

Source code in workflow/scripts/prepare_network_common.py
def calc_renewable_pu_avail(
    renewable_ds: xr.Dataset, planning_year: int, snapshots: pd.Index
) -> pd.DataFrame:
    """calaculate the renewable per unit availability

    Args:
        renewable_ds (xr.Dataset): the renewable dataset from build_renewable_potential
        planning_year (int): the investment year
        snapshots (pd.Index): the network snapshots
    """
    rnwable_p_max_pu = renewable_ds["profile"].transpose("time", "bus").to_pandas()
    rnwable_p_max_pu = shift_profile_to_planning_year(rnwable_p_max_pu, planning_year)
    rnwable_p_max_pu = rnwable_p_max_pu.loc[snapshots]
    return rnwable_p_max_pu.sort_index(axis=1)