-
Notifications
You must be signed in to change notification settings - Fork 121
Update initialization for turbulent mixing layer and add validation results #879
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
Conversation
examples/3D_turb_mixing/turbulence_stat/results/Reynolds_stress/tstep_8064.png
Outdated
Show resolved
Hide resolved
examples/3D_turb_mixing/turbulence_stat/submit_batch_job_carpenter.sh
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #879 +/- ##
==========================================
- Coverage 45.98% 44.00% -1.98%
==========================================
Files 68 68
Lines 18629 18433 -196
Branches 2239 2228 -11
==========================================
- Hits 8566 8112 -454
- Misses 8711 9017 +306
+ Partials 1352 1304 -48 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
examples/3D_turb_mixing/turbulence_stat/average_tke_over_self_similar.m
Outdated
Show resolved
Hide resolved
|
@sbryngelson Only frontier test fails. I guess something might be wrong with the pseudo-random number generator, but I am still trying to figure out what causes the failure. If you have any idea on what could be possibly wrong, that would be greatly appreciated! |
|
@hyeoksu-lee that is indeed weird. if I recall correctly, the Frontier CPU test passes? If that's correct, then it's very strange the GPU case would fail. I notice the failure is for a very small tolerance error. What does that particular test actually look like? Does it meaningfully change the state variables over the ~50 time steps (or whatever it is)? Perhaps it's just not a great test that is very sensitive to compiler optimizations or floating point roundoff. |
| integer :: xint, val | ||
| real(wp) :: x | ||
|
|
||
| x = (multiplier/real(modulus, wp))*a + (increment/real(modulus, wp)) |
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.
if you think the error in the Cray/Frontier case is due to the RNG, then you can print the random number it generates as a test and see it in the CI output (I think that should work, I believe we print the simulation output of failed tests in the CI output). also: Carpenter is a cray machine, so you can load cray modules there, compile MFC, and see if it passes tests!
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.
using Carpenter for this is probably the fastest way to debug. you'll have to change the modules from the ones ./mfc.sh load uses to the Cray ones. let me know if you can't figure this out, I have Carpenter access (i think)
|
@sbryngelson Thank you for the suggestions! I will try to verify with Carpenter's cray modules. Not sure if I can find all the required modules though. I'll keep you updated |
Let me know if that's the case and I'll try to help (put it in Slack). |
|
@sbryngelson Using Carpenter Cray, I found that the PRNG was sensitive to machine precision errors due to the multiplication of a very large number followed by trimming. I’ve updated the PRNG to make it more robust against such precision issues. Test suite passed on both Carpenter GNU and Cray as well as my local macbook, so I believe the Frontier tests should now pass. In the meantime, I will have to update the results of |
|
@hyeoksu-lee ah, good find, very nice! Looks like it passed just fine. FYI the GT (Phoenix) runners are down or acting very strangely right now but I expect them to show fine results. I will mark this PR as a draft PR and you can mark it 'ready to review' once you check your final statistics. |
|
@sbryngelson Statistics looks good. This PR is now ready for review. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
Pull Request Overview
This PR replaces the previous linear-instability initialization of the turbulent mixing layer with a spectrum-based synthetic turbulence generator (Guo et al. 2023), updates all related configuration and broadcast parameters (mixlayer_perturb_nk, mixlayer_perturb_k0), and adds MATLAB tools (and documentation) for turbulence statistics and validation of the 3D mixing layer example.
- Replace
s_superposition_instability_wavewiths_perturb_mixlayerand remove legacy linear-stability code. - Introduce new parameters
mixlayer_perturb_nkandmixlayer_perturb_k0, propagate them through global parameters, MPI proxies, start-up, and namelists. - Add MATLAB scripts (
run_turbulence.m,average_tke_over_self_similar.m), example README, and reference documentation.
Reviewed Changes
Copilot reviewed 22 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/pre_process/m_perturbation.fpp | Remove linear-stability routines; add s_perturb_mixlayer subroutine and PRNG constants. |
| src/pre_process/m_initial_condition.fpp | Update initialization to call s_perturb_mixlayer instead. |
| src/common/m_constants.fpp | Define PRNG constants (modulus, multiplier, increment, etc.). |
| src/pre_process/m_global_parameters.fpp | Add mixlayer_perturb_nk and mixlayer_perturb_k0 defaults. |
| src/pre_process/m_mpi_proxy.fpp | Broadcast new mixing-layer parameters; remove deprecated mixlayer_domain. |
| src/pre_process/m_start_up.fpp | Include new perturbation parameters in namelist. |
| src/pre_process/m_checker.fpp | Simplify validation rules for mixlayer_perturb. |
| toolchain/mfc/run/case_dicts.py | Register new parameter types for mixlayer_perturb_nk and mixlayer_perturb_k0. |
| toolchain/mfc/test/cases.py | Replace legacy instability-wave test with alter_mixlayer_perturb. |
| examples/3D_turb_mixing/turbulence_stat/* | Add MATLAB scripts, README, and averaging tools for validation. |
| examples/3D_turb_mixing/case.py | Update 3D example to higher Re, grid stretching, and mixlayer config. |
| docs/documentation/case.md | Update docs to describe new synthetic turbulence parameters. |
| docs/documentation/references.md | Add Guo (2023) and Michalke (1964) references. |
| .typos.toml | Allow “TKE” in typo checker. |
Comments suppressed due to low confidence (3)
examples/2D_mixing_artificial_Ma/case.py:110
- Enabling mixlayer_perturb for a 2D case (p == 0) will trigger the PROHIBIT check (
p > 0) and cause startup to fail. Please disable or guard this setting in 2D examples.
"mixlayer_vel_coef": 1.0,
src/pre_process/m_checker.fpp:191
- The new PROHIBIT rule only checks
p > 0but does not enforcemixlayer_vel_profile = .true.. To avoid misconfiguration, consider adding validation that the velocity profile flag is enabled when perturbations are requested.
@:PROHIBIT(mixlayer_perturb .and. p == 0, "mixlayer_perturb requires p > 0")
toolchain/mfc/test/cases.py:634
- The new test generator only covers 3D (
len(dimInfo[0]) == 3) cases. If 2D support is intended, add a branch to test mixlayer perturbations in 2D.
def alter_mixlayer_perturb(dimInfo):
|
@sbryngelson I guess this is now ready for merging |
…esults (MFlowCode#879) Co-authored-by: Copilot <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Spencer Bryngelson <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]> Co-authored-by: Hyeoksu Lee <[email protected]>
User description
Description
This PR includes an update on initialization method for turbulent mixing layer. Also, Matlab scripts for computing turbulence statistics are added to
examples/3D_turb_mixing/turbulence_statas well as validation results.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?
Ran
examples/3D_turb_mixingon CarpenterStreamwise velocity field at final time

Vorticity magnitude at final time

Evolution of Reynolds stress

Evolution of TKE budget

TKE budget averaged over self-similar period

Momentum thickness growth rate (see run_turbulence.m for references in legend)

Checklist
docs/)examples/that demonstrate my new feature performing as expected.They run to completion and demonstrate "interesting physics"
./mfc.sh formatbefore committing my codePR Type
Enhancement, Documentation, Tests
Description
• Replace linear stability analysis with synthetic turbulence generation method for mixing layer initialization using Guo et al. (2023) approach
• Add comprehensive MATLAB scripts for turbulence statistics computation including Reynolds stress, TKE budget analysis, and validation against reference data
• Update 3D turbulent mixing layer example with higher Reynolds number (320), increased domain size and grid resolution
• Add new configuration parameters
mixlayer_perturb_nkandmixlayer_perturb_k0for synthetic turbulence control• Remove deprecated
mixlayer_domainparameter and associated complex validation requirements• Implement pseudo-random number generator with supporting constants and helper functions
• Add documentation for new mixing layer perturbation method and turbulence analysis tools
• Update test cases and parameter dictionaries to support new synthetic turbulence approach
Changes walkthrough 📝
6 files
m_perturbation.fpp
Replace linear stability analysis with synthetic turbulence generationsrc/pre_process/m_perturbation.fpp
• Removed complex linear stability analysis code for mixing layer
instability waves
• Replaced
s_superposition_instability_wavewith news_perturb_mixlayerfunction• Added spectrum-based synthetic
turbulence generation method using Guo et al. (2023) approach
•
Implemented pseudo-random number generator and helper functions for
perturbation generation
m_initial_condition.fpp
Update function call for mixing layer perturbationsrc/pre_process/m_initial_condition.fpp
• Changed function call from
s_superposition_instability_wavetos_perturb_mixlayerm_constants.fpp
Add constants for pseudo-random number generatorsrc/common/m_constants.fpp
• Added constants for pseudo-random number generator implementation
•
Defined modulus, multiplier, increment, amplifier, and decimal_trim
parameters
case.py
Update 3D turbulent mixing layer example configurationexamples/3D_turb_mixing/case.py
• Updated Reynolds number from 50 to 320
• Increased domain size and
grid resolution significantly
• Added grid stretching in y-direction
with new parameters
• Modified time stepping and output settings
run_turbulence.m
Add MATLAB script for turbulence statistics analysisexamples/3D_turb_mixing/turbulence_stat/run_turbulence.m
• Added comprehensive MATLAB script for turbulence statistics
computation
• Implements Reynolds stress and TKE budget calculations
•
Includes plotting functions and comparison with reference data
•
Provides mixing layer thickness and growth rate analysis
average_tke_over_self_similar.m
Add TKE budget averaging and validation scriptexamples/3D_turb_mixing/turbulence_stat/average_tke_over_self_similar.m
• Added MATLAB script to compute time-averaged TKE budget over
self-similar period
• Implements interpolation and normalization of
TKE transport, production, and dissipation terms
• Includes plotting
functionality with comparison to reference data from multiple studies
• Contains helper functions for derivative computation and TKE budget
visualization
7 files
m_mpi_proxy.fpp
Update MPI broadcasts for new mixing layer parameterssrc/pre_process/m_mpi_proxy.fpp
• Added MPI broadcast for new parameter
mixlayer_perturb_nk• Added
MPI broadcast for new parameter
mixlayer_perturb_k0• Removed MPI
broadcast for deprecated parameter
mixlayer_domainm_global_parameters.fpp
Add new mixing layer perturbation parameterssrc/pre_process/m_global_parameters.fpp
• Added new parameters
mixlayer_perturb_nkandmixlayer_perturb_k0forsynthetic turbulence
• Removed deprecated parameter
mixlayer_domain•
Set default values for new parameters (nk=100, k0=0.4446)
m_checker.fpp
Simplify mixing layer perturbation validationsrc/pre_process/m_checker.fpp
• Simplified validation for
mixlayer_perturbto only requirep > 0•
Removed complex validation requirements for model equations, fluids,
and boundary conditions
m_start_up.fpp
Update namelist for new mixing layer parameterssrc/pre_process/m_start_up.fpp
• Updated namelist to include new parameters
mixlayer_perturb_nkandmixlayer_perturb_k0• Removed deprecated parameter
mixlayer_domainfrom namelist
case_dicts.py
Update parameter dictionary for new mixing layer optionstoolchain/mfc/run/case_dicts.py
• Added new parameter types for
mixlayer_perturb_nkandmixlayer_perturb_k0• Removed deprecated parameter
mixlayer_domainset_user_inputs.m
Add user input configuration for turbulence statisticsexamples/3D_turb_mixing/turbulence_stat/set_user_inputs.m
• Added MATLAB function to configure simulation parameters for
turbulent mixing layer analysis
• Defines fluid properties, Reynolds
number, grid configuration, and time stepping parameters
• Sets up
domain dimensions and stretched grid parameters for y-direction
•
Configures system indices for multi-fluid and multi-dimensional
simulations
.typos.toml
Allow TKE acronym in typo checker.typos.toml
• Added
TKEto the list of accepted words in typo checkingconfiguration
1 files
cases.py
Update test case for new mixing layer perturbation methodtoolchain/mfc/test/cases.py
• Replaced complex
alter_instability_wavefunction with simplifiedalter_mixlayer_perturb• Updated test case configuration for 3D mixing
layer with new parameters
• Simplified test case setup removing
bubble-related configurations
1 files
golden-metadata.txt
Update test metadata for new build environmenttests/D13FDB23/golden-metadata.txt
• Updated test metadata with new build configuration and environment
•
Changed from Delta cluster to M4Pro local machine
• Updated compiler
versions and CMake configuration
3 files
case.md
Update documentation for new mixing layer perturbation methoddocs/documentation/case.md
• Updated documentation for mixing layer parameters
• Removed
mixlayer_domainparameter description• Added description of new
synthetic turbulence generation method
• Updated requirements for
mixlayer_perturboptionREADME.md
Add README for turbulence statistics analysis toolsexamples/3D_turb_mixing/turbulence_stat/README.md
• Added README file describing turbulence statistics analysis tools
•
Provides references to relevant literature
• Documents file structure
and usage instructions
references.md
Add turbulence-related academic referencesdocs/documentation/references.md
• Added reference to Guo et al. (2023) for turbulence generation
methods
• Added reference to Michalke (1964) for hyperbolic-tangent
velocity profile instability
9 files