Skip to content

Commit

Permalink
OARO SKK config option and tests (watertap-org#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharybinger authored Dec 9, 2023
1 parent 06149c9 commit da3f61c
Show file tree
Hide file tree
Showing 3 changed files with 849 additions and 27 deletions.
127 changes: 100 additions & 27 deletions watertap/unit_models/osmotically_assisted_reverse_osmosis_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from watertap.core.membrane_channel_base import (
validate_membrane_config_args,
ConcentrationPolarizationType,
TransportModel,
)

from watertap.core import InitializationMixin
Expand Down Expand Up @@ -386,6 +387,21 @@ def _add_flux_balance(self):
doc="Pure water density",
)

if self.config.transport_model == TransportModel.SKK:
self.reflect_coeff = Var(
initialize=0.9,
domain=NonNegativeReals,
units=pyunits.dimensionless,
doc="Reflection coefficient of the membrane",
)

self.alpha = Var(
initialize=1e8,
domain=NonNegativeReals,
units=units_meta("time") * units_meta("length") ** -1,
doc="Alpha coefficient of the membrane",
)

self.flux_mass_phase_comp = Var(
self.flowsheet().config.time,
self.difference_elements,
Expand All @@ -399,34 +415,84 @@ def _add_flux_balance(self):
doc="Mass flux across membrane at inlet and outlet",
)

@self.Constraint(
self.flowsheet().config.time,
self.difference_elements,
self.config.property_package.phase_list,
self.config.property_package.component_list,
doc="Solvent and solute mass flux",
)
def eq_flux_mass(b, t, x, p, j):
prop_feed = b.feed_side.properties[t, x]
prop_perm = b.permeate_side.properties[t, x]
interface_feed = b.feed_side.properties_interface[t, x]
interface_perm = b.permeate_side.properties_interface[t, x]
comp = self.config.property_package.get_component(j)
if comp.is_solvent():
return b.flux_mass_phase_comp[t, x, p, j] == b.A_comp[
t, j
] * b.dens_solvent * (
(prop_feed.pressure - prop_perm.pressure)
- (
interface_feed.pressure_osm_phase[p]
- interface_perm.pressure_osm_phase[p]
if self.config.transport_model == TransportModel.SD:

@self.Constraint(
self.flowsheet().config.time,
self.difference_elements,
self.config.property_package.phase_list,
self.config.property_package.component_list,
doc="Solvent and solute mass flux",
)
def eq_flux_mass(b, t, x, p, j):
prop_feed = b.feed_side.properties[t, x]
prop_perm = b.permeate_side.properties[t, x]
interface_feed = b.feed_side.properties_interface[t, x]
interface_perm = b.permeate_side.properties_interface[t, x]
comp = self.config.property_package.get_component(j)
if comp.is_solvent():
return b.flux_mass_phase_comp[t, x, p, j] == b.A_comp[
t, j
] * b.dens_solvent * (
(prop_feed.pressure - prop_perm.pressure)
- (
interface_feed.pressure_osm_phase[p]
- interface_perm.pressure_osm_phase[p]
)
)
elif comp.is_solute():
return b.flux_mass_phase_comp[t, x, p, j] == b.B_comp[t, j] * (
interface_feed.conc_mass_phase_comp[p, j]
- interface_perm.conc_mass_phase_comp[p, j]
)

elif self.config.transport_model == TransportModel.SKK:

@self.Constraint(
self.flowsheet().config.time, solute_set, doc="SKK alpha coeff."
)
def eq_alpha(b, t, j):
return b.alpha == (1 - b.reflect_coeff) / b.B_comp[t, j]

@self.Constraint(
self.flowsheet().config.time,
self.difference_elements,
self.config.property_package.phase_list,
self.config.property_package.component_list,
doc="Solvent and solute mass flux using SKK model",
)
def eq_flux_mass(b, t, x, p, j):
prop_feed = b.feed_side.properties[t, x]
prop_perm = b.permeate_side.properties[t, x]
interface_feed = b.feed_side.properties_interface[t, x]
interface_perm = b.permeate_side.properties_interface[t, x]
comp = self.config.property_package.get_component(j)
if comp.is_solvent():
return b.flux_mass_phase_comp[t, x, p, j] == b.A_comp[
t, j
] * b.dens_solvent * (
(prop_feed.pressure - prop_perm.pressure)
- b.reflect_coeff
* (
interface_feed.pressure_osm_phase[p]
- interface_perm.pressure_osm_phase[p]
)
)
elif comp.is_solute():
return b.flux_mass_phase_comp[t, x, p, j] == b.B_comp[t, j] * (
interface_feed.conc_mass_phase_comp[p, j]
- interface_perm.conc_mass_phase_comp[p, j]
) + (1 - b.reflect_coeff) * (
(
(b.flux_mass_phase_comp[t, x, p, "H2O"] / b.dens_solvent)
* interface_feed.conc_mass_phase_comp[p, j]
)
)
)
elif comp.is_solute():
return b.flux_mass_phase_comp[t, x, p, j] == b.B_comp[t, j] * (
interface_feed.conc_mass_phase_comp[p, j]
- interface_perm.conc_mass_phase_comp[p, j]
)

else:
raise ConfigurationError(
"Unsupported transport model: {}".format(self.config.transport_model)
)

@self.Expression(
self.flowsheet().config.time,
Expand Down Expand Up @@ -811,6 +877,13 @@ def calculate_scaling_factors(self):
if iscale.get_scaling_factor(self.recovery_vol_phase) is None:
iscale.set_scaling_factor(self.recovery_vol_phase, 1)

if self.config.transport_model == TransportModel.SKK:
if iscale.get_scaling_factor(self.alpha) is None:
iscale.set_scaling_factor(self.alpha, 1e-8)

if iscale.get_scaling_factor(self.reflect_coeff) is None:
iscale.set_scaling_factor(self.reflect_coeff, 1)

for (t, p, j), v in self.recovery_mass_phase_comp.items():
if j in self.config.property_package.solvent_set:
sf = 1
Expand Down
Loading

0 comments on commit da3f61c

Please sign in to comment.