Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 1 addition & 33 deletions watertap/flowsheets/lsrro/lsrro.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
)
import watertap.property_models.NaCl_prop_pack as props
from parameter_sweep import LinearSample, parameter_sweep
from watertap.flowsheets.lsrro.multi_sweep import _lsrro_presweep
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -1816,39 +1817,6 @@ def feed_concentration_recovery_profile(
return results, output_filename, fig, ax


def _lsrro_presweep(
number_of_stages=2,
A_value=5 / 3.6e11,
permeate_quality_limit=1000e-6,
has_CP=True,
quick_start=False,
):
"""
Set up model for optimization, unfix feed mass flowrates, and fix mass concentration and volumetric flowrate for anticipated parameter sensitivity
"""
m = build(
number_of_stages=number_of_stages,
has_NaCl_solubility_limit=True,
has_calculated_concentration_polarization=has_CP,
has_calculated_ro_pressure_drop=True,
)
set_operating_conditions(m)
if not quick_start:
initialize(m)
solve(m)
m.fs.feed.flow_mass_phase_comp.unfix()
m.fs.feed.properties[0].conc_mass_phase_comp["Liq", "NaCl"].fix()
m.fs.feed.properties[0].flow_vol_phase["Liq"].fix()
optimize_set_up(
m,
set_default_bounds_on_module_dimensions=True,
A_value=A_value,
permeate_quality_limit=permeate_quality_limit,
)

return m


if __name__ == "__main__":
m, results = run_lsrro_case(
number_of_stages=3,
Expand Down
36 changes: 32 additions & 4 deletions watertap/flowsheets/lsrro/multi_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,37 @@
from watertap.flowsheets.lsrro import lsrro


def run_case(number_of_stages, nx, output_filename=None, quick_start=False):
def _lsrro_presweep(
number_of_stages=2,
A_value=5 / 3.6e11,
permeate_quality_limit=1000e-6,
has_CP=True,
quick_start=False,
):
m = lsrro.build(
number_of_stages=number_of_stages,
has_NaCl_solubility_limit=True,
has_calculated_concentration_polarization=has_CP,
has_calculated_ro_pressure_drop=True,
)
lsrro.set_operating_conditions(m)
if not quick_start:
lsrro.initialize(m)
lsrro.solve(m)
m.fs.feed.flow_mass_phase_comp.unfix()
m.fs.feed.properties[0].conc_mass_phase_comp["Liq", "NaCl"].fix()
m.fs.feed.properties[0].flow_vol_phase["Liq"].fix()
lsrro.optimize_set_up(
m,
set_default_bounds_on_module_dimensions=True,
A_value=A_value,
permeate_quality_limit=permeate_quality_limit,
)

return m


def run_case(number_of_stages, nx, output_filename=None):
"""
Run the parameter sweep tool on the LSRRO flowsheet, sweeping over feed
concentration from 5 to 250 kg/m^3 and water recovery from 30% to 90%.
Expand Down Expand Up @@ -49,9 +79,7 @@ def run_case(number_of_stages, nx, output_filename=None, quick_start=False):
sweep_params = {}
outputs = {}

m = lsrro._lsrro_presweep(
number_of_stages=number_of_stages, quick_start=quick_start
)
m = _lsrro_presweep(number_of_stages=number_of_stages)

# Sweep parameters ------------------------------------------------------------------------

Expand Down
4 changes: 1 addition & 3 deletions watertap/flowsheets/lsrro/tests/test_lssro_multi_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def test_against_multisweep(number_of_stages, tmp_path):
_this_file_path, "parameter_sweep_baselines", csv_file_name
)
with pytest.warns(UserWarning, match=r"Too few points to perform interpolation\."):
run_case(
number_of_stages, 2, output_filename=csv_test_file_name, quick_start=True
)
run_case(number_of_stages, 2, output_filename=csv_test_file_name)

baseline = pd.read_csv(csv_baseline_file_name).astype(float).T.to_dict()
test = pd.read_csv(csv_test_file_name).astype(float).T.to_dict()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ def test_against_paper_analysis(csv_file, row_index):
has_calculated_ro_pressure_drop=True,
A_value=5 / 3.6e11,
B_max=None,
number_of_RO_finite_elements=10,
quick_start=True
number_of_RO_finite_elements=10
)
except ValueError:
results = None
Expand Down
Loading