Skip to content

Commit ec47eb3

Browse files
committed
update python scripts
1 parent 7cfd97e commit ec47eb3

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed
File renamed without changes.

examples/notebook/plot.py renamed to examples/notebook/plot_potential.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from math import ceil
55

66
exact = True
7-
angle_res = 0.005 # radians
7+
angle_res = 0.005 # radians
88

9-
x, y, pot_interpolated, pot_exact, err = np.loadtxt('pot_at_angles.dat', unpack=True)
9+
x, y, pot_interpolated, pot_exact, err = np.loadtxt("pot_at_angles.dat", unpack=True)
1010
if exact:
1111
pot = pot_exact
1212
else:
@@ -19,18 +19,22 @@
1919
ngridy = ceil((y.max() - y.min()) / angle_res)
2020
xi = np.linspace(x.min(), x.max(), ngridx)
2121
yi = np.linspace(y.min(), y.max(), ngridy)
22-
zi = griddata((x, y), pot, (xi[None,:], yi[:,None]), method='linear')
23-
plt.contourf(xi, yi, zi, 20, cmap = plt.cm.RdBu)
22+
zi = griddata((x, y), pot, (xi[None, :], yi[:, None]), method="linear")
23+
plt.contourf(xi, yi, zi, 20, cmap=plt.cm.RdBu)
2424

2525
# Overlay exact potential from each vertex (colored circles)
26-
x, y, z, theta, phi, pot = np.loadtxt('pot_at_vertices.dat', unpack=True)
27-
plt.scatter(theta, phi, c=pot, cmap=plt.cm.RdBu, s=15, marker='o', edgecolor='k', linewidths=0.1)
28-
plt.colorbar() # draw colorbar
26+
x, y, z, theta, phi, pot = np.loadtxt("pot_at_vertices.dat", unpack=True)
27+
plt.scatter(
28+
theta, phi, c=pot, cmap=plt.cm.RdBu, s=15, marker="o", edgecolor="k", linewidths=0.1
29+
)
30+
plt.colorbar() # draw colorbar
2931
plt.clim(-maxpot, maxpot)
30-
plt.ylim(0.0, 2.0*np.pi)
32+
plt.ylim(0.0, 2.0 * np.pi)
3133
plt.xlim(0.0, np.pi)
3234
plt.xlabel(r"Polar angle, $\theta$")
3335
plt.ylabel(r"Azimuthal angle, $\phi$")
34-
plt.title("Electric potential around a patchy particle:\n(Circles = ref. points on subdivided icosahedron)", fontsize=12)
35-
plt.savefig('potential.pdf')
36-
36+
plt.title(
37+
"Electric potential around a patchy particle:\n(Circles = ref. points on subdivided icosahedron)",
38+
fontsize=12,
39+
)
40+
plt.savefig("potential.pdf")

0 commit comments

Comments
 (0)