Skip to content

Commit 72df181

Browse files
dgvacareveloDiego VacaDiego VacaDiego Vaca
authored
Strang Splitting for lagrange bubbles (#827)
Co-authored-by: Diego Vaca <diegovaca@autoreg-6682246.dyn.wpi.edu> Co-authored-by: Diego Vaca <diegovaca@Mac.lan> Co-authored-by: Diego Vaca <diegovaca@Diegos-MacBook-Pro-128.local>
1 parent 40164cf commit 72df181

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1564
-2183
lines changed

docs/documentation/case.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ The effect and use of the source term are assessed by [Schmidmayer et al., 2019]
436436
- `time_stepper` specifies the order of the Runge-Kutta (RK) time integration scheme that is used for temporal integration in simulation, from the 1st to 5th order by corresponding integer.
437437
Note that `time_stepper = 3` specifies the total variation diminishing (TVD), third order RK scheme ([Gottlieb and Shu, 1998](references.md)).
438438

439-
- `adap_dt` activates the Strang operator splitting scheme which splits flux and source terms in time marching, and an adaptive time stepping strategy is implemented for the source term. It requires ``bubbles = 'T'``, ``polytropic = 'T'``, ``adv_n = 'T'`` and `time_stepper = 3`.
439+
- `adap_dt` activates the Strang operator splitting scheme which splits flux and source terms in time marching, and an adaptive time stepping strategy is implemented for the source term. It requires ``bubbles_euler = 'T'``, ``polytropic = 'T'``, ``adv_n = 'T'`` and `time_stepper = 3`. Additionally, it can be used with ``bubbles_lagrange = 'T'`` and `time_stepper = 3`
440440

441441
- `weno_order` specifies the order of WENO scheme that is used for spatial reconstruction of variables by an integer of 1, 3, 5, and 7, that correspond to the 1st, 3rd, 5th, and 7th order, respectively.
442442

@@ -790,8 +790,6 @@ When ``polytropic = 'F'``, the gas compression is modeled as non-polytropic due
790790
| `x0` | Real | Reference length |
791791
| `Thost` | Real | Temperature of the surrounding liquid (host) |
792792
| `diffcoefvap` | Real | Vapor diffusivity in the gas |
793-
| `rkck_adap_dt` | Logical | Activates the adaptive rkck time stepping algorithm |
794-
| `rkck_tolerance` | Real | Admissible error truncation tolerance in the rkck stepper |
795793

796794
- `nBubs_glb` Total number of bubbles. Their initial conditions need to be specified in the ./input/lag_bubbles.dat file. See the example cases for additional information.
797795

@@ -805,8 +803,6 @@ When ``polytropic = 'F'``, the gas compression is modeled as non-polytropic due
805803

806804
- `massTransfer_model` Activates the mass transfer model at the bubble's interface based on ([Preston et al., 2007](references.md)).
807805

808-
- `rkck_adap_dt` Activates the adaptive 4th/5th order Runge—Kutta–Cash–Karp (RKCK) time-stepping algorithm (requires `time_stepper ==4`). A maximum error between the 4th and 5th order Runge-Kutta-Cash-Karp solutions for the same time step size is calculated. If the error is smaller than a tolerance (`rkck_tolerance`), then the algorithm employs the 5th order solution, while if not, both eulerian/lagrangian variables are re-calculated with a smaller time step size.
809-
810806
### 10. Velocity Field Setup
811807

812808
| Parameter | Type | Description |
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
#!/usr/bin/env python3
2+
import math
3+
import json
4+
5+
# Bubble screen
6+
# Description: A planar acoustic wave interacts with a bubble cloud
7+
# in water. The background field is modeled in using an Eulerian framework,
8+
# while the bubbles are tracked using a Lagrangian framework.
9+
10+
# Reference values for nondimensionalization
11+
x0 = 1.0e-03 # length - m
12+
rho0 = 1.0e03 # density - kg/m3
13+
c0 = 1475.0 # speed of sound - m/s
14+
p0 = rho0 * c0 * c0 # pressure - Pa
15+
T0 = 298 # temperature - K
16+
17+
# Host properties (water)
18+
gamma_host = 2.7466 # Specific heat ratio
19+
pi_inf_host = 792.02e06 # Stiffness - Pa
20+
mu_host = 1e-3 # Dynamic viscosity - Pa.s
21+
c_host = 1475.0 # speed of sound - m/s
22+
rho_host = 1000 # density kg/m3
23+
T_host = 298 # temperature K
24+
25+
# Lagrangian bubbles' properties
26+
R_uni = 8314 # Universal gas constant - J/kmol/K
27+
MW_g = 28.0 # Molar weight of the gas - kg/kmol
28+
MW_v = 18.0 # Molar weight of the vapor - kg/kmol
29+
gamma_g = 1.4 # Specific heat ratio of the gas
30+
gamma_v = 1.333 # Specific heat ratio of the vapor
31+
pv = 2350 # Vapor pressure of the host - Pa
32+
cp_g = 1.0e3 # Specific heat of the gas - J/kg/K
33+
cp_v = 2.1e3 # Specific heat of the vapor - J/kg/K
34+
k_g = 0.025 # Thermal conductivity of the gas - W/m/K
35+
k_v = 0.02 # Thermal conductivity of the vapor - W/m/K
36+
diffVapor = 2.5e-5 # Diffusivity coefficient of the vapor - m2/s
37+
sigBubble = 0.069 # Surface tension of the bubble - N/m
38+
mu_g = 1.48e-5
39+
40+
# Acoustic source properties
41+
patm = 101325.0 # Atmospheric pressure - Pa
42+
pamp = 1.0e5 # Amplitude of the acoustic source - Pa
43+
freq = 300e03 # Source frequency - Hz
44+
wlen = c_host / freq # Wavelength - m
45+
46+
# Domain and time set up
47+
48+
xb = -12.0e-3 # Domain boundaries - m (x direction)
49+
xe = 12.0e-3
50+
yb = -2.5e-3 # Domain boundaries - m (y direction)
51+
ye = 2.5e-3
52+
z_virtual = 5.0e-3 # Virtual depth (z direction)
53+
54+
Nx = 240 # number of elements into x direction
55+
Ny = 50 # number of elements into y direction
56+
57+
dt = 7.5e-9 # constant time-step - sec
58+
59+
# Configuring case dictionary
60+
print(
61+
json.dumps(
62+
{
63+
# Logistics
64+
"run_time_info": "T",
65+
# Computational Domain Parameters
66+
"x_domain%beg": xb / x0,
67+
"x_domain%end": xe / x0,
68+
"y_domain%beg": yb / x0,
69+
"y_domain%end": ye / x0,
70+
"stretch_y": "F",
71+
"stretch_x": "F",
72+
"m": Nx,
73+
"n": Ny,
74+
"p": 0,
75+
"dt": dt * (c0 / x0),
76+
"t_step_start": 0,
77+
"t_step_stop": 3000,
78+
"t_step_save": 500,
79+
# Simulation Algorithm Parameters
80+
"model_eqns": 2,
81+
"time_stepper": 3,
82+
"num_fluids": 2,
83+
"num_patches": 1,
84+
"viscous": "T",
85+
"mpp_lim": "F",
86+
"weno_order": 5,
87+
"weno_eps": 1.0e-16,
88+
"mapped_weno": "T",
89+
"riemann_solver": 2,
90+
"wave_speeds": 1,
91+
"avg_state": 2,
92+
"bc_x%beg": -6,
93+
"bc_x%end": -6,
94+
"bc_y%beg": -1,
95+
"bc_y%end": -1,
96+
# Acoustic source
97+
"acoustic_source": "T",
98+
"num_source": 1,
99+
"acoustic(1)%support": 2,
100+
"acoustic(1)%pulse": 1,
101+
"acoustic(1)%npulse": 1,
102+
"acoustic(1)%mag": pamp / p0,
103+
"acoustic(1)%wavelength": wlen / x0,
104+
"acoustic(1)%length": 2 * (ye - yb) / x0,
105+
"acoustic(1)%loc(1)": -7.0e-03 / x0,
106+
"acoustic(1)%loc(2)": 0.0,
107+
"acoustic(1)%dir": 0.0,
108+
"acoustic(1)%delay": 0.0,
109+
# Formatted Database Files Structure Parameters
110+
"format": 1,
111+
"precision": 2,
112+
"prim_vars_wrt": "T",
113+
"parallel_io": "T",
114+
# Patch 1: Water (left)
115+
"patch_icpp(1)%geometry": 3,
116+
"patch_icpp(1)%x_centroid": 0.0,
117+
"patch_icpp(1)%y_centroid": 0.0,
118+
"patch_icpp(1)%length_x": 2 * (xe - xb) / x0,
119+
"patch_icpp(1)%length_y": 2 * (ye - yb) / x0,
120+
"patch_icpp(1)%vel(1)": 0.0,
121+
"patch_icpp(1)%vel(2)": 0.0,
122+
"patch_icpp(1)%pres": patm / p0,
123+
"patch_icpp(1)%alpha_rho(1)": rho_host / rho0,
124+
"patch_icpp(1)%alpha_rho(2)": 0.0,
125+
"patch_icpp(1)%alpha(1)": 1.0,
126+
"patch_icpp(1)%alpha(2)": 0.0,
127+
# Lagrangian Bubbles
128+
"bubbles_lagrange": "T",
129+
"bubble_model": 2, # Keller-Miksis model
130+
"lag_params%nBubs_glb": 1194, # Number of bubbles
131+
"lag_params%solver_approach": 2,
132+
"lag_params%cluster_type": 2,
133+
"lag_params%pressure_corrector": "T",
134+
"lag_params%smooth_type": 1,
135+
"lag_params%heatTransfer_model": "T",
136+
"lag_params%massTransfer_model": "T",
137+
"lag_params%epsilonb": 1.0,
138+
"lag_params%valmaxvoid": 0.9,
139+
"lag_params%write_bubbles": "F",
140+
"lag_params%write_bubbles_stats": "F",
141+
"lag_params%c0": c0,
142+
"lag_params%rho0": rho0,
143+
"lag_params%T0": T0,
144+
"lag_params%x0": x0,
145+
"lag_params%diffcoefvap": diffVapor,
146+
"lag_params%Thost": T_host,
147+
"lag_params%charwidth": z_virtual / x0,
148+
# Fluids Physical Parameters
149+
# Host medium
150+
"fluid_pp(1)%gamma": 1.0 / (gamma_host - 1.0),
151+
"fluid_pp(1)%pi_inf": gamma_host * (pi_inf_host / p0) / (gamma_host - 1.0),
152+
"fluid_pp(1)%Re(1)": 1.0 / (mu_host / (rho0 * c0 * x0)),
153+
"fluid_pp(1)%mul0": mu_host,
154+
"fluid_pp(1)%ss": sigBubble,
155+
"fluid_pp(1)%pv": pv,
156+
"fluid_pp(1)%gamma_v": gamma_v,
157+
"fluid_pp(1)%M_v": MW_v,
158+
"fluid_pp(1)%k_v": k_v,
159+
"fluid_pp(1)%cp_v": cp_v,
160+
# Bubble gas state
161+
"fluid_pp(2)%gamma": 1.0 / (gamma_g - 1.0),
162+
"fluid_pp(2)%pi_inf": 0.0e00,
163+
"fluid_pp(2)%Re(1)": 1.0 / (mu_g / (rho0 * c0 * x0)),
164+
"fluid_pp(2)%gamma_v": gamma_g,
165+
"fluid_pp(2)%M_v": MW_g,
166+
"fluid_pp(2)%k_v": k_g,
167+
"fluid_pp(2)%cp_v": cp_g,
168+
}
169+
)
170+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
The user input file 'input/lag_bubbles.dat' contains the initial conditions of the lagrangian bubbles.
3+
Each row represents the initial state of one specific bubble, which are:
4+
5+
xPosition/x0 yPosition/x0 zPosition/x0 xVel/c0 yVel/c0 zVel/c0 radius/x0 interfaceVelocity/c0

examples/3D_lagrange_shbubcollapse/case.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"n": Ny,
8181
"p": Nz,
8282
"dt": round(dt * c0 / x0, 6),
83+
"adap_dt": "T",
8384
"n_start": 0,
8485
"t_save": saveTime * (c0 / x0),
8586
"t_stop": stopTime * (c0 / x0),
@@ -89,7 +90,7 @@
8990
"num_patches": 1,
9091
"mpp_lim": "F",
9192
"viscous": "T",
92-
"time_stepper": 4, # 4th/5th RKCK
93+
"time_stepper": 3,
9394
"weno_order": 5,
9495
"weno_eps": 1.0e-16,
9596
"mapped_weno": "T",
@@ -141,8 +142,6 @@
141142
# Lagrangian Bubbles
142143
"bubbles_lagrange": "T",
143144
"bubble_model": 2, # Keller-Miksis model
144-
"rkck_adap_dt": "T", # Activate adaptive time stepper
145-
"rkck_tolerance": 1.0e-05,
146145
"lag_params%nBubs_glb": 1,
147146
"lag_params%solver_approach": 2, # Two-way coupled
148147
"lag_params%cluster_type": 2,

src/common/m_checker_common.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ contains
6262
!! Called by s_check_inputs_common for simulation and post-processing
6363
subroutine s_check_inputs_time_stepping
6464
if (cfl_dt) then
65-
@:PROHIBIT((cfl_target < 0 .or. cfl_target > 1._wp) .and. .not. rkck_adap_dt)
65+
@:PROHIBIT(cfl_target < 0 .or. cfl_target > 1._wp)
6666
@:PROHIBIT(t_stop <= 0)
6767
@:PROHIBIT(t_save <= 0)
6868
@:PROHIBIT(t_save > t_stop)

src/common/m_constants.fpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,16 @@ module m_constants
5050
integer, parameter :: mapCells = 3 !< Number of cells around the bubble where the smoothening function will have effect
5151
real(wp), parameter :: R_uni = 8314._wp ! Universal gas constant - J/kmol/K
5252

53-
! RKCK constants
54-
integer, parameter :: num_ts_rkck = 6 !< Number of time-stages in the RKCK stepper
55-
! RKCK 4th/5th time stepper coefficients based on Cash J. and Karp A. (1990)
56-
real(wp), parameter :: rkck_c1 = 0._wp, rkck_c2 = 0.2_wp, rkck_c3 = 0.3_wp, rkck_c4 = 0.6_wp, & ! c1 c2 c3 c4 c5 c6
57-
rkck_c5 = 1._wp, rkck_c6 = 0.875_wp
58-
real(wp), dimension(6), parameter :: rkck_coef1 = (/0.2_wp, 0._wp, 0._wp, 0._wp, 0._wp, 0._wp/) ! a21
59-
real(wp), dimension(6), parameter :: rkck_coef2 = (/3._wp/40._wp, 9._wp/40._wp, 0._wp, 0._wp, & ! a31 a32
60-
0._wp, 0._wp/)
61-
real(wp), dimension(6), parameter :: rkck_coef3 = (/0.3_wp, -0.9_wp, 1.2_wp, 0._wp, 0._wp, 0._wp/) ! a41 a42 a43
62-
real(wp), dimension(6), parameter :: rkck_coef4 = (/-11._wp/54._wp, 2.5_wp, -70._wp/27._wp, & ! a51 a52 a53 a54
63-
35._wp/27._wp, 0._wp, 0._wp/)
64-
real(wp), dimension(6), parameter :: rkck_coef5 = (/1631._wp/55296._wp, 175._wp/512._wp, & ! a61 a62 a63 a64 a65
65-
575._wp/13824._wp, 44275._wp/110592._wp, &
66-
253._wp/4096._wp, 0._wp/)
67-
real(wp), dimension(6), parameter :: rkck_coef6 = (/37._wp/378._wp, 0._wp, 250._wp/621._wp, & ! b1 b2 b3 b4 b5 b6
68-
125._wp/594._wp, 0._wp, 512._wp/1771._wp/)
69-
real(wp), dimension(6), parameter :: rkck_coefE = (/37._wp/378._wp - 2825._wp/27648._wp, 0._wp, & ! er1 er2 er3 er4 er5 er6 (4th/5th error)
70-
250._wp/621._wp - 18575._wp/48384._wp, &
71-
125._wp/594._wp - 13525._wp/55296._wp, &
72-
-277._wp/14336._wp, 512._wp/1771._wp - 0.25_wp/)
73-
! Adaptive rkck constants
74-
real(wp), parameter :: verysmall_dt = 1e-14_wp !< Very small dt, stop stepper
75-
real(wp), parameter :: SAFETY = 0.9_wp !< Next dt will be maximum 0.9*dt if truncation error is above tolerance.
76-
real(wp), parameter :: RNDDEC = 1e8_wp !< Round calculated dt (16th digit) to avoid the inclusion of random decimals
77-
real(wp), parameter :: PSHRNK = -0.25_wp !< Factor to reduce dt when truncation error above tolerance
78-
real(wp), parameter :: SHRNKDT = 0.5_wp !< Factor to reduce dt due to negative bubble radius
79-
real(wp), parameter :: ERRCON = 1.89e-4_wp !< Limit to slightly increase dt when truncation error is between ERRCON and 1
80-
real(wp), parameter :: PGROW = -0.2_wp !< Factor to increase dt when truncation error is between ERRCON and 1
53+
! Strang Splitting constants
54+
real(wp), parameter :: dflt_adap_dt_tol = 1e-4_wp !< Default tolerance for adaptive step size
55+
integer, parameter :: adap_dt_max_iters = 100 !< Maximum number of iterations
56+
! Constants of the algorithm described by Heirer, E. Hairer S.P.Nørsett G. Wanner, Solving Ordinary Differential Equations I, Chapter II.4
57+
! to choose the initial time step size for the adaptive time stepping routine
58+
real(wp), parameter :: threshold_first_guess = 1e-5_wp
59+
real(wp), parameter :: threshold_second_guess = 1e-15_wp
60+
real(wp), parameter :: scale_first_guess = 1e-3_wp
61+
real(wp), parameter :: scale_guess = 1e-2_wp
62+
real(wp), parameter :: small_guess = 1e-6_wp
8163

8264
! Relativity
8365
integer, parameter :: relativity_cons_to_prim_max_iter = 100

src/post_process/m_global_parameters.fpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ module m_global_parameters
314314

315315
!> @name Lagrangian bubbles
316316
!> @{
317-
logical :: bubbles_lagrange, rkck_adap_dt
317+
logical :: bubbles_lagrange
318318
!> @}
319319

320320
real(wp) :: Bx0 !< Constant magnetic field in the x-direction (1D)
@@ -443,7 +443,6 @@ contains
443443

444444
! Lagrangian bubbles modeling
445445
bubbles_lagrange = .false.
446-
rkck_adap_dt = .false.
447446

448447
! IBM
449448
num_ibs = dflt_int

src/post_process/m_mpi_proxy.fpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ contains
170170
& 'file_per_process', 'relax', 'cf_wrt', &
171171
& 'adv_n', 'ib', 'cfl_adap_dt', 'cfl_const_dt', 'cfl_dt', &
172172
& 'surface_tension', 'hyperelasticity', 'bubbles_lagrange', &
173-
& 'rkck_adap_dt', 'output_partial_domain', 'relativity', &
174-
& 'cont_damage' ]
173+
& 'output_partial_domain', 'relativity', 'cont_damage' ]
175174
call MPI_BCAST(${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
176175
#:endfor
177176

src/post_process/m_start_up.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ subroutine s_read_input_file
8383
polydisperse, poly_sigma, file_per_process, relax, &
8484
relax_model, cf_wrt, sigma, adv_n, ib, num_ibs, &
8585
cfl_adap_dt, cfl_const_dt, t_save, t_stop, n_start, &
86-
cfl_target, surface_tension, bubbles_lagrange, rkck_adap_dt, &
86+
cfl_target, surface_tension, bubbles_lagrange, &
8787
sim_data, hyperelasticity, Bx0, relativity, cont_damage
8888

8989
! Inquiring the status of the post_process.inp file
@@ -113,7 +113,7 @@ subroutine s_read_input_file
113113

114114
nGlobal = (m_glb + 1)*(n_glb + 1)*(p_glb + 1)
115115

116-
if (cfl_adap_dt .or. cfl_const_dt .or. rkck_adap_dt) cfl_dt = .true.
116+
if (cfl_adap_dt .or. cfl_const_dt) cfl_dt = .true.
117117

118118
else
119119
call s_mpi_abort('File post_process.inp is missing. Exiting.')

src/pre_process/m_global_parameters.fpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,6 @@ module m_global_parameters
267267
integer :: chemxb, chemxe
268268
!> @}
269269

270-
!> @ lagrangian solver parameters
271-
logical :: rkck_adap_dt
272-
!> @}
273-
274270
integer, allocatable, dimension(:, :, :) :: logic_grid
275271

276272
type(pres_field) :: pb
@@ -545,9 +541,6 @@ contains
545541
fluid_pp(i)%G = 0._wp
546542
end do
547543

548-
! Lagrangian solver
549-
rkck_adap_dt = .false.
550-
551544
Bx0 = dflt_real
552545

553546
end subroutine s_assign_default_values_to_user_inputs

0 commit comments

Comments
 (0)