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

ElectroNP ZO model with UnitModelBlockData base #1020

Merged
merged 22 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7d35890
add
luohezhiming Mar 16, 2023
4766c52
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Mar 16, 2023
ef81bae
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Mar 22, 2023
168bbaf
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Mar 27, 2023
a09b4e9
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Mar 30, 2023
44a22e8
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Mar 31, 2023
1c1a135
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Apr 5, 2023
401f997
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Apr 10, 2023
258f6fe
delete redundant files
luohezhiming Apr 11, 2023
2c994c3
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Apr 17, 2023
5b6baed
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Apr 21, 2023
0afa551
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Apr 24, 2023
479fb6d
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming Apr 28, 2023
f962022
Add ElectroNP ZO model
luohezhiming May 2, 2023
2dabf05
refine code
luohezhiming May 3, 2023
31c8be6
Update watertap/unit_models/electroNP_ZO.py
luohezhiming May 3, 2023
d31ce21
Update watertap/unit_models/electroNP_ZO.py
luohezhiming May 4, 2023
7e67624
refine model
luohezhiming May 4, 2023
5a20331
Merge branch 'electroNP' of https://github.com/luohezhiming/watertap …
luohezhiming May 4, 2023
b393ed0
Merge branch 'main' of https://github.com/watertap-org/watertap
luohezhiming May 9, 2023
6444221
Merge branch 'main' into electroNP
luohezhiming May 9, 2023
b6d734b
Merge branch 'main' into electroNP
ksbeattie May 11, 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
89 changes: 89 additions & 0 deletions watertap/costing/units/electroNP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#################################################################################
# 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,
make_capital_cost_var,
)


def build_electroNP_cost_param_block(blk):

blk.HRT = pyo.Var(
initialize=1.3333,
doc="Hydraulic retention time",
units=pyo.units.hr,
)
blk.sizing_cost = pyo.Var(
initialize=1.25,
doc="Reactor sizing cost",
units=pyo.units.USD_2020 / pyo.units.m**3,
)


@register_costing_parameter_block(
build_rule=build_electroNP_cost_param_block,
parameter_block_name="electroNP",
)
def cost_electroNP(blk, cost_electricity_flow=True, cost_MgCl2_flow=True):
"""
ElectroNP costing method
"""
cost_electroNP_capital(
blk,
blk.costing_package.electroNP.HRT,
blk.costing_package.electroNP.sizing_cost,
)

t0 = blk.flowsheet().time.first()
if cost_electricity_flow:
blk.costing_package.cost_flow(
pyo.units.convert(
blk.unit_model.electricity[t0],
to_units=pyo.units.kW,
),
"electricity",
)

if cost_MgCl2_flow:
blk.costing_package.cost_flow(
pyo.units.convert(
blk.unit_model.MgCl2_flowrate[t0],
to_units=pyo.units.kg / pyo.units.hr,
),
"magnesium chloride",
)


def cost_electroNP_capital(blk, HRT, sizing_cost):
"""
Generic function for costing an ElectroNP system.
"""
make_capital_cost_var(blk)

blk.HRT = pyo.Expression(expr=HRT)
blk.sizing_cost = pyo.Expression(expr=sizing_cost)

flow_in = pyo.units.convert(
blk.unit_model.properties_in[0].flow_vol,
to_units=pyo.units.m**3 / pyo.units.hr,
)

print(f"base_currency: {blk.costing_package.base_currency}")
blk.capital_cost_constraint = pyo.Constraint(
expr=blk.capital_cost
== pyo.units.convert(
blk.HRT * flow_in * blk.sizing_cost,
to_units=blk.costing_package.base_currency,
)
)
11 changes: 11 additions & 0 deletions watertap/costing/watertap_costing_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
EnergyRecoveryDevice,
Electrodialysis0D,
Electrodialysis1D,
ElectroNPZO,
IonExchange0D,
GAC,
)
Expand All @@ -55,6 +56,7 @@
from .units.pump import cost_pump
from .units.reverse_osmosis import cost_reverse_osmosis
from .units.uv_aop import cost_uv_aop
from .units.electroNP import cost_electroNP


class _DefinedFlowsDict(MutableMapping, dict):
Expand Down Expand Up @@ -95,6 +97,7 @@ class WaterTAPCostingData(FlowsheetCostingBlockData):
Ultraviolet0D: cost_uv_aop,
Electrodialysis0D: cost_electrodialysis,
Electrodialysis1D: cost_electrodialysis,
ElectroNPZO: cost_electroNP,
IonExchange0D: cost_ion_exchange,
GAC: cost_gac,
}
Expand Down Expand Up @@ -159,6 +162,14 @@ def build_global_params(self):
units=pyo.units.kg / pyo.units.kWh,
)

self.magnesium_chloride_cost = pyo.Param(
mutable=True,
initialize=0.0786,
doc="Magnesium chloride cost",
units=pyo.units.USD_2020 / pyo.units.kg,
)
self.add_defined_flow("magnesium chloride", self.magnesium_chloride_cost)

# fix the parameters
self.fix_all_vars()

Expand Down
1 change: 1 addition & 0 deletions watertap/unit_models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
from .ion_exchange_0D import IonExchange0D
from .thickener import Thickener
from .dewatering import DewateringUnit
from .electroNP_ZO import ElectroNPZO
Loading