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

Poorly formulated constraint in MCAS model #1547

Open
andrewlee94 opened this issue Jan 2, 2025 · 0 comments
Open

Poorly formulated constraint in MCAS model #1547

andrewlee94 opened this issue Jan 2, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@andrewlee94
Copy link
Collaborator

Description

The MCAS property model has the following constraint formulation (line 1464):

def rule_mass_frac_phase_comp(b, p, j):
    return b.mass_frac_phase_comp[p, j] == b.flow_mass_phase_comp[p, j] / sum(
        b.flow_mass_phase_comp[p, j] for j in self.params.component_list
    )

This leads to a potential division by zero as flow goes to zero and thus would be better reformulated as:

def rule_mass_frac_phase_comp(b, p, j):
    return b.flow_mass_phase_comp[p, j] == b.mass_frac_phase_comp[p, j]  * sum(
        b.flow_mass_phase_comp[p, j] for j in self.params.component_list
    )

However, doing this results in issues with the scaling methods, primarily due to the transform_property_constraints function which assumes that all constraints are written in the form of property = function(). I suspect that this might have further reaching effects than just this.

Motivation

Generally, constraints should be formulated in ways to avoid potential singularities, such as avoiding divisions where possible (unless the denominator is a simple constant). Doing so helps avoid numerical issues during solving and will generally make models more robust (and often better scaled).

Possible Implementation

This issue effectively has two parts:

  1. Looking for poorly formulated constraints and rewriting them (relatively easy, especially with the diagnostics tools), and
  2. Updating the scaling routines to accommodate these changes (somewhat more effort, especially with the above mentioned transform_property_constraints function). However, given the current push to using the new Scaler classes this hopefully becomes much easier (or at least can be done at the same time).

Additional Context

No response

@andrewlee94 andrewlee94 added the enhancement New feature or request label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants