Skip to content

Commit

Permalink
added initial guess arguments for heating and cooling step times
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Noring committed Sep 21, 2023
1 parent 74ad787 commit 234ab3e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,9 @@ def _add_general_parameters(self):
units=units.Pa * units.s,
doc="Gas phase viscosity",
)
self.particle_sphericity = Param(initialize=1, units=units.dimensionless)
self.particle_sphericity = Param(
initialize=1, units=units.dimensionless, doc="Particle sphericity"
)
self.bed_voidage_mf = Param(
initialize=0.5,
units=units.dimensionless,
Expand Down
16 changes: 10 additions & 6 deletions idaes/models_extra/temperature_swing_adsorption/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def initialize(
json_file: str = None,
output_level=None,
exclude_unused_vars: bool = True,
heating_time_guess=1000,
cooling_time_guess=500,
):

if not exclude_unused_vars:
Expand All @@ -69,7 +71,10 @@ def initialize(
"to True to avoid raising an InitializationError."
)

super(FixedBedTSA0DInitializer, self).initialize(
self.heating_time_guess = heating_time_guess
self.cooling_time_guess = cooling_time_guess

super().initialize(
model=model,
initial_guesses=initial_guesses,
json_file=json_file,
Expand Down Expand Up @@ -106,7 +111,6 @@ def initialization_routine(
self.opt = get_solver(self.config.solver, self.config.solver_options)
else:
self.opt = self.config.solver
print(self.opt.options)

# initialization of fixed bed TSA model unit
init_log.info("Starting fixed bed TSA initialization")
Expand All @@ -131,14 +135,14 @@ def initialization_routine(

# deactivate final condition constraint and fix time
blk.heating.fc_temperature_eq.deactivate()
blk.heating.time.fix(1e3 * units.s)
blk.heating.time.fix(self.heating_time_guess * units.s)

# check degrees of freedom and solve
if degrees_of_freedom(blk.heating) == 0:
self._false_position_method(
blk,
cycle_step=blk.heating,
t_guess=1e3,
t_guess=self.heating_time_guess,
)
else:
raise InitializationError(
Expand Down Expand Up @@ -177,14 +181,14 @@ def initialization_routine(

# deactivate final condition constraint and fix time
blk.cooling.fc_temperature_eq.deactivate()
blk.cooling.time.fix(500 * units.s)
blk.cooling.time.fix(self.cooling_time_guess * units.s)

# check degrees of freedom and solve
if degrees_of_freedom(blk.cooling) == 0:
self._false_position_method(
blk,
cycle_step=blk.cooling,
t_guess=500,
t_guess=self.cooling_time_guess,
)
else:
raise InitializationError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ def test_units(self, model):
@pytest.mark.component
def test_initialize(self, model):
initializer = FixedBedTSA0DInitializer()
initializer.initialize(model.fs.unit)

initializer.initialize(
model.fs.unit, heating_time_guess=70000, cooling_time_guess=110000
)
assert initializer.summary[model.fs.unit]["status"] == InitializationStatus.Ok

@pytest.mark.solver
Expand Down Expand Up @@ -231,8 +232,9 @@ def test_units(self, model):
@pytest.mark.component
def test_initialize(self, model):
initializer = FixedBedTSA0DInitializer()
initializer.initialize(model.fs.unit)

initializer.initialize(
model.fs.unit, heating_time_guess=2000, cooling_time_guess=900
)
assert initializer.summary[model.fs.unit]["status"] == InitializationStatus.Ok

@pytest.mark.solver
Expand Down Expand Up @@ -341,8 +343,9 @@ def test_dof(self, model):
@pytest.mark.component
def test_initialize(self, model):
initializer = FixedBedTSA0DInitializer()
initializer.initialize(model.fs.unit)

initializer.initialize(
model.fs.unit, heating_time_guess=700, cooling_time_guess=700
)
assert initializer.summary[model.fs.unit]["status"] == InitializationStatus.Ok

@pytest.mark.solver
Expand Down

0 comments on commit 234ab3e

Please sign in to comment.