-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjacobi.py
More file actions
54 lines (38 loc) · 1.39 KB
/
jacobi.py
File metadata and controls
54 lines (38 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import numpy as np
from matplotlib import pyplot as plt
from vfpic import config
cfg = config ()
shape = (2, 8, cfg.nz+2, cfg.nx+2)
if (cfg.precision == 4):
dtype = np.float32
elif (cfg.precision == 8):
dtype = np.float64
else:
print "Error: Unkown precision"
print "precision = ", precision
data = np.fromfile ("jacobi.dat", dtype=dtype).reshape (shape)
rho1 = data[0,0,:,:].copy()
J1 = data[0,1:4,:,:].copy()
phi1 = data[0,4,:,:].copy()
A1 = data[0,5:8,:,:].copy()
rho2 = data[1,0,:,:].copy()
J2 = data[1,1:4,:,:].copy()
phi2 = data[1,4,:,:].copy()
A2 = data[1,5:8,:,:].copy()
plt.ion ()
plt.clf()
fig, axes = plt.subplots (3, 4, num=1)
axes[0,0].imshow (phi1,aspect="auto")
#for j in range (3): axes[0,j+1].imshow (A1[j,:,:],aspect="auto")
for j in range (3): axes[0,j+1].imshow (np.roll (A1[j,:,:], cfg.nx/2, axis=1),aspect="auto")
axes[1,0].imshow (phi2,aspect="auto")
#for j in range (3): axes[1,j+1].imshow (A2[j,:,:],aspect="auto")
for j in range (3): axes[1,j+1].imshow (np.roll (A1[j,:,:], cfg.nx/2, axis=1),aspect="auto")
axes[2,0].imshow (phi1 - phi2,aspect="auto")
#for j in range (3): axes[2,j+1].imshow (A1[j,:,:] - A2[j,:,:],aspect="auto")
for j in range (3): axes[2,j+1].imshow (np.roll (A1[j,:,:] - A2[j,:,:], cfg.nx/2, axis=1),aspect="auto")
for axis in axes.flatten ():
axis.set_xticklabels ("")
axis.set_yticklabels ("")
plt.tight_layout ()