2 # -*- coding: iso-8859-1 -*-
4 import matplotlib
as mpl
6 import matplotlib
.cm
as cm
7 import matplotlib
.mlab
as mlab
8 import matplotlib
.pyplot
as plt
9 import matplotlib
.patches
as patch
10 import matplotlib
.colors
as col
12 FOUT
= '../dimer_in_potential.png'
13 FCOF
= '../rk_out.dat'
14 FP1
= '../rk_point1.dat'
15 FP2
= '../rk_point2.dat'
20 evry
= 1 # plot periodicity, don't set < 10 (bug)
21 offx
= -98 # offset of (x,y) in L
25 driveangle
= 41 # angle of ac drive
26 sper
= 4 # spacial periodicity
27 pad
= 0.01 # small padding so the ticks get drawn correctly...
29 res
= (1440/80,900/80) # default dpi is 80
30 cmap
= cm
.gray_r
# colormap
31 shader
= False # applies ultra cool shadows to the map!
35 cblabel
= r
'$\cos(x)\cos(y)+\cos(x)+\cos(y)$'
38 title
= 'F = 0.1, alpha = 83, l = 3.0, a = 1.5, eta1 = 1.0, eta2 = 1.5, theta = 0'
40 ################################################################################
42 print "reading data..."
44 data_cof
= mlab
.csv2rec(FCOF
, delimiter
='\t', comments
='#')
45 data_p1
= mlab
.csv2rec(FP1
, delimiter
='\t', comments
='#')
46 data_p2
= mlab
.csv2rec(FP2
, delimiter
='\t', comments
='#')
55 pxdiff
= data_p2
.x
- data_p1
.x
56 pydiff
= data_p2
.y
- data_p1
.y
66 trunc_cofx
= cofx
[fromt
*tau
:tot
*tau
:evry
]
67 trunc_cofy
= cofy
[fromt
*tau
:tot
*tau
:evry
]
68 trunc_p1x
= p1x
[fromt
*tau
:tot
*tau
:evry
]
69 trunc_p2x
= p2x
[fromt
*tau
:tot
*tau
:evry
]
70 trunc_p2y
= p2y
[fromt
*tau
:tot
*tau
:evry
]
71 trunc_p1y
= p1y
[fromt
*tau
:tot
*tau
:evry
]
72 trunc_pxdiff
= pxdiff
[fromt
*tau
:tot
*tau
:evry
]
73 trunc_pydiff
= pydiff
[fromt
*tau
:tot
*tau
:evry
]
74 trunc_t
= t
[fromt
*tau
:tot
*tau
:evry
]
76 xmax
= np
.ceil(max(trunc_cofx
)/L
)
77 xmin
= np
.ceil(min(trunc_cofx
)/L
)
78 ymax
= np
.ceil(max(trunc_cofy
)/L
)
79 ymin
= np
.ceil(min(trunc_cofy
)/L
)
82 xdiff
= np
.ceil(abs(max(trunc_cofx
)-min(trunc_cofx
))/L
)
83 ydiff
= np
.ceil(abs(max(trunc_cofy
)-min(trunc_cofy
))/L
)
89 print xdiff
-(xdiff
-sper
)
93 limx_min
= (xmax
-sper
)*L
96 limx_max
= (xmin
+sper
)*L
99 limy_min
= (ymax
-sper
)*L
102 limy_max
= (ymin
+sper
)*L
104 print (limx_max
-limx_min
)/L
106 print "x:","(",limx_min
,",",limx_max
,")"
107 print "y:","(",limy_min
,",",limy_max
,")"
109 xticks
= np
.arange(limx_min
,limx_max
+pad
,L
)
110 yticks
= np
.arange(limy_min
,limy_max
+pad
,L
)
111 xlim
= (limx_min
-pad
,limx_max
+pad
)
112 ylim
= (limy_min
-pad
,limy_max
+pad
)
113 tlabel
= ("-2L","-L","0","L","2L")
115 print "generating basemap..."
117 x
= np
.arange(limx_min
,limx_max
, delta
)
118 y
= np
.arange(limy_min
,limy_max
, delta
)
119 X
,Y
= np
.meshgrid(x
, y
)
120 Z
= np
.cos(X
)*np
.cos(Y
)+np
.cos(X
)+np
.cos(Y
)
123 fig
= plt
.figure(figsize
=res
)
125 ax
= fig
.add_subplot(111)
128 print "applying lightsource..."
129 ls
= col
.LightSource(azdeg
=0,altdeg
=90)
130 rgb
= ls
.shade(Z
,cmap
)
132 print "plotting basemap..."
133 pot
= plt
.imshow(rgb
, extent
=[limx_min
,limx_max
,limy_min
,limy_max
])
136 print "plotting basemap..."
137 pot
= plt
.pcolormesh(X
,Y
,Z
, cmap
=cmap
)
140 cb
= plt
.colorbar(pot
)
141 cb
.set_label(cblabel
)
143 print "plotting dimer onto the basemap..."
144 cof
= ax
.scatter(trunc_cofx
, trunc_cofy
, c
='yellow', marker
='o', lw
=0, s
=msize
/4, label
='cof')
145 x1
= ax
.scatter(trunc_p1x
, trunc_p1y
, c
='blue', marker
='o', lw
=0, s
=msize
, label
='x1')
146 x2
= ax
.scatter(trunc_p2x
, trunc_p2y
, c
='purple', marker
='o', lw
=0, s
=msize
, label
='x2')
147 #bond = ax.arrow(trunc_p1x, trunc_p1y, trunc_pxdiff, trunc_pydiff, color='r', lw=0.1, label='bond')
151 for i
in range(len(trunc_t
)):
152 #bond = ax.arrow(p1x[i], p1y[i], pxdiff[i], pydiff[i], color='r', lw=0.1, label='bond')
153 if trunc_t
[i
] >= k
*every
:
154 #print "plotting because",t[i],"=",k,"*",every,"(",k*every,")"
155 bond
= ax
.arrow(trunc_p1x
[i
], trunc_p1y
[i
],
156 trunc_pxdiff
[i
], trunc_pydiff
[i
],
157 color
='r', lw
=0.1, label
='bond',
160 elif trunc_t
[i
] < k
*every
:
161 #print "not plotting because",t[i],"!=",k,"*",every,"(",k*every,")"
166 ax
.arrow(limx_min
,limy_min
, 10*np
.cos(driveangle
*np
.pi
/180),
167 10*np
.sin(driveangle
*np
.pi
/180), lw
=5.0, color
='g')
171 for i in range(len(x)):
173 s1 = ax.axhline(y=n/2)
180 ax
.set_xlabel(xlabel
, size
=fs_labels
)
181 ax
.set_ylabel(ylabel
, size
=fs_labels
)
182 ax
.set_xticks(xticks
)
183 ax
.set_yticks(yticks
)
184 ax
.set_xlim(limx_min
,limx_max
)
185 ax
.set_ylim(limy_min
,limy_max
)
186 ax
.set_xticklabels(tlabel
, size
=fs_ticks
)
187 ax
.set_yticklabels(tlabel
, size
=fs_ticks
)
189 legend
= fig
.legend((cof
, x1
, x2
, bond
), (r
'$\vec{r}_s$', r
'$\vec{r}_1$',
190 r
'$\vec{r}_2$', r
'$|\vec{r}_1-\vec{r}_2|$'), shadow
=True,
192 legend
.get_frame().set_alpha(0.75)
196 print "saving to file.."
200 if (show_plot
is True):
201 print "showing plot..."