Skip to content

Commit

Permalink
ElectroNP ZO model with UnitModelBlockData base (#1020)
Browse files Browse the repository at this point in the history
* add

* delete redundant files

* Add ElectroNP ZO model

* refine code

* Update watertap/unit_models/electroNP_ZO.py

Co-authored-by: MarcusHolly <96305519+MarcusHolly@users.noreply.github.com>

* Update watertap/unit_models/electroNP_ZO.py

Co-authored-by: Adam Atia <aatia@keylogic.com>

* refine model

---------

Co-authored-by: MarcusHolly <96305519+MarcusHolly@users.noreply.github.com>
Co-authored-by: Adam Atia <aatia@keylogic.com>
  • Loading branch information
3 people authored May 11, 2023
1 parent cd2ec4d commit 1334584
Show file tree
Hide file tree
Showing 5 changed files with 878 additions and 0 deletions.
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

0 comments on commit 1334584

Please sign in to comment.