Fix temperature drift caused by ekh timing mismatch in flux-type top BC#318
Open
Xinzhe20 wants to merge 1 commit into
Open
Fix temperature drift caused by ekh timing mismatch in flux-type top BC#318Xinzhe20 wants to merge 1 commit into
Xinzhe20 wants to merge 1 commit into
Conversation
closure() updates ekh to ekh_{N+1} at the start of each RK3 substep,
but fluxtop() (called via boundary()) had already set the top ghost
cell thl0(ke+1) using the previous ekh_N. diffc() then computed the
top-boundary flux using the mismatched ekh_{N+1}, causing the
realized flux to deviate from the prescribed wttop by ~0.72%,
producing a systematic linear domain-temperature drift (dT/dt not
converging to zero, scaling with dt).
Fix: call fluxtop() again immediately after closure() inside
subgrid(), using the just-updated ekh, before diffc() consumes the
ghost cell. Only active when ltempeq .and. BCtopT == BCtopT_flux.
Verified on Imperial CX3: drift reduced from +7.93e-04 K.m/s to
-2.10e-05 K.m/s (97% reduction), case 001 (unpatched) vs case 002
(patched), bctfz = wttop = -0.1. Re-verified with a clean rebuild
(case 005, 26000s run) to confirm the cleaned-up patch reproduces
identical convergence behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closure() updates ekh to ekh_{N+1} at the start of each RK3 substep, but fluxtop() (called via boundary()) had already set the top ghost cell thl0(ke+1) using the previous ekh_N. diffc() then computed the top-boundary flux using the mismatched ekh_{N+1}, causing the realized flux to deviate from the prescribed wttop by ~0.72%, producing a systematic linear domain-temperature drift (dT/dt not converging to zero, scaling with dt).
Fix: call fluxtop() again immediately after closure() inside subgrid(), using the just-updated ekh, before diffc() consumes the ghost cell. Only active when ltempeq .and. BCtopT == BCtopT_flux.
Verified on hpc: drift reduced from +7.93e-04 K.m/s to -2.10e-05 K.m/s (97% reduction), case 001 (unpatched) vs case 002 (patched), bctfz = wttop = -0.1. Re-verified with a clean rebuild (case 005, 26000s run) to confirm the cleaned-up patch reproduces identical convergence behavior.
Closes #317