From 620c471cb85ebd352a800abf02099f8f1fe64120 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Mon, 11 Dec 2023 18:57:58 -0500 Subject: [PATCH] perturb parameter (#252) Co-authored-by: RasmitDevkota Co-authored-by: Rasmit Devkota --- docs/documentation/case.md | 12 +++++++++--- src/pre_process/m_check_patches.fpp | 1 + src/pre_process/m_checker.f90 | 10 +++++++--- src/pre_process/m_global_parameters.fpp | 2 ++ src/pre_process/m_initial_condition.fpp | 2 +- src/pre_process/m_mpi_proxy.fpp | 4 ++-- src/pre_process/m_start_up.fpp | 2 +- src/simulation/m_rhs.fpp | 10 +++++----- toolchain/mfc/run/case_dicts.py | 2 +- 9 files changed, 29 insertions(+), 16 deletions(-) diff --git a/docs/documentation/case.md b/docs/documentation/case.md index fd97d3b43..c31f8c034 100644 --- a/docs/documentation/case.md +++ b/docs/documentation/case.md @@ -505,8 +505,10 @@ 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 | @@ -514,9 +516,13 @@ The table lists velocity field parameters. The parameters are optionally used to - `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. diff --git a/src/pre_process/m_check_patches.fpp b/src/pre_process/m_check_patches.fpp index ec0421a6c..f2262d58d 100644 --- a/src/pre_process/m_check_patches.fpp +++ b/src/pre_process/m_check_patches.fpp @@ -302,6 +302,7 @@ contains end subroutine s_check_2D_TaylorGreen_vortex_patch_geometry! -------------- + !> This subroutine verifies that the geometric parameters of !! the analytical patch have consistently been inputted by !! the user. diff --git a/src/pre_process/m_checker.f90 b/src/pre_process/m_checker.f90 index 91ea228bd..15ecc7161 100644 --- a/src/pre_process/m_checker.f90 +++ b/src/pre_process/m_checker.f90 @@ -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. & diff --git a/src/pre_process/m_global_parameters.fpp b/src/pre_process/m_global_parameters.fpp index 3958b4ffd..a28d5808a 100644 --- a/src/pre_process/m_global_parameters.fpp +++ b/src/pre_process/m_global_parameters.fpp @@ -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 @@ -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 diff --git a/src/pre_process/m_initial_condition.fpp b/src/pre_process/m_initial_condition.fpp index c15be1c38..2fd267811 100644 --- a/src/pre_process/m_initial_condition.fpp +++ b/src/pre_process/m_initial_condition.fpp @@ -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 diff --git a/src/pre_process/m_mpi_proxy.fpp b/src/pre_process/m_mpi_proxy.fpp index 7e43a5242..22be385e6 100644 --- a/src/pre_process/m_mpi_proxy.fpp +++ b/src/pre_process/m_mpi_proxy.fpp @@ -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 diff --git a/src/pre_process/m_start_up.fpp b/src/pre_process/m_start_up.fpp index 2633ec626..c78234356 100644 --- a/src/pre_process/m_start_up.fpp +++ b/src/pre_process/m_start_up.fpp @@ -115,7 +115,7 @@ contains weno_order, bc_x, bc_y, bc_z, num_patches, & hypoelasticity, patch_icpp, fluid_pp, & precision, parallel_io, vel_profile, instability_wave, & - perturb_flow, perturb_flow_fluid, & + perturb_flow, perturb_flow_fluid, perturb_flow_mag, & perturb_sph, perturb_sph_fluid, fluid_rho, & cyl_coord, loops_x, loops_y, loops_z, & rhoref, pref, bubbles, R0ref, nb, & diff --git a/src/simulation/m_rhs.fpp b/src/simulation/m_rhs.fpp index 6d781fdc0..0d7e9ee64 100644 --- a/src/simulation/m_rhs.fpp +++ b/src/simulation/m_rhs.fpp @@ -845,7 +845,7 @@ contains ! =============================================================== if (alt_soundspeed) then -!$acc parallel loop collapse(3) gang vector default(present) + !$acc parallel loop collapse(3) gang vector default(present) do l = 0, p do k = 0, n do j = 0, m @@ -1037,7 +1037,7 @@ contains end do end do else -!$acc parallel loop collapse(3) gang vector default(present) + !$acc parallel loop collapse(3) gang vector default(present) do l = 0, p do k = 0, n do j = 0, m @@ -1132,7 +1132,7 @@ contains end do !Non-polytropic qbmm needs to account for change in bubble radius due to a change in nb if(qbmm .and. (.not. polytropic) ) then - !$acc parallel loop collapse(5) gang vector default(present) private(nb_q, nR, nR2, R, R2, nb_dot, nR_dot, nR2_dot, var) + !$acc parallel loop collapse(5) gang vector default(present) private(nb_q, nR, nR2, R, R2, nb_dot, nR_dot, nR2_dot, var) do i = 1, nb do q = 1, nnode do l = 0, p @@ -1256,7 +1256,7 @@ contains end if end do else -!$acc parallel loop collapse(4) gang vector default(present) + !$acc parallel loop collapse(4) gang vector default(present) do j = advxb, advxe do l = 0, p do k = 0, n @@ -2363,4 +2363,4 @@ contains end subroutine s_finalize_rhs_module ! --------------------------------- -end module m_rhs \ No newline at end of file +end module m_rhs diff --git a/toolchain/mfc/run/case_dicts.py b/toolchain/mfc/run/case_dicts.py index 1a753d1b9..5180bc8f4 100644 --- a/toolchain/mfc/run/case_dicts.py +++ b/toolchain/mfc/run/case_dicts.py @@ -13,7 +13,7 @@ PRE_PROCESS = COMMON + [ 'old_grid', 'old_ic', 't_step_old', 't_step_start', 'vel_profile', - 'instability_wave', 'perturb_flow', 'perturb_flow_fluid', + 'instability_wave', 'perturb_flow', 'perturb_flow_fluid', 'perturb_flow_mag', 'perturb_sph', 'perturb_sph_fluid', 'fluid_rho', 'num_patches', 'qbmm', 'dist_type', 'R0_type', 'sigR', 'sigV', 'rhoRV' ]