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

Allow single-step backward Euler integrator #1773

Conversation

chongchonghe
Copy link

@chongchonghe chongchonghe commented Mar 5, 2025

This allows the user to use a single-step Backward Euler integrator, ignoring its accuracy. There are situations where we control relative error by setting the hydro/radiation timestep, and in a reaction network we simply want a backward Euler solve and don't care about error.

To force the BackwardEuler integrator to do a single-step integration, set integrator.do_single_step = 1.

Verified with the burn_cell unit test:

cd unit_test/burn_cell
make INTEGRATOR_DIR=BackwardEuler
echo "integrator.do_single_step = 1" >> inputs_aprox13
./main3d.gnu.ex inputs_aprox13 

Context: this is part of the effort to couple multi-group radiation hydrodynamics with thermochemistry in Quokka.

Addresses #1771

@zingale zingale changed the base branch from main to development March 5, 2025 12:09
@zingale
Copy link
Member

zingale commented Mar 5, 2025

can you also add a note to the docs here:
https://github.com/AMReX-Astro/Microphysics/blob/main/Docs/source/ode_integrators.rst

@chongchonghe
Copy link
Author

can you also add a note to the docs here: https://github.com/AMReX-Astro/Microphysics/blob/main/Docs/source/ode_integrators.rst

Done.

@zingale
Copy link
Member

zingale commented Mar 5, 2025

you also need to fix the style CI failures -- it looks like you used tabs and have trailing whitespace.

@zingale
Copy link
Member

zingale commented Mar 5, 2025

also, rather than making atol_enuc special (e.g., why is this set to -1 and not the others?) it might be better to simply define a new parameter in Microphysics/integration/BackwardEuler/_parameters, like do_single_step that defaults to 0, but if set to 1 does what you want.

I think that would be cleaner.

@chongchonghe
Copy link
Author

chongchonghe commented Mar 7, 2025

@zingale I've added a integrator.do_single_step parameter to toggle single-step EU. I tested it on my computer and it worked fine. We don't have a unit test for this yet, because I don't know how to make a test problem use BackwardEuler without manually modify CMakeLists.txt in the root directory (see #1772 ).

@zingale
Copy link
Member

zingale commented Mar 7, 2025

you can test it with GNU make -- we don't use cmake. Just do:

make INTEGRATOR_DIR=BackwardEuler

in the test directory.

@chongchonghe
Copy link
Author

chongchonghe commented Mar 8, 2025

you can test it with GNU make -- we don't use cmake. Just do:

make INTEGRATOR_DIR=BackwardEuler

in the test directory.

Thanks, that works. I kept the changes minimal and it works just fine.

@zingale
Copy link
Member

zingale commented Mar 8, 2025

there are also still CI style failures.

@chongchonghe
Copy link
Author

there are also still CI style failures.

Fixed.

@chongchonghe chongchonghe requested a review from zingale March 9, 2025 01:19
@zingale zingale merged commit f4280ca into AMReX-Astro:development Mar 10, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants