Skip to content

Commit

Permalink
Reformatted with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerpolley committed Oct 31, 2024
1 parent ff9a777 commit 603c4b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
19 changes: 7 additions & 12 deletions idaes/models/unit_models/stream_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ def build(self):
self._get_indexing_sets()

self.inlet_block = self.config.property_package.build_state_block(
self.flowsheet().time, doc="Material properties at inlet", **tmp_dict
self.flowsheet().time, doc="Material properties at inlet", **tmp_dict
)
self.outlet_block = Block()
self.multiplier = Var(
initialize=1,
domain=PositiveReals,
units=pyunits.dimensionless,
doc="Factor by which to scale dimensionless streams"
doc="Factor by which to scale dimensionless streams",
)
self.add_inlet_port(name="inlet", block=self.inlet_block)
self.outlet = Port(doc="Outlet port")
Expand All @@ -165,15 +165,11 @@ def rule_no_scale_var(b, *args, var=None):
for var_name in self.inlet.vars.keys():
var = getattr(self.inlet, var_name)
if "flow" in var_name:
rule=partial(rule_scale_var, var=var)
rule = partial(rule_scale_var, var=var)
else:
rule=partial(rule_no_scale_var, var=var)
rule = partial(rule_no_scale_var, var=var)
self.outlet_block.add_component(
var_name,
VarLikeExpression(
var.index_set(),
rule=rule
)
var_name, VarLikeExpression(var.index_set(), rule=rule)
)
expr = getattr(self.outlet_block, var_name)
self.outlet.add(expr, var_name)
Expand Down Expand Up @@ -250,11 +246,10 @@ def calculate_scaling_factors(self):

# Need to pass on scaling factors from the property block to the outlet
# VarLikeExpressions so arcs get scaled right
scale = 1/self.multiplier.value
scale = 1 / self.multiplier.value
for var_name in self.inlet.vars.keys():
var = getattr(self.inlet, var_name)
outlet_expr = getattr(self.outlet, var_name)
for key, subvar in var.items():
sf = iscale.get_scaling_factor(subvar, default=1, warning=True)
iscale.set_scaling_factor(outlet_expr[key],scale*sf)

iscale.set_scaling_factor(outlet_expr[key], scale * sf)
3 changes: 2 additions & 1 deletion idaes/models/unit_models/tests/test_stream_scaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def test_initialize(self, sapon):

# No solve or numerical tests, as StreamScaler block has nothing to solve


class TestBTX(object):
@pytest.fixture(scope="class")
def btx(self):
Expand Down Expand Up @@ -372,4 +373,4 @@ def test_get_stream_table_contents(self, iapws):
def test_initialize(self, iapws):
initialization_tester(iapws)

# No solve or numerical tests as there is nothing to solve for
# No solve or numerical tests as there is nothing to solve for

0 comments on commit 603c4b5

Please sign in to comment.