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
= '../eu_out.dat'
14 FP1
= '../eu_point1.dat'
15 FP2
= '../eu_point2.dat'
20 evry
= 1000 # plot periodicity, don't set < 10 (bug)
21 offx
= -98 # offset of (x,y) in L
25 acangle
= 58 # angle of ac drive
26 dcangle
= 0 # angle of dc bias
27 sper
= 4 # spacial periodicity
28 pad
= 0.01 # small padding so the ticks get drawn correctly...
30 res
= (1440/80,900/80) # default dpi is 80
31 cmap
= cm
.gray_r
# colormap
32 shader
= False # applies ultra cool shadows to the map!
36 cblabel
= r
'$\cos(x)\cos(y)+\cos(x)+\cos(y)$'
41 title
= 'F = 0.1, alpha = 83, l = 3.0, a = 1.5, eta1 = 1.0, eta2 = 1.5, theta = 0'
43 ################################################################################
45 print "reading data..."
47 data_cof
= mlab
.csv2rec(FCOF
, delimiter
='\t', comments
='#')
48 data_p1
= mlab
.csv2rec(FP1
, delimiter
='\t', comments
='#')
49 data_p2
= mlab
.csv2rec(FP2
, delimiter
='\t', comments
='#')
58 pxdiff
= data_p2
.x
- data_p1
.x
59 pydiff
= data_p2
.y
- data_p1
.y
69 trunc_cofx
= cofx
[fromt
*tau
:tot
*tau
:evry
]
70 trunc_cofy
= cofy
[fromt
*tau
:tot
*tau
:evry
]
71 trunc_p1x
= p1x
[fromt
*tau
:tot
*tau
:evry
]
72 trunc_p2x
= p2x
[fromt
*tau
:tot
*tau
:evry
]
73 trunc_p2y
= p2y
[fromt
*tau
:tot
*tau
:evry
]
74 trunc_p1y
= p1y
[fromt
*tau
:tot
*tau
:evry
]
75 trunc_pxdiff
= pxdiff
[fromt
*tau
:tot
*tau
:evry
]
76 trunc_pydiff
= pydiff
[fromt
*tau
:tot
*tau
:evry
]
77 trunc_t
= t
[fromt
*tau
:tot
*tau
:evry
]
79 xmax
= np
.ceil(max(trunc_cofx
)/L
)
80 xmin
= np
.ceil(min(trunc_cofx
)/L
)
81 ymax
= np
.ceil(max(trunc_cofy
)/L
)
82 ymin
= np
.ceil(min(trunc_cofy
)/L
)
84 xdiff
= np
.ceil(abs(max(trunc_cofx
)-min(trunc_cofx
))/L
)
85 ydiff
= np
.ceil(abs(max(trunc_cofy
)-min(trunc_cofy
))/L
)
91 print xdiff
-(xdiff
-sper
)
95 limx_max
= (xmin
+2+sper
)*L
97 limx_min
= (xmax
-1-sper
)*L
100 limy_min
= (ymin
-2)*L
101 limy_max
= (ymin
-2+sper
)*L
103 limy_min
= (ymax
-sper
)*L
106 print (limx_max
-limx_min
)/L
108 print "x:","(",limx_min
,",",limx_max
,")"
109 print "y:","(",limy_min
,",",limy_max
,")"
111 xticks
= np
.arange(limx_min
,limx_max
+pad
,L
)
112 yticks
= np
.arange(limy_min
,limy_max
+pad
,L
)
113 xlim
= (limx_min
-pad
,limx_max
+pad
)
114 ylim
= (limy_min
-pad
,limy_max
+pad
)
115 tlabel
= ("-2L","-L","0","L","2L")
117 print "generating basemap..."
119 x
= np
.arange(limx_min
,limx_max
, delta
)
120 y
= np
.arange(limy_min
,limy_max
, delta
)
121 X
,Y
= np
.meshgrid(x
, y
)
122 Z
= np
.cos(X
)*np
.cos(Y
)+np
.cos(X
)+np
.cos(Y
)
125 fig
= plt
.figure(figsize
=res
)
127 ax
= fig
.add_subplot(111)
130 print "applying lightsource..."
131 ls
= col
.LightSource(azdeg
=0,altdeg
=90)
132 rgb
= ls
.shade(Z
,cmap
)
134 print "plotting basemap..."
135 pot
= plt
.imshow(rgb
, extent
=[limx_min
,limx_max
,limy_min
,limy_max
])
138 print "plotting basemap..."
139 pot
= plt
.pcolormesh(X
,Y
,Z
, cmap
=cmap
)
142 cb
= plt
.colorbar(pot
)
143 cb
.set_label(cblabel
)
145 print "plotting dimer onto the basemap..."
146 if (cof_only
is False):
147 cof
= ax
.scatter(trunc_cofx
, trunc_cofy
, c
='yellow', marker
='o', lw
=0, s
=msize
/4, label
='cof')
148 x1
= ax
.scatter(trunc_p1x
, trunc_p1y
, c
='blue', marker
='o', lw
=0, s
=msize
, label
='x1')
149 x2
= ax
.scatter(trunc_p2x
, trunc_p2y
, c
='purple', marker
='o', lw
=0, s
=msize
, label
='x2')
152 for i
in range(len(trunc_t
)):
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
],
157 trunc_pydiff
[i
], color
='r',
158 lw
=0.1, label
='bond',
161 elif trunc_t
[i
] < k
*every
:
162 #print "not plotting because",t[i],"!=",k,"*",every,"(",k*every,")"
164 elif (cof_only
is True):
165 cof
= ax
.scatter(trunc_cofx
, trunc_cofy
, c
='red', marker
='o',
166 lw
=0, s
=msize
/4, label
='cof')
173 ax
.arrow(limx_min
,limy_min
, 10*np
.cos(acangle
*np
.pi
/180),
174 10*np
.sin(acangle
*np
.pi
/180), lw
=2.5, color
='blue',
175 head_width
=0.15, shape
='full')
178 ax
.arrow(limx_min
,limy_min
, 10*np
.cos(dcangle
*np
.pi
/180),
179 10*np
.sin(dcangle
*np
.pi
/180), lw
=2.5, color
='red',
180 head_width
=0.15, shape
='full')
182 ax
.set_xlabel(xlabel
, size
=fs_labels
)
183 ax
.set_ylabel(ylabel
, size
=fs_labels
)
184 ax
.set_xticks(xticks
)
185 ax
.set_yticks(yticks
)
186 ax
.set_xlim(limx_min
,limx_max
)
187 ax
.set_ylim(limy_min
,limy_max
)
188 ax
.set_xticklabels(tlabel
, size
=fs_ticks
)
189 ax
.set_yticklabels(tlabel
, size
=fs_ticks
)
191 if (cof_only
is False):
192 legend
= fig
.legend((cof
, x1
, x2
, bond
), (r
'$\vec{r}_s$', r
'$\vec{r}_1$',
193 r
'$\vec{r}_2$', r
'$|\vec{r}_1-\vec{r}_2|$'), shadow
=True,
196 elif (cof_only is True):
197 legend = fig.legend((cof),(r'$\vec{r}_s$'), shadow=True, fancybox=True)
201 #legend.get_frame().set_alpha(0.75)
206 print "saving to file.."
210 if (show_plot
is True):
211 print "showing plot..."