Skip to content

Commit 3566d40

Browse files
committed
ruff
1 parent 0e54fd1 commit 3566d40

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/gresho/gresho.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,27 @@ def set_up_simulation():
5353
sim.state["t"] = 0.0
5454
X, Y = sim.mesh
5555
R = jnp.sqrt((X - 0.5) ** 2 + (Y - 0.5) ** 2)
56+
5657
def v_phi(r):
5758
return jnp.where(
5859
r < 0.2,
5960
5.0 * r,
6061
jnp.where(r < 0.4, 2.0 - 5.0 * r, 0.0),
6162
)
63+
6264
def P0(r):
6365
return jnp.where(
6466
r < 0.2,
6567
5.0 + 12.5 * r**2,
66-
jnp.where(r < 0.4, 9.0 + 12.5 * r**2 - 20.0 * r + 4.0 * jnp.log(r / 0.2), 3.0 + 4.0 * jnp.log(2.0)),
68+
jnp.where(
69+
r < 0.4,
70+
9.0 + 12.5 * r**2 - 20.0 * r + 4.0 * jnp.log(r / 0.2),
71+
3.0 + 4.0 * jnp.log(2.0),
72+
),
6773
)
68-
vx = -v_phi(R) * (Y - 0.5) / (R + (R==0))
69-
vy = v_phi(R) * (X - 0.5) / (R + (R==0))
74+
75+
vx = -v_phi(R) * (Y - 0.5) / (R + (R == 0))
76+
vy = v_phi(R) * (X - 0.5) / (R + (R == 0))
7077
sim.state["rho"] = jnp.ones(X.shape)
7178
sim.state["vx"] = vx
7279
sim.state["vy"] = vy
@@ -78,7 +85,7 @@ def P0(r):
7885
def make_plot(sim):
7986
# Plot the solution
8087
plt.figure(figsize=(6, 4), dpi=80)
81-
v_phi = jnp.sqrt(sim.state["vx"]**2 + sim.state["vy"]**2)
88+
v_phi = jnp.sqrt(sim.state["vx"] ** 2 + sim.state["vy"] ** 2)
8289
plt.imshow(v_phi.T, cmap="jet", vmin=0.0, vmax=1.0)
8390
plt.gca().invert_yaxis()
8491
plt.colorbar(label="v_phi")

0 commit comments

Comments
 (0)