Skip to content

Commit

Permalink
Update scaling based on BSM2-P flowsheet testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusHolly committed Jan 16, 2025
1 parent 7681d4b commit 9744a93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
8 changes: 0 additions & 8 deletions watertap/unit_models/anaerobic_digester.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,6 @@ def constraint_scaling_routine(
overwrite=overwrite,
)

# Scale unit level constraints
if hasattr(model, "AD_retention_time"):
self.scale_constraint_by_nominal_value(
model.AD_retention_time[0],
scheme=ConstraintScalingScheme.inverseMaximum,
overwrite=overwrite,
)


@declare_process_block_class("AD")
class ADData(UnitModelBlockData):
Expand Down
14 changes: 4 additions & 10 deletions watertap/unit_models/tests/test_anaerobic_digester.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,7 @@ def test_constraint_scaling_routine(self, model):

sfx_unit = model.fs.unit.scaling_factor
assert isinstance(sfx_unit, Suffix)
assert len(sfx_unit) == 1
assert sfx_unit[model.fs.unit.AD_retention_time[0]] == pytest.approx(
5.3178178178e-7, rel=1e-8
)
assert len(sfx_unit) == 0

@pytest.mark.component
def test_scale_model(self, model):
Expand Down Expand Up @@ -960,10 +957,7 @@ def test_scale_model(self, model):

sfx_unit = model.fs.unit.scaling_factor
assert isinstance(sfx_unit, Suffix)
assert len(sfx_unit) == 1
assert sfx_unit[model.fs.unit.AD_retention_time[0]] == pytest.approx(
5.3178178178e-7, rel=1e-8
)
assert len(sfx_unit) == 0

# TODO: Remove test once iscale is deprecated
@pytest.mark.integration
Expand Down Expand Up @@ -1104,7 +1098,7 @@ def test_example_case_scaler_scaling_default(self):
sm = TransformationFactory("core.scale_model").create_using(m, rename=False)
jac, _ = get_jacobian(sm, scaled=False)
assert (jacobian_cond(jac=jac, scaled=False)) == pytest.approx(
2.428479487421e12, rel=1e-3
6.97139638e11, rel=1e-3
)

@pytest.mark.integration
Expand Down Expand Up @@ -1189,5 +1183,5 @@ def test_example_case_scaler_scaling(self):
sm = TransformationFactory("core.scale_model").create_using(m, rename=False)
jac, _ = get_jacobian(sm, scaled=False)
assert (jacobian_cond(jac=jac, scaled=False)) == pytest.approx(
2.27372477638e11, rel=1e-3
2.86956021256e11, rel=1e-3
)

0 comments on commit 9744a93

Please sign in to comment.