Skip to content

Commit 49e9c85

Browse files
Fix damping layer default values (#69)
* Fix damping layer default values * Fix example acoustic 2D
1 parent 57bbc2e commit 49e9c85

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

examples/acoustic_2D.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@
6161
# config boundary conditions
6262
# (none, null_dirichlet or null_neumann)
6363
space_model.config_boundary(
64-
damping_length=0,
64+
damping_length=(0, 510, 510, 510),
6565
boundary_condition=(
6666
"null_neumann", "null_dirichlet",
67-
"none", "null_dirichlet"
68-
),
69-
damping_polynomial_degree=3,
70-
damping_alpha=0.001
67+
"null_dirichlet", "null_dirichlet"
68+
)
7169
)
7270

71+
print(' damping_alpha=',space_model.damping_alpha)
72+
7373
# create the time model
7474
time_model = TimeModel(
7575
space_model=space_model,
76-
tf=1.0,
76+
tf=2.0,
7777
saving_stride=0
7878
)
7979

simwave/kernel/frontend/model.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,24 @@ def damping_alpha(self):
187187
try:
188188
return self._damping_alpha
189189
except AttributeError:
190-
return 0.001
190+
if self.dimension == 2:
191+
# 2 dimension
192+
z_min, z_max, x_min, x_max = self.bounding_box
193+
z_top_damp, z_bottom_damp, x_left_damp, x_right_damp = self.damping_length
194+
nz = z_max - z_min + z_top_damp + z_bottom_damp
195+
nx = x_max - x_min + x_left_damp + x_right_damp
196+
# get the maximum domain length in one of 2 dimensions (meters)
197+
max_length = max(nz, nx)
198+
else:
199+
# 3 dimension
200+
z_min, z_max, x_min, x_max, y_min, y_max = self.bounding_box
201+
z_top_damp, z_bottom_damp, x_left_damp, x_right_damp, y_front_damp, y_back_damp = self.damping_length
202+
nz = z_max - z_min + z_top_damp + z_bottom_damp
203+
nx = x_max - x_min + x_left_damp + x_right_damp
204+
ny = y_max - y_min + y_front_damp + y_back_damp
205+
# get the maximum domain length in one of 3 dimensions (meters)
206+
max_length = max(nz, nx, ny)
207+
return np.log(1/10 ** -3) * (self.dimension * np.max(self.velocity_model) / (2 * max_length) ) / max_length ** 2
191208

192209
def fd_coefficients(self, derivative_order):
193210
"""
@@ -269,7 +286,7 @@ def halo_size(self):
269286
return (space_order_radius, ) * self.dimension * 2
270287

271288
def config_boundary(self, damping_length=0.0, boundary_condition="none",
272-
damping_polynomial_degree=3, damping_alpha=0.001):
289+
damping_polynomial_degree=2, damping_alpha=None):
273290
"""
274291
Applies the domain extension (for absorbing layers with damping)
275292
and boundary conditions.
@@ -296,7 +313,8 @@ def config_boundary(self, damping_length=0.0, boundary_condition="none",
296313
"""
297314

298315
self._damping_polynomial_degree = damping_polynomial_degree
299-
self._damping_alpha = damping_alpha
316+
if damping_alpha is not None:
317+
self._damping_alpha = damping_alpha
300318

301319
# if it is not, convert damping_length to tuple
302320
if isinstance(damping_length, (float, int)):
@@ -394,11 +412,9 @@ def damping_mask(self):
394412
mode="linear_ramp",
395413
end_values=self.nbl_pad_width
396414
)
397-
398415
# change the damping values (coefficients) according to a function
399416
degree = self.damping_polynomial_degree
400417
damp_mask = (damp_mask ** degree) * self.damping_alpha
401-
402418
# damp mask in the halo region
403419
# The values in this extended region is zero
404420
damp_mask = np.pad(array=damp_mask, pad_width=self.halo_pad_width)

0 commit comments

Comments
 (0)