Skip to content

Commit

Permalink
Merge pull request #152 from zacharybinger/ZLD_Backup_2
Browse files Browse the repository at this point in the history
KBHDP ZLD
  • Loading branch information
kurbansitterley authored Dec 11, 2024
2 parents 3fad7dc + ccafe10 commit 1f98aaf
Show file tree
Hide file tree
Showing 4 changed files with 1,137 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import idaes.logger as idaeslog
from watertap.property_models.NaCl_prop_pack import NaClParameterBlock
from watertap.property_models.multicomp_aq_sol_prop_pack import MCASParameterBlock
from watertap.property_models.seawater_prop_pack import SeawaterParameterBlock
from idaes.models.unit_models import Product, Feed
from idaes.core.util.model_statistics import *
from watertap_contrib.reflo.costing import (
Expand Down Expand Up @@ -57,34 +58,24 @@ def main():
file_dir = os.path.dirname(os.path.abspath(__file__))

m = build_system(RE=True)
display_system_build(m)
display_system_build(m.fs.treatment)
display_system_build(m.fs.energy)
add_connections(m)
add_constraints(m)
# add_constraints(m)
set_operating_conditions(m)
apply_scaling(m)
init_system(m)
add_costing(m)
scale_costing(m)

print(m.fs.treatment.MD.display())
# add_costing(m)
# scale_costing(m)
# box_solve_problem(m)
# solve(m, debug=True)
solve(m, debug=True)

# scale_costing(m)

optimize(m, ro_mem_area=None, water_recovery=0.8, grid_frac=None, objective="LCOW")
solve(m, debug=True)
# # display_flow_table(m)
# display_system_stream_table(m)
# report_RO(m, m.fs.treatment.RO)
# # # # # report_pump(m, m.fs.treatment.pump)
# # report_PV(m)
# # # # # m.fs.treatment.costing.display()
# # # # # m.fs.energy.costing.display()""
# # # # # m.fs.costing.display()
# display_costing_breakdown(m)
# # # # # print(m.fs.energy.pv.display())
# # # print_system_scaling_report(m)
report_PV(m)
# print(m.fs.energy.pv.display())
# optimize(m, ro_mem_area=None, water_recovery=0.8, grid_frac=None, objective="LCOW")
# solve(m, debug=True)

return m

Expand All @@ -110,15 +101,10 @@ def build_system(RE=True):

m.fs.RO_properties = NaClParameterBlock()
m.fs.UF_properties = WaterParameterBlock(solute_list=["tds", "tss"])
m.fs.MD_properties = SeawaterParameterBlock()

build_treatment(m)
# if RE:
# print('Building System with Renewable Energy')
# m.fs.RE = RE
build_energy(m)
# else:
# print('Building System without Renewable Energy')
# m.fs.RE = RE

return m

Expand All @@ -135,7 +121,7 @@ def build_treatment(m):
treatment.UF = FlowsheetBlock(dynamic=False)
treatment.pump = Pump(property_package=m.fs.RO_properties)
treatment.RO = FlowsheetBlock(dynamic=False)
treatment.DWI = FlowsheetBlock(dynamic=False)
treatment.MD = FlowsheetBlock(dynamic=False)

treatment.MCAS_to_TDS_translator = Translator_MCAS_to_TDS(
inlet_property_package=m.fs.MCAS_properties,
Expand All @@ -151,19 +137,26 @@ def build_treatment(m):
outlet_state_defined=True,
)

treatment.NaCl_to_TDS_translator = Translator_NaCl_to_TDS(
inlet_property_package=m.fs.RO_properties,
outlet_property_package=m.fs.MD_properties,
has_phase_equilibrium=False,
outlet_state_defined=True,
)

build_ec(m, treatment.EC, prop_package=m.fs.UF_properties)
build_UF(m, treatment.UF, prop_package=m.fs.UF_properties)
build_ro(m, treatment.RO, prop_package=m.fs.RO_properties)
build_DWI(m, treatment.DWI, prop_package=m.fs.RO_properties)
build_md(m, treatment.MD, prop_package=m.fs.MD_properties)

m.fs.units = [
treatment.feed,
treatment.EC,
treatment.UF,
treatment.pump,
treatment.RO,
treatment.DWI,
# treatment.product,
treatment.MD,
treatment.product,
treatment.sludge,
]

Expand All @@ -185,6 +178,13 @@ def build_treatment(m):
"flow_mass_phase_comp", 1e2, index=("Liq", "NaCl")
)

m.fs.MD_properties.set_default_scaling(
"flow_mass_phase_comp", 1, index=("Liq", "H2O")
)
m.fs.MD_properties.set_default_scaling(
"flow_mass_phase_comp", 1e2, index=("Liq", "TDS")
)


def build_energy(m):
energy = m.fs.energy = Block()
Expand Down Expand Up @@ -239,9 +239,14 @@ def add_connections(m):
destination=treatment.product.inlet,
)

treatment.ro_to_dwi = Arc(
treatment.ro_to_translator = Arc(
source=treatment.RO.disposal.outlet,
destination=treatment.DWI.feed.inlet,
destination=treatment.NaCl_to_TDS_translator.inlet,
)

treatment.translator_to_md = Arc(
source=treatment.NaCl_to_TDS_translator.outlet,
destination=treatment.MD.feed.inlet,
)

TransformationFactory("network.expand_arcs").apply_to(m)
Expand Down Expand Up @@ -275,7 +280,6 @@ def add_treatment_costing(m):
add_ec_costing(m, treatment.EC, treatment.costing)
add_UF_costing(m, treatment.UF, treatment.costing)
add_ro_costing(m, treatment.RO, treatment.costing)
add_DWI_costing(m, treatment.DWI, treatment.costing)

treatment.costing.ultra_filtration.capital_a_parameter.fix(500000)
treatment.costing.total_investment_factor.fix(1)
Expand Down Expand Up @@ -511,11 +515,16 @@ def init_treatment(m, verbose=True, solver=None):

init_ro_system(m, treatment.RO)
propagate_state(treatment.ro_to_product)
# propagate_state(treatment.ro_to_dwi)
propagate_state(treatment.ro_to_translator)

treatment.product.initialize(optarg=optarg)
# init_DWI(m, treatment.DWI)
display_system_stream_table(m)
treatment.NaCl_to_TDS_translator.initialize(optarg=optarg)
propagate_state(treatment.translator_to_md)

init_md(treatment.MD)
# TODO: Continue from here
# treatment.product.initialize(optarg=optarg)
# # init_DWI(m, treatment.DWI)
# display_system_stream_table(m)


def init_system(m, verbose=True, solver=None):
Expand Down Expand Up @@ -745,9 +754,9 @@ def display_system_stream_table(m):
print("\n\n")


def display_system_build(m):
def display_system_build(blk):
blocks = []
for v in m.fs.component_data_objects(ctype=Block, active=True, descend_into=False):
for v in blk.component_data_objects(ctype=Block, active=True, descend_into=False):
print(v)


Expand All @@ -762,7 +771,7 @@ def display_costing_breakdown(m):
print_EC_costing_breakdown(m.fs.treatment.EC)
print_UF_costing_breakdown(m.fs.treatment.UF)
print_RO_costing_breakdown(m.fs.treatment.RO)
print_DWI_costing_breakdown(m.fs.treatment.DWI)
# print_DWI_costing_breakdown(m.fs.treatment.DWI)
print_PV_costing_breakdown(m.fs.energy.pv)


Expand Down
Loading

0 comments on commit 1f98aaf

Please sign in to comment.