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

BSM2 Anoxic CSTR Costing #1186

Merged
merged 32 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
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 Nov 7, 2023
4fe4d9a
Add costing to BSM2 flowsheet
MarcusHolly Nov 7, 2023
a21cb8e
Fix pylint issue
MarcusHolly Nov 7, 2023
94ec318
Add electricity intensity to system-level metrics in flowsheet
MarcusHolly Nov 7, 2023
e7a9539
Merge branch 'main' into anoxic_tank_cost
MarcusHolly Nov 17, 2023
6658fa9
Add CSTR unit model based on IDAES CSTR
MarcusHolly Nov 18, 2023
dbb3211
Update CSTR costing method
MarcusHolly Nov 18, 2023
e1477bf
Use new CSTR model in BSM2 flowsheet
MarcusHolly Nov 18, 2023
816409d
Add tests for CSTR unit model
MarcusHolly Nov 20, 2023
82e719f
Ignore mixer costs in BSM2 flowsheet for now
MarcusHolly Nov 20, 2023
fbcc50b
Merge branch 'main' into anoxic_tank_cost
MarcusHolly Nov 20, 2023
228d8fe
Remove unused imports
MarcusHolly Nov 20, 2023
9e18c86
Address pylint issue
MarcusHolly Nov 20, 2023
835d9a8
Add default costing method for cstr
MarcusHolly Nov 20, 2023
df546bc
Add LCOW into cost testing
MarcusHolly Nov 20, 2023
fbc092d
Update init file
MarcusHolly Nov 20, 2023
b62db8f
Remove duplicate import
MarcusHolly Nov 20, 2023
7386242
Change HRT to a Var and add an HRT constraint in unit model
MarcusHolly Nov 20, 2023
ae15d4a
Update costing test to use BSM2 flowsheet conditions
MarcusHolly Nov 20, 2023
3bccd1e
Revert HRT back to a mutable parameter
MarcusHolly Nov 20, 2023
65870ff
Treat HRT as a variable and modify costing appropriately
MarcusHolly Nov 20, 2023
af96904
Use cost_by_flow_volume utility function
MarcusHolly Nov 20, 2023
390eb5a
Revert changes made to BSM2 flowsheet
MarcusHolly Nov 21, 2023
9e2b42b
Merge branch 'main' into anoxic_tank_cost
adam-a-a Nov 22, 2023
55c4503
Address Adam's comments
MarcusHolly Nov 27, 2023
fb2a438
Merge branch 'anoxic_tank_cost' of https://github.com/MarcusHolly/wat…
MarcusHolly Nov 27, 2023
b9d2c71
Update class name/import
MarcusHolly Nov 27, 2023
5babe49
Address merge conflict
MarcusHolly Nov 28, 2023
fc56ef6
Make units explicit in unit costing test
MarcusHolly Nov 29, 2023
d49433b
Add check asserting units are consistent
MarcusHolly Nov 30, 2023
c06f4a5
Merge branch 'main' into anoxic_tank_cost
MarcusHolly Dec 1, 2023
e92f616
Merge branch 'main' into anoxic_tank_cost
adam-a-a Dec 5, 2023
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
4 changes: 3 additions & 1 deletion watertap/costing/costing_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import pyomo.environ as pyo
from idaes.core import declare_process_block_class
from idaes.core.base.costing_base import FlowsheetCostingBlockData
from idaes.models.unit_models import Mixer, HeatExchanger
from idaes.models.unit_models import Mixer, HeatExchanger, CSTR

from watertap.core.util.misc import is_constant_up_to_units

from watertap.costing.unit_models.mixer import cost_mixer
from watertap.costing.unit_models.heat_exchanger import cost_heat_exchanger
from watertap.costing.unit_models.cstr import cost_cstr


@declare_process_block_class("WaterTAPCostingBlock")
Expand All @@ -33,6 +34,7 @@ class WaterTAPCostingBlockData(FlowsheetCostingBlockData):
unit_mapping = {
Mixer: cost_mixer,
HeatExchanger: cost_heat_exchanger,
CSTR: cost_cstr,
}

def build(self):
Expand Down
45 changes: 45 additions & 0 deletions watertap/costing/unit_models/cstr.py
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,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

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),
),
)
1 change: 1 addition & 0 deletions watertap/unit_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
from .thickener import Thickener
from .dewatering import DewateringUnit
from .electroNP_ZO import ElectroNPZO
from .cstr import CSTR
from .clarifier import Clarifier
84 changes: 84 additions & 0 deletions watertap/unit_models/cstr.py
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
Loading
Loading