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

PETSc Tweaks #1235

Merged
merged 20 commits into from
Aug 29, 2023
Merged

PETSc Tweaks #1235

merged 20 commits into from
Aug 29, 2023

Conversation

dallan-keylogic
Copy link
Contributor

Changes proposed in this PR:

-Only include active blocks when constraints/variables are collected for PETSc solve
-Rename snes_solver option to initial_solver because the point of the option is to permit use of initial solvers besides snes
-Add symbolic solver labels to initial condition problem
-Get rid of unused list fix_derivs

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.

@@ -420,8 +420,8 @@ def petsc_dae_by_time_element(
initial_variables=None,
detect_initial=True,
skip_initial=False,
snes_solver="petsc_snes",
snes_options=None,
initial_solver="petsc_snes",
Copy link
Member

Choose a reason for hiding this comment

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

Seeing as we are pushing to get backward compatibility tests into place, this look like a place where we are going to need backward compatibility options and warnings. I.e. we need to keep the old options around, and have them raise deprecation warnings if they are used before sending the value to the new argument (and raise an exception if both old and new are provided).

Copy link
Contributor Author

@dallan-keylogic dallan-keylogic Aug 3, 2023

Choose a reason for hiding this comment

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

I was hoping that this feature being around for only a month and not making it into a major release would prevent that from being necessary. Perhaps not, however.

Edit: snes_solver has been around only for a month. However, snes_options has been around longer.

Copy link
Member

Choose a reason for hiding this comment

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

If it is that new then we are probably OK, but we need to double check that is the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got the deprecation logged for snes_options. Ready for a new review.

@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (b01bc20) 76.71% compared to head (51a4391) 76.71%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1235   +/-   ##
=======================================
  Coverage   76.71%   76.71%           
=======================================
  Files         382      382           
  Lines       61182    61188    +6     
  Branches    11289    11291    +2     
=======================================
+ Hits        46935    46940    +5     
- Misses      11814    11817    +3     
+ Partials     2433     2431    -2     
Files Changed Coverage Δ
idaes/core/solvers/petsc.py 85.65% <100.00%> (+0.65%) ⬆️

... and 1 file with indirect coverage changes

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

@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Aug 3, 2023
Copy link
Member

@eslickj eslickj left a comment

Choose a reason for hiding this comment

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

I wanted to make this change when I added the snes_solver option, since it's not necessarily an SNES solver anymore, but I didn't want to break anything. Once @andrewlee94 gets his deprecation warning, I'm good with this.

Copy link
Member

@andrewlee94 andrewlee94 left a comment

Choose a reason for hiding this comment

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

Looking good - just a couple of minor comments to avoid some edge cases and be more inline with other deprecations.

regular_vars, time_vars = flatten_dae_components(m, time, pyo.Var)
regular_cons, time_cons = flatten_dae_components(m, time, pyo.Constraint)
if snes_options is not None:
logger = idaeslog.getIdaesLogger("idaes")
Copy link
Member

@andrewlee94 andrewlee94 Aug 8, 2023

Choose a reason for hiding this comment

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

We generally use logger = idaeslog.getLogger(__name__) for this - using __name__ gives more granularity and avoids hard-coded string constants. Also, Pyomo has a deprecation warning function for things like this:

from pyomo.common.deprecation import deprecation_warning

deprecation_warning(
    msg=msg, logger=logger, version="2.0.0", remove_in="3.0.0"
)

idaes/core/solvers/petsc.py Show resolved Hide resolved
Copy link
Member

@andrewlee94 andrewlee94 left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewlee94 andrewlee94 enabled auto-merge (squash) August 8, 2023 18:52
@andrewlee94 andrewlee94 added enhancement New feature or request backward-compat Affects backward compatibility PETSc labels Aug 8, 2023
@andrewlee94 andrewlee94 merged commit 359c240 into IDAES:main Aug 29, 2023
36 checks passed
@dallan-keylogic dallan-keylogic deleted the petsc-init-solver branch August 29, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backward-compat Affects backward compatibility enhancement New feature or request PETSc Priority:Normal Normal Priority Issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants