[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
ea0e2f66ce
commit
2d2b0338cc
@ -231,48 +231,78 @@ def add_solar_potential_constraints(n, config):
|
|||||||
rename = {"Generator-ext": "Generator"}
|
rename = {"Generator-ext": "Generator"}
|
||||||
|
|
||||||
gen_index = n.generators[n.generators.p_nom_extendable].index
|
gen_index = n.generators[n.generators.p_nom_extendable].index
|
||||||
filters = [("solar", True), ("thermal", False), ("rooftop", False)] ## filter all utility solar generation except solar thermal
|
filters = [
|
||||||
solar = reduce(lambda gen_index, f: gen_index[gen_index.str.contains(f[0]) == f[1]], filters, gen_index)
|
("solar", True),
|
||||||
solar_today = n.generators[(n.generators.carrier=='solar') & (n.generators.p_nom_extendable)].index
|
("thermal", False),
|
||||||
solar_hsat = n.generators[(n.generators.carrier=='solar-hsat') ].index
|
("rooftop", False),
|
||||||
|
] ## filter all utility solar generation except solar thermal
|
||||||
if not solar.empty :
|
solar = reduce(
|
||||||
|
lambda gen_index, f: gen_index[gen_index.str.contains(f[0]) == f[1]],
|
||||||
|
filters,
|
||||||
|
gen_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
|
||||||
|
|
||||||
land_use = pd.DataFrame(1, index=solar, columns=['land_use_factor'])
|
if not solar.empty:
|
||||||
|
|
||||||
|
land_use = pd.DataFrame(1, index=solar, columns=["land_use_factor"])
|
||||||
for key in land_use_factors.keys():
|
for key in land_use_factors.keys():
|
||||||
land_use = land_use.apply(lambda x: (x*land_use_factors[key]) if key in x.name else x, axis=1)
|
land_use = land_use.apply(
|
||||||
|
lambda x: (x * land_use_factors[key]) if key in x.name else x, axis=1
|
||||||
|
)
|
||||||
|
|
||||||
if "m" in snakemake.wildcards.clusters:
|
if "m" in snakemake.wildcards.clusters:
|
||||||
location = (
|
location = pd.Series(
|
||||||
pd.Series([' '.join(i.split(' ')[:2]) for i in n.generators.index], index=n.generators.index)
|
[" ".join(i.split(" ")[:2]) for i in n.generators.index],
|
||||||
|
index=n.generators.index,
|
||||||
)
|
)
|
||||||
ggrouper= pd.Series(n.generators.loc[solar].index.rename('bus').map(location), index=n.generators.loc[solar].index,).to_xarray()
|
ggrouper = pd.Series(
|
||||||
rhs = (n.generators.loc[solar_today,"p_nom_max"]
|
n.generators.loc[solar].index.rename("bus").map(location),
|
||||||
.groupby(n.generators.loc[solar_today].index.rename('bus').map(location)).sum() -
|
index=n.generators.loc[solar].index,
|
||||||
n.generators.loc[solar_hsat,"p_nom_opt"]
|
).to_xarray()
|
||||||
.groupby(n.generators.loc[solar_hsat].index.rename('bus').map(location)).sum() * land_use_factors['solar-hsat'] ).clip(lower=0)
|
rhs = (
|
||||||
|
n.generators.loc[solar_today, "p_nom_max"]
|
||||||
|
.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))
|
||||||
|
.sum()
|
||||||
|
* land_use_factors["solar-hsat"]
|
||||||
|
).clip(lower=0)
|
||||||
|
|
||||||
else :
|
else:
|
||||||
location = (
|
location = (
|
||||||
n.buses.location
|
n.buses.location
|
||||||
if "location" in n.buses.columns
|
if "location" in n.buses.columns
|
||||||
else pd.Series(n.buses.index, index=n.buses.index)
|
else pd.Series(n.buses.index, index=n.buses.index)
|
||||||
)
|
)
|
||||||
ggrouper= (n.generators.loc[solar].bus)
|
ggrouper = n.generators.loc[solar].bus
|
||||||
rhs = (n.generators.loc[solar_today,"p_nom_max"]
|
rhs = (
|
||||||
.groupby(n.generators.loc[solar_today].bus.map(location)).sum() -
|
n.generators.loc[solar_today, "p_nom_max"]
|
||||||
n.generators.loc[solar_hsat,"p_nom_opt"]
|
.groupby(n.generators.loc[solar_today].bus.map(location))
|
||||||
.groupby(n.generators.loc[solar_hsat].bus.map(location)).sum() * land_use_factors['solar-hsat'] ).clip(lower=0)
|
.sum()
|
||||||
|
- n.generators.loc[solar_hsat, "p_nom_opt"]
|
||||||
|
.groupby(n.generators.loc[solar_hsat].bus.map(location))
|
||||||
|
.sum()
|
||||||
|
* land_use_factors["solar-hsat"]
|
||||||
|
).clip(lower=0)
|
||||||
|
|
||||||
lhs = (
|
lhs = (
|
||||||
(n.model["Generator-p_nom"].rename(rename).loc[solar]
|
(
|
||||||
*land_use.squeeze().values)
|
n.model["Generator-p_nom"].rename(rename).loc[solar]
|
||||||
.groupby(ggrouper)
|
* land_use.squeeze().values
|
||||||
|
)
|
||||||
|
.groupby(ggrouper)
|
||||||
.sum()
|
.sum()
|
||||||
)
|
)
|
||||||
|
|
||||||
print('adding solar rooftop constraints...')
|
print("adding solar rooftop constraints...")
|
||||||
n.model.add_constraints(lhs <= rhs, name="solar_potential")
|
n.model.add_constraints(lhs <= rhs, name="solar_potential")
|
||||||
|
|
||||||
|
|
||||||
def add_co2_sequestration_limit(n, limit=200):
|
def add_co2_sequestration_limit(n, limit=200):
|
||||||
|
Loading…
Reference in New Issue
Block a user