Skip to content

Commit

Permalink
done dipole; fix checker
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisZYJ committed Jul 22, 2024
1 parent a4e8642 commit 2ddeb39
Show file tree
Hide file tree
Showing 10 changed files with 757 additions and 45 deletions.
7 changes: 6 additions & 1 deletion docs/documentation/case.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu
| ---: | :----: | :--- |
| `acoustic_source` | Logical | Acoustic source module activation |
| `num_source` | Integer | Number of acoustic sources |
| `acoustic(i)%%support` | Integer | Geometry of spatial support for the acoustic source |
| `acoustic(i)%%support` | Integer | Geometry of spatial support for the acoustic source |
| `acoustic(i)%%dipole` | Logical | Dipole source activation (optional; default = false for monopole) |
| `acoustic(i)%%loc(j)` | Real | $j$-th coordinate of the point that defines the acoustic source location |
| `acoustic(i)%%pulse` | Integer | Acoustic wave form: [1] Sine [2] Gaussian [3] Square |
| `acoustic(i)%%npulse` | Real | Number of pulse cycles |
Expand Down Expand Up @@ -543,6 +544,8 @@ Details of the transducer acoustic source model can be found in [Maeda and Colon

- `%%support` specifies the choice of the geometry of acoustic source distribution. See table [Acoustic Supports](#acoustic-supports) for details.

- `%%dipole` changes the default monopole (one-sided) source to a dipole source. It is only available for planar waves.

- `%%loc(j)` specifies the location of the acoustic source in the $j$-th coordinate direction. For planer support, the location defines midpoint of the source plane. For transducer arrays, the location defines the center of the transducer or transducer array (not the focal point; for 3D it's the tip of the spherical cap, for 2D it's the tip of the arc).

- `%%pulse` specifies the acoustic wave form. `%%pulse = 1`, `2`, and `3` correspond to sinusoidal wave, Gaussian wave, and square wave, respectively.
Expand Down Expand Up @@ -815,6 +818,8 @@ Additional requirements for all acoustic support types:

- `%%support` must be set to the acoustic support number listed in the table.

- `%%dipole` is only supported for planar sources.

- `%%npulse = 1 or 3` requires exactly one of `%%frequency` or `%%wavelength` to be set. It accepts `%%delay` as an optional parameter (default = 0).

- `%%npulse = 2` requires exactly one of `%%gauss_sigma_time` or `%%gauss_sigma_space` to be set. It requires `%%delay` to be set.
Expand Down
83 changes: 83 additions & 0 deletions examples/1D_acoustic_dipole/case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python3

import json

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

# Computational Domain Parameters ==========================================
'x_domain%beg' : 0,
'x_domain%end' : 0.001,
'm' : 199,
'n' : 0,
'p' : 0,
'dt' : 2e-9,
't_step_start' : 0,
't_step_stop' : 250,
't_step_save' : 1,
# ==========================================================================

# Simulation Algorithm Parameters ==========================================
'num_patches' : 1,
'model_eqns' : 2,
'alt_soundspeed' : 'F',
'num_fluids' : 1,
'adv_alphan' : 'T',
'mpp_lim' : 'F',
'mixture_err' : 'F',
'time_stepper' : 3,
'weno_order' : 5,
'weno_eps' : 1.E-16,
'teno' : 'T',
'teno_CT' : 1E-8,
'null_weights' : 'F',
'mp_weno' : 'F',
'riemann_solver' : 2,
'wave_speeds' : 1,
'avg_state' : 2,
'bc_x%beg' : -6,
'bc_x%end' : -6,
# ==========================================================================

# Formatted Database Files Structure Parameters ============================
'format' : 2,
'precision' : 2,
'prim_vars_wrt' :'T',
'rho_wrt' :'T',
'parallel_io' :'T',
# ==========================================================================

# Patch 1 Liquid ===========================================================
'patch_icpp(1)%geometry' : 1,
'patch_icpp(1)%x_centroid' : 0.0005,
'patch_icpp(1)%length_x' : 0.001,
'patch_icpp(1)%vel(1)' : 0.0,
'patch_icpp(1)%pres' : 1E+05,
'patch_icpp(1)%alpha_rho(1)' : 1100,
'patch_icpp(1)%alpha(1)' : 1.0,
# ==========================================================================

# Acoustic source ==========================================================
'acoustic_source' : 'T',
'num_source' : 1,
'acoustic(1)%support' : 1,
'acoustic(1)%dipole' : 'T',
'acoustic(1)%loc(1)' : 0.0005,
'acoustic(1)%pulse' : 2,
'acoustic(1)%npulse' : 1,
'acoustic(1)%dir' : 1.,
'acoustic(1)%mag' : 1.,
'acoustic(1)%gauss_sigma_time' : 2E-8,
'acoustic(1)%delay' : 1E-7,
# ==========================================================================

# Fluids Physical Parameters ===============================================
'fluid_pp(1)%gamma' : 1.E+00/(4.4E+00-1.E+00),
'fluid_pp(1)%pi_inf' : 4.4E+00*5.57E+08/(4.4E+00 - 1.E+00),
# ==========================================================================
}))

