From 7165782d342a25e994b5b4c9abe8f49a158b98b6 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Thu, 17 Aug 2023 15:46:00 +0200 Subject: [PATCH] Create execute model and sub modules for market and grid optimization --- .../{tools/execute.py => execute/__init__.py} | 25 ++++++ etrago/execute/grid_optimization.py | 70 +++++++++++++++ etrago/execute/market_optimization.py | 90 +++++++++++++++++++ 3 files changed, 185 insertions(+) rename etrago/{tools/execute.py => execute/__init__.py} (98%) mode change 100755 => 100644 create mode 100644 etrago/execute/grid_optimization.py create mode 100644 etrago/execute/market_optimization.py diff --git a/etrago/tools/execute.py b/etrago/execute/__init__.py old mode 100755 new mode 100644 similarity index 98% rename from etrago/tools/execute.py rename to etrago/execute/__init__.py index f7a13412a..912141b9d --- a/etrago/tools/execute.py +++ b/etrago/execute/__init__.py @@ -398,6 +398,31 @@ def lopf(self): self.export_to_csv(path) +def optimize(self): + """Run optimization of dispatch and grid and storage expansion based on arguments + + Returns + ------- + None. + + """ + + if self.args["method"]["type"] == "lopf": + + self.lopf() + + elif self.args["method"]["type"] == "market_grid": # besseren Namen finden + + self.market_optimization() + + self.market_results_to_grid() + + self.grid_optimization() + + else: + print("Method not defined") + + def dispatch_disaggregation(self): """ Function running the tempral disaggregation meaning the optimization diff --git a/etrago/execute/grid_optimization.py b/etrago/execute/grid_optimization.py new file mode 100644 index 000000000..51fc8c455 --- /dev/null +++ b/etrago/execute/grid_optimization.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Copyright 2016-2023 Flensburg University of Applied Sciences, +# Europa-Universität Flensburg, +# Centre for Sustainable Energy Systems, +# DLR-Institute for Networked Energy Systems +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +# File description +""" +Defines the market optimization within eTraGo +""" +import os + +if "READTHEDOCS" not in os.environ: + import logging + import time + + import numpy as np + import pandas as pd + + + logger = logging.getLogger(__name__) + +__copyright__ = ( + "Flensburg University of Applied Sciences, " + "Europa-Universität Flensburg, " + "Centre for Sustainable Energy Systems, " + "DLR-Institute for Networked Energy Systems" +) +__license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)" +__author__ = ( + "ulfmueller, ClaraBuettner, CarlosEpia" +) + + +def grid_optimization(self): + + add_redispatch_generators(self) + + self.network.lopf( + solver_name=self.args["solver"], + solver_options=self.args["solver_options"], + pyomo=True, + extra_functionality=extra_functionality(), + formulation=self.args["model_formulation"], + + ) + + +def add_redispatch_generators(self): + """Add ramp up and ramp down generators + + Returns + ------- + None. + + """ + pass \ No newline at end of file diff --git a/etrago/execute/market_optimization.py b/etrago/execute/market_optimization.py new file mode 100644 index 000000000..ff2f76235 --- /dev/null +++ b/etrago/execute/market_optimization.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +# Copyright 2016-2023 Flensburg University of Applied Sciences, +# Europa-Universität Flensburg, +# Centre for Sustainable Energy Systems, +# DLR-Institute for Networked Energy Systems +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +# File description +""" +Defines the market optimization within eTraGo +""" +import os + +if "READTHEDOCS" not in os.environ: + import logging + import time + + import numpy as np + import pandas as pd + + + logger = logging.getLogger(__name__) + +__copyright__ = ( + "Flensburg University of Applied Sciences, " + "Europa-Universität Flensburg, " + "Centre for Sustainable Energy Systems, " + "DLR-Institute for Networked Energy Systems" +) +__license__ = "GNU Affero General Public License Version 3 (AGPL-3.0)" +__author__ = ( + "ulfmueller, ClaraBuettner, CarlosEpia" +) + + +def market_optimization(self): + + build_market_model() + + self.market_model.lopf( + solver_name=self.args["solver"], + solver_options=self.args["solver_options"], + pyomo=True, + extra_functionality=extra_functionality(), + formulation=self.args["model_formulation"], + + ) + + +def build_market_model(): + """Builds market model based on imported network from eTraGo + + + - import market regions from file or database + - Cluster network to market regions + -- consider marginal cost incl. generator noise when grouoping electrical + generation capacities + + Returns + ------- + None. + + """ + # Not useful, just for demonstration + self.market_model = self.network.copy() + + + +def extra_functionality(): + """Placeholder for extra functionalities within market optimization + + Returns + ------- + None. + + """ + + return None \ No newline at end of file