Skip to content

Commit

Permalink
Merge pull request #24 from IDAES/dev
Browse files Browse the repository at this point in the history
Merge dev into main
  • Loading branch information
rundxdi authored Oct 13, 2024
2 parents 870dfc6 + a877ed0 commit 32bb5ed
Show file tree
Hide file tree
Showing 10 changed files with 1,235 additions and 490 deletions.
86 changes: 86 additions & 0 deletions gtep/config_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from pyomo.common.config import (
ConfigBlock,
ConfigDict,
ConfigList,
ConfigValue,
In,
NonNegativeFloat,
NonNegativeInt,
PositiveInt,
Bool,
)
from pyomo.common.deprecation import deprecation_warning

_supported_flows = {
"DC": ("gtep.dcopf", "DC power flow approximation"),
"CP": ("gtep.cp", "Copper plate power flow approximation"),
}


def _get_model_config():
CONFIG = ConfigBlock("GTEPModelConfig")
CONFIG.declare(
"flow_model",
ConfigValue(
default="DC",
domain=In(_supported_flows),
description="Power flow approximation to use.",
),
)
CONFIG.declare(
"time_period_dict",
ConfigDict(
description="Time period dict, specified as \{(investment period #, length): \{(commitment period #, length): \{dispatch period #: length\}\}\}"
),
)
CONFIG.declare(
"dispatch_randomizations",
ConfigValue(
default=True,
domain=Bool,
description="Introduces random dispatch information rather than having fixed values per-commitment period.",
),
)
return CONFIG


def _add_common_configs(CONFIG):
pass


def _add_investment_configs(CONFIG):
CONFIG.declare(
"thermal_generation",
ConfigValue(
default=False,
domain=Bool,
description="Include thermal generation investment options",
),
)
CONFIG.declare(
"renewable_generation",
ConfigValue(
default=False,
domain=Bool,
description="Include renewable generation investment options",
),
)
CONFIG.declare(
"storage",
ConfigValue(
default=False, domain=Bool, description="Include storage investment options"
),
)
CONFIG.declare(
"transmission",
ConfigValue(
default=False,
domain=Bool,
description="Include transmission investment options",
),
)
pass


def _add_solver_configs(CONFIG):
pass
4 changes: 2 additions & 2 deletions gtep/data/5bus_jsc/gen.csv
Original file line number Diff line number Diff line change
@@ -1,9 +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_CC-c,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-c,4,WIND,W,0,0,1,120,0,0,0,,,,,,,,,,0,,,,,,,,,,,
4_WIND,4,WIND,W,0,0,1,120,0,0,0,,,,,,,,,,0,,,,,,,,,,,
5 changes: 3 additions & 2 deletions gtep/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pyomo.contrib.appsi.solvers.gurobi import Gurobi



data_path = "./data/5bus"
data_object = ExpansionPlanningData()
data_object.load_prescient(data_path)
Expand All @@ -22,8 +23,8 @@
TransformationFactory("gdp.bound_pretransformation").apply_to(mod_object.model)
TransformationFactory("gdp.bigm").apply_to(mod_object.model)
# opt = SolverFactory("gurobi")
# opt = Gurobi()
opt = Highs()
opt = Gurobi()
# opt = Highs()
# # mod_object.results = opt.solve(mod_object.model, tee=True)
mod_object.results = opt.solve(mod_object.model)

Expand Down
73 changes: 73 additions & 0 deletions gtep/driver_config_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
from gtep.gtep_model import ExpansionPlanningModel
from gtep.gtep_data import ExpansionPlanningData
from gtep.gtep_solution import ExpansionPlanningSolution
from pyomo.core import TransformationFactory
from pyomo.contrib.appsi.solvers.highs import Highs
from pyomo.contrib.appsi.solvers.gurobi import Gurobi
from icecream import ic


data_path = "./gtep/data/5bus"
data_object = ExpansionPlanningData()
data_object.load_prescient(data_path)



mod_object = ExpansionPlanningModel(
stages=1,
data=data_object.md,
num_reps=1,
len_reps=1,
num_commit=24,
num_dispatch=4,
)

for k,v in mod_object.config.items():
ic(k,v)

quit()

mod_object.create_model()

ic(mod_object)


quit()
TransformationFactory("gdp.bound_pretransformation").apply_to(mod_object.model)
TransformationFactory("gdp.bigm").apply_to(mod_object.model)
# opt = SolverFactory("gurobi")
opt = Gurobi()
# opt = Highs()
# # mod_object.results = opt.solve(mod_object.model, tee=True)
mod_object.results = opt.solve(mod_object.model)

sol_object = ExpansionPlanningSolution()
sol_object.load_from_model(mod_object)
sol_object.dump_json("./gtep_solution.json")

sol_object.import_data_object(data_object)

# sol_object.read_json("./gtep_lots_of_buses_solution.json") # "./gtep/data/WECC_USAEE"
# sol_object.read_json("./gtep_11bus_solution.json") # "./gtep/data/WECC_Reduced_USAEE"
# sol_object.read_json("./gtep_solution.json")
# sol_object.read_json("./updated_gtep_solution_test.json")
# sol_object.read_json("./gtep_wiggles.json")
sol_object.plot_levels(save_dir="./plots/")

# save_numerical_results = False
# if save_numerical_results:

# sol_object = ExpansionPlanningSolution()

# sol_object.load_from_model(mod_object)
# sol_object.dump_json()
# load_numerical_results = False
# if load_numerical_results:
# # sol_object.read_json("./gtep_solution.json")
# sol_object.read_json("./bigger_longer_wigglier_gtep_solution.json")
# plot_results = False
# if plot_results:
# sol_object.plot_levels(save_dir="./plots/")


pass
2 changes: 1 addition & 1 deletion gtep/driver_jsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# data=data_object.md, num_reps=2, len_reps=1, stages=2, num_commit=24, num_dispatch=12
# )
mod_object = ExpansionPlanningModel(
data=data_object.md, num_reps=1, len_reps=1, stages=1, num_commit=24, num_dispatch=12
data=data_object.md, num_reps=1, len_reps=1, stages=1, num_commit=24, num_dispatch=2
)
mod_object.create_model()
TransformationFactory("gdp.bound_pretransformation").apply_to(mod_object.model)
Expand Down
6 changes: 3 additions & 3 deletions gtep/gtep_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ def load_prescient(self, data_path, options_dict=None):
self.load_default_data_settings()

for gen in self.md.data["elements"]["generator"]:
if "-c" in gen: # key/Gen UID in csv file; -c = candidate?
if "-c" in gen: # key/Gen UID in csv file; -c = candidate?
self.md.data["elements"]["generator"][gen]["in_service"] = False

# JSC addn
for branch in self.md.data["elements"]["branch"]:
if "-c" in branch: # key/Branch UID
if "-c" in branch: # key/Branch UID
self.md.data["elements"]["branch"][branch]["in_service"] = False

## NOTE: Below is only for multiple representative periods and creates a list
Expand Down
Loading

0 comments on commit 32bb5ed

Please sign in to comment.