-
Notifications
You must be signed in to change notification settings - Fork 57
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
BSM2 Anoxic CSTR Costing #1186
Merged
Merged
BSM2 Anoxic CSTR Costing #1186
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
1245716
Add anoxic cstr costing
MarcusHolly 4fe4d9a
Add costing to BSM2 flowsheet
MarcusHolly a21cb8e
Fix pylint issue
MarcusHolly 94ec318
Add electricity intensity to system-level metrics in flowsheet
MarcusHolly e7a9539
Merge branch 'main' into anoxic_tank_cost
MarcusHolly 6658fa9
Add CSTR unit model based on IDAES CSTR
MarcusHolly dbb3211
Update CSTR costing method
MarcusHolly e1477bf
Use new CSTR model in BSM2 flowsheet
MarcusHolly 816409d
Add tests for CSTR unit model
MarcusHolly 82e719f
Ignore mixer costs in BSM2 flowsheet for now
MarcusHolly fbcc50b
Merge branch 'main' into anoxic_tank_cost
MarcusHolly 228d8fe
Remove unused imports
MarcusHolly 9e18c86
Address pylint issue
MarcusHolly 835d9a8
Add default costing method for cstr
MarcusHolly df546bc
Add LCOW into cost testing
MarcusHolly fbc092d
Update init file
MarcusHolly b62db8f
Remove duplicate import
MarcusHolly 7386242
Change HRT to a Var and add an HRT constraint in unit model
MarcusHolly ae15d4a
Update costing test to use BSM2 flowsheet conditions
MarcusHolly 3bccd1e
Revert HRT back to a mutable parameter
MarcusHolly 65870ff
Treat HRT as a variable and modify costing appropriately
MarcusHolly af96904
Use cost_by_flow_volume utility function
MarcusHolly 390eb5a
Revert changes made to BSM2 flowsheet
MarcusHolly 9e2b42b
Merge branch 'main' into anoxic_tank_cost
adam-a-a 55c4503
Address Adam's comments
MarcusHolly fb2a438
Merge branch 'anoxic_tank_cost' of https://github.com/MarcusHolly/wat…
MarcusHolly b9d2c71
Update class name/import
MarcusHolly 5babe49
Address merge conflict
MarcusHolly fc56ef6
Make units explicit in unit costing test
MarcusHolly d49433b
Add check asserting units are consistent
MarcusHolly c06f4a5
Merge branch 'main' into anoxic_tank_cost
MarcusHolly e92f616
Merge branch 'main' into anoxic_tank_cost
adam-a-a File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
################################################################################# | ||
# WaterTAP Copyright (c) 2020-2023, The Regents of the University of California, | ||
# through Lawrence Berkeley National Laboratory, Oak Ridge National Laboratory, | ||
# National Renewable Energy Laboratory, and National Energy Technology | ||
# Laboratory (subject to receipt of any required approvals from the U.S. Dept. | ||
# of Energy). All rights reserved. | ||
# | ||
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license | ||
# information, respectively. These files are also available online at the URL | ||
# "https://github.com/watertap-org/watertap/" | ||
################################################################################# | ||
|
||
import pyomo.environ as pyo | ||
from ..util import ( | ||
register_costing_parameter_block, | ||
cost_by_flow_volume, | ||
) | ||
|
||
|
||
def build_cstr_cost_param_block(blk): | ||
# Source: https://www.fwrj.com/articles/9812.pdf | ||
blk.sizing_cost = pyo.Var( | ||
initialize=0.34, | ||
doc="Reactor sizing cost", | ||
units=pyo.units.USD_1998 / pyo.units.m**3, | ||
) | ||
|
||
|
||
@register_costing_parameter_block( | ||
build_rule=build_cstr_cost_param_block, | ||
parameter_block_name="cstr", | ||
) | ||
def cost_cstr(blk): | ||
""" | ||
CSTR costing method | ||
""" | ||
cost_by_flow_volume( | ||
blk, | ||
blk.unit_model.hydraulic_retention_time[0] | ||
* blk.costing_package.cstr.sizing_cost, | ||
pyo.units.convert( | ||
blk.unit_model.control_volume.properties_in[0].flow_vol, | ||
(pyo.units.meter**3 / pyo.units.hours), | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
############################################################################### | ||
# WaterTAP Copyright (c) 2021, The Regents of the University of California, | ||
# through Lawrence Berkeley National Laboratory, Oak Ridge National | ||
# Laboratory, National Renewable Energy Laboratory, and National Energy | ||
# Technology Laboratory (subject to receipt of any required approvals from | ||
# the U.S. Dept. of Energy). All rights reserved. | ||
# | ||
# Please see the files COPYRIGHT.md and LICENSE.md for full copyright and license | ||
# information, respectively. These files are also available online at the URL | ||
# "https://github.com/watertap-org/watertap/" | ||
# | ||
############################################################################### | ||
""" | ||
CSTR unit model for BSM2 and plant-wide wastewater treatment modeling. | ||
This unit inherits from the IDAES CSTR unit. | ||
""" | ||
|
||
# Import IDAES cores | ||
from idaes.core import ( | ||
declare_process_block_class, | ||
) | ||
from idaes.models.unit_models.cstr import CSTRData as CSTRIDAESData | ||
|
||
import idaes.logger as idaeslog | ||
|
||
from pyomo.environ import ( | ||
Constraint, | ||
NonNegativeReals, | ||
Var, | ||
units as pyunits, | ||
) | ||
|
||
from watertap.costing.unit_models.cstr import cost_cstr | ||
|
||
__author__ = "Marcus Holly" | ||
|
||
|
||
# Set up logger | ||
_log = idaeslog.getLogger(__name__) | ||
|
||
|
||
@declare_process_block_class("CSTR") | ||
MarcusHolly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class CSTRData(CSTRIDAESData): | ||
""" | ||
CSTR unit block for BSM2 | ||
""" | ||
|
||
CONFIG = CSTRIDAESData.CONFIG() | ||
|
||
def build(self): | ||
""" | ||
Begin building model. | ||
Args: | ||
None | ||
Returns: | ||
None | ||
""" | ||
|
||
# Call UnitModel.build to set up dynamics | ||
super(CSTRData, self).build() | ||
|
||
self.hydraulic_retention_time = Var( | ||
self.flowsheet().time, | ||
initialize=4, | ||
domain=NonNegativeReals, | ||
units=pyunits.s, | ||
doc="Hydraulic retention time", | ||
) | ||
|
||
def CSTR_retention_time_rule(self, t): | ||
return ( | ||
self.hydraulic_retention_time[t] | ||
== self.volume[t] / self.control_volume.properties_in[t].flow_vol | ||
) | ||
|
||
self.CSTR_retention_time = Constraint( | ||
self.flowsheet().time, | ||
rule=CSTR_retention_time_rule, | ||
doc="Total CSTR retention time", | ||
) | ||
|
||
@property | ||
def default_costing_method(self): | ||
return cost_cstr |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the unit cost for the largest size shown in the range from the reference. Perhaps we should choose a value like the mean or median.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I chose the largest size is because the flowrate in BSM2 actually goes way beyond the ranges listed in this reference. The largest flow in the reference is 100,000 GPD (378.5 m3/day) whereas the BSM2 feed flowrate is 20648 m3/day. So I didn't think it made sense to choose a mean or median value. Although if we intend on using this CSTR for non-BSM2 purposes, then it would make more sense to use an average value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough!