-
Notifications
You must be signed in to change notification settings - Fork 173
Euler-Lagrange capabilities - Phase 1 #1926
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
Draft
thierrydaoud
wants to merge
1
commit into
MFlowCode:master
Choose a base branch
from
thierrydaoud:el-phase1
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.
+6,502
−656
Draft
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # 2D Shock–Particle Curtain Interaction | ||
|
|
||
| A Mach 1.66 planar shock, held by a Dirichlet inflow, hits a 2 mm thick curtain of glass particles (radius 57.5 µm, volume fraction 0.21) in 82.7 kPa air between slip walls. It uses the Euler-Lagrange solid-particle solver (`particles_lagrange`) with two-way coupling, Osnes quasi-steady drag, pressure-gradient force and added mass. | ||
|
|
||
| The setup follows the multiphase shock tube experiment of Wagner et al. (2012): | ||
| > J. L. Wagner, S. J. Beresh, S. P. Kearney, W. M. Trott, J. N. Castaneda, B. O. Pruett, and M. R. Baer, "A multiphase shock tube for shock wave interactions with dense particle fields", Experiments in Fluids, vol. 52, no. 6, pp. 1507–1517, 2012. https://doi.org/10.1007/s00348-012-1272-x | ||
|
|
||
| `gen_particles.py` writes the particles (seeded, uniform in the curtain band) to `input/particles.dat`; `case.py` calls it when pre_process runs, or run it yourself with `python3 gen_particles.py`. In 2D each particle stands for a slab of depth `charwidth`, so projected particles may overlap. | ||
|
|
||
| ```shell | ||
| ./mfc.sh run examples/2D_particle_curtain/case.py -n 4 | ||
| ``` | ||
|
|
||
| ## Result | ||
|
|
||
| Density-gradient schlieren |∇ρ|/ρ with the particles (white) at t = 500 µs. | ||
|
|
||
| <img src="result.png"/> | ||
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,130 @@ | ||
| #!/usr/bin/env python3 | ||
| # Planar shock (driven by a Dirichlet inflow) hitting a dense particle curtain between slip walls | ||
| # (Euler-Lagrange, two-way coupling). The particles come from gen_particles.py. | ||
| import argparse | ||
| import json | ||
| import math | ||
| import os | ||
|
|
||
| import gen_particles | ||
|
|
||
| parser = argparse.ArgumentParser(prog="2D_particle_curtain", formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
| parser.add_argument("--mfc", type=json.loads, default="{}", metavar="DICT", help="MFC's toolchain's internal state.") | ||
| args = parser.parse_args() | ||
|
|
||
| # Write input/particles.dat only when ./mfc.sh run runs pre_process (validate, test and docs also load this file) | ||
| if args.mfc.get("command") == "run" and "pre_process" in args.mfc.get("targets", []): | ||
| gen_particles.write_particles(os.path.dirname(os.path.abspath(__file__))) | ||
|
|
||
| # Air (ideal gas) | ||
| gamma = 1.4 | ||
| R_air = 287.0 # J/(kg K) | ||
|
|
||
|
|
||
| def normal_shock(M, p1, rho1): | ||
| """Pressure, density and lab-frame velocity behind a normal shock of Mach number M moving into still gas (p1, rho1).""" | ||
| p2 = p1 * (1.0 + 2.0 * gamma / (gamma + 1.0) * (M**2 - 1.0)) | ||
| rho2 = rho1 * (gamma + 1.0) * M**2 / ((gamma - 1.0) * M**2 + 2.0) | ||
| u2 = 2.0 / (gamma + 1.0) * math.sqrt(gamma * p1 / rho1) * (M - 1.0 / M) | ||
| return p2, rho2, u2 | ||
|
|
||
|
|
||
| # Ambient air (Wagner et al. 2012) and the state behind the incident shock | ||
| M_shock = 1.66 | ||
| p_amb, T_amb = 82700.0, 296.4 | ||
| rho_amb = p_amb / (R_air * T_amb) | ||
| p_post, rho_post, u_post = normal_shock(M_shock, p_amb, rho_amb) | ||
|
|
||
| # Grid: x in [-0.2, 0.3], y in [0, 0.015] (slip walls at y = 0 and y = 0.015) | ||
| xb, xe, yb, ye = -0.2, 0.3, 0.0, 0.015 | ||
| Nx, Ny = 2000, 30 | ||
| dx = (xe - xb) / Nx | ||
|
|
||
| print( | ||
| json.dumps( | ||
| { | ||
| # Logistics | ||
| "run_time_info": "T", | ||
| # Computational domain | ||
| "x_domain%beg": xb, | ||
| "x_domain%end": xe, | ||
| "y_domain%beg": yb, | ||
| "y_domain%end": ye, | ||
| "m": Nx - 1, | ||
| "n": Ny - 1, | ||
| "p": 0, | ||
| "cfl_adap_dt": "T", | ||
| "cfl_target": 0.4, | ||
| "n_start": 0, | ||
| "t_stop": 5.0e-4, | ||
| "t_save": 5.0e-5, | ||
| # Simulation algorithm | ||
| "model_eqns": 2, | ||
| "num_fluids": 1, | ||
| "num_patches": 2, | ||
| "time_stepper": 3, | ||
| "weno_order": 5, | ||
| "weno_eps": 1.0e-16, | ||
| "mapped_weno": "T", | ||
| "mp_weno": "T", | ||
| "riemann_solver": 2, | ||
| "wave_speeds": 1, | ||
| "avg_state": 2, | ||
| "bc_x%beg": -17, | ||
| "bc_x%end": -8, | ||
| "bc_y%beg": -15, | ||
| "bc_y%end": -15, | ||
| # Output | ||
| "format": 1, | ||
| "precision": 2, | ||
| "prim_vars_wrt": "T", | ||
| "parallel_io": "T", | ||
| "lag_db_wrt": "T", | ||
| "lag_voidfrac_wrt": "T", | ||
| # Patch 1: ambient air | ||
| "patch_icpp(1)%geometry": 3, | ||
| "patch_icpp(1)%x_centroid": 0.5 * (xb + xe), | ||
| "patch_icpp(1)%y_centroid": 0.5 * (yb + ye), | ||
| "patch_icpp(1)%length_x": xe - xb, | ||
| "patch_icpp(1)%length_y": ye - yb, | ||
| "patch_icpp(1)%vel(1)": 0.0, | ||
| "patch_icpp(1)%vel(2)": 0.0, | ||
| "patch_icpp(1)%pres": p_amb, | ||
| "patch_icpp(1)%alpha_rho(1)": rho_amb, | ||
| "patch_icpp(1)%alpha(1)": 1.0, | ||
| # Patch 2: post-shock state on the left (x < -5 mm); the Dirichlet inflow holds it | ||
| "patch_icpp(2)%geometry": 3, | ||
| "patch_icpp(2)%alter_patch(1)": "T", | ||
| "patch_icpp(2)%x_centroid": -0.1025, | ||
| "patch_icpp(2)%y_centroid": 0.5 * (yb + ye), | ||
| "patch_icpp(2)%length_x": 0.195, | ||
| "patch_icpp(2)%length_y": ye - yb, | ||
| "patch_icpp(2)%vel(1)": u_post, | ||
| "patch_icpp(2)%vel(2)": 0.0, | ||
| "patch_icpp(2)%pres": p_post, | ||
| "patch_icpp(2)%alpha_rho(1)": rho_post, | ||
| "patch_icpp(2)%alpha(1)": 1.0, | ||
| # Fluid: air | ||
| "fluid_pp(1)%eos": "ideal_gas", | ||
| "fluid_pp(1)%gamma": 1.0 / (gamma - 1.0), | ||
| "fluid_pp(1)%cv": 717.5, | ||
| # Lagrangian particles | ||
| "particles_lagrange": "T", | ||
| "fd_order": 2, | ||
| "particle_pp%rho0ref_particle": 2520.0, | ||
| "particle_params%input_path": "input/particles.dat", | ||
| "particle_params%nparticles_glb": gen_particles.n_particles, | ||
| "particle_params%solver_approach": 2, | ||
| "particle_params%qs_force": 3, | ||
| "particle_params%pressure_gradient_force": "T", | ||
| "particle_params%added_mass_force": 1, | ||
| "particle_params%mu_ref(1)": 1.716e-5, | ||
| "particle_params%suth(1)": 110.4, | ||
| "particle_params%interpolation_order": 2, | ||
|
thierrydaoud marked this conversation as resolved.
|
||
| "particle_params%epsilonb": 1.0, | ||
| "particle_params%valmaxvoid": 0.9, | ||
| "particle_params%charwidth": gen_particles.charwidth, | ||
| }, | ||
| indent=4, | ||
| ) | ||
| ) | ||
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,31 @@ | ||
| #!/usr/bin/env python3 | ||
| # Writes <outdir>/input/particles.dat for the particle curtain (default outdir: this example's directory). | ||
| # case.py calls it when pre_process runs; the test suite calls it for the Example test. | ||
| import math | ||
| import os | ||
| import random | ||
| import sys | ||
|
|
||
| # Glass particles, radius 57.5 um, volume fraction 0.21 in the band x in [0, 2 mm] across the channel y in [0, 15 mm]. | ||
| # In 2D each particle stands for a slab of depth charwidth, so projected particles may overlap (collisions are not modeled). | ||
| rp = 57.5e-6 | ||
| x_curtain = (0.0, 2.0e-3) | ||
| y_channel = (0.0, 0.015) | ||
| vf = 0.21 | ||
| charwidth = 2.5e-4 # the grid spacing | ||
| n_particles = round(vf * (x_curtain[1] - x_curtain[0]) * (y_channel[1] - y_channel[0]) * charwidth / (4.0 / 3.0 * math.pi * rp**3)) | ||
|
|
||
|
|
||
| def write_particles(outdir): | ||
| """Uniform random (seeded) positions in the curtain band, one line per particle: x, y, z, u, v, w, radius.""" | ||
| random.seed(1) | ||
| os.makedirs(os.path.join(outdir, "input"), exist_ok=True) | ||
| with open(os.path.join(outdir, "input", "particles.dat"), "w") as f: | ||
| for _ in range(n_particles): | ||
| x = random.uniform(*x_curtain) | ||
| y = random.uniform(y_channel[0] + rp, y_channel[1] - rp) | ||
| f.write(f"{x:.16e} {y:.16e} 0.0 0.0 0.0 0.0 {rp:.16e}\n") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| write_particles(sys.argv[1] if len(sys.argv) > 1 else os.path.dirname(os.path.abspath(__file__))) |
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,15 @@ | ||
| # 2D Blast Wave Through a Particle Half-Ring | ||
|
|
||
| A Mach 10 cylindrical blast wave, released from a high-pressure driver at the origin, hits a half-ring of 1612 magnesium particles (radius 50 µm) in air. It uses the Euler-Lagrange solid-particle solver (`particles_lagrange`) with two-way coupling, Osnes quasi-steady drag, pressure-gradient force and added mass. | ||
|
|
||
| `gen_particles.py` writes the particles (seeded random placement without overlaps, radius 11.05–12.65 mm) to `input/particles.dat`; `case.py` calls it when pre_process runs, or run it yourself with `python3 gen_particles.py`. | ||
|
|
||
| ```shell | ||
| ./mfc.sh run examples/2D_particle_hemisphere/case.py -n 4 | ||
| ``` | ||
|
thierrydaoud marked this conversation as resolved.
|
||
|
|
||
| ## Result | ||
|
|
||
| Density-gradient schlieren |∇ρ|/ρ with the particles (white) at t = 50 µs. | ||
|
|
||
| <img src="result.png"/> | ||
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.
Uh oh!
There was an error while loading. Please reload this page.