From cb45ea98ff778017ec0f5c53951a56bb04278443 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Tue, 27 Feb 2024 11:51:30 -0700 Subject: [PATCH 1/5] Create CODEOWNERS --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ + From 1d9d83a844ff24242eef8d01376f5fe382732c11 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Tue, 27 Feb 2024 12:45:10 -0700 Subject: [PATCH 2/5] removing unused vars --- gtep/gtep_model.py | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index 5bca48b..45084ba 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -512,13 +512,19 @@ def quickstart_reserve_limits(b, thermalGen): # Load shed per bus b.loadShed = Var(m.buses, domain=NonNegativeReals, initialize=0) - # TODO: adjacent bus angle difference constraints should be added -- what should they be? - # TODO: likewise, what do we want angle bounds to actually be? - + # Voltage angle def bus_angle_bounds(b, bus): - return (-90, 90) + return (-30, 30) + + b.busAngle = Var(m.buses, domain=Reals, initialize=0, bounds=bus_angle_bounds) + + # Voltage angle difference + def delta_bus_angle_bounds(b, line): + return (-60, 60) - b.busAngle = Var(m.buses, domain=Reals, initialize=0) + b.deltaBusAngle = Var( + m.transmission, domain=Reals, initialize=0, bounds=delta_bus_angle_bounds + ) def add_dispatch_constraints( @@ -1264,26 +1270,6 @@ def model_set_declaration(m, stages, rep_per=["a", "b"], com_per=2, dis_per=2): ## NOTE: will want to cover baseline generator types in IDAES - m.oldGenerators = Set( - within=m.generators, - initialize=( - gen - for gen in m.generators - if m.md.data["elements"]["generator"][gen]["in_service"] - ), - doc="Existing generators; subset of all generators", - ) - - m.newGenerators = Set( - within=m.generators, - initialize=( - gen - for gen in m.generators - if not m.md.data["elements"]["generator"][gen]["in_service"] - ), - doc="Potential generators; subset of all generators", - ) - if m.md.data["elements"].get("storage"): m.storage = Set( initialize=(batt for batt in m.md.data["elements"]["storage"]), @@ -1478,15 +1464,6 @@ def model_data_references(m): region: m.md.data["system"]["min_spinning_reserve"] for region in m.regions } - # Maximum operating reserve available for each generator; expressed as a fraction - # maximum generator output - ## NOTE: This does not appear to exist elsewhere in the code currently (1/18/24)? - # I think this is very rarely defined in data? but should be checked - m.maxOperatingReserve = { - gen: m.md.data["elements"]["generator"][gen]["max_operating_reserve"] - for gen in m.thermalGenerators - } - # Maximum spinning reserve available for each generator; expressed as a fraction # maximum generator output m.maxSpinningReserve = { From bb23f1b61f2b84ef9954d28d8ca5783fb51d746e Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Wed, 28 Feb 2024 13:42:08 -0700 Subject: [PATCH 3/5] help what are docs --- .readthedocs.yml | 19 +++++++++++++++++++ .vscode/settings.json | 11 +++++++++++ docs/Makefile | 20 ++++++++++++++++++++ docs/make.bat | 35 +++++++++++++++++++++++++++++++++++ docs/source/conf.py | 35 +++++++++++++++++++++++++++++++++++ docs/source/index.rst | 20 ++++++++++++++++++++ gtep/driver.py | 19 +++++++++++++++++++ gtep/gtep_model.py | 3 +++ 8 files changed, 162 insertions(+) create mode 100644 .readthedocs.yml create mode 100644 .vscode/settings.json create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 gtep/driver.py diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..a796acd --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,19 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Build settings +build: + os: ubuntu-22.04 + tools: + python: "3.11" + +# Build documentation in the docs/ directory with Sphinx +sphinx: + fail_on_warning: false + +python: + install: ["pyomo", "scipy==1.11", "gridx-egret", "gridx-prescient", "anyio==3.1", "pint", "sphinx", "sphinx-rtd-theme"] diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9d2c8ee --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + "./gtep", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true +} \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..dc1312a --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..5202e18 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,35 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +import os + +project = "idaes-gtep" +copyright = "2024, Kyle Skolfield" +author = "Kyle Skolfield" +release = "0.1" + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = ["sphinx.ext.autodoc", "sphinx.ext.mathjax"] + +templates_path = ["_templates"] +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "sphinx_rtd_theme" +html_static_path = ["_static"] + +on_rtd = os.environ.get("READTHEDOCS", None) == "True" +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..e04441b --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. idaes-gtep documentation master file, created by + sphinx-quickstart on Wed Feb 28 13:10:52 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to idaes-gtep's documentation! +====================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/gtep/driver.py b/gtep/driver.py new file mode 100644 index 0000000..1e7ff3c --- /dev/null +++ b/gtep/driver.py @@ -0,0 +1,19 @@ +from pyomo.environ import ConcreteModel, Var, SolverFactory, value +from pyomo.environ import units as u +from gtep.gtep_model import ExpansionPlanningModel +from gtep.gtep_data import ExpansionPlanningData +from egret.data.model_data import ModelData +from pyomo.core import TransformationFactory + + +data_path = "./gtep/data/5bus" +data_object = ExpansionPlanningData() +data_object.load_prescient(data_path) +mod_object = ExpansionPlanningModel( + data=data_object, num_reps=1, len_reps=1, num_commit=1, num_dispatch=1 +) +mod_object.create_model() +TransformationFactory("gdp.bound_pretransformation").apply_to(mod_object.model) +TransformationFactory("gdp.bigm").apply_to(mod_object.model) +opt = SolverFactory("gurobi") +mod_object.results = opt.solve(mod_object.model, tee=True) diff --git a/gtep/gtep_model.py b/gtep/gtep_model.py index 45084ba..1f0a247 100644 --- a/gtep/gtep_model.py +++ b/gtep/gtep_model.py @@ -182,6 +182,7 @@ def add_investment_variables( m = b.model() b.investmentStage = investment_stage + # Thermal generator disjuncts (operational, installed, retired, disabled, extended) @b.Disjunct(m.thermalGenerators) def genOperational(disj, gen): return @@ -212,6 +213,7 @@ def investStatus(disj, gen): disj.genExtended[gen], ] + # Renewable generator MW values (operational, installed, retired, extended) b.renewableOperational = Var( m.renewableGenerators, within=NonNegativeReals, initialize=0 ) @@ -225,6 +227,7 @@ def investStatus(disj, gen): m.renewableGenerators, within=NonNegativeReals, initialize=0 ) + # Track and accumulate costs and penalties b.quotaDeficit = Var(within=NonNegativeReals, initialize=0, units=u.MW) b.operatingCostInvestment = Var(within=Reals, initialize=0, units=u.USD) b.expansionCost = Var(within=Reals, initialize=0, units=u.USD) From 8b3f49d924f3008ed63ff1bb2c4e4cf0a3ec9e15 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Wed, 28 Feb 2024 13:44:52 -0700 Subject: [PATCH 4/5] miranda's fault --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index a796acd..872ae73 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -16,4 +16,4 @@ sphinx: fail_on_warning: false python: - install: ["pyomo", "scipy==1.11", "gridx-egret", "gridx-prescient", "anyio==3.1", "pint", "sphinx", "sphinx-rtd-theme"] + install: [pyomo, scipy==1.11, gridx-egret, gridx-prescient, anyio==3.1, pint, sphinx, sphinx-rtd-theme] From 181bbe9737eb54c4318a98dce5c3c731a8111b16 Mon Sep 17 00:00:00 2001 From: Kyle Skolfield Date: Wed, 28 Feb 2024 13:47:45 -0700 Subject: [PATCH 5/5] still miranda's fault --- .readthedocs.yml | 3 ++- docs/requirements.txt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 docs/requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index 872ae73..e02de96 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -16,4 +16,5 @@ sphinx: fail_on_warning: false python: - install: [pyomo, scipy==1.11, gridx-egret, gridx-prescient, anyio==3.1, pint, sphinx, sphinx-rtd-theme] + install: + - requirements: docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..c0de83c --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,8 @@ +pyomo +scipy==1.11 +gridx-egret +gridx-prescient +anyio==3.1 +pint +sphinx +sphinx-rtd-theme \ No newline at end of file