# ==============================================================================
93 changes: 53 additions & 40 deletions src/simulation/m_checker.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,93 +233,106 @@ contains
call s_mpi_abort('acoustic('//trim(jStr)//')%pulse must be '// &
'specified. Exiting ...')
elseif (.not. any(acoustic(j)%pulse == (/1, 2, 3/))) then
call s_mpi_abort('Only acoustic(i)npulse = 1, 2, or 3 is '// &
call s_mpi_abort('Only acoustic('//trim(jStr)//')%npulse = 1, 2, or 3 is '// &
'allowed. Exiting ...')
end if
if (any(acoustic(j)%pulse == (/1, 3/)) .and. &
.not. xor(f_is_default(acoustic(j)%frequency), f_is_default(acoustic(j)%wavelength))) then
call s_mpi_abort('One and only one of acoustic(i)frequency '// &
'or acoustic(i)wavelength must be specified '// &
'for acoustic(i)pulse = 1 or 3. Exiting ...')
call s_mpi_abort('One and only one of acoustic('//trim(jStr)//')%frequency '// &
'or acoustic('//trim(jStr)//')%wavelength must be specified '// &
'for pulse = 1 or 3. Exiting ...')
elseif (acoustic(j)%pulse == 2 .and. &
.not. xor(f_is_default(acoustic(j)%gauss_sigma_time), f_is_default(acoustic(j)%gauss_sigma_dist))) then
call s_mpi_abort('One and only one of acoustic(i)gauss_sigma_time '// &
'or acoustic(i)gauss_sigma_dist must be specified '// &
'for acoustic(i)pulse = 2. Exiting ...')
call s_mpi_abort('One and only one of acoustic('//trim(jStr)//')%gauss_sigma_time '// &
'or acoustic('//trim(jStr)//')%gauss_sigma_dist must be specified '// &
'for pulse = 2. Exiting ...')
end if
if (f_is_default(acoustic(j)%npulse)) then
call s_mpi_abort('acoustic('//trim(jStr)//')%npulse must be '// &
'specified. Exiting ...')
elseif (acoustic(j)%support >= 5 .and. (.not. f_is_integer(acoustic(j)%npulse))) then
call s_mpi_abort('acoustic(i)npulse must be an integer for '// &
'acoustic(i)support >= 5 (Cylindrical or '// &
'Spherical support). Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%npulse '// &
'must be an integer for support >= 5 '// &
'(non-planar supports). Exiting ...')
elseif (acoustic(j)%npulse >= 5 .and. acoustic(j)%dipole) then
call s_mpi_abort('acoustic('//trim(jStr)//')%dipole is not '// &
'supported for support >= 5 '// &
'(non-planar supports). Exiting ...')
elseif (acoustic(j)%support < 5 .and. f_is_default(acoustic(j)%dir)) then
call s_mpi_abort('acoustic('//trim(jStr)//')%dir must be '// &
'specified for planer support. Exiting ...')
'specified for support < 5 (planer support). '// &
'Exiting ...')
elseif (acoustic(j)%support == 1 .and. f_approx_equal(acoustic(j)%dir, 0d0)) then
call s_mpi_abort('acoustic(i)dir must be non-zero for '// &
'acoustic(i)support = 1. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')dir must be non-zero '// &
'for support = 1. Exiting ...')
elseif (acoustic(j)%pulse == 2 .and. f_is_default(acoustic(j)%delay)) then
call s_mpi_abort('acoustic('//trim(jStr)//')%delay must be '// &
'specified for acoustic(i)pulse = 2 (Gaussian). '// &
'specified for pulse = 2 (Gaussian). '// &
'Exiting ...')
elseif (acoustic(j)%pulse == 3 .and. acoustic(j)%support >= 5) then
call s_mpi_abort('acoustic(i)support >= 5 (Cylindrical or '// &
'Spherical support) is not allowed for '// &
'acoustic(i)pulse = 3 (square wave). Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%support >= 5 '// &
'(Cylindrical or Spherical support) is not '// &
'allowed for pulse = 3 (square wave). Exiting ...')
end if

