Skip to content

Commit fb72ca2

Browse files
committed
lint: Fix my linter
1 parent e29d36a commit fb72ca2

4 files changed

Lines changed: 32 additions & 28 deletions

File tree

devito/timestepping/superstep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ def superstep_generator(field, stencil, k, tn=0):
7070

7171

7272
def superstep_solution_transfer(old, new, new_p, tn):
73-
''' Transfer the timesteps from a previous simulation to a 2 field superstep simulation
73+
''' Transfer state from a previous TimeFunction to a 2 field superstep
7474
Used after injecting source using standard timestepping.
7575
'''
76-
idx = tn % 3 if old.save is None else -1
76+
idx = tn % 3 if old.save is None else -1
7777
new.data[0, :] = old.data[idx - 1]
7878
new.data[1, :] = old.data[idx]
7979
new_p.data[0, :] = old.data[idx - 2]

examples/timestepping/acoustic_superstep_2d.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ def layered_velocity(grid, step=0):
5252
velocity.data[:, 3*q:] = 3000
5353
return velocity
5454

55+
5556
def marmousi(grid, step=0):
5657
# Grab dataset from pwd or download
57-
url = 'https://github.com/devitocodes/data/raw/refs/heads/master/Simple2D/vp_marmousi_bi' # noqa: E501
58+
url = 'https://github.com/devitocodes/data/raw/refs/heads/master/Simple2D/vp_marmousi_bi' # noqa: E501
5859
filename = Path('marmousi.np')
5960
shape = (1601, 401)
6061
if not filename.exists():
@@ -95,7 +96,7 @@ def acoustic_model(model, step=1, snapshots=1):
9596
velocity = model.velocity(grid, step)
9697
u = TimeFunction(name="u", grid=grid, time_order=2, space_order=2)
9798

98-
pde = (1/velocity**2)*u.dt2 - u.laplace # + damp*u.dt
99+
pde = (1/velocity**2)*u.dt2 - u.laplace
99100
stencil = Eq(u.forward, solve(pde, u.forward))
100101

101102
tn1 = int(np.ceil((t1 - t0)/model.critical_dt))
@@ -158,29 +159,29 @@ def acoustic_model(model, step=1, snapshots=1):
158159
layered_model = model(
159160
name='layered',
160161
velocity=layered_velocity,
161-
shape = (101, 101),
162-
origin = (0., 0.),
163-
extent = (1000, 1000), # 1kmx1km
164-
source = (500, 20),
165-
t0 = 0,
166-
t1 = 0.2,
167-
t2 = 0.65,
168-
critical_dt = 0.002357,
169-
zlim = 30
162+
shape=(101, 101),
163+
origin=(0., 0.),
164+
extent=(1000, 1000), # 1kmx1km
165+
source=(500, 20),
166+
t0=0,
167+
t1=0.2,
168+
t2=0.65,
169+
critical_dt=0.002357,
170+
zlim=30
170171
)
171172

172173
marmousi_model = model(
173174
name='marmousi',
174175
velocity=marmousi,
175-
shape = (274, 301),
176-
origin = (4875., 262.5),
177-
extent = (3000, 2737.5), # 3kmx2.7km
178-
source = (1000, 1200),
179-
t0 = 0,
180-
t1 = 0.2,
181-
t2 = 0.5,
182-
critical_dt = 0.0013728,
183-
zlim = 20
176+
shape=(274, 301),
177+
origin=(4875., 262.5),
178+
extent=(3000, 2737.5), # 3kmx2.7km
179+
source=(1000, 1200),
180+
t0=0,
181+
t1=0.2,
182+
t2=0.5,
183+
critical_dt=0.0013728,
184+
zlim=20
184185
)
185186

186187

examples/timestepping/superstep_1d.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from devito.timestepping.superstep import superstep_generator
88

99
# Parameters
10-
## Spatial
10+
# Spatial
1111
shape = (501, )
1212
pad = (0, )
13-
origin= (0, )
13+
origin = (0, )
1414
extent = (1, )
1515
# Time
1616
t0 = 0
@@ -22,11 +22,13 @@
2222
ylim = np.ceil(1/np.sqrt(2*np.pi*sigma_sq))
2323
xlim = (0, 1)
2424

25+
2526
def gaussian(x, mu=0, sigma_sq=1):
2627
''' Generate a Gaussian initial condition
2728
'''
2829
return np.exp(-((x - mu)**2)/(2*sigma_sq))/(np.sqrt(2*np.pi*sigma_sq))
2930

31+
3032
def wave_on_string(step=1):
3133
grid = Grid(shape=shape, extent=extent)
3234

@@ -70,6 +72,7 @@ def wave_on_string(step=1):
7072
idx = tn % 3
7173
return newu.data[idx]
7274

75+
7376
if __name__ == '__main__':
7477
fig, ax = plt.subplots(1, 1)
7578
x = np.linspace(0, 1, *shape)

examples/timestepping/superstep_2d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
def gaussian2d(xx, yy, mu=0, sigma_sq=1):
1111
return np.exp(-((xx - mu)**2 + (yy - mu)**2)/(2*sigma_sq))/(np.sqrt(2*np.pi*sigma_sq))
1212

13+
1314
# Spatial Domain
1415
shape = (101, 101)
1516
origin = (0., 0.)
16-
extent = (1000, 1000) # 1kmx1km
17+
extent = (1000, 1000) # 1kmx1km
1718
# Time Domain
1819
t0 = 0
1920
t1 = 0.5
@@ -35,8 +36,7 @@ def ripple_on_pond(step=1, snapshots=1):
3536

3637
u = TimeFunction(name="u", grid=grid, time_order=2, space_order=2)
3738

38-
# The source/sink terms are injected in after the fact (???)
39-
pde = (1/velocity**2)*u.dt2 - u.laplace # + damp*u.dt
39+
pde = (1/velocity**2)*u.dt2 - u.laplace
4040
stencil = Eq(u.forward, solve(pde, u.forward))
4141

4242
# Initial condition
@@ -82,6 +82,7 @@ def ripple_on_pond(step=1, snapshots=1):
8282

8383
return u_save.data
8484

85+
8586
if __name__ == '__main__':
8687
# Supersteps
8788
k = [1, 3, 4]
@@ -111,4 +112,3 @@ def ripple_on_pond(step=1, snapshots=1):
111112
hspace=0.06
112113
)
113114
plt.show()
114-

0 commit comments

Comments
 (0)