Skip to content

Commit a0c45c1

Browse files
committed
improving spacing in some tests
1 parent 1fd4a02 commit a0c45c1

1 file changed

Lines changed: 17 additions & 63 deletions

File tree

tests/test_multistage.py

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,8 @@ def test_coupled_op_computing(self, time_int):
276276

277277
# Define wavefield unknowns: u (displacement) and v (velocity)
278278
fun_labels = ['u_multi_stage', 'v_multi_stage']
279-
u_multi_stage = [
280-
TimeFunction(
281-
name=name,
282-
grid=grid,
283-
space_order=2,
284-
time_order=1,
285-
dtype=np.float64) for name in fun_labels]
279+
u_multi_stage = [TimeFunction(name=name, grid=grid, space_order=2, time_order=1,
280+
dtype=np.float64) for name in fun_labels]
286281

287282
# Source definition
288283
src_spatial = Function(name="src_spat", grid=grid,
@@ -328,14 +323,8 @@ def test_low_order_convergence_ODE(self, time_int):
328323
# Time integrator solution
329324
# Define wavefield unknowns: u (displacement) and v (velocity)
330325
fun_labels = ['u', 'v']
331-
u_multi_stage = [
332-
TimeFunction(
333-
name=name
334-
+ '_multi_stage',
335-
grid=grid,
336-
space_order=2,
337-
time_order=1,
338-
dtype=np.float64) for name in fun_labels]
326+
u_multi_stage = [TimeFunction(name=name + '_multi_stage', grid=grid, space_order=2, time_order=1,
327+
dtype=np.float64) for name in fun_labels]
339328

340329
# PDE (2D acoustic)
341330
eq_rhs = [
@@ -383,12 +372,8 @@ def test_low_order_convergence(self, time_int):
383372
# Define wavefield unknowns: u (displacement) and v (velocity)
384373
fun_labels = ['u', 'v']
385374
u_multi_stage = [
386-
TimeFunction(
387-
name=f"{name}_multi_stage_{time_int}",
388-
grid=grid,
389-
space_order=2,
390-
time_order=1,
391-
dtype=np.float64) for name in fun_labels]
375+
TimeFunction(name=f"{name}_multi_stage_{time_int}", grid=grid, space_order=2, time_order=1,
376+
dtype=np.float64) for name in fun_labels]
392377

393378
# PDE (2D acoustic)
394379
eq_rhs = [u_multi_stage[1], (Derivative(u_multi_stage[0], (x, 2), fd_order=2)
@@ -405,11 +390,8 @@ def test_low_order_convergence(self, time_int):
405390
time_order=1, dtype=np.float64) for name in fun_labels]
406391

407392
# PDE (2D acoustic)
408-
eq_rhs = [u[1], (Derivative(u[0], (x, 2), fd_order=2)
409-
+ Derivative(u[0], (y, 2), fd_order=2)
410-
+ src_spatial
411-
* src_temporal)
412-
* vel**2]
393+
eq_rhs = [u[1], (Derivative(u[0], (x, 2), fd_order=2) + Derivative(u[0], (y, 2), fd_order=2)
394+
+ src_spatial * src_temporal) * vel**2]
413395

414396
# Time integration scheme
415397
pdes = [Eq(u[i].forward, solve(Eq(u[i].dt - eq_rhs[i]), u[i].forward))
@@ -430,13 +412,8 @@ def test_trivial_coupled_op_computing_exp(self, time_int='HORK_EXP'):
430412

431413
# Define wavefield unknowns: u (displacement) and v (velocity)
432414
fun_labels = ['u_multi_stage', 'v_multi_stage']
433-
u_multi_stage = [
434-
TimeFunction(
435-
name=name,
436-
grid=grid,
437-
space_order=2,
438-
time_order=1,
439-
dtype=np.float64) for name in fun_labels]
415+
u_multi_stage = [TimeFunction(name=name, grid=grid, space_order=2, time_order=1,
416+
dtype=np.float64) for name in fun_labels]
440417

441418
# PDE system
442419
system_eqs_rhs = [u_multi_stage[1],
@@ -455,17 +432,11 @@ def test_coupled_op_computing_exp(self, time_int='HORK_EXP'):
455432

456433
# Define wavefield unknowns: u (displacement) and v (velocity)
457434
fun_labels = ['u_multi_stage', 'v_multi_stage']
458-
u_multi_stage = [
459-
TimeFunction(
460-
name=name,
461-
grid=grid,
462-
space_order=2,
463-
time_order=1,
464-
dtype=np.float64) for name in fun_labels]
435+
u_multi_stage = [TimeFunction(name=name, grid=grid, space_order=2, time_order=1,
436+
dtype=np.float64) for name in fun_labels]
465437

466438
# Source definition
467-
src_spatial = Function(name="src_spat", grid=grid,
468-
space_order=2, dtype=np.float64)
439+
src_spatial = Function(name="src_spat", grid=grid, space_order=2, dtype=np.float64)
469440
src_spatial.data[100, 100] = 1
470441
src_temporal = sym.exp(- 100 * (t - 0.01) ** 2)
471442
# import matplotlib.pyplot as plt
@@ -517,29 +488,12 @@ def test_HORK_EXP_convergence(self, degree):
517488
# Time integrator solution
518489
# Define wavefield unknowns: u (displacement) and v (velocity)
519490
fun_labels = ['u', 'v']
520-
u_multi_stage = [
521-
TimeFunction(
522-
name=name
523-
+ '_multi_stage',
524-
grid=grid,
525-
space_order=2,
526-
time_order=1,
491+
u_multi_stage = [TimeFunction(name=name + '_multi_stage', grid=grid, space_order=2, time_order=1,
527492
dtype=np.float64) for name in fun_labels]
528493

529494
# PDE (2D acoustic)
530-
eq_rhs = [
531-
u_multi_stage[1],
532-
(Derivative(
533-
u_multi_stage[0],
534-
(x,
535-
2),
536-
fd_order=2)
537-
+ Derivative(
538-
u_multi_stage[0],
539-
(y,
540-
2),
541-
fd_order=2))
542-
* vel**2]
495+
eq_rhs = [u_multi_stage[1], (Derivative(u_multi_stage[0],(x,2), fd_order=2) + Derivative(
496+
u_multi_stage[0], (y,2), fd_order=2)) * vel**2]
543497

544498
src = [[src_spatial * vel**2, src_temporal, u_multi_stage[1]]]
545499

@@ -565,4 +519,4 @@ def test_HORK_EXP_convergence(self, degree):
565519
op = Operator(pdes, subs=grid.spacing_map)
566520
op(dt=dt0, time=nt)
567521
assert (np.linalg.norm(u[0].data[0, :] - u_multi_stage[0].data[0, :]) / np.linalg.norm(
568-
u[0].data[0, :])) < 10**-5, "the method is not converging to the solution"
522+
u[0].data[0, :])) < 10**-5, "the method is not converging to the solution"

0 commit comments

Comments
 (0)