Skip to content
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

Attempts at TG vortex and perturb magnitude parameter #251

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/documentation/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,18 +505,24 @@ Implementation of the parameterse into the model follow [Ando (2010)](references
| Parameter | Type | Description |
| ---: | :----: | :--- |
| `perturb_flow` | Logical | Perturb the initlal velocity field by random noise |
| `perturb_flow_fluid` | Integer | Fluid density whose flow is to be perturbed |
| `perturb_flow_mag` | Real | Set the magnitude of flow perturbations |
| `perturb_sph` | Logical | Perturb the initial partial density by random noise |
| `perturb_sph_fluid` | Integer | Fluid component whose partial density to be perturbed |
| `perturb_sph_fluid` | Integer | Fluid component whose partial density is to be perturbed |
| `vel_profile` | Logical | Set the mean streamwise velocity to hyperbolic tangent profile |
| `instability_wave` | Logical | Perturb the initial velocity field by instability waves |

The table lists velocity field parameters. The parameters are optionally used to define initial velocity profiles and perturbations.

- `perturb_flow` activates the perturbation of initial velocity by random noise.

- `perturb_sph` activates the perturbation of intial partial density by random noise.
- `perturb_flow_fluid` specifies the fluid component whose flow is to be perturbed.

- `perturb_sph_fluid` specifies the fluid component whose the partial density to be perturbed.
- `perturb_flow` activates the perturbation of initial velocity by random noise.

- `perturb_sph` activates the perturbation of initial partial density by random noise.

- `perturb_sph_fluid` specifies the fluid component whose partial density is to be perturbed.

- `vel_profile` activates setting the mean streamwise velocity to hyperbolic tangent profile. This option works only for 2D and 3D cases.

Expand Down
113 changes: 113 additions & 0 deletions examples/2D_TaylorGreenVortex/case_turb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env python3

import math
import json

gamma = 1.4
Re_lit = 1600
Ma = 0.1

# Dimensions of the Vortex
l = 1.0
L = math.pi*l

pres_i = 1.E+05
alpha_rho1_i = 1.22

# Turbulent Mach Number
c = (gamma * pres_i/alpha_rho1_i) ** 0.5
vel1_i = Ma * c

Mu = alpha_rho1_i * vel1_i * l/Re_lit # Define the fluid's dynamic viscosity

# Numerical setup
Nx = 255
dx = 2 * L/(1.*(Nx+1))

C = 0.3
mydt = C * dx / c
Nt = 1000

# Configuring case dictionary
print(json.dumps({
# Logistics ================================================
'run_time_info' : 'T',
# ==========================================================

# Computational Domain Parameters ==========================
# Periodic Domain from -pi*l to pi*l
'x_domain%beg' : -L,
'x_domain%end' : L,
'y_domain%beg' : -L,
'y_domain%end' : L,
'm' : Nx,
'n' : Nx,
'p' : 0,
'dt' : mydt,
't_step_start' : 0,
't_step_stop' : math.ceil(Nt),
't_step_save' : math.ceil(Nt/10),
# ==========================================================

# Simulation Algorithm Parameters ==========================
'num_patches' : 1,
'model_eqns' : 2,
'alt_soundspeed' : 'F',
'num_fluids' : 1,
'adv_alphan' : 'T',
'mpp_lim' : 'F',
'mixture_err' : 'T',
'time_stepper' : 3,
'weno_order' : 5,
'weno_eps' : 1.E-16,
'mapped_weno' : 'T',
'null_weights' : 'F',
'mp_weno' : 'F',
'weno_Re_flux' : 'T',
'weno_avg' : 'T',
'riemann_solver' : 2,
'wave_speeds' : 1,
'avg_state' : 2,
'perturb_flow' : 'T',
'perturb_flow_fluid' : 1,
'perturb_flow_mag' : 1.E2,
'bc_x%beg' : -1,
'bc_x%end' : -1,
'bc_y%beg' : -1,
'bc_y%end' : -1,
# ==========================================================

# Formatted Database Files Structure Parameters ============
'format' : 1,
'precision' : 2,
'prim_vars_wrt' :'T',
'parallel_io' :'F',
'omega_wrt(3)' :'T',
'fd_order' :'1',
'E_wrt' :'T',
# ==========================================================

# Patch 1: Base ============================================
# Uncomment the configuration of the Taylor Green Vortex in
# 2D analytical patch under m_patch.f90
'patch_icpp(1)%geometry' : 20,
'patch_icpp(1)%x_centroid' : 0.0,
'patch_icpp(1)%y_centroid' : 0.0,
'patch_icpp(1)%length_x' : 2.0*L,
'patch_icpp(1)%length_y' : 2.0*L,
'patch_icpp(1)%vel(1)' : vel1_i, # Define the characteristic velocity of the vortex
'patch_icpp(1)%vel(2)' : l, # Define the characteristic length of the vortex
'patch_icpp(1)%pres' : 1.E+05,
'patch_icpp(1)%alpha_rho(1)' : 1.22,
'patch_icpp(1)%alpha(1)' : 1.,
# ==========================================================


# Fluids Physical Parameters ===============================
'fluid_pp(1)%gamma' : 1.E+00/(gamma-1.E+00),
'fluid_pp(1)%pi_inf' : 0.0,
# Shear viscosity of STD air
'fluid_pp(1)%Re(1)' : 1/Mu,
# ==========================================================
}))
# ==============================================================================
118 changes: 118 additions & 0 deletions examples/3D_TaylorGreenVortex/case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/env python3

import math
import json

gamma = 1.4
Re_lit = 1600
Ma = 0.1

# Dimensions of the Vortex
l = 1.0
L = math.pi*l

pres_i = 1.E+05
alpha_rho1_i = 1.22

# Turbulent Mach Number
c = (gamma * pres_i/alpha_rho1_i) ** 0.5
vel1_i = Ma * c

Mu = alpha_rho1_i * vel1_i * l/Re_lit # Define the fluid's dynamic viscosity

# Numerical setup
Nx = 255
dx = 2 * L/(1.*(Nx+1))

C = 0.3
mydt = C * dx / c
Nt = 1000

# Configuring case dictionary
print(json.dumps({
# Logistics ================================================
'run_time_info' : 'T',
# ==========================================================

# Computational Domain Parameters ==========================
# Periodic Domain from -pi*l to pi*l
'x_domain%beg' : -L,
'x_domain%end' : L,
'y_domain%beg' : -L,
'y_domain%end' : L,
'z_domain%beg' : -L,
'z_domain%end' : L,
'm' : Nx,
'n' : Nx,
'p' : Nx,
'dt' : mydt,
't_step_start' : 0,
't_step_stop' : math.ceil(Nt),
't_step_save' : math.ceil(Nt/10),
# ==========================================================

# Simulation Algorithm Parameters ==========================
'num_patches' : 1,
'model_eqns' : 2,
'alt_soundspeed' : 'F',
'num_fluids' : 1,
'adv_alphan' : 'T',
'mpp_lim' : 'F',
'mixture_err' : 'T',
'time_stepper' : 3,
'weno_order' : 5,
'weno_eps' : 1.E-16,
'mapped_weno' : 'T',
'null_weights' : 'F',
'mp_weno' : 'F',
'weno_Re_flux' : 'T',
'weno_avg' : 'T',
'riemann_solver' : 2,
'wave_speeds' : 1,
'avg_state' : 2,
'perturb_flow' : 'T',
'perturb_flow_fluid' : 1,
'perturb_flow_mag' : 1.E2,
'bc_x%beg' : -1,
'bc_x%end' : -1,
'bc_y%beg' : -1,
'bc_y%end' : -1,
'bc_z%beg' : -1,
'bc_z%end' : -1,
# ==========================================================

# Formatted Database Files Structure Parameters ============
'format' : 1,
'precision' : 2,
'prim_vars_wrt' :'T',
'parallel_io' :'T',
'omega_wrt(3)' :'T',
'fd_order' : 2,
# ==========================================================

# Patch 1: Base ============================================
# Uncomment the configuration of the Taylor Green Vortex in
# 2D analytical patch under m_patch.f90
'patch_icpp(1)%geometry' : 22,
'patch_icpp(1)%x_centroid' : 0.0,
'patch_icpp(1)%y_centroid' : 0.0,
'patch_icpp(1)%z_centroid' : 0.0,
'patch_icpp(1)%length_x' : 2.0*L,
'patch_icpp(1)%length_y' : 2.0*L,
'patch_icpp(1)%length_z' : 2.0*L,
'patch_icpp(1)%vel(1)' : vel1_i, # Define the characteristic velocity of the vortex
'patch_icpp(1)%vel(2)' : l, # Define the characteristic length of the vortex
'patch_icpp(1)%pres' : 1.E+05,
'patch_icpp(1)%alpha_rho(1)' : 1.22,
'patch_icpp(1)%alpha(1)' : 1.,
# ==========================================================


# Fluids Physical Parameters ===============================
'fluid_pp(1)%gamma' : 1.E+00/(gamma-1.E+00),
'fluid_pp(1)%pi_inf' : 0.0,
# Shear viscosity of STD air
'fluid_pp(1)%Re(1)' : 1/Mu,
# ==========================================================
}))
# ==============================================================================
36 changes: 36 additions & 0 deletions src/pre_process/m_check_patches.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ contains
call s_check_2D_TaylorGreen_vortex_patch_geometry(i)
elseif (patch_icpp(i)%geometry == 21) then
call s_check_model_geometry(i)
elseif (patch_icpp(i)%geometry == 22) then
call s_check_3D_TaylorGreen_vortex_patch_geometry(i)
else
call s_mpi_abort('Unsupported choice of the '// &
'geometry of active patch '//trim(iStr)//&
Expand Down Expand Up @@ -302,6 +304,40 @@ contains

end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry! --------------

!> This subroutine verifies that the geometric parameters of
!! the Taylor Green vortex patch have been entered by the user
!! consistently.
!! @param patch_id Patch identifier
subroutine s_check_3D_TaylorGreen_vortex_patch_geometry(patch_id) ! --------

integer, intent(IN) :: patch_id
call s_int_to_str(patch_id, iStr)

! Constraints on the TaylorGreen vortex patch geometric parameters
if (p == 0 &
.or. &
patch_icpp(patch_id)%x_centroid == dflt_real &
.or. &
patch_icpp(patch_id)%y_centroid == dflt_real &
.or. &
patch_icpp(patch_id)%z_centroid == dflt_real &
.or. &
patch_icpp(patch_id)%length_x <= 0d0 &
.or. &
patch_icpp(patch_id)%length_y <= 0d0 &
.or. &
patch_icpp(patch_id)%length_z <= 0d0 &
.or. &
patch_icpp(patch_id)%vel(2)<= 0d0) then

call s_mpi_abort('Inconsistency(ies) detected in '// &
'geometric parameters of Taylor Green '// &
'vortex patch '//trim(iStr)//'. Exiting ...')

end if

end subroutine s_check_3D_TaylorGreen_vortex_patch_geometry! --------------

!> This subroutine verifies that the geometric parameters of
!! the analytical patch have consistently been inputted by
!! the user.
Expand Down
10 changes: 7 additions & 3 deletions src/pre_process/m_checker.f90
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,15 @@ subroutine s_check_inputs()
call s_mpi_abort('Unsupported choice for the value of '// &
'num_patches. Exiting ...')
! Constraints on perturbing the initial condition
elseif ((perturb_flow .and. perturb_flow_fluid == dflt_int) &
elseif ((perturb_flow &
.and. &
(perturb_flow_fluid == dflt_int .or. perturb_flow_mag == dflt_real)) &
.or. &
((perturb_flow .neqv. .true.) .and. (perturb_flow_fluid /= dflt_int))) then
((perturb_flow .neqv. .true.) &
.and. &
(perturb_flow_fluid /= dflt_int .or. perturb_flow_mag /= dflt_real))) then
call s_mpi_abort('Unsupported choice of the combination of '// &
'values for perturb_flow and perturb_flow_fluid. '// &
'values for perturb_flow, perturb_flow_fluid, and perturb_flow_mag. '// &
'Exiting ...')
elseif ((perturb_flow_fluid > num_fluids) &
.or. &
Expand Down
2 changes: 2 additions & 0 deletions src/pre_process/m_global_parameters.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ module m_global_parameters
! Perturb density of surrounding air so as to break symmetry of grid
logical :: perturb_flow
integer :: perturb_flow_fluid !< Fluid to be perturbed with perturb_flow flag
real(kind(0d0)) :: perturb_flow_mag !< Magnitude of perturbation with perturb_flow flag
logical :: perturb_sph
integer :: perturb_sph_fluid !< Fluid to be perturbed with perturb_sph flag
real(kind(0d0)), dimension(num_fluids_max) :: fluid_rho
Expand Down Expand Up @@ -254,6 +255,7 @@ contains
instability_wave = .false.
perturb_flow = .false.
perturb_flow_fluid = dflt_int
perturb_flow_mag = dflt_real
perturb_sph = .false.
perturb_sph_fluid = dflt_int
fluid_rho = dflt_real
Expand Down
2 changes: 1 addition & 1 deletion src/pre_process/m_initial_condition.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ contains
! q_prim_vf(perturb_flow_fluid)%sf(i,j,k) = q_prim_vf(perturb_flow_fluid)%sf(i,j,k) + rand_real
! Perturb velocity
call random_number(rand_real)
rand_real = rand_real*1.d-2
rand_real = rand_real*perturb_flow_mag
q_prim_vf(mom_idx%beg)%sf(i, j, k) = (1.d0 + rand_real)*q_prim_vf(mom_idx%beg)%sf(i, j, k)
q_prim_vf(mom_idx%end)%sf(i, j, k) = rand_real*q_prim_vf(mom_idx%beg)%sf(i, j, k)
if (bubbles) then
Expand Down
4 changes: 2 additions & 2 deletions src/pre_process/m_mpi_proxy.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ contains
& 'y_domain%end', 'z_domain%beg', 'z_domain%end', 'a_x', 'a_y', &
& 'a_z', 'x_a', 'x_b', 'y_a', 'y_b', 'z_a', 'z_b', 'bc_x%beg', &
& 'bc_x%end', 'bc_y%beg', 'bc_y%end', 'bc_z%beg', 'bc_z%end', &
& 'pref', 'rhoref', 'poly_sigma', 'R0ref', 'Web', 'Ca', 'Re_inv', &
& 'sigR', 'sigV', 'rhoRV' ]
& 'perturb_flow_mag', 'pref', 'rhoref', 'poly_sigma', 'R0ref', &
& 'Web', 'Ca', 'Re_inv', 'sigR', 'sigV', 'rhoRV' ]
call MPI_BCAST(${VAR}$, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD, ierr)
#:endfor

Expand Down
Loading
Loading