Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nf scaling. #1145

Merged
merged 41 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
14b0274
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 22, 2023
e8d8df2
Update nf_with_bypass.py
avdudchenko Sep 22, 2023
6339842
Relaxed hardness constraint in jupyer notebook, and fixed test
avdudchenko Sep 22, 2023
498cda2
Fixing black formating?
avdudchenko Sep 22, 2023
7dbe1ca
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 23, 2023
1ea8928
Merge branch 'main' into nf_scailing_update
avdudchenko Sep 23, 2023
9e2615f
update scaiing
avdudchenko Sep 23, 2023
a8ec4c7
Merge branch 'nf_scailing_update' of https://github.com/avdudchenko/w…
avdudchenko Sep 23, 2023
c8f8315
updated scailing/major patch
avdudchenko Sep 23, 2023
50d5de4
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 24, 2023
17e4d18
fixed formating and removed prints
avdudchenko Sep 24, 2023
54fefd1
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 24, 2023
2c4d4aa
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 24, 2023
740c772
Update watertap/unit_models/nanofiltration_DSPMDE_0D.py
adam-a-a Sep 26, 2023
5e8f95d
Update watertap/unit_models/tests/test_nanofiltration_DSPMDE_0D.py
adam-a-a Sep 26, 2023
be85e4f
Merge remote-tracking branch 'upstream/main' into nf_scailing_update
avdudchenko Sep 26, 2023
6cc035b
updarted partioning scailign
avdudchenko Sep 27, 2023
17291e3
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 27, 2023
cd7e6e7
Update test_nf.py
avdudchenko Sep 27, 2023
608af7a
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 27, 2023
fbc8617
Update nawi_spring_meeting2023.ipynb
avdudchenko Sep 27, 2023
c647ea9
Update nawi_spring_meeting2023.ipynb
avdudchenko Sep 27, 2023
1b599d1
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 27, 2023
02f00db
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 27, 2023
281a992
Update nawi_spring_meeting2023.ipynb
avdudchenko Sep 27, 2023
1644dfc
Update nawi_spring_meeting2023.ipynb
avdudchenko Sep 27, 2023
5ba4974
removed duplicate calc scailign
avdudchenko Sep 27, 2023
6ea0e3e
Merge branch 'main' into nf_scailing_update
avdudchenko Sep 29, 2023
ce6f865
Update watertap/unit_models/nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
7857c71
Update watertap/unit_models/nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
8771da9
Update watertap/unit_models/nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
18c5574
Update watertap/unit_models/nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
4b6ebae
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
f89e036
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
b1fea16
Revert "Update multicomp_aq_sol_prop_pack.py"
avdudchenko Sep 29, 2023
0e22f60
Update nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
5918800
Update nawi_spring_meeting2023.ipynb
avdudchenko Sep 29, 2023
3be712a
Update watertap/unit_models/nanofiltration_DSPMDE_0D.py
avdudchenko Sep 29, 2023
ee46fb6
Merge branch 'main' into nf_scailing_update
avdudchenko Sep 29, 2023
632d997
Apply suggestions from code review
adam-a-a Oct 2, 2023
9df6623
pylint<3 (for now)
bknueven Oct 3, 2023
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
2 changes: 1 addition & 1 deletion tutorials/nawi_spring_meeting2023.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@
" units=pyunits.mg / pyunits.L,\n",
" doc=\"Maximum total hardness as CaCO3\",\n",
" )\n",
"m.fs.max_hardness.fix(0.25*value(m.fs.feed.properties[0].total_hardness))\n",
"m.fs.max_hardness.fix(0.5*value(m.fs.feed.properties[0].total_hardness))\n",
"\n",
"m.fs.max_hardness_constraint = Constraint(expr=m.fs.unit.mixed_permeate[0].total_hardness \n",
" <= m.fs.max_hardness)\n",
Expand Down
1 change: 0 additions & 1 deletion watertap/examples/flowsheets/nf_dspmde/nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ def unfix_opt_vars(m):
m.fs.NF.nfUnit.velocity.unfix()
m.fs.NF.nfUnit.velocity.setub(0.25)
m.fs.product.max_hardness.fix(500)
m.fs.NF.nfUnit.recovery_vol_phase.fix(0.90)
Copy link
Contributor

@adam-a-a adam-a-a Sep 26, 2023

Choose a reason for hiding this comment

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

Does this still break if you fix to 90% after scale refinement (considering all the latest changes with all checks passing)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I still would prefer fixing recovery rate here simply for the sake of avoiding future test failures due to recov rate riding up to the upper bound and subtle variations that could occur from that, but going to approve this anyway and leave the choice to you


# Touch total_hardness (on-demand property) at feed and disposal for reporting
m.fs.feed.properties[0].total_hardness
Expand Down
10 changes: 5 additions & 5 deletions watertap/examples/flowsheets/nf_dspmde/tests/test_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
def test_main():
m = main()
test_dict = {
"lcow": [m.fs.costing.LCOW, 0.144583],
"pressure": [m.fs.NF.pump.outlet.pressure[0] * 1e-5, 5.372779],
"area": [m.fs.NF.nfUnit.area, 405.66782957],
"lcow": [m.fs.costing.LCOW, 0.141678],
"pressure": [m.fs.NF.pump.outlet.pressure[0] * 1e-5, 5.21856],
"area": [m.fs.NF.nfUnit.area, 444.423],
"recovery": [
m.fs.NF.nfUnit.recovery_vol_phase[0.0, "Liq"] * 100,
90,
94.64,
Copy link
Contributor

Choose a reason for hiding this comment

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

My only concern about letting recovery be "optimized" is that it'll drive up to the upper bound and at least previously, the test solution will deviate by a little every now and then with new changes in future PRs. It may be the case that the latest changes to scaling have remedied the issue completely, but it might also be the case that we'll see future tests fail because the solution converged to another recovery value close to 95% upper bound but outside of the tolerance of the regression test.

],
}
for (model_result, testval) in test_dict.values():
for model_result, testval in test_dict.values():
assert pytest.approx(testval, rel=1e-3) == value(model_result)
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
def test_main():
m = main()
test_dict = {
"lcow": [m.fs.costing.LCOW, 0.13728251],
"pressure": [m.fs.NF.pump.outlet.pressure[0] * 1e-5, 4.53838],
"area": [m.fs.NF.nfUnit.area, 414.08584896],
"lcow": [m.fs.costing.LCOW, 0.1354909],
"pressure": [m.fs.NF.pump.outlet.pressure[0] * 1e-5, 4.60503],
"area": [m.fs.NF.nfUnit.area, 426.6869],
"recovery": [
m.fs.NF.nfUnit.recovery_vol_phase[0.0, "Liq"] * 100,
90,
92.49,
],
"bypass": [
m.fs.by_pass_splitter.split_fraction[0, "bypass"] * 100,
10.94636,
10.185489,
],
}
for model_result, testval in test_dict.values():
Expand Down
6 changes: 1 addition & 5 deletions watertap/property_models/multicomp_aq_sol_prop_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ def build(self):
)

if self.config.diffus_calculation == DiffusivityCalculation.none:

self.diffus_phase_comp = Var(
self.phase_list,
self.solute_set,
Expand Down Expand Up @@ -664,7 +663,6 @@ def initialize(

# initialize vars calculated from state vars
for k in self.keys():

# Vars indexed by phase and component_list
for j in self[k].params.component_list:
if self.params.config.material_flow_basis == MaterialFlowBasis.molar:
Expand Down Expand Up @@ -1084,6 +1082,7 @@ def _dens_mass_phase(self):
units=pyunits.kg * pyunits.m**-3,
doc="Mass density",
)

# TODO: reconsider this approach for solution density based on arbitrary solute_list
def rule_dens_mass_phase(b, p):
if b.params.config.density_calculation == DensityCalculation.constant:
Expand Down Expand Up @@ -1233,7 +1232,6 @@ def _conc_equiv_phase_comp(self):
)

def rule_conc_equiv_phase_comp(b, p, j):

return b.conc_equiv_phase_comp[p, j] == b.conc_mol_phase_comp[p, j] * abs(
b.params.charge_comp[j]
)
Expand Down Expand Up @@ -1375,14 +1373,12 @@ def rule_diffus_phase_comp(b, p, j):
self.params.config.diffus_calculation
== DiffusivityCalculation.HaydukLaudie
):

if j not in molar_volume_data_indices:
b.diffus_phase_comp[p, j].fix(
self.params.config.diffusivity_data[p, j]
)
return Constraint.Skip
else:

diffus_coeff_inv_units = pyunits.s * pyunits.m**-2
visc_solvent_inv_units = pyunits.cP**-1
molar_volume_inv_units = pyunits.mol * pyunits.cm**-3
Expand Down
Loading
Loading