Skip to content

Commit

Permalink
Merge branch 'main' into re-double-loop-infra
Browse files Browse the repository at this point in the history
  • Loading branch information
lbianchi-lbl authored Jun 30, 2022
2 parents fa3a409 + d034a77 commit 9b93eda
Show file tree
Hide file tree
Showing 13 changed files with 28,098 additions and 27 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -665,11 +665,12 @@ def initialize(m, solver=None,
"""Initialize the units included in the flowsheet
"""

optarg = {
"max_iter": 300,
"halt_on_ampl_error": "yes",
}
solver = get_solver(solver, optarg)
if solver is None:
optarg = {
"max_iter": 300,
"halt_on_ampl_error": "yes",
}
solver = get_solver(solver, optarg)

# Include scaling factors
iscale.calculate_scaling_factors(m)
Expand Down Expand Up @@ -736,8 +737,7 @@ def initialize(m, solver=None,
print("*************** Integrated Model Initialized ***************")


def build_costing(m, solver=None,
optarg={"tol": 1e-8, "max_iter": 300}):
def build_costing(m):
"""This method adds cost correlations for the storage design analysis
and it is used to estimate the capital and operatig cost of
integrating an energy storage system. It contains cost
Expand All @@ -754,8 +754,6 @@ def build_costing(m, solver=None,
# power plant. The cost correlations used here are taken from the
# IDAES costing method.

if solver is None:
solver = get_solver('ipopt', optarg)
###########################################################################
# Data #
###########################################################################
Expand Down Expand Up @@ -911,7 +909,16 @@ def op_variable_plant_cost_rule(b):
return m


def initialize_with_costing(m):
def initialize_with_costing(m, solver=None):

# Create a solver object if it is not passed
if solver is None:
optarg = {
"max_iter": 300,
"halt_on_ampl_error": "yes",
}
solver = get_solver(solver, optarg)

# Initialize operating cost
calculate_variable_from_constraint(
m.fs.operating_cost,
Expand Down Expand Up @@ -1304,6 +1311,15 @@ def model_analysis(m, solver,
expr=m.fs.es_turbine.work[0] * (-1e-6) <= max_power_storage
)

# Add LMP signal value
m.fs.lmp = Var(
m.fs.time,
domain=Reals,
initialize=80,
doc="Hourly LMP in $/MWh"
)
m.fs.lmp[0].fix(22)

# Fix boiler outlet pressure and storage heat exchangers area and
# salt temperatures
m.fs.boiler.outlet.pressure.fix(m.main_steam_pressure)
Expand Down Expand Up @@ -1335,6 +1351,7 @@ def model_analysis(m, solver,
# Add bounds to salt inventory
inventory_max = 1e7 # Units in kg
inventory_min = 75000 # Units in kg
tank_max = 6739292 # Units in kg

# Add salt inventory mass balances
m.fs.previous_salt_inventory_hot = Var(
Expand All @@ -1354,14 +1371,14 @@ def model_analysis(m, solver,
m.fs.previous_salt_inventory_cold = Var(
m.fs.time,
domain=NonNegativeReals,
initialize=inventory_max-inventory_min,
initialize=tank_max-inventory_min,
bounds=(0, inventory_max),
doc="Cold salt at the beginning of the time period in kg"
)
m.fs.salt_inventory_cold = Var(
m.fs.time,
domain=NonNegativeReals,
initialize=inventory_max-inventory_min,
initialize=tank_max-inventory_min,
bounds=(0, inventory_max),
doc="Cold salt inventory at the end of the time period in kg"
)
Expand Down Expand Up @@ -1395,7 +1412,6 @@ def constraint_salt_maxflow_cold(b):
)

# Fix the previous salt inventory based on the tank scenario
tank_max = 6739291 # Units in kg
if tank_scenario == "hot_empty":
m.fs.previous_salt_inventory_hot[0].fix(inventory_min)
m.fs.previous_salt_inventory_cold[0].fix(tank_max - inventory_min)
Expand Down Expand Up @@ -1440,6 +1456,8 @@ def constraint_salt_maxflow_cold(b):
)

print_results(m, results)

return m


if __name__ == "__main__":
Expand All @@ -1460,15 +1478,6 @@ def constraint_salt_maxflow_cold(b):
# Build integrated ultra-supercritical plant model
m_isp = main(max_power=max_power)

# Add LMP signal value
m_isp.fs.lmp = Var(
m_isp.fs.time,
domain=Reals,
initialize=80,
doc="Hourly LMP in $/MWh"
)
m_isp.fs.lmp[0].fix(22)

# Solve the optimization problem
m = model_analysis(m_isp,
solver,
Expand Down
Loading

0 comments on commit 9b93eda

Please sign in to comment.