Skip to content

Commit

Permalink
Changing ElectroN-P unit model to separator structure (#1091)
Browse files Browse the repository at this point in the history
* changing unit model to separator

* updating flowsheet

* running black

* running pylint

* changing scaling

* running black

* solving pylint

* scaling

* revert to old names

* Fix object reference typo and add test to catch similar errors

* run black

---------

Co-authored-by: MarcusHolly <[email protected]>
Co-authored-by: adam-a-a <[email protected]>
  • Loading branch information
3 people authored Aug 18, 2023
1 parent 579b0b9 commit b1a88e3
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 322 deletions.
3 changes: 1 addition & 2 deletions watertap/costing/units/electroNP.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


def build_electroNP_cost_param_block(blk):

blk.HRT = pyo.Var(
initialize=1.3333,
doc="Hydraulic retention time",
Expand Down Expand Up @@ -104,7 +103,7 @@ def cost_electroNP_capital(blk, HRT, sizing_cost):
blk.sizing_cost = pyo.Expression(expr=sizing_cost)

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ def build_flowsheet():
m.fs.electroNP.costing = UnitModelCostingBlock(flowsheet_costing_block=m.fs.costing)

m.fs.costing.cost_process()
m.fs.costing.add_annual_water_production(
m.fs.electroNP.properties_treated[0].flow_vol
)
m.fs.costing.add_annual_water_production(m.fs.electroNP.treated.flow_vol[0])
m.fs.costing.add_LCOW(m.fs.AD.inlet.flow_vol[0])

# connections
Expand Down Expand Up @@ -183,7 +181,7 @@ def build_flowsheet():

iscale.calculate_scaling_factors(m)

iscale.set_scaling_factor(m.fs.electroNP.properties_byproduct[0.0].flow_vol, 1e7)
iscale.set_scaling_factor(m.fs.electroNP.byproduct.flow_vol[0.0], 1e7)
iscale.set_scaling_factor(m.fs.AD.vapor_phase[0].pressure_sat, 1e-3)

m.fs.AD.initialize(outlvl=idaeslog.INFO_HIGH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# information, respectively. These files are also available online at the URL
# "https://github.com/watertap-org/watertap/"
#################################################################################
'''
"""
Flowsheet example full Water Resource Recovery Facility
(WRRF; a.k.a., wastewater treatment plant) with ASM1 and ADM1.
The flowsheet follows the same formulation as benchmark simulation model no.2 (BSM2)
but comprises different specifications for default values than BSM2.
'''
"""
__author__ = "Alejandro Garciadiego, Xinhong Liu, Adam Atia"

import pyomo.environ as pyo
Expand Down Expand Up @@ -81,17 +81,17 @@ def main():
add_costing(m)
# Assert DOF = 0 after adding costing
# assert_degrees_of_freedom(m, 0)
#TODO: initialize costing after adding to flowsheet
#m.fs.costing.initialize()

# TODO: initialize costing after adding to flowsheet
# m.fs.costing.initialize()

# results = solve(m)

display_results(m)

return m, results


def build_flowsheet():
m = pyo.ConcreteModel()

Expand Down Expand Up @@ -284,6 +284,7 @@ def mass_transfer_R4(self, t):

return m


def set_operating_conditions(m):
# Feed Water Conditions
m.fs.FeedWater.flow_vol.fix(20648 * pyo.units.m**3 / pyo.units.day)
Expand Down Expand Up @@ -364,12 +365,13 @@ def set_operating_conditions(m):
m.fs.CL.split_fraction[0, "effluent", "S_ND"].fix(0.993)
m.fs.CL.split_fraction[0, "effluent", "X_ND"].fix(0.5192)
m.fs.CL.split_fraction[0, "effluent", "S_ALK"].fix(0.993)

# Anaerobic digester
m.fs.RADM.volume_liquid.fix(3400)
m.fs.RADM.volume_vapor.fix(300)
m.fs.RADM.liquid_outlet.temperature.fix(308.15)


def initialize_system(m):
# Initialize flowsheet
# Apply sequential decomposition - 1 iteration should suffice
Expand Down Expand Up @@ -437,17 +439,20 @@ def function(unit):

seq.run(m, function)


def add_costing(m):
#TODO: implement unit model and flowsheet level costing
# TODO: implement unit model and flowsheet level costing
pass


def solve(blk, solver=None):
if solver is None:
solver = get_solver()
results = solver.solve(blk)
pyo.assert_optimal_termination(results)
return results


def display_results(m):
m.display()

Expand Down Expand Up @@ -479,5 +484,5 @@ def display_results(m):
m.fs.component(u).report()


if __name__ == '__main__':
if __name__ == "__main__":
m, results = main()
Loading

0 comments on commit b1a88e3

Please sign in to comment.