-
Notifications
You must be signed in to change notification settings - Fork 98
Strang Splitting for lagrange bubbles #827
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
base: master
Are you sure you want to change the base?
Conversation
@dgvacarevelo Could you add a 2D example case that includes the use of |
@wilfonba I have added the suggested example. Here is how it behaves using the bubble screen problem. |
@dgvacarevelo Thanks for adding this! |
Looks like there's a Frontier issue somewhere. I'll try to take a look this afternoon or tomorrow and narrow it down. |
src/simulation/m_bubbles.fpp
Outdated
! Compute d_0 = ||y0|| and d_1 = ||f(x0,y0)|| | ||
d_0 = sqrt((myR_tmp(1)**2._wp + myV_tmp(1)**2._wp)/2._wp) | ||
d_1 = sqrt((myV_tmp(1)**2._wp + myA_tmp(1)**2._wp)/2._wp) | ||
if (d_0 < 1e-5_wp .or. d_1 < 1e-5_wp) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more magic numbers. where do these all come from? Should they be user-adjustable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These parameters are used to provide an initial estimate for the size of the first sub-step. If this estimate turns out to be too large (or too small), the substepping algorithm will adjust it dynamically based on the specified tolerance value (adap_dt_tol
). By allowing the tolerance to be user-adjustable, I believe the user is given sufficient control over the behavior and accuracy of the algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you make these not magic numbers in the code at least, and give them comments to explain them further
@@ -928,9 +892,27 @@ contains | |||
idwint, & | |||
gm_alpha_qp%vf) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get the feeling that something in here could be where Frontier is going wrong.
trying some gpt4.5 code review and found some quite useful comments i like. see below It looks like I encountered a technical issue while trying to open the PR files directly from GitHub. However, I can still provide specific suggestions on how Fortran Please consider the following targeted improvements, assuming you’re working with subroutines similar to 🔹 1. Refactor Long Argument ListsProblem: Subroutines like Solution: Use type :: BubbleState
real(wp) :: R, V, Pb, Mv
end type
type :: EOSParams
real(wp) :: ntait, Btait, alf, Cson
end type Before: call f_advance_substep(fRho, fP, fR, fV, fR0, fpb, ...) After: call f_advance_substep(state, eos, env_params, ...) 🔹 2. Introduce Constants Instead of Magic NumbersProblem: Repeated usage of values like Solution: real(wp), parameter :: TOL = 1e-4_wp
real(wp), parameter :: SMALL = 1e-12_wp
real(wp), parameter :: RK3_COEFF = 1.0_wp / 6.0_wp Use these in place of hardcoded values. 🔹 3. Improve Loop Control for Adaptive Time SteppingProblem: Loops like Solution: Add max iteration count and fail-safe exit. integer :: iter_count
integer, parameter :: MAX_ADAPT_ITERS = 100
iter_count = 0
do while (t_new < 0.5_wp * dt .and. iter_count < MAX_ADAPT_ITERS)
iter_count = iter_count + 1
...
end do
if (iter_count >= MAX_ADAPT_ITERS) then
print *, "Warning: adaptive time stepping failed to converge"
end if 🔹 4. Encapsulate Bubble Physics StagesProblem: RK stages for radius, velocity, pressure, and mass evolve together, but logic is spread across many lines. Solution: Create helper functions for each RK stage. call advance_bubble_stage(stage_idx, state_in, state_out, params) This improves modularity and makes debugging easier. 🔹 5. Cleaner Strang Splitting StructureProblem: No clear separation of pre-split and post-split components. Solution: Use functions like: call advance_physics_part1(state, dt_half)
call advance_physics_part2(state, dt_full)
call advance_physics_part1(state, dt_half) Encapsulate each phase of Strang splitting. 🔹 6. Numerical RobustnessProblem: Direct comparison of floating point to zero. Solution: Replace: if (myA_tmp(1) == 0._wp) ... With: if (abs(myA_tmp(1)) < SMALL) ... 🔹 7. Clearer Variable NamingProblem: Variables like Solution: Use more descriptive names: real(wp), dimension(4) :: bubble_radius_stage Or comments: ! stage 4 = final RK stage value
bubble_radius = myR_tmp(4) 🔹 8. Add Diagnostic Output (Optional)When debugging adaptive solvers, a diagnostic printout can be helpful: if (debug_mode) then
print *, "Step accepted with h =", h, " err_R =", err_R, " err_V =", err_V
end if 🔹 9. Testing & Validation SupportInclude optional test modes where:
|
if this adds substepping for EE bubbles can you add a proper test for it, as well as an example? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #827 +/- ##
==========================================
+ Coverage 43.15% 43.35% +0.19%
==========================================
Files 68 68
Lines 20262 20123 -139
Branches 2427 2400 -27
==========================================
- Hits 8745 8724 -21
+ Misses 10054 9933 -121
- Partials 1463 1466 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@dgvacarevelo there is a problem with Frontier runs. You can try to figure it out by asking questions on the Slack channel. The GT Phoenix runners are failing because the computer is under maintenance. |
there are a few remaining things... like the old rkck is not fully removed from the code and some other minor things... check out the review below Reviewing Fortran PR changes The user asked for a code review focusing on Reviewing Fortran code changes I need to carefully examine changes to style, correctness, bugs, and performance in the Fortran code. Key updates include the removal of Reviewing RKCK and time_stepper changes The user’s changes involve removing Thought for 1m 2s Below is a focused review of every 1 Global removal of the RKCK stepperYou eliminated the Cash–Karp (time _stepper == 4) path and its adaptive‐timestep option
2
|
Description
This PR is an effort to enhance the Euler-Lagrange model for sub-grid bubble dynamics. The RKCK algorithm (time_stepper==4) was removed and the EL subroutines are now compatible with the Strang Splitting algorithm, which is highly important to simulate collapsing bubbles. Additionally, this PR will fix the bug #797.
Type of change
Please delete options that are not relevant.
Scope
If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration
A cuboidal bubble cloud interacts with a sinusoidal planar wave. This case is included as an example case (examples/3D_lag_bubbles_bubblescreen). The pressure at the center of the cloud is measured and compared. Both simulations make use of the 3rd order RK-TV time-stepper, and the results with adap_dt=T agrees well with the outcome when adap_dt=F.
A single bubble of 8 micrometers encounters a sinusoidal planar wave. This case is also included as an example case (examples/3D_lag_bubbles_shbubcollapse). The radius evolution of the bubble is compared with the experiment reported by (Ohl et. al, 1999) (https://doi.org/10.1098/rsta.1999.0327). Similarly, both simulations make use of the 3rd order RK-TV time-stepper, and the results with adap_dt=T agrees well with the outcome when adap_dt=F. However, when bubble collapse occurs, enabling adaptive time stepping (adap_dt = T) is essential; otherwise, the simulation fails near the collapse point. As shown in the plotted results, the simulation with adap_dt = F terminates prematurely at approximately t ≈ 27 microseconds.
Test Configuration:
Checklist
docs/
)examples/
that demonstrate my new feature performing as expected.They run to completion and demonstrate "interesting physics"
./mfc.sh format
before committing my codeIf your code changes any code source files (anything in
src/simulation
)To make sure the code is performing as expected on GPU devices, I have:
nvtx
ranges so that they can be identified in profiles./mfc.sh run XXXX --gpu -t simulation --nsys
, and have attached the output file (.nsys-rep
) and plain text results to this PR./mfc.sh run XXXX --gpu -t simulation --omniperf
, and have attached the output file and plain text results to this PR.