-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrandomWalk_plot.py
More file actions
199 lines (158 loc) · 5.29 KB
/
randomWalk_plot.py
File metadata and controls
199 lines (158 loc) · 5.29 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env python
import matplotlib
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.pyplot as plt
data = np.loadtxt('positionVSMeanSquareOutput.dat')
dataProb = np.loadtxt('positionVSProbabilityOutput2.dat')
time = data[:, 0] + 1
MSDth = time #<x^2> analytical
MSDnum = data[:, 1] #<x^2> numerical / computer simulated
MSDerr = data[:, 3] #error bar of <x^2>
Fsq1 = data[:, 4] #F_s(q1,x(t))
Fsq1num = data[:, 10] #F_s(q1,x(t)) numerical
Fsq1err = data[:, 7] #error bar of F_s(q1,x(t))
Fsq2 = data[:, 5] #F_s(q2,x(t))
Fsq2num = data[:, 11] #F_s(q1,x(t)) numerical
Fsq2err = data[:, 8] #error bar of F_s(q2,x(t))
Fsq3 = data[:, 6] #F_s(q3,x(t))
Fsq3num = data[:, 12] #F_s(q1,x(t)) numerical
Fsq3err = data[:, 9] #error bar of F_s(q2,x(t))
xAxis = dataProb[:,0] #Probability
yAxis = dataProb[:,1]
binomDist = dataProb[:,2]
with PdfPages('positionVSMeanSquareOutput.pdf') as pdf:
# ======== 1 log-log <x^2> VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$MSD(t)$', fontsize=10)
plt.xscale('log')
plt.yscale('log')
plt.plot( time , MSDnum, 'r-*',label= r'Numeric', linewidth=1)
plt.plot( time , MSDth, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 2 log-log <x^2> with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$MSD(t)$', fontsize=10)
plt.xscale('log')
plt.yscale('log')
plt.errorbar(time , MSDnum, MSDerr, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , MSDth, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 3 log-log Fsq1 with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=8)
plt.ylabel(r'$log F_s(q1, x(t))$', fontsize=8)
plt.xscale('log')
plt.yscale('log')
plt.errorbar(time , Fsq1, Fsq1err, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , Fsq1num, 'c-',label= r'Theory', linewidth=1)
plt.tight_layout()
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 4 log-log Fsq2 with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$log F_s(q2, x(t))$', fontsize=10)
plt.xscale('log')
plt.yscale('log')
plt.errorbar(time , Fsq2, Fsq2err, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , Fsq2num, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 5 log-log Fsq3 with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([10^(-1),])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$log F_s(q3, x(t))$', fontsize=10)
plt.xscale('log')
plt.yscale('log')
plt.errorbar(time , Fsq3, Fsq3err, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , Fsq3num, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== **** NO LOG PLOTS **** ==============
# ======== 6 <x^2> VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$MSD(t)$', fontsize=10)
plt.plot( time , MSDnum, 'r-*',label= r'Numeric', linewidth=1)
plt.plot( time , MSDth, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 7 log-log <x^2> with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$MSD(t)$', fontsize=10)
plt.errorbar(time , MSDnum, MSDerr, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , MSDth, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 8 log-log Fsq1 with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$F_s(q1, x(t))$', fontsize=10)
plt.errorbar(time , Fsq1, Fsq1err, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , Fsq1num, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 9 log-log Fsq2 with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$F_s(q2, x(t))$', fontsize=10)
plt.errorbar(time , Fsq2, Fsq2err, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , Fsq2num, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== 10 log-log Fsq3 with error bars VS time ==============
plt.xlim([1,500])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
plt.ylabel(r'$F_s(q3, x(t))$', fontsize=10)
plt.errorbar(time , Fsq3, Fsq3err, color='r', label= r'Numeric', linewidth=1)
plt.plot( time , Fsq3num, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()
# ======== PROBABILITY ==============
# TASK: To create a better plot for the distribution
plt.xlim([-200,200])
# plt.ylim([,1.9])
plt.xlabel(r'$t$', fontsize=15)
# plt.ylabel(r'$F_s(q3, x(t))$', fontsize=10)
plt.errorbar(xAxis , yAxis, color='r', label= r'Numeric', linewidth=1)
plt.plot(xAxis , binomDist, 'c-',label= r'Theory', linewidth=1)
plt.legend(loc=4)
#plt.show()
pdf.savefig()
plt.close()