address review commments

This commit is contained in:
Fabian 2023-08-04 12:58:31 +02:00
parent 8622398ceb
commit ad6322bcb3
9 changed files with 24 additions and 15 deletions

4
.gitignore vendored
View File

@ -16,7 +16,7 @@ gurobi.log
/networks
/benchmarks
/logs
# /notebooks
/notebooks
/data
/cutouts
@ -68,7 +68,7 @@ doc/_build
*.geojson
# *.ipynb
*.ipynb
data/costs_*

View File

@ -19,6 +19,7 @@ if not exists("config/config.yaml"):
configfile: "config/config.yaml"
configfile: "config/config.validation.yaml"
COSTS = f"data/costs_{config['costs']['year']}.csv"

View File

@ -669,6 +669,7 @@ solving:
glpk-default: {} # Used in CI
mem: 30000 #memory in MB; 20 GB enough for 50+B+I+H2; 100 GB for 181+B+I+H2
walltime: "12:00:00"
# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#plotting
plotting:

View File

@ -62,7 +62,7 @@ renewable:
flatten_dispatch: 0.01
conventional:
unit_commitment: true
unit_commitment: false
dynamic_fuel_price: true
nuclear:
p_max_pu: "data/nuclear_p_max_pu.csv"

View File

@ -3,6 +3,7 @@ Trigger, Description, Definition, Status
``nSEG``; e.g. ``4380SEG``, "Apply time series segmentation with `tsam <https://tsam.readthedocs.io/en/latest/index.html>`_ package to ``n`` adjacent snapshots of varying lengths based on capacity factors of varying renewables, hydro inflow and load.", ``prepare_network``: apply_time_segmentation(), In active use
``Co2L``, Add an overall absolute carbon-dioxide emissions limit configured in ``electricity: co2limit``. If a float is appended an overall emission limit relative to the emission level given in ``electricity: co2base`` is added (e.g. ``Co2L0.05`` limits emissisions to 5% of what is given in ``electricity: co2base``), ``prepare_network``: `add_co2limit() <https://github.com/PyPSA/pypsa-eur/blob/6b964540ed39d44079cdabddee8333f486d0cd63/scripts/prepare_network.py#L19>`_ and its `caller <https://github.com/PyPSA/pypsa-eur/blob/6b964540ed39d44079cdabddee8333f486d0cd63/scripts/prepare_network.py#L154>`__, In active use
``Ep``, Add cost for a carbon-dioxide price configured in ``costs: emission_prices: co2`` to ``marginal_cost`` of generators (other emission types listed in ``network.carriers`` possible as well), ``prepare_network``: `add_emission_prices() <https://github.com/PyPSA/pypsa-eur/blob/6b964540ed39d44079cdabddee8333f486d0cd63/scripts/prepare_network.py#L24>`_ and its `caller <https://github.com/PyPSA/pypsa-eur/blob/6b964540ed39d44079cdabddee8333f486d0cd63/scripts/prepare_network.py#L158>`__, In active use
``Ept``, Add monthly cost for a carbon-dioxide price based on historical values built by the rule ``build_monthly_prices``, In active use
``CCL``, Add minimum and maximum levels of generator nominal capacity per carrier for individual countries. These can be specified in the file linked at ``electricity: agg_p_nom_limits`` in the configuration. File defaults to ``data/agg_p_nom_minmax.csv``., ``solve_network``, In active use
``EQ``, "Require each country or node to on average produce a minimal share of its total consumption itself. Example: ``EQ0.5c`` demands each country to produce on average at least 50% of its consumption; ``EQ0.5`` demands each node to produce on average at least 50% of its consumption.", ``solve_network``, In active use
``ATK``, "Require each node to be autarkic. Example: ``ATK`` removes all lines and links. ``ATKc`` removes all cross-border lines and links.", ``prepare_network``, In active use

Can't render this file because it has a wrong number of fields in line 6.

View File

@ -27,7 +27,7 @@ rule solve_network:
threads: 4
resources:
mem_mb=memory,
walltime="24:00:00",
walltime=config["solving"].get("walltime", "12:00:00"),
shadow:
"minimal"
conda:
@ -58,6 +58,7 @@ rule solve_operations_network:
threads: 4
resources:
mem_mb=(lambda w: 10000 + 372 * int(w.clusters)),
walltime=config["solving"].get("walltime", "12:00:00"),
shadow:
"minimal"
conda:

View File

@ -106,6 +106,7 @@ rule solve_sector_network_myopic:
threads: 4
resources:
mem_mb=config["solving"]["mem"],
walltime=config["solving"].get("walltime", "12:00:00"),
benchmark:
(
BENCHMARKS

View File

@ -28,6 +28,7 @@ rule solve_sector_network:
threads: config["solving"]["solver"].get("threads", 4)
resources:
mem_mb=config["solving"]["mem"],
walltime=config["solving"].get("walltime", "12:00:00"),
benchmark:
(
RESULTS

View File

@ -115,14 +115,17 @@ def add_dynamic_emission_prices(n):
co2_price = (
co2_price.reindex(n.snapshots).fillna(method="ffill").fillna(method="bfill")
)
# TODO: enable this without having dynamic marginal costs defined beforehand
emissions = (
n.generators.carrier.map(n.carriers.co2_emissions) / n.generators.efficiency
)
co2_cost = expand_series(emissions, n.snapshots).T.mul(co2_price.iloc[:, 0], axis=0)
n.generators_t.marginal_cost += co2_cost.reindex(
columns=n.generators_t.marginal_cost.columns
)
static = n.generators.marginal_cost
dynamic = n.get_switchable_as_dense("Generator", "marginal_cost")
marginal_cost = dynamic + co2_cost.reindex(columns=dynamic.columns, fill_value=0)
n.generators_t.marginal_cost = marginal_cost.loc[:, marginal_cost.ne(static).any()]
def set_line_s_max_pu(n, s_max_pu=0.7):
@ -277,7 +280,7 @@ if __name__ == "__main__":
from _helpers import mock_snakemake
snakemake = mock_snakemake(
"prepare_network", simpl="", clusters="37c", ll="v1.0", opts="24H-Ept"
"prepare_network", simpl="", clusters="37", ll="v1.0", opts="Ept"
)
configure_logging(snakemake)
@ -351,7 +354,12 @@ if __name__ == "__main__":
c.df.loc[sel, attr] *= factor
for o in opts:
if "Ep" in o:
if "Ept" in o:
logger.info(
"Setting time dependent emission prices according spot market price"
)
add_dynamic_emission_prices(n)
elif "Ep" in o:
m = re.findall("[0-9]*\.?[0-9]+$", o)
if len(m) > 0:
logger.info("Setting emission prices according to wildcard value.")
@ -360,11 +368,6 @@ if __name__ == "__main__":
logger.info("Setting emission prices according to config value.")
add_emission_prices(n, snakemake.params.costs["emission_prices"])
break
if "Ept" in o:
logger.info(
"Setting time dependent emission prices according spot market price"
)
add_dynamic_emission_prices(n)
ll_type, factor = snakemake.wildcards.ll[0], snakemake.wildcards.ll[1:]
set_transmission_limit(n, ll_type, factor, costs, Nyears)