|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# Planar shock (driven by a Dirichlet inflow) hitting a dense particle curtain between slip walls |
| 3 | +# (Euler-Lagrange, two-way coupling). The particles come from gen_particles.py. |
| 4 | +import argparse |
| 5 | +import json |
| 6 | +import math |
| 7 | +import os |
| 8 | + |
| 9 | +import gen_particles |
| 10 | + |
| 11 | +parser = argparse.ArgumentParser(prog="2D_particle_curtain", formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
| 12 | +parser.add_argument("--mfc", type=json.loads, default="{}", metavar="DICT", help="MFC's toolchain's internal state.") |
| 13 | +args = parser.parse_args() |
| 14 | + |
| 15 | +# Write input/particles.dat only when ./mfc.sh run runs pre_process (validate, test and docs also load this file) |
| 16 | +if args.mfc.get("command") == "run" and "pre_process" in args.mfc.get("targets", []): |
| 17 | + gen_particles.write_particles(os.path.dirname(os.path.abspath(__file__))) |
| 18 | + |
| 19 | +# Air (ideal gas) |
| 20 | +gamma = 1.4 |
| 21 | +R_air = 287.0 # J/(kg K) |
| 22 | + |
| 23 | + |
| 24 | +def normal_shock(M, p1, rho1): |
| 25 | + """Pressure, density and lab-frame velocity behind a normal shock of Mach number M moving into still gas (p1, rho1).""" |
| 26 | + p2 = p1 * (1.0 + 2.0 * gamma / (gamma + 1.0) * (M**2 - 1.0)) |
| 27 | + rho2 = rho1 * (gamma + 1.0) * M**2 / ((gamma - 1.0) * M**2 + 2.0) |
| 28 | + u2 = 2.0 / (gamma + 1.0) * math.sqrt(gamma * p1 / rho1) * (M - 1.0 / M) |
| 29 | + return p2, rho2, u2 |
| 30 | + |
| 31 | + |
| 32 | +# Ambient air (Wagner et al. 2012) and the state behind the incident shock |
| 33 | +M_shock = 1.66 |
| 34 | +p_amb, T_amb = 82700.0, 296.4 |
| 35 | +rho_amb = p_amb / (R_air * T_amb) |
| 36 | +p_post, rho_post, u_post = normal_shock(M_shock, p_amb, rho_amb) |
| 37 | + |
| 38 | +# Grid: x in [-0.2, 0.3], y in [0, 0.015] (slip walls at y = 0 and y = 0.015) |
| 39 | +xb, xe, yb, ye = -0.2, 0.3, 0.0, 0.015 |
| 40 | +Nx, Ny = 2000, 30 |
| 41 | +dx = (xe - xb) / Nx |
| 42 | + |
| 43 | +print( |
| 44 | + json.dumps( |
| 45 | + { |
| 46 | + # Logistics |
| 47 | + "run_time_info": "T", |
| 48 | + # Computational domain |
| 49 | + "x_domain%beg": xb, |
| 50 | + "x_domain%end": xe, |
| 51 | + "y_domain%beg": yb, |
| 52 | + "y_domain%end": ye, |
| 53 | + "m": Nx - 1, |
| 54 | + "n": Ny - 1, |
| 55 | + "p": 0, |
| 56 | + "cfl_adap_dt": "T", |
| 57 | + "cfl_target": 0.4, |
| 58 | + "n_start": 0, |
| 59 | + "t_stop": 5.0e-4, |
| 60 | + "t_save": 5.0e-5, |
| 61 | + # Simulation algorithm |
| 62 | + "model_eqns": 2, |
| 63 | + "num_fluids": 1, |
| 64 | + "num_patches": 2, |
| 65 | + "time_stepper": 3, |
| 66 | + "weno_order": 5, |
| 67 | + "weno_eps": 1.0e-16, |
| 68 | + "mapped_weno": "T", |
| 69 | + "mp_weno": "T", |
| 70 | + "riemann_solver": 2, |
| 71 | + "wave_speeds": 1, |
| 72 | + "avg_state": 2, |
| 73 | + "bc_x%beg": -17, |
| 74 | + "bc_x%end": -8, |
| 75 | + "bc_y%beg": -15, |
| 76 | + "bc_y%end": -15, |
| 77 | + # Output |
| 78 | + "format": 1, |
| 79 | + "precision": 2, |
| 80 | + "prim_vars_wrt": "T", |
| 81 | + "parallel_io": "T", |
| 82 | + "lag_db_wrt": "T", |
| 83 | + "lag_voidfrac_wrt": "T", |
| 84 | + # Patch 1: ambient air |
| 85 | + "patch_icpp(1)%geometry": 3, |
| 86 | + "patch_icpp(1)%x_centroid": 0.5 * (xb + xe), |
| 87 | + "patch_icpp(1)%y_centroid": 0.5 * (yb + ye), |
| 88 | + "patch_icpp(1)%length_x": xe - xb, |
| 89 | + "patch_icpp(1)%length_y": ye - yb, |
| 90 | + "patch_icpp(1)%vel(1)": 0.0, |
| 91 | + "patch_icpp(1)%vel(2)": 0.0, |
| 92 | + "patch_icpp(1)%pres": p_amb, |
| 93 | + "patch_icpp(1)%alpha_rho(1)": rho_amb, |
| 94 | + "patch_icpp(1)%alpha(1)": 1.0, |
| 95 | + # Patch 2: post-shock state on the left (x < -5 mm); the Dirichlet inflow holds it |
| 96 | + "patch_icpp(2)%geometry": 3, |
| 97 | + "patch_icpp(2)%alter_patch(1)": "T", |
| 98 | + "patch_icpp(2)%x_centroid": -0.1025, |
| 99 | + "patch_icpp(2)%y_centroid": 0.5 * (yb + ye), |
| 100 | + "patch_icpp(2)%length_x": 0.195, |
| 101 | + "patch_icpp(2)%length_y": ye - yb, |
| 102 | + "patch_icpp(2)%vel(1)": u_post, |
| 103 | + "patch_icpp(2)%vel(2)": 0.0, |
| 104 | + "patch_icpp(2)%pres": p_post, |
| 105 | + "patch_icpp(2)%alpha_rho(1)": rho_post, |
| 106 | + "patch_icpp(2)%alpha(1)": 1.0, |
| 107 | + # Fluid: air |
| 108 | + "fluid_pp(1)%eos": "ideal_gas", |
| 109 | + "fluid_pp(1)%gamma": 1.0 / (gamma - 1.0), |
| 110 | + "fluid_pp(1)%cv": 717.5, |
| 111 | + # Lagrangian particles |
| 112 | + "particles_lagrange": "T", |
| 113 | + "fd_order": 2, |
| 114 | + "particle_pp%rho0ref_particle": 2520.0, |
| 115 | + "particle_params%input_path": "input/particles.dat", |
| 116 | + "particle_params%nparticles_glb": gen_particles.n_particles, |
| 117 | + "particle_params%solver_approach": 2, |
| 118 | + "particle_params%qs_force": 3, |
| 119 | + "particle_params%pressure_gradient_force": "T", |
| 120 | + "particle_params%added_mass_force": 1, |
| 121 | + "particle_params%mu_ref(1)": 1.716e-5, |
| 122 | + "particle_params%suth(1)": 110.4, |
| 123 | + "particle_params%interpolation_order": 2, |
| 124 | + "particle_params%epsilonb": 1.0, |
| 125 | + "particle_params%valmaxvoid": 0.9, |
| 126 | + "particle_params%charwidth": gen_particles.charwidth, |
| 127 | + }, |
| 128 | + indent=4, |
| 129 | + ) |
| 130 | +) |
0 commit comments