Add simulation setup for 2D jet in crossflow#1372
Add simulation setup for 2D jet in crossflow#1372sidkamat wants to merge 2 commits intoMFlowCode:masterfrom
Conversation
This script sets up parameters for a 2D jet in crossflow simulation, including free stream conditions, jet inlet conditions, viscosities, simulation parameters, and case dictionary for the simulation.
📝 WalkthroughWalkthroughA new Python script was added to the examples directory for a 2D jet-in-crossflow case. The script computes fluid and jet parameters including derived sound speed and inlet velocities from specified conditions. It defines simulation grid, runtime settings, and constructs a comprehensive configuration dictionary that covers domain extents, discretization sizes, CFL control, algorithm and model parameters, boundary-condition patch settings, and two-fluid patch initial conditions. The configuration includes embedded computed values and formatted expressions (such as a 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b320adf9-55e8-435c-be01-d8b93917a72c
📒 Files selected for processing (1)
examples/2D_jet_in_crossflow/case_2D_jicf.py
| import math | ||
| import json | ||
|
|
||
| #Free stream | ||
| p_inf=16281 | ||
| rho_inf=0.416 | ||
| c_inf=math.sqrt(1.4*p_inf/rho_inf) | ||
| vel_inf = 2.5*c_inf | ||
|
|
||
| #Jet inlet conditions | ||
| p_J = 1.0 * p_inf | ||
| vel_J = 41.0 | ||
| rho_J = 1000.0 | ||
|
|
||
| #Viscosities | ||
| mu_inf = 1.85e-5 | ||
| mu_J = 2.67e-3 | ||
|
|
||
| d_jet = 1.2e-3 | ||
|
|
||
| #Simulation parameters | ||
| Ny = 3999 | ||
| Nx = 11999 | ||
| time_end = 5e-4 | ||
| cfl = 0.6 | ||
| eps=1e-8 | ||
|
|
||
| #Case dictionary | ||
|
|
||
| print( | ||
| json.dumps( | ||
| { | ||
| #Logistics | ||
| "run_time_info": "T", | ||
| #Computational domain parameters | ||
| "x_domain%beg": -40*d_jet, | ||
| "x_domain%end": 60*d_jet, | ||
| "y_domain%beg": 0.0, | ||
| "y_domain%end": 35*d_jet, | ||
| "m": int(Nx), | ||
| "n": int(Ny), | ||
| "p": 0, | ||
| "cfl_adap_dt": "T", | ||
| "t_stop": time_end, | ||
| "t_save": time_end/50, | ||
| "n_start":0, | ||
| "cfl_target": cfl, | ||
| #Simulation algorithm parameters | ||
| "num_patches": 2, | ||
| "model_eqns": 3, | ||
| "alt_soundspeed": "F", | ||
| "num_fluids": 2, | ||
| "mpp_lim": "T", | ||
| "mixture_err": "F", | ||
| "time_stepper": 3, | ||
| "recon_type": 2, | ||
| "muscl_order": 2, | ||
| "muscl_lim": 1, | ||
| "riemann_solver": 2, | ||
| "wave_speeds": 1, | ||
| "avg_state": 2, | ||
| "elliptic_smoothing":"T", | ||
| "elliptic_smoothing_iters": 10, #50, | ||
| "bc_x%beg": -17, | ||
| "bc_x%end": -12, | ||
| "bc_y%beg": -17, | ||
| "bc_y%end": -3, | ||
| "num_bc_patches": 0, | ||
| #Formatted Database File Structures | ||
| "format": 1, | ||
| "precision": 2, | ||
| "prim_vars_wrt": "T", | ||
| "parallel_io": "T", | ||
| #Patch 1: Free stream | ||
| "patch_icpp(1)%geometry": 3, | ||
| "patch_icpp(1)%x_centroid": 0.0, | ||
| "patch_icpp(1)%y_centroid":50*djet, | ||
| "patch_icpp(1)%length_x": 1000*djet, | ||
| "patch_icpp(1)%length_y": 1000*djet, | ||
| "patch_icpp(1)%vel(1)": f"{vel_inf} * tanh(y / {d_jet / 4})", | ||
| "patch_icpp(1)%vel(2)": 0.0, | ||
| "patch_icpp(1)%pres": p_inf, | ||
| "patch_icpp(1)%alpha_rho(1)": rho_inf*(1.0-eps), | ||
| "patch_icpp(1)%alpha(1)": 1.0-eps, | ||
| "patch_icpp(1)%alpha_rho(2)":eps, | ||
| "patch_icpp(1)%alpha(2)": eps, | ||
| #Patch 2: Jet | ||
| "patch_icpp(2)%geometry": 3, | ||
| "patch_icpp(2)%alter_patch(1)": "T", | ||
| "patch_icpp(2)%x_centroid": 0.0, | ||
| "patch_icpp(2)%y_centroid": 0.0, | ||
| "patch_icpp(2)%length_x": d_jet, | ||
| "patch_icpp(2)%length_y": d_jet, | ||
| "patch_icpp(2)%vel(1)": 0.0, | ||
| "patch_icpp(2)%vel(2)": vel_J, | ||
| "patch_icpp(2)%pres": p_J, | ||
| "patch_icpp(2)%alpha_rho(1)": eps, | ||
| "patch_icpp(2)%alpha(1)": eps, | ||
| "patch_icpp(2)%alpha_rho(2)":(1.0-eps)*rho_J, | ||
| "patch_icpp(2)%alpha(2)": 1.0-eps, | ||
| #Fluid properties | ||
| "fluid_pp(1)%gamma": 1.00/(1.4-1.0), | ||
| "fluid_pp(1)%pi_inf": 0.0, | ||
| "fluid_pp(2)%gamma": 1.0/(6.12-1.0), | ||
| "fluid_pp(2)%pi_inf": 6.12 * 3.43e8 / (6.12 - 1), | ||
| "viscous": "T", | ||
| "fluid_pp(1)%Re(1)": 1/mu_inf, | ||
| "fluid_pp(2)%Re(1)": 1/mu_J, | ||
| "surface_tension": "T", | ||
| "cf_wrt": "T", | ||
| "sigma": 0.072, | ||
| } | ||
| ) | ||
| ) | ||
|
|
There was a problem hiding this comment.
Run repository formatter before committing
CI shows this file was auto-reformatted, so the current diff is not formatting-clean and will keep failing checks until formatted output is staged.
./mfc.sh format -j 8
git add examples/2D_jet_in_crossflow/case_2D_jicf.pyAs per coding guidelines: "**/*.{fpp,f90,py}: Run ./mfc.sh format -j 8 to auto-format Fortran (.fpp/.f90) and Python files before committing".
🧰 Tools
🪛 GitHub Actions: Lint Toolchain
[error] 1-1: Precheck formatting check failed (mfc: Checking formatting). Code was not formatted; file was auto-formatted—review and stage the changes.
🪛 GitHub Actions: Pretty
[error] 1-1: CI formatting check failed: ./mfc.sh format reformatted 1 file, but git diff --exit-code detected changes (process exited with code 1). File reformatted: examples/2D_jet_in_crossflow/case_2D_jicf.py.
🪛 Ruff (0.15.9)
[error] 77-77: Undefined name djet
(F821)
[error] 78-78: Undefined name djet
(F821)
[error] 79-79: Undefined name djet
(F821)
| "patch_icpp(1)%y_centroid":50*djet, | ||
| "patch_icpp(1)%length_x": 1000*djet, | ||
| "patch_icpp(1)%length_y": 1000*djet, |
There was a problem hiding this comment.
Fix undefined variable typo (djet → d_jet)
Line 77–79 use djet, but only d_jet is defined (Line 19). This will crash the case script with NameError before it can emit JSON.
🐛 Proposed fix
- "patch_icpp(1)%y_centroid":50*djet,
- "patch_icpp(1)%length_x": 1000*djet,
- "patch_icpp(1)%length_y": 1000*djet,
+ "patch_icpp(1)%y_centroid": 50 * d_jet,
+ "patch_icpp(1)%length_x": 1000 * d_jet,
+ "patch_icpp(1)%length_y": 1000 * d_jet,🧰 Tools
🪛 Ruff (0.15.9)
[error] 77-77: Undefined name djet
(F821)
[error] 78-78: Undefined name djet
(F821)
[error] 79-79: Undefined name djet
(F821)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1372 +/- ##
==========================================
- Coverage 64.90% 64.84% -0.06%
==========================================
Files 70 70
Lines 18254 18217 -37
Branches 1508 1500 -8
==========================================
- Hits 11847 11813 -34
- Misses 5444 5449 +5
+ Partials 963 955 -8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This script sets up parameters for a 2D jet in supersonic crossflow simulation, including free stream conditions, jet inlet conditions, viscosities, simulation parameters, and case dictionary for the simulation.
Description
Added case file for a 2D jet in supersonic crossflow case
Fixes #(issue)
Type of change
New example case
Testing
How did you test your changes?
Checklist
See the developer guide for full coding standards.
GPU changes (expand if you modified
src/simulation/)AI code reviews
Reviews are not triggered automatically. To request a review, comment on the PR:
@coderabbitai review— incremental review (new changes only)@coderabbitai full review— full review from scratch/review— Qodo review/improve— Qodo code suggestions@claude full review— Claude full review (also triggers on PR open/reopen/ready)claude-full-review— Claude full review via label