Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 15, 2024
1 parent 96118ab commit a352cc3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions config/test/config.myopic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ electricity:
Store: [H2]
Link: [H2 pipeline]

renewable_carriers: [solar,solar-hsat, onwind, offwind-ac, offwind-dc, offwind-float]
renewable_carriers: [solar, solar-hsat, onwind, offwind-ac, offwind-dc, offwind-float]

atlite:
default_cutout: be-03-2013-era5
Expand All @@ -69,7 +69,7 @@ renewable:
solar:
cutout: be-03-2013-era5
solar-hsat:
cutout: be-03-2013-era5
cutout: be-03-2013-era5

clustering:
temporal:
Expand Down
2 changes: 1 addition & 1 deletion config/test/config.overnight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ renewable:
solar:
cutout: be-03-2013-era5
solar-hsat:
cutout: be-03-2013-era5
cutout: be-03-2013-era5

clustering:
temporal:
Expand Down
2 changes: 1 addition & 1 deletion config/test/config.perfect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ renewable:
solar:
cutout: be-03-2013-era5
solar-hsat:
cutout: be-03-2013-era5
cutout: be-03-2013-era5

clustering:
temporal:
Expand Down
8 changes: 5 additions & 3 deletions scripts/add_brownfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ def adjust_renewable_profiles(n, input_profiles, params, year):
)

for carrier in params["carriers"]:
if carrier == "hydro" or (carrier == "solar-hsat" and
not snakemake.config["sector"]["solar_utility_horizontal_axis_tracking"]
): continue
if carrier == "hydro" or (
carrier == "solar-hsat"
and not snakemake.config["sector"]["solar_utility_horizontal_axis_tracking"]
):
continue

with xr.open_dataset(getattr(input_profiles, "profile_" + carrier)) as ds:
if ds.indexes["bus"].empty or "year" not in ds.indexes:
Expand Down
44 changes: 26 additions & 18 deletions scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,15 @@ def check_p_min_p_max(p_nom_max):
def _add_land_use_constraint(n):
# warning: this will miss existing offwind which is not classed AC-DC and has carrier 'offwind'

for carrier in ["solar","solar rooftop",
"solar-hsat", "onwind", "offwind-ac", "offwind-dc", "offwind-float"]:
for carrier in [
"solar",
"solar rooftop",
"solar-hsat",
"onwind",
"offwind-ac",
"offwind-dc",
"offwind-float",
]:
extendable_i = (n.generators.carrier == carrier) & n.generators.p_nom_extendable
n.generators.loc[extendable_i, "p_nom_min"] = 0

Expand Down Expand Up @@ -160,8 +167,14 @@ def _add_land_use_constraint_m(n, planning_horizons, config):
grouping_years = config["existing_capacities"]["grouping_years_power"]
current_horizon = snakemake.wildcards.planning_horizons

for carrier in ["solar", "solar rooftop",
"solar-hsat", "onwind", "offwind-ac", "offwind-dc"]:
for carrier in [
"solar",
"solar rooftop",
"solar-hsat",
"onwind",
"offwind-ac",
"offwind-dc",
]:
extendable_i = (n.generators.carrier == carrier) & n.generators.p_nom_extendable
n.generators.loc[extendable_i, "p_nom_min"] = 0

Expand Down Expand Up @@ -219,15 +232,17 @@ def add_solar_potential_constraints(n, config):
rename = {"Generator-ext": "Generator"}

solar_carriers = ["solar", "solar-hsat"]
solar = n.generators[n.generators.carrier.isin(solar_carriers)
& n.generators.p_nom_extendable].index

solar = n.generators[
n.generators.carrier.isin(solar_carriers) & n.generators.p_nom_extendable
].index

solar_today = n.generators[
(n.generators.carrier == "solar") & (n.generators.p_nom_extendable)
].index
solar_hsat = n.generators[(n.generators.carrier == "solar-hsat")].index

if solar.empty: return
if solar.empty:
return

land_use = pd.DataFrame(1, index=solar, columns=["land_use_factor"])
for carrier, factor in land_use_factors.items():
Expand All @@ -246,9 +261,7 @@ def add_solar_potential_constraints(n, config):
).to_xarray()
rhs = (
n.generators.loc[solar_today, "p_nom_max"]
.groupby(
n.generators.loc[solar_today].index.rename("bus").map(location)
)
.groupby(n.generators.loc[solar_today].index.rename("bus").map(location))
.sum()
- n.generators.loc[solar_hsat, "p_nom_opt"]
.groupby(n.generators.loc[solar_hsat].index.rename("bus").map(location))
Expand All @@ -257,9 +270,7 @@ def add_solar_potential_constraints(n, config):
).clip(lower=0)

else:
location = (
pd.Series(n.buses.index, index=n.buses.index)
)
location = pd.Series(n.buses.index, index=n.buses.index)
ggrouper = n.generators.loc[solar].bus
rhs = (
n.generators.loc[solar_today, "p_nom_max"]
Expand All @@ -272,10 +283,7 @@ def add_solar_potential_constraints(n, config):
).clip(lower=0)

lhs = (
(
n.model["Generator-p_nom"].rename(rename).loc[solar]
* land_use.squeeze()
)
(n.model["Generator-p_nom"].rename(rename).loc[solar] * land_use.squeeze())
.groupby(ggrouper)
.sum()
)
Expand Down

0 comments on commit a352cc3

Please sign in to comment.