Skip to content

Conversation

@dallan-keylogic
Copy link
Contributor

@dallan-keylogic dallan-keylogic commented Sep 3, 2025

Fixes

  • Modular properties initializer now correctly uses the passed log level
  • Updated initialization to ensure we have 0 degrees of freedom for FpcTP initialization (addressing Error in initialization of control volume out properties when initializing a unit model for the FpcTP state definition when using modular properties. #1646)
  • Updated initialization to ensure that the postcheck doesn't raise an error because the VLE constraints are not satisfied
  • VLE in Ideal equation of state now uses equilibrium temperature rather than actual temperature
  • RPP5 now responds to configuration about whether or not to include enthalpy of formation in enthalpy calculations
  • Made a change to InitializerBase to decrease the scope of try/except block (hasattr is implemented internally with a try/except block)
  • Removed legacy CubicEoS

Enhancements

  • Log fugacity in Ideal now uses log-form variables for mole fraction
  • Antoine equation now returns log expression directly for RPP5

Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

Comment on lines -278 to 283
"""
try:
if hasattr(model, "fix_initialization_states"):
model.fix_initialization_states()
except AttributeError:
else:
_log.info_high(
f"Model {model.name} does not have a fix_initialization_states method - attempting to continue."
)
Copy link
Contributor Author

@dallan-keylogic dallan-keylogic Sep 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change revealed that there was an error in the legacy Cubic EoS initialization---the fix_initialization_states method was trying to deactivate sum_mol_frac_out, but that constraint doesn't appear to exist (at least, not with that name), which was raising an AttributeError that was swallowed in the try/except block. That illustrates why this change was necessary.

Since we said that we were going to remove the legacy CubicEoS in the May release, the straightforward solution is to just remove it now.

@dallan-keylogic dallan-keylogic changed the title Modular properties fixes Modular properties fixes and enhancements Sep 3, 2025
Comment on lines 106 to 112
if not log:
try:
mthd = c_arg.return_expression
except AttributeError:
mthd = c_arg
else:
mthd = c_arg.return_log_expression
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to require the user to add a return_log_expression function to their implementation of Antoine's law?

@dallan-keylogic dallan-keylogic added the CI:run-integration triggers_workflow: Integration label Sep 3, 2025
@dallan-keylogic dallan-keylogic self-assigned this Sep 3, 2025
@idaes-build idaes-build removed the CI:run-integration triggers_workflow: Integration label Sep 3, 2025
@codecov
Copy link

codecov bot commented Sep 3, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.06%. Comparing base (d96090c) to head (d396282).
⚠️ Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
.../models/properties/modular_properties/eos/ideal.py 74.57% 8 Missing and 7 partials ⚠️
...erties/modular_properties/base/generic_property.py 68.42% 3 Missing and 3 partials ⚠️
.../models/properties/modular_properties/pure/RPP5.py 84.61% 1 Missing and 1 partial ⚠️
...rties/modular_properties/phase_equil/bubble_dew.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1656      +/-   ##
==========================================
+ Coverage   76.95%   77.06%   +0.10%     
==========================================
  Files         397      395       -2     
  Lines       63580    62761     -819     
  Branches    10367    10233     -134     
==========================================
- Hits        48929    48366     -563     
+ Misses      12213    11985     -228     
+ Partials     2438     2410      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dallan-keylogic
Copy link
Contributor Author

The test failure in Examples requires a fix to be pushed to the Examples repo.

scaler_block = [blk for blk in model.values()][0]

if hasattr(scaler_block, "inherent_equilibrium_constraint") and (
not scaler_block.params._electrolyte # TODO why do we need this check?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is TODO necessary? I beleive it creates confusion on who we are talking to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like me to remove the TODO or the entire comment?

or scaler_block.params.config.state_components == StateIndex.true
):
init_log.debug(
"Cannot converge inherent reaction constraints "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning may be confusing. When we say "they need to be solved at the control volume level," the user may not know if that is something they must now do.

or "mole_frac_phase_comp" in k.define_state_vars()
):
k.equilibrium_constraint.deactivate()
# TODO Inherent reactions with a true component basis will fail here too
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not understant TODO message

for idx in self.fug_phase_comp:
sf_x = iscale.get_scaling_factor(
self.mole_frac_phase_comp[idx],
default=1e3, # I'd prefer 10, but this is consistent with existing scaling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "I prefer" comment or change wording

def log_fug_phase_comp_eq(b, p, j, pp):
if (p, j) not in b.phase_component_set:
raise KeyError(f"Component {j} is not present in phase {p}.")
# TODO does allowing a calculation with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change wording on TODO message

cobj = b.params.get_component(j)
if b.params.has_inherent_reactions:
raise PropertyNotSupportedError(
"Bubble/dew calculations for systems with inherent "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only a question. What would be required to support this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends. If all we want to do is have any temperature at which we can solve the VLE equations for SmoothVLE, then we can probably just use the current system composition in the bubble/dew calculations. However, if we want temperature_bubble and temperature_dew to be the system's actual bubble and dew temperatures, we would need to write inherent reaction equilibrium equations not just at the system's temperature, but also at the bubble/dew temperature. That adds a lot of complexity and overhead, so I'd rather punt on the issue until we have a specific problem we're trying to solve.

We don't have this issue with the CubicComplementarityVLE because the equilibrium temperature there is not directly related to the bubble/dew temperatures.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, we're not going to be using CubicComplementarityVLE with the Ideal EoS anyway.

Copy link
Contributor

@agarciadiego agarciadiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of comments about commented code

@ksbeattie ksbeattie added the Priority:High High Priority Issue or PR label Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority:High High Priority Issue or PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants