Skip to content

Commit

Permalink
fixed a typo error in init set_value; added init method for pressure_…
Browse files Browse the repository at this point in the history
…osm, conductivity and ionic strength; fixed an index issue for the conductivity var
  • Loading branch information
lbibl committed Apr 28, 2022
1 parent 3bb628d commit 25aa85b
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion watertap/property_models/ion_DSPMDE_prop_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,17 @@ def initialize(

# initialize vars caculated from state vars
for k in self.keys():
# Vars indexd by component (and phase)
for j in self[k].params.component_list:
if self[k].is_property_constructed("mass_frac_phase_comp"):
self[k].mass_frac_phase_comp["Liq", j].set_value(
self[k].flow_mass_phase_comp["Liq", j]
/ sum(
self[k].flow_mass_phase_comp["Liq", j]
for j in self[k].params.component_list
)
)
if self[k].is_property_constructed("conc_mass_phase_comp"):
self[k].conc_mass_phase_comp["Liq", j].set_value(
self[k].dens_mass_phase["Liq"]
* self[k].mass_frac_phase_comp["Liq", j]
Expand Down Expand Up @@ -513,13 +522,42 @@ def initialize(
for j in self[k].params.component_list
)
)
# Vars indexd by solute_set
for j in self[k].params.solute_set:
if self[k].is_property_constructed("molality_comp"):
self[k].molality_comp[j].set_value(
self[k].flow_mol_phase_comp["Liq", j]
/ self[k].flow_mol_phase_comp["Liq", "H2O"]
/ self[k].params.mw_comp["H2O"]
)
# Vars indexd not indexed or indexed only by phase
if self[k].is_property_constructed("ionic_strength"):
self[k].ionic_strength.set_value(
0.5
* sum(
self[k].charge_comp[j] ** 2 * self[k].molality_comp[j]
for j in self[k].params.ion_set | self[k].params.solute_set
)
)
if self[k].is_property_constructed("pressure_osm_phase"):
self[k].pressure_osm_phase["Liq"].set_value(
sum(
self[k].conc_mol_phase_comp["Liq", j]
for j in self[k].params.ion_set | self[k].params.solute_set
)
* Constants.gas_constant
* self[k].temperature
)
if self[k].is_property_constructed("electrical_conductivity_phase"):
self[k].electrical_conductivity_phase["Liq"].set_value(
sum(
Constants.faraday_constant
* abs(self[k].charge_comp[j])
* self[k].electrical_mobility_comp[j]
* self[k].conc_mol_phase_comp["Liq", j]
for j in self[k].params.ion_set | self[k].params.solute_set
)
)

# Check when the state vars are fixed already result in dof 0
for k in self.keys():
Expand Down Expand Up @@ -1077,7 +1115,7 @@ def rule_electrical_conductivity_phase(b):
* abs(b.charge_comp[j])
* b.electrical_mobility_comp[j]
* b.conc_mol_phase_comp["Liq", j]
for j in self.params.ion_set
for j in self.params.ion_set | self.params.solute_set
) # maybe revisit for other emprical calculation or non-ideal situation

self.eq_electrical_conductivity_phase = Constraint(
Expand Down

0 comments on commit 25aa85b

Please sign in to comment.