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

If microphysics burn fails, retry hydro #615

Merged
merged 14 commits into from
Apr 21, 2024

Conversation

psharda
Copy link
Contributor

@psharda psharda commented Apr 20, 2024

Description

If the (VODE) burn fails in microphysics, we should retry hydro with a reduced timestep, just like we retry hydro with a reduced timestep if the CFL is violated.

These changes have been successfully tested on CPUs and GPUs.

Related issues

PopIII test on NVIDIA GPUs crashes due to a burn failure in VODE. This did not occur on AMD GPUs at the same timestep.

Resolves #372 for chemistry

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues see (see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • I have tested this PR on my local computer and all tests pass.
  • I have manually triggered the GPU tests with the magic comment /azp run.
  • I have requested a reviewer for this PR.

@psharda psharda added enhancement New feature or request help wanted Extra attention is needed labels Apr 20, 2024
@psharda psharda requested a review from BenWibking April 20, 2024 14:55
@psharda
Copy link
Contributor Author

psharda commented Apr 20, 2024

@BenWibking I have a conceptual problem with my changes: I can reduce the timestep and retry the burn (for a certain max_retries). Say, the burn is successful on the first or second retry. But I can't just exit chemistry and move on to the next timestep (or module) because the burn was only done for 1/2 or 1/4 of the actual timestep. Don't I need to do the burn twice or four times at the reduced step so that at the end, I have my chemical state for the full timestep?

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/Chemistry.hpp Outdated Show resolved Hide resolved
src/Chemistry.hpp Outdated Show resolved Hide resolved
@BenWibking
Copy link
Collaborator

@BenWibking I have a conceptual problem with my changes: I can reduce the timestep and retry the burn (for a certain max_retries). Say, the burn is successful on the first or second retry. But I can't just exit chemistry and move on to the next timestep (or module) because the burn was only done for 1/2 or 1/4 of the actual timestep. Don't I need to do the burn twice or four times at the reduced step so that at the end, I have my chemical state for the full timestep?

Yes that's correct. However you should just use the existing code in the hydro update that does this. VODE internally already does what you've done here. The thing that will make it more robust is if you return a boolean success flag to the hydro update so that the whole hydro update is triggered.

@psharda psharda changed the title If microphysics burn fails, retry with reduced timestep If microphysics burn fails, retry hydro Apr 20, 2024
@psharda
Copy link
Contributor Author

psharda commented Apr 20, 2024

@BenWibking done. Tested it on my computer on cpus and it works. But I am wondering if there is a better way to deal with the burns in the first and the second halves of hydro? Currently, I just check if the burn in either half failed, and if it did, I ask for a hydro retry with a reduced timestep.

@psharda psharda marked this pull request as ready for review April 20, 2024 20:11
@psharda psharda removed the help wanted Extra attention is needed label Apr 20, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/RadhydroSimulation.hpp Outdated Show resolved Hide resolved
@BenWibking
Copy link
Collaborator

@BenWibking done. Tested it on my computer on cpus and it works. But I am wondering if there is a better way to deal with the burns in the first and the second halves of hydro? Currently, I just check if the burn in either half failed, and if it did, I ask for a hydro retry with a reduced timestep.

That's the approach I would take. I don't see what is wrong with this.

@psharda
Copy link
Contributor Author

psharda commented Apr 20, 2024

Success!

[Level 5 step 732] ADVANCE with time = 4.1376331850e+13 dt = 6.9429380442e+08
WARNNING: Unsuccessful burn. Retrying hydro step.
        >> WARNING: Hydro advance failed on level 5
        >> Re-trying hydro advance at level 5 with reduced timestep (nsubsteps = 2, dt_new = 347146902.2)
[Level 5 step 732] Advanced 1572864 cells

@psharda
Copy link
Contributor Author

psharda commented Apr 20, 2024

/azp run

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@psharda
Copy link
Contributor Author

psharda commented Apr 21, 2024

Can be approved now @BenWibking

Copy link
Collaborator

@BenWibking BenWibking left a comment

Choose a reason for hiding this comment

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

One minor change in the first Strang half-step, otherwise everything looks good.

src/RadhydroSimulation.hpp Show resolved Hide resolved
@psharda psharda requested a review from BenWibking April 21, 2024 15:04
@psharda
Copy link
Contributor Author

psharda commented Apr 21, 2024

/azp run

Copy link

Azure Pipelines successfully started running 5 pipeline(s).

@BenWibking BenWibking added this pull request to the merge queue Apr 21, 2024
Merged via the queue into quokka-astro:development with commit 525d025 Apr 21, 2024
19 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Apr 22, 2024
### Description
This triggers the retry mechanism for the hydro update if the cooling
solve fails. This mirrors the behavior for the chemistry solve (#615).

### Related issues
Closes #372.

### Checklist
_Before this pull request can be reviewed, all of these tasks should be
completed. Denote completed tasks with an `x` inside the square brackets
`[ ]` in the Markdown source below:_
- [x] I have added a description (see above).
- [x] I have added a link to any related issues see (see above).
- [x] I have read the [Contributing
Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md).
- [ ] I have added tests for any new physics that this PR adds to the
code.
- [x] I have tested this PR on my local computer and all tests pass.
- [x] I have manually triggered the GPU tests with the magic comment
`/azp run`.
- [x] I have requested a reviewer for this PR.
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

Successfully merging this pull request may close these issues.

retry hydro update when operator-split reactions fail
2 participants