Skip to content

Commit

Permalink
tweaking initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bknueven committed Nov 15, 2022
1 parent f59f778 commit e015406
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion watertap/core/membrane_channel_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def _get_state_args_interface(self, initialize_guess, prop_in, prop_out):
if self._flow_direction == FlowDirection.forward:
initialize_guess["cp_modulus"] = 1.1
else:
initialize_guess["cp_modulus"] = 0.9
initialize_guess["cp_modulus"] = 0.5
else:
initialize_guess["cp_modulus"] = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,23 +568,21 @@ def initialize_build(
# Create solver
opt = get_solver(solver, optarg)

# Solve unit *without* flux equation
self.eq_flux_mass.deactivate()
# Solve unit
with idaeslog.solver_log(solve_log, idaeslog.DEBUG) as slc:
res = opt.solve(self, tee=slc.tee)
# occasionally it might be worth retrying a solve
if not check_optimal_termination(res):
init_log.warning(
f"Trouble solving unit model {self.name}, trying one more time"
)
res = opt.solve(self, tee=slc.tee)
init_log.info_high(f"Initialization Step 2 {idaeslog.condition(res)}")

# Solve unit *with* flux equation
self.eq_flux_mass.activate()
with idaeslog.solver_log(solve_log, idaeslog.DEBUG) as slc:
res = opt.solve(self, tee=slc.tee)
init_log.info_high(f"Initialization Step 3 {idaeslog.condition(res)}")

# release inlet state, in case this error is caught
self.permeate_side.release_state(permeate_flags, outlvl)
self.feed_side.release_state(feed_flags, outlvl)
self.eq_permeate_isothermal.activate()
print("DOF after release state", degrees_of_freedom(self))

init_log.info(f"Initialization Complete: {idaeslog.condition(res)}")

Expand Down

0 comments on commit e015406

Please sign in to comment.