if (any(acoustic(j)%support == (/5, 6, 7, 9, 10, 11/))) then ! Transducer or Transducer array
if (f_is_default(acoustic(j)%foc_length)) then
call s_mpi_abort('foc_length must be specified for '// &
'acoustic(i)support = 5, 6, 7, 9, 10, or 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%foc_length '// &
'must be specified for support '// &
'= 5, 6, 7, 9, 10, or 11. Exiting ...')
elseif (acoustic(j)%foc_length <= 0d0) then
call s_mpi_abort('foc_length must be positive for '// &
'acoustic(i)support = 5, 6, 7, 9, 10, or 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%foc_length '// &
'must be positive for support '// &
'= 5, 6, 7, 9, 10, or 11. Exiting ...')
end if
if (f_is_default(acoustic(j)%aperture)) then
call s_mpi_abort('aperture must be specified for '// &
'acoustic(i)support = 5, 6, 7, 9, 10, or 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%aperture '// &
'must be specified for support '// &
'= 5, 6, 7, 9, 10, or 11. Exiting ...')
elseif (acoustic(j)%aperture <= 0d0) then
call s_mpi_abort('aperture must be positive for '// &
'acoustic(i)support = 5, 6, 7, 9, 10, or 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%aperture '// &
'must be positive for support '// &
'= 5, 6, 7, 9, 10, or 11. Exiting ...')
end if
end if

if (any(acoustic(j)%support == (/9, 10, 11/))) then ! Transducer array
if (acoustic(j)%num_elements == dflt_int) then
call s_mpi_abort('num_elements must be specified for '// &
'acoustic(i)support = 9, 10, or 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%num_elements '// &
'must be specified for support '// &
'= 9, 10, or 11. Exiting ...')
elseif (acoustic(j)%num_elements <= 0) then
call s_mpi_abort('num_elements must be positive for '// &
'acoustic(i)support = 9, 10, or 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%num_elements '// &
'must be positive for support '// &
'= 9, 10, or 11. Exiting ...')
end if
if (acoustic(j)%element_on /= dflt_int) then
if (acoustic(j)%element_on < 0) then
call s_mpi_abort('element_on must be non-negative. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%element_on '// &
'must be non-negative. Exiting ...')
elseif (acoustic(j)%element_on > acoustic(j)%num_elements) then
call s_mpi_abort('element_on must be less than or equal '// &
'to num_elements. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%element_on '// &
'must be less than or equal '// &
'to num_elements. Exiting ...')
end if
end if
end if

if (any(acoustic(j)%support == (/9, 10/))) then ! 2D transducer array
if (f_is_default(acoustic(j)%element_spacing_angle)) then
call s_mpi_abort('element_spacing_angle must be specified for '// &
'acoustic(i)support = 9 or 10. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%element_spacing_angle '// &
'must be specified for support = 9 or 10. Exiting ...')
elseif (acoustic(j)%element_spacing_angle < 0d0) then
call s_mpi_abort('element_spacing_angle must be non-negative for '// &
'acoustic(i)support = 9 or 10. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%element_spacing_angle '// &
'must be non-negative for support = 9 or 10. Exiting ...')
end if
elseif (acoustic(j)%support == 11) then ! 3D transducer array
if (f_is_default(acoustic(j)%element_polygon_ratio)) then
call s_mpi_abort('element_polygon_ratio must be specified for '// &
'acoustic(i)support = 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%element_polygon_ratio '// &
'must be specified for support = 11. Exiting ...')
elseif (acoustic(j)%element_polygon_ratio <= 0d0) then
call s_mpi_abort('element_polygon_ratio must be positive for '// &
'acoustic(i)support = 11. Exiting ...')
call s_mpi_abort('acoustic('//trim(jStr)//')%element_polygon_ratio '// &
'must be positive for support = 11. Exiting ...')
end if
end if
end do
Expand Down
8 changes: 4 additions & 4 deletions src/simulation/m_monopole.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ contains
call s_source_spatial(j, k, l, loc_acoustic(:, ai), ai, source_spatial, angle, xyz_to_r_ratios)
mom_src_diff = source_temporal*source_spatial

if (dipole(ai)) then
mass_src_diff = mom_src_diff/c
mom_src_diff = 0d0
if (dipole(ai)) then ! Double amplitude & No momentum source term (only works for Planar)
mass_src(j, k, l) = mass_src(j, k, l) + 2d0*mom_src_diff/c
if (model_eqns /= 4) E_src(j, k, l) = E_src(j, k, l) + 2d0*mom_src_diff*c/(small_gamma - 1d0)
cycle
end if

Expand Down Expand Up @@ -431,7 +431,7 @@ contains
if (support(ai) == 5 .or. support(ai) == 6) then ! 2D or 2D axisymmetric
current_angle = -atan(r(2)/(foc_length(ai) - r(1)))
angle_half_aperture = asin((aperture(ai)/2d0)/(foc_length(ai)))

if (abs(current_angle) < angle_half_aperture .and. r(1) < foc_length(ai)) then
dist = foc_length(ai) - dsqrt(r(2)**2d0 + (foc_length(ai) - r(1))**2d0)
source = 1d0/(dsqrt(2d0*pi)*sig/2d0)*dexp(-0.5d0*(dist/(sig/2d0))**2d0)
Expand Down
Loading

0 comments on commit 2ddeb39

Please sign in to comment.