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

Solve ASM2D Flowsheet without bound_push and autoscale function #1133

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""

# Some more information about this module
__author__ = "Alejandro Garciadiego, Andrew Lee"
__author__ = "Alejandro Garciadiego, Andrew Lee, Adam Atia"

import pyomo.environ as pyo
from pyomo.network import Arc, SequentialDecomposition
Expand Down Expand Up @@ -56,15 +56,6 @@
_log = idaeslog.getLogger(__name__)


def automate_rescale_variables(m):
for var, sv in iscale.badly_scaled_var_generator(m):
if iscale.get_scaling_factor(var) is None:
continue
sf = iscale.get_scaling_factor(var)
iscale.set_scaling_factor(var, sf / sv)
iscale.calculate_scaling_factors(m)


def build_flowsheet():
m = pyo.ConcreteModel()

Expand Down Expand Up @@ -389,10 +380,10 @@ def scale_variables(m):
seq.set_guesses_for(m.fs.R3.inlet, tear_guesses)

def function(unit):
unit.initialize(outlvl=idaeslog.INFO, optarg={"bound_push": 1e-8})
badly_scaled_vars = list(iscale.badly_scaled_var_generator(unit))
if len(badly_scaled_vars) > 0:
automate_rescale_variables(unit)
unit.initialize(outlvl=idaeslog.INFO)
# badly_scaled_vars = list(iscale.badly_scaled_var_generator(unit))
# if len(badly_scaled_vars) > 0:
# automate_rescale_variables(unit)

seq.run(m, function)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_results(self, model):
assert value(model.fs.Treated.temperature[0]) == pytest.approx(298.15, rel=1e-4)
assert value(model.fs.Treated.pressure[0]) == pytest.approx(101325, rel=1e-4)
assert value(model.fs.Treated.conc_mass_comp[0, "S_A"]) == pytest.approx(
5.4560e-5, rel=1e-4
5.4560e-5, rel=1e-3
)
assert value(model.fs.Treated.conc_mass_comp[0, "S_F"]) == pytest.approx(
2.5736e-3, rel=1e-2
Expand Down
Loading