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 DAE Solver "initial_only" only option. #1347

Open
eslickj opened this issue Feb 21, 2024 · 2 comments
Open

PETSc DAE Solver "initial_only" only option. #1347

eslickj opened this issue Feb 21, 2024 · 2 comments
Assignees
Labels
Priority:Normal Normal Priority Issue or PR user request Requests from external users

Comments

@eslickj
Copy link
Member

eslickj commented Feb 21, 2024

When using the petsc.petsc_dae_by_time_element() function to solve a DAE model, I think it would be useful to have an "initial_only" option. I may not have thought this through well enough, but the idea is that when you initialize a DAE model and you are solving with an integrator, only the initial condition matters. Next time you solve it the trajectory is just replaced. If I break the model up and initialize unit by unit, getting the trajectory is just a waste of time. This isn't really a PETSc solver issue specifically, but petsc.petsc_dae_by_time_element() does conveniently split off the initial condition equations for you. I'm know there are other ways to approach this, but adding the option seems convenient.

I think this would be easy to implement. Just terminate the function after solving the initial conditions. The results should be in the model. Return the solver status and None for the trajectory.

@eslickj eslickj added the user request Requests from external users label Feb 21, 2024
@dallan-keylogic
Copy link
Contributor

Possibly what should be done is to provide a way to return the initial condition problem. I've had to do things like add break statements in the middle of the PETSc code in order to do model diagnostics because my initial condition problem was badly specified. The only trick is figuring out how to handle the context manager.

@ksbeattie ksbeattie added the Priority:Normal Normal Priority Issue or PR label Feb 22, 2024
@eslickj
Copy link
Member Author

eslickj commented Feb 23, 2024

@dallan-keylogic, what about a new context manager that you could use like

with InitialConditionProblemManager(...) as ic_model:
    #diagnostics, solve, or whatever.

We could maybe just copy the first part of the petsc time stepping solver wrapper and build on TemporarySubsystemManager. It shouldn't be too hard to put together since it's basically all there. The only trick is you may want an option to revert any changes you make to variable values. Like if I want to solve the initial condition problem, I want to keep the variable values. If you are doing diagnostics, maybe you don't want to keep any changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:Normal Normal Priority Issue or PR user request Requests from external users
Projects
None yet
Development

No branches or pull requests

4 participants