Skip to content

Commit

Permalink
added errors for greybox
Browse files Browse the repository at this point in the history
  • Loading branch information
avdudchenko committed Nov 22, 2024
1 parent c3498fc commit 5ce566e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions idaes/core/util/model_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,12 @@ def report_structural_issues(self, stream=None):

# Potential evaluation errors
# TODO: High Index?
if len(greybox_block_set(self._model)) != 0:
raise NotImplementedError(
"Model contains Greybox models, which are not supported by Diagnostics toolbox at the moment"
)
stats = _collect_model_statistics(self._model)

warnings, next_steps = self._collect_structural_warnings()
cautions = self._collect_structural_cautions()

Expand Down Expand Up @@ -1797,6 +1802,10 @@ def report_numerical_issues(self, stream=None):
"""
if stream is None:
stream = sys.stdout
if len(greybox_block_set(self._model)) != 0:
raise NotImplementedError(
"Model contains Greybox models, which are not supported by Diagnostics toolbox at the moment"
)

jac, nlp = get_jacobian(self._model, scaled=False)

Expand Down
14 changes: 7 additions & 7 deletions idaes/core/util/model_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def total_constraints_set(block):
def number_total_constraints(block):
"""
Method to return the total number of Constraint components in a model.
This will include constraints provided by Greybox models using
This will include number of constraints provided by Greybox models using
number_activated_greybox_equalities function.
Args:
Expand Down Expand Up @@ -425,7 +425,7 @@ def total_equalities_set(block):
def number_total_equalities(block):
"""
Method to return the total number of equality Constraint components in a
model. This will include number of activated equalities using number_activated_greybox_equalities function.
model. This will include number of activated equalities Greybox using number_activated_greybox_equalities function.
Args:
block : model to be studied
Expand Down Expand Up @@ -571,7 +571,7 @@ def deactivated_equalities_set(block):
def number_deactivated_equalities(block):
"""
Method to return the number of deactivated equality Constraint components
in a model. This include number of deactivated equality constraints in Greybox models.
in a model. This will include number of deactivated equality constraints in Greybox models.
Args:
block : model to be studied
Expand Down Expand Up @@ -1216,7 +1216,7 @@ def unfixed_greybox_variables(block):
block : model to be studied
Returns:
A ComponentSet of unfixed Var components which appear in Greybox models
A ComponentSet of all unfixed Var components which appear in Greybox models
"""
var_set = ComponentSet()
for var in greybox_variables(block):
Expand All @@ -1233,8 +1233,8 @@ def greybox_variables(block):
block : model to be studied
Returns:
A ComponentSet including all unfixed Var components which appear within
activated equality Constraints in block
A ComponentSet of all Var components which appear within
activated Greybox model blocks
"""
var_set = ComponentSet()
for grey_box in activated_greybox_block_set(block):
Expand Down Expand Up @@ -1346,7 +1346,7 @@ def number_unused_variables(block):
block : model to be studied
Returns:
Number of Var components which do not appear within any activagted
Number of Var components which do not appear within any activated
Constraints in block
"""
return len(unused_variables_set(block))
Expand Down

0 comments on commit 5ce566e

Please sign in to comment.