Skip to content
Merged
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: 33 additions & 1 deletion watertap/flowsheets/lsrro/lsrro.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
)
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 @@ -1817,6 +1816,39 @@ 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,
Comment on lines +1831 to +1833
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this really should be updated to match what was specified in run_lsrro_case

)
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,
Comment on lines +1844 to +1846
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also make sure this aligns with what user provided up front

)

return m


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


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):
def run_case(number_of_stages, nx, output_filename=None, quick_start=False):
"""
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 @@ -79,7 +49,9 @@ def run_case(number_of_stages, nx, output_filename=None):
sweep_params = {}
outputs = {}

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

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

Expand Down
4 changes: 3 additions & 1 deletion watertap/flowsheets/lsrro/tests/test_lssro_multi_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ 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)
run_case(
number_of_stages, 2, output_filename=csv_test_file_name, quick_start=True
)

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,7 +95,8 @@ 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
number_of_RO_finite_elements=10,
quick_start=True
)
except ValueError:
results = None
Expand Down
Loading