-
Notifications
You must be signed in to change notification settings - Fork 2
/
SyncError_tmp1.py
77 lines (56 loc) · 1.62 KB
/
SyncError_tmp1.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import sys
import os
import math
init_time = 0
nodes = 15
end_time = nodes
step = (end_time - init_time) / nodes
pwd = os.getcwd()
N =16
Nstr = str(N)
NN = N*N
P_data = []
P_mod = []
P_diff = np.zeros((nodes, 256))
def cal(time):
time = str(time)
P_syn = np.loadtxt(pwd+"/"+Nstr+"x"+Nstr+"/P_t"+time+".dat")
P_mod.append(P_syn)
P_msr = np.loadtxt(pwd+"/"+Nstr+"x"+Nstr+"_msr/P_t"+time+".dat")
P_data.append(P_msr)
u_syn = np.loadtxt(pwd+"/"+Nstr+"x"+Nstr+"/u_t"+time+".dat")
u_msr = np.loadtxt(pwd+"/"+Nstr+"x"+Nstr+"_msr/u_t"+time+".dat")
v_syn = np.loadtxt(pwd+"/"+Nstr+"x"+Nstr+"/v_t"+time+".dat")
v_msr = np.loadtxt(pwd+"/"+Nstr+"x"+Nstr+"_msr/v_t"+time+".dat")
P_error = sum((P_syn-P_msr)**2)
u_error = sum((u_syn-u_msr)**2)
v_error = sum((v_syn-v_msr)**2)
return P_error, u_error, v_error
P_series = np.zeros(nodes)
u_series = np.zeros(nodes)
v_series = np.zeros(nodes)
P_SE = np.zeros(nodes)
u_SE = np.zeros(nodes)
v_SE = np.zeros(nodes)
for time in range(init_time, end_time, step):
(P_series[time/step],u_series[time/step],v_series[time/step]) = cal(time)
P_data[0].item(0)
for i in range(0, nodes):
P_diff[i] = P_data[i] - P_mod[i]
#t = np.arange(init_time, end_time, step)
#
#fig, ax = plt.subplots()
#ax.plot(t, P_series, 'y', label='P_series')
#ax.plot(t, u_series, 'b', label='u_series')
#ax.plot(t, v_series, 'k', label='v_series')
#
#
#legend = ax.legend(loc='upper center', shadow=True)
#ax.set_yscale('log')
#
#plt.savefig("temp.png")
#plt.show()