Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional requirement and simple test case for Prescient #652

Merged
merged 18 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8,785 changes: 8,785 additions & 0 deletions idaes/tests/prescient/5bus/DAY_AHEAD_load.csv

Large diffs are not rendered by default.

8,785 changes: 8,785 additions & 0 deletions idaes/tests/prescient/5bus/DAY_AHEAD_renewables.csv

Large diffs are not rendered by default.

105,409 changes: 105,409 additions & 0 deletions idaes/tests/prescient/5bus/REAL_TIME_load.csv

Large diffs are not rendered by default.

105,409 changes: 105,409 additions & 0 deletions idaes/tests/prescient/5bus/REAL_TIME_renewables.csv

Large diffs are not rendered by default.

Empty file.
8 changes: 8 additions & 0 deletions idaes/tests/prescient/5bus/branch.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
UID,From Bus,To Bus,R,X,B,Cont Rating,LTE Rating,STE Rating,Tr Ratio
"branch_2_3",2,3,0.00108,0.0108,0.01852,80.0,92.0,104.0,0
"branch_1_2",1,2,0.00281,0.0281,0.00712,66.6,76.6,86.6,0
"branch_1_4",1,4,0.00304,0.0304,0.00658,66.6,76.6,86.6,0
"branch_4_10",4,10,0.00297,0.0297,0.00674,66.6,76.6,86.6,0
"branch_1_10",1,10,0.00064,0.0064,0.03126,66.6,76.6,86.6,0
"branch_3_4_0",3,4,0.00297,0.0297,0.00337,66.6,76.6,86.6,1.05
"branch_3_4_1",3,4,0.003274425,0.03274425,0.003056689,28.4,32.7,36.9,0.952380952
6 changes: 6 additions & 0 deletions idaes/tests/prescient/5bus/bus.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bus ID,Bus Name,BaseKV,Bus Type,MW Load,MVAR Load,V Mag,V Angle,Area,Zone
1,bus1,230,PV,0,0,1,0.048935018,1,1
4,bus4,230,Ref,28.5714286,9.3907143,1,0,1,1
10,bus5,230,PV,0,0,1,0.06266308,1,1
2,bus2,230,PQ,21.4285714,7.0435714,1.04407,-0.012822061,2,1
3,bus3,230,PV,21.4285714,7.0435714,1,-0.009768957,2,1
9 changes: 9 additions & 0 deletions idaes/tests/prescient/5bus/gen.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
GEN UID,Bus ID,Unit Type,Fuel,MW Inj,MVAR Inj,V Setpoint p.u.,PMax MW,PMin MW,QMax MVAR,QMin MVAR,Min Down Time Hr,Min Up Time Hr,Ramp Rate MW/Min,Start Time Cold Hr,Start Time Warm Hr,Start Time Hot Hr,Start Heat Cold MBTU,Start Heat Warm MBTU,Start Heat Hot MBTU,Non Fuel Start Cost $,Fuel Price $/MMBTU,Output_pct_0,Output_pct_1,Output_pct_2,Output_pct_3,Output_pct_4,HR_avg_0,HR_incr_1,HR_incr_2,HR_incr_3,HR_incr_4
3_CT,3,CT,G,0,0,1,20,8,20,-20,1,1,3,,,1,,,51.75,0,0.75,0.4,0.6,0.8,1,,135722.5,97862.5,98072.5,107135,
10_STEAM,10,STEAM,C,0,0,1,76,30,76,-76,4,8,2,12,10,4,11383.41,10488.35,7355.42,0,1,0.394736842,0.596052632,0.798684211,1,,30166.66667,14402.61434,17182.46753,18283.66017,
4_CC,4,CC,G,0,0,1,100,10,55,-55,3,3,3.7,,,3,,,5665.23,0,0.5,0.4,0.6,0.8,1,,51019.54545,26818.18182,29550.90909,30308.18182,
4_STEAM,4,STEAM,O,0,0,1,12,5,12,-12,2,4,1,12,4,2,703.76,455.37,393.28,0,1.5,0.416666667,0.608333333,0.808333333,1,,179457.9999,124504.3483,125050,133643.478,
10_PV,10,PV,S,0,0,1,25.9,0,0,0,,,,,,,,,,0,,,,,,,,,,,
2_RTPV,2,RTPV,S,0,0,1,9.3,0,0,0,,,,,,,,,,0,,,,,,,,,,,
1_HYDRO,1,HYDRO,H,0,0,1,50,0,16,-10,,,,,,,,,,0,,,,,,,,,,,
4_WIND,4,WIND,W,0,0,1,120,0,0,0,,,,,,,,,,0,,,,,,,,,,,
3 changes: 3 additions & 0 deletions idaes/tests/prescient/5bus/initial_status.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
3_CT,10_STEAM,4_CC,4_STEAM
24,-24,24,-24,
14,0,40,0
1 change: 1 addition & 0 deletions idaes/tests/prescient/5bus/reserves.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reserve Product,Requirement (MW)
7 changes: 7 additions & 0 deletions idaes/tests/prescient/5bus/simulation_objects.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Simulation_Parameters,Description,DAY_AHEAD,REAL_TIME
Periods_per_Step,the number of discrete periods represented in each simulation step,24,1
Period_Resolution,seconds per period,3600,300
Date_From,simulation beginning period,01/01/2020 0:00,12/31/2020 0:00
Date_To,simulation ending period (must account for lookahed data availability),01/01/2020 0:00,12/31/2020 0:00
Look_Ahead_Periods_per_Step,the number of look ahead periods included in each optimization step,24,2
Look_Ahead_Resolution,look-ahead period resolution,3600,300
17 changes: 17 additions & 0 deletions idaes/tests/prescient/5bus/timeseries_pointers.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Simulation,Category,Object,Parameter,Data File
DAY_AHEAD,Generator,1_HYDRO,PMin MW,DAY_AHEAD_renewables.csv
DAY_AHEAD,Generator,2_RTPV,PMin MW,DAY_AHEAD_renewables.csv
DAY_AHEAD,Generator,1_HYDRO,PMax MW,DAY_AHEAD_renewables.csv
DAY_AHEAD,Generator,2_RTPV,PMax MW,DAY_AHEAD_renewables.csv
DAY_AHEAD,Generator,10_PV,PMax MW,DAY_AHEAD_renewables.csv
DAY_AHEAD,Generator,4_WIND,PMax MW,DAY_AHEAD_renewables.csv
DAY_AHEAD,Area,1,MW Load,DAY_AHEAD_load.csv
DAY_AHEAD,Area,2,MW Load,DAY_AHEAD_load.csv
REAL_TIME,Generator,1_HYDRO,PMin MW,REAL_TIME_renewables.csv
REAL_TIME,Generator,2_RTPV,PMin MW,REAL_TIME_renewables.csv
REAL_TIME,Generator,1_HYDRO,PMax MW,REAL_TIME_renewables.csv
REAL_TIME,Generator,2_RTPV,PMax MW,REAL_TIME_renewables.csv
REAL_TIME,Generator,10_PV,PMax MW,REAL_TIME_renewables.csv
REAL_TIME,Generator,4_WIND,PMax MW,REAL_TIME_renewables.csv
REAL_TIME,Area,1,MW Load,REAL_TIME_load.csv
REAL_TIME,Area,2,MW Load,REAL_TIME_load.csv
12 changes: 12 additions & 0 deletions idaes/tests/prescient/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#################################################################################
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES), and is copyright (c) 2018-2021
# by the software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory, National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia University
# Research Corporation, et al. All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and
# license information.
#################################################################################
100 changes: 100 additions & 0 deletions idaes/tests/prescient/test_prescient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#################################################################################
# The Institute for the Design of Advanced Energy Systems Integrated Platform
# Framework (IDAES IP) was produced under the DOE Institute for the
# Design of Advanced Energy Systems (IDAES), and is copyright (c) 2018-2021
# by the software owners: The Regents of the University of California, through
# Lawrence Berkeley National Laboratory, National Technology & Engineering
# Solutions of Sandia, LLC, Carnegie Mellon University, West Virginia University
# Research Corporation, et al. All rights reserved.
#
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and
# license information.
#################################################################################

import importlib
from numbers import Number
from pathlib import Path
from typing import Dict, Union, List

import pytest
import pandas as pd


prescient_simulator = pytest.importorskip("prescient.simulator", reason="prescient (optional dependency) not available")


@pytest.fixture(scope="module")
def base_dir() -> Path:
pkg_init_path = Path(importlib.util.find_spec("idaes.tests.prescient").origin)
return pkg_init_path.parent


# define custom type for type hinting
PrescientOptions = Dict[str, Union[str, bool, Number, dict]]


class Test5Bus:
"Simple test using 5bus use case"

@pytest.fixture
def data_path(self, base_dir: Path) -> Path:
return base_dir / "5bus"

@pytest.mark.unit
def test_data_path_available(self, data_path: Path):
assert data_path.is_dir()

@pytest.fixture
def output_dir(self, tmp_path: Path) -> Path:
path = tmp_path / "5bus_output"
path.mkdir()
return path

@pytest.fixture
def prescient_options(self, data_path: Path, output_dir: Path) -> PrescientOptions:
return {
"data_path": str(data_path),
"input_format":"rts-gmlc",
"simulate_out_of_sample":True,
"run_sced_with_persistent_forecast_errors":True,
"output_directory": str(output_dir),
"start_date":"07-10-2020",
"num_days":2,
"sced_horizon":1,
"ruc_mipgap":0.01,
"reserve_factor":0.1,
"deterministic_ruc_solver":"cbc",
"deterministic_ruc_solver_options":{"feas":"off", "DivingF":"on",},
"sced_solver":"cbc",
"sced_frequency_minutes":60,
"ruc_horizon":36,
"compute_market_settlements":True,
"monitor_all_contingencies":False,
"output_solver_logs":False,
"price_threshold":1000,
"contingency_price_threshold":100,
"reserve_price_threshold":5,
}

@pytest.fixture
def run_simulator(self, prescient_options: PrescientOptions) -> None:
from prescient.simulator import Prescient

sim = Prescient()
sim.simulate(**prescient_options)

@pytest.fixture
def simulation_results_table(
self,
run_simulator,
output_dir: Path,
name: str = "overall_simulation_output.csv"
) -> pd.DataFrame:

path = output_dir / name
return pd.read_csv(path)

@pytest.mark.component
# TODO use a more specific test to validate simulation output
def test_simulation_results(self, simulation_results_table: pd.DataFrame):
assert not simulation_results_table.empty
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def dmf_data_files(root: str = DMF_DATA_ROOT) -> List[Tuple[str, List[str]]]:
"prerelease": DEPENDENCIES_FOR_PRERELEASE_VERSION,
"optional": [
"tensorflow", # idaes.surrogate.keras_surrogate
"gridx-prescient>=2.1", # idaes.tests.prescient
# A Lee 11-Jan-22: no precompiled version of CoolProp available for Pyhton 3.9
"coolprop; python_version < '3.9'" # idaes.generic_models.properties.general.coolprop
"coolprop; python_version < '3.9'", # idaes.generic_models.properties.general.coolprop
],
},
package_data={
Expand Down