Skip to content

Commit

Permalink
Merge pull request #6 from IDAES/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rundxdi authored Feb 28, 2024
2 parents 0e8384c + 181bbe9 commit de51c71
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

20 changes: 20 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# .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:
- requirements: docs/requirements.txt
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./gtep",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pyomo
scipy==1.11
gridx-egret
gridx-prescient
anyio==3.1
pint
sphinx
sphinx-rtd-theme
35 changes: 35 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -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()]
20 changes: 20 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -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`
19 changes: 19 additions & 0 deletions gtep/driver.py
Original file line number Diff line number Diff line change
@@ -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)
48 changes: 14 additions & 34 deletions gtep/gtep_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand All @@ -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)
Expand Down Expand Up @@ -512,13 +515,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(
Expand Down Expand Up @@ -1264,26 +1273,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"]),
Expand Down Expand Up @@ -1478,15 +1467,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 = {
Expand Down

0 comments on commit de51c71

Please sign in to comment.