-
Notifications
You must be signed in to change notification settings - Fork 137
Add Herschel-Bulkley non-Newtonian viscosity model #1298
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
Open
jasontruong2707
wants to merge
23
commits into
MFlowCode:master
Choose a base branch
from
jasontruong2707:feature/non-newtonian-viscosity
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d5b86df
Add Herschel-Bulkley non-Newtonian viscosity model
sbryngelson 67f74c0
fix: add GPU_DECLARE/GPU_UPDATE for fluid_pp (required for non-Newton…
sbryngelson 1be6ef3
fix: skip mu_max clamp when mu_max is unset (default sentinel is nega…
sbryngelson 6d8313a
fix: restore master's hyper_cleaning s_L/s_R (was incorrectly changed…
sbryngelson 13b79f1
fix: restore hyper_cleaning block inside wave_speeds==1 branch (stale…
sbryngelson cc6373c
Merge branch 'master' into feature/non-newtonian-viscosity
sbryngelson e32f038
Merge branch 'master' into feature/non-newtonian-viscosity
sbryngelson d8facd7
Merge branch 'master' into feature/non-newtonian-viscosity
sbryngelson 9e08f60
Merge master into feature/non-newtonian-viscosity
sbryngelson e8903e3
Merge branch 'master' into feature/non-newtonian-viscosity
sbryngelson d9e5b04
Merge master into feature/non-newtonian-viscosity: resolve conflicts
sbryngelson 8b2c874
fix: replace momxb with eqn_idx%mom%beg in m_re_visc.fpp
sbryngelson 0994f50
format: wrap long lines in m_re_visc.fpp to pass CI cleanliness check
sbryngelson eab5b06
format: collapse multi-line ValueError to single line in registry.py
sbryngelson 231ae8d
ci: retrigger CI after transient network failures in NVHPC jobs
sbryngelson d02076c
Fix non-Newtonian viscosity bugs: mu_max sentinel, shear-rate clamp, …
sbryngelson 3fdebb6
Fix IBM non-Newtonian viscosity: compute local shear rate per cell in…
sbryngelson 266c79e
Expose s_compute_velocity_gradients_at_cell as public for IBM use
sbryngelson 989b1e7
Fix nvfortran GPU build: drop pure from subroutines with GPU_LOOP dir…
sbryngelson 3c636c5
Update golden file for non-Newtonian shear-thinning test (45DA4729)
sbryngelson 4813f74
Fix zero-shear NaN/Inf in f_compute_hb_viscosity
sbryngelson 55ded73
Fix three bugs flagged in code review
sbryngelson 93973d6
fix: invalid Fortran continuation in m_ibm.fpp breaks Cray ftn build
sbryngelson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| 2D Lid-Driven Cavity Flow with Herschel-Bulkley Non-Newtonian Fluid | ||
|
|
||
| Re = 5000, n = 1.5 (shear-thickening) with mesh stretching near walls. | ||
|
|
||
| HB model: mu = (tau0/gdot)*(1 - exp(-m*gdot)) + K * gdot^(n-1) | ||
| Re_gen = rho * U^(2-n) * L^n / K = 1 * 1^0.5 * 1^1.5 / 0.0002 = 5000 | ||
|
|
||
| Mesh stretching: cosh-based clustering near all 4 walls (x_a, x_b, y_a, y_b). | ||
| """ | ||
|
|
||
| import json | ||
|
|
||
| eps = 1e-6 | ||
|
|
||
| # HB model parameters | ||
| tau0 = 0.0 # Yield stress (set to 0 for power-law fluid) | ||
| K = 0.0002 # Consistency index (Re=5000: K = 1/5000) | ||
| nn = 1.5 # Flow behavior index (shear-thickening) | ||
| mu_min = 0.00002 # K * gdot_min^(n-1) = 0.0002 * (0.01)^0.5 | ||
| mu_max = 0.0632 # K * gdot_max^(n-1) = 0.0002 * (1e5)^0.5 | ||
| hb_m = 1000.0 # Papanastasiou regularization parameter | ||
| mu_bulk = 0.0 | ||
|
|
||
| lid_velocity = 1.0 # Lid velocity (m/s) | ||
|
|
||
| # Configuring case dictionary | ||
| print( | ||
| json.dumps( | ||
| { | ||
| # Logistics | ||
| "run_time_info": "T", | ||
| # Computational Domain Parameters | ||
| "x_domain%beg": 0.0, | ||
| "x_domain%end": 1.0, | ||
| "y_domain%beg": 0.0, | ||
| "y_domain%end": 1.0, | ||
| "m": 255, | ||
| "n": 255, | ||
| "p": 0, | ||
| "cfl_adap_dt": "T", | ||
| "cfl_target": 0.5, | ||
| "n_start": 0, | ||
| "t_stop": 50.0, | ||
| "t_save": 25.0, | ||
| # Simulation Algorithm Parameters | ||
| "num_patches": 1, | ||
| "model_eqns": 2, | ||
| "alt_soundspeed": "F", | ||
| "num_fluids": 2, | ||
| "mpp_lim": "F", | ||
| "mixture_err": "T", | ||
| "time_stepper": 3, | ||
| "weno_order": 5, | ||
| "weno_eps": 1e-16, | ||
| "mapped_weno": "T", | ||
| "weno_Re_flux": "T", | ||
| "mp_weno": "T", | ||
| "weno_avg": "T", | ||
| "riemann_solver": 2, | ||
| "wave_speeds": 1, | ||
| "avg_state": 2, | ||
| "bc_x%beg": -16, | ||
| "bc_x%end": -16, | ||
| "bc_y%beg": -16, | ||
| "bc_y%end": -16, | ||
| "bc_y%ve1": lid_velocity, | ||
| "viscous": "T", | ||
| # Formatted Database Files Structure Parameters | ||
| "format": 1, | ||
| "precision": 2, | ||
| "prim_vars_wrt": "T", | ||
| "omega_wrt(3)": "T", | ||
| "fd_order": 4, | ||
| "parallel_io": "T", | ||
| # Patch 1: Base | ||
| "patch_icpp(1)%geometry": 3, | ||
| "patch_icpp(1)%x_centroid": 0.5, | ||
| "patch_icpp(1)%y_centroid": 0.5, | ||
| "patch_icpp(1)%length_x": 1.0, | ||
| "patch_icpp(1)%length_y": 1.0, | ||
| "patch_icpp(1)%vel(1)": 0, | ||
| "patch_icpp(1)%vel(2)": 0.0, | ||
| "patch_icpp(1)%pres": 1e3, | ||
| "patch_icpp(1)%alpha_rho(1)": 0.5, | ||
| "patch_icpp(1)%alpha(1)": 0.5, | ||
| "patch_icpp(1)%alpha_rho(2)": 0.5, | ||
| "patch_icpp(1)%alpha(2)": 0.5, | ||
| # Fluids Physical Parameters | ||
| # Fluid 1: | ||
| "fluid_pp(1)%gamma": 1.0 / (1.4 - 1.0), | ||
| "fluid_pp(1)%pi_inf": 0.0, | ||
| "fluid_pp(1)%Re(1)": 1.0 / K, | ||
| "fluid_pp(1)%non_newtonian": "T", | ||
| "fluid_pp(1)%tau0": tau0, | ||
| "fluid_pp(1)%K": K, | ||
| "fluid_pp(1)%nn": nn, | ||
| "fluid_pp(1)%mu_max": mu_max, | ||
| "fluid_pp(1)%mu_min": mu_min, | ||
| "fluid_pp(1)%mu_bulk": mu_bulk, | ||
| "fluid_pp(1)%hb_m": hb_m, | ||
| # Fluid 2: | ||
| "fluid_pp(2)%gamma": 1.0 / (1.4 - 1.0), | ||
| "fluid_pp(2)%pi_inf": 0.0, | ||
| "fluid_pp(2)%Re(1)": 1.0 / K, | ||
| "fluid_pp(2)%non_newtonian": "T", | ||
| "fluid_pp(2)%tau0": tau0, | ||
| "fluid_pp(2)%K": K, | ||
| "fluid_pp(2)%nn": nn, | ||
| "fluid_pp(2)%mu_max": mu_max, | ||
| "fluid_pp(2)%mu_min": mu_min, | ||
| "fluid_pp(2)%mu_bulk": mu_bulk, | ||
| "fluid_pp(2)%hb_m": hb_m, | ||
| } | ||
| ) | ||
| ) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| 2D Poiseuille Flow with Herschel-Bulkley Non-Newtonian Fluid | ||
|
|
||
| Pressure-driven channel flow between two no-slip walls, driven by a constant | ||
| body force in the streamwise (x) direction. Periodic BCs in x, no-slip in y. | ||
|
|
||
| HB model: mu = (tau0/gdot)*(1 - exp(-m*gdot)) + K * gdot^(n-1) | ||
| - tau0: yield stress | ||
| - K: consistency index | ||
| - n: flow behavior index (< 1 shear-thinning, > 1 shear-thickening) | ||
| - m: Papanastasiou regularization parameter | ||
|
|
||
| For Newtonian Poiseuille validation, set tau0=0, nn=1, K=mu. | ||
| The analytical solution is: u(y) = (G/(2*mu)) * y * (H - y) | ||
| where G = rho * g_x is the effective pressure gradient. | ||
| """ | ||
|
|
||
| import json | ||
| import math | ||
|
|
||
| # -- Channel geometry (square domain) -- | ||
| L = 1.0 # Channel length (streamwise, x) | ||
| H = 1.0 # Channel height (wall-normal, y) | ||
|
|
||
| # -- Grid resolution -- | ||
| Nx = 24 # Cells in x (streamwise, minimal — periodic) | ||
| Ny = 81 # Cells in y (wall-normal) | ||
|
|
||
| # -- Fluid properties -- | ||
| rho = 1.0 # Density | ||
| p0 = 1e5 # Reference pressure (high for low Mach) | ||
| gamma = 1.4 # Ratio of specific heats | ||
|
|
||
| # Sound speed and CFL | ||
| c = math.sqrt(gamma * p0 / rho) | ||
| dx = L / (Nx + 1) | ||
| cfl = 0.3 | ||
| dt = cfl * dx / c | ||
|
|
||
| # -- Body force (pressure gradient substitute) -- | ||
| # G = rho * g_x acts as dp/dx driving force | ||
| g_x = 0.5 | ||
|
|
||
| # -- HB non-Newtonian model parameters -- | ||
| tau0 = 0.0 # Yield stress (set 0 for power-law) | ||
| K = 0.1 # Consistency index | ||
| nn = 2.0 # Flow behavior index (< 1 = shear-thinning) | ||
| hb_m = 1000.0 # Papanastasiou regularization parameter | ||
| mu_min = 1e-4 # Minimum viscosity bound | ||
| mu_max = 10.0 # Maximum viscosity bound | ||
| mu_bulk = 0.0 # Bulk viscosity | ||
|
|
||
| # Reference Re based on consistency index (used as baseline) | ||
| Re_ref = 1.0 / K # = 100 | ||
|
|
||
| # -- Time control -- | ||
| t_end = 10.0 # End time (allow flow to reach steady state) | ||
| t_save = 5.0 # Save interval | ||
|
|
||
| eps = 1e-6 | ||
|
|
||
| # Configuring case dictionary | ||
| print( | ||
| json.dumps( | ||
| { | ||
| # Logistics | ||
| "run_time_info": "T", | ||
| # Computational Domain Parameters | ||
| "x_domain%beg": 0.0, | ||
| "x_domain%end": L, | ||
| "y_domain%beg": 0.0, | ||
| "y_domain%end": H, | ||
| "m": Nx, | ||
| "n": Ny, | ||
| "p": 0, | ||
| "cfl_adap_dt": "T", | ||
| "cfl_target": cfl, | ||
| "n_start": 0, | ||
| "t_stop": t_end, | ||
| "t_save": t_save, | ||
| # Simulation Algorithm Parameters | ||
| "num_patches": 1, | ||
| "model_eqns": 2, | ||
| "alt_soundspeed": "F", | ||
| "num_fluids": 2, | ||
| "mpp_lim": "F", | ||
| "mixture_err": "T", | ||
| "time_stepper": 3, | ||
| "weno_order": 5, | ||
| "weno_eps": 1e-16, | ||
| "mapped_weno": "T", | ||
| "weno_Re_flux": "T", | ||
| "mp_weno": "T", | ||
| "weno_avg": "T", | ||
| "riemann_solver": 2, | ||
| "wave_speeds": 1, | ||
| "avg_state": 2, | ||
| # Boundary Conditions | ||
| # Periodic in x (streamwise), no-slip walls in y | ||
| "bc_x%beg": -1, | ||
| "bc_x%end": -1, | ||
| "bc_y%beg": -16, | ||
| "bc_y%end": -16, | ||
| # Viscous | ||
| "viscous": "T", | ||
| # Body Force (drives the flow like a pressure gradient) | ||
| "bf_x": "T", | ||
| "g_x": g_x, | ||
| "k_x": 0.0, | ||
| "w_x": 0.0, | ||
| "p_x": 0.0, | ||
| # Formatted Database Files Structure Parameters | ||
| "format": 1, | ||
| "precision": 2, | ||
| "prim_vars_wrt": "T", | ||
| "omega_wrt(3)": "T", | ||
| "fd_order": 4, | ||
| "parallel_io": "T", | ||
| # Patch 1: Entire channel domain (initially at rest) | ||
| "patch_icpp(1)%geometry": 3, | ||
| "patch_icpp(1)%x_centroid": L / 2.0, | ||
| "patch_icpp(1)%y_centroid": H / 2.0, | ||
| "patch_icpp(1)%length_x": L, | ||
| "patch_icpp(1)%length_y": H, | ||
| "patch_icpp(1)%vel(1)": 0.0, | ||
| "patch_icpp(1)%vel(2)": 0.0, | ||
| "patch_icpp(1)%pres": p0, | ||
| "patch_icpp(1)%alpha_rho(1)": rho * 0.5, | ||
| "patch_icpp(1)%alpha(1)": 0.5, | ||
| "patch_icpp(1)%alpha_rho(2)": rho * 0.5, | ||
| "patch_icpp(1)%alpha(2)": 0.5, | ||
| # Fluid 1: HB non-Newtonian fluid | ||
| "fluid_pp(1)%gamma": 1.0 / (gamma - 1.0), | ||
| "fluid_pp(1)%pi_inf": 0.0, | ||
| "fluid_pp(1)%Re(1)": Re_ref, | ||
| "fluid_pp(1)%non_newtonian": "T", | ||
| "fluid_pp(1)%tau0": tau0, | ||
| "fluid_pp(1)%K": K, | ||
| "fluid_pp(1)%nn": nn, | ||
| "fluid_pp(1)%hb_m": hb_m, | ||
| "fluid_pp(1)%mu_min": mu_min, | ||
| "fluid_pp(1)%mu_max": mu_max, | ||
| "fluid_pp(1)%mu_bulk": mu_bulk, | ||
| # Fluid 2: same properties (single-phase effectively) | ||
| "fluid_pp(2)%gamma": 1.0 / (gamma - 1.0), | ||
| "fluid_pp(2)%pi_inf": 0.0, | ||
| "fluid_pp(2)%Re(1)": Re_ref, | ||
| "fluid_pp(2)%non_newtonian": "T", | ||
| "fluid_pp(2)%tau0": tau0, | ||
| "fluid_pp(2)%K": K, | ||
| "fluid_pp(2)%nn": nn, | ||
| "fluid_pp(2)%hb_m": hb_m, | ||
| "fluid_pp(2)%mu_min": mu_min, | ||
| "fluid_pp(2)%mu_max": mu_max, | ||
| "fluid_pp(2)%mu_bulk": mu_bulk, | ||
| } | ||
| ) | ||
| ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Docstring describes mesh stretching, but the case config does not enable it.
The header says wall clustering/stretching is used, but no
stretch_*toggles or stretching coefficients are set in the emitted JSON.📝 Proposed fix
📝 Committable suggestion