Skip to content

Add method for determining degrees of freedom on a unit model-by-unit model basis #1722

@dallan-keylogic

Description

@dallan-keylogic

Frequently, we want to determine how many degrees of freedom a unit model has. This causes a problem, however, because there are actually three numbers that we might be concerned with:

  1. The total number of degrees of freedom (what we get now when we call degrees_of_freedom(unit)).
  2. The number of degrees of freedom in a unit model when the variables on the inlet ports are fixed.
  3. The number of degrees of freedom in a unit model when all initialization states are fixed (which may include variables like heat_duty on heaters, etc.).

Additionally, it might be useful to find overconstrained and underconstrained sets in both cases (2) and (3).

Presently, the fix_initialization_states method on unit models lives in the space between (2) and (3). The default method implemented on the UnitModelBlock class just fixes all variables on any ports with "inlet" in their names:

        for p in self.component_objects(Port, descend_into=False):
            if "inlet" in p.name:
                # Assume name is correct and fix all variables inside
                p.fix()

For units like the Mixer, the method is overridden so that the state variables on all the (user-named) inlet ports (which may not have "inlet" in their name) are fixed. However, some models (typically StateBlocks in property models) fix additional variables and deactivate additional constraints. Also, variables and constraints are frequently deactivated and reactivated as part of the main initialization method.

I think the best solution is probably to have the model designer register a ComponentSet named inlet_ports on the unit model. That handles cases like the Mixer, and we can look up ports with inlet in their names as a fallback method. I don't want fix_initialization_states to be performing double duty. That requires going back to our unit models and adding an additional attribute, but that shouldn't take long.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions