2 # -*- coding: iso-8859-1 -*-
4 import matplotlib
as mpl
5 mpl
.rc('text', usetex
= True)
8 import matplotlib
.cm
as cm
9 import matplotlib
.mlab
as mlab
10 import matplotlib
.pyplot
as plt
11 import matplotlib
.patches
as patch
12 import matplotlib
.colors
as col
14 FOUT
= "../latex/images/dimer_intro.png"
26 pad
= 0.01 # small padding so the ticks get drawn correctly...
28 hw
= 0.15 # arrow head width
29 res
= (800/80,600/80) # default dpi is 80
30 cmap
= cm
.gray_r
# colormap
31 shader
= False # applies ultra cool shadows to the map!
33 xticks
= [-2*L
,-L
,0,L
,2*L
]
34 yticks
= [-2*L
,-L
,0,L
,2*L
]
35 tlabel
= ["-2L","-L","0","L","2L"]
38 cblabel
= r
'$\cos{x}\cos{y}+\cos{x}+\cos{y}$'
42 ################################################################################
47 rad_transport
= transport_angle
*PI
/180
49 rad_alpha
= alpha
*PI
/180
57 print "generating basemap..."
59 x
= np
.arange(limx_min
,limx_max
, delta
)
60 y
= np
.arange(limy_min
,limy_max
, delta
)
61 X
,Y
= np
.meshgrid(x
, y
)
62 Z
= np
.cos(X
)*np
.cos(Y
)+np
.cos(X
)+np
.cos(Y
)
65 fig
= plt
.figure(figsize
=res
)
67 ax
= fig
.add_subplot(111)
70 print "applying lightsource..."
71 ls
= col
.LightSource(azdeg
=0,altdeg
=90)
72 rgb
= ls
.shade(Z
,cmap
)
74 print "plotting basemap..."
75 pot
= plt
.imshow(rgb
, extent
=[limx_min
,limx_max
,limy_min
,limy_max
])
78 print "plotting basemap..."
79 pot
= plt
.pcolormesh(X
,Y
,Z
, cmap
=cmap
)
82 cb
= plt
.colorbar(pot
)
83 cb
.set_label(cblabel
, size
=fs_labels
)
85 print "plotting dimer onto the basemap..."
87 def make_circle(start
,stop
,r
):
88 t
= np
.arange(start
,stop
,0.01)
89 #t = t.reshape((len(t), 1))
90 ret_x
= cofx
+ r
* np
.cos(t
)
91 ret_y
= cofy
+ r
* np
.sin(t
)
95 varphi_plot_x
, varphi_plot_y
= make_circle(rad1
, rad2
, 2.0)
96 psi_plot_x
, psi_plot_y
= make_circle(rad_phi
, rad_transport
, 0.8)
98 ax
.scatter(cofx
, cofy
, c
='yellow', marker
='o', lw
=0, s
=msize
*4,
100 ax
.arrow(cofx
, cofy
, np
.cos(rad1
)*dimer_length
*L
,
101 np
.sin(rad1
)*dimer_length
*L
, color
='r', lw
=0.1, alpha
=0.5)
102 ax
.arrow(cofx
, cofy
, np
.cos(rad2
)*dimer_length
*L
,
103 np
.sin(rad2
)*dimer_length
*L
, color
='r', lw
=0.1, alpha
=0.5)
104 ax
.arrow(cofx
, cofy
, -np
.cos(rad1
)*dimer_length
*L
,
105 -np
.sin(rad1
)*dimer_length
*L
, color
='r', lw
=0.1, alpha
=0.5)
106 ax
.arrow(cofx
, cofy
, -np
.cos(rad2
)*dimer_length
*L
,
107 -np
.sin(rad2
)*dimer_length
*L
, color
='r', lw
=0.1, alpha
=0.5)
108 ax
.scatter(cofx
+np
.cos(rad1
)*dimer_length
*L
,
109 cofy
+np
.sin(rad1
)*dimer_length
*L
, c
='blue', marker
='o',
110 lw
=0, s
=msize
, label
='x1')
111 ax
.scatter(cofx
-np
.cos(rad1
)*dimer_length
*L
,
112 cofy
-np
.sin(rad1
)*dimer_length
*L
, c
='purple', marker
='o',
113 lw
=0, s
=msize
, label
='x1')
114 ax
.scatter(cofx
+np
.cos(rad2
)*dimer_length
*L
,
115 cofy
+np
.sin(rad2
)*dimer_length
*L
, c
='blue',
116 marker
='o', lw
=0, s
=msize
, label
='x2')
117 ax
.scatter(cofx
-np
.cos(rad2
)*dimer_length
*L
,
118 cofy
-np
.sin(rad2
)*dimer_length
*L
, c
='purple',
119 marker
='o', lw
=0, s
=msize
, label
='x2')
120 ax
.plot(varphi_plot_x
, varphi_plot_y
, color
='black')
121 ax
.arrow(cofx
, cofy
, np
.cos(rad_phi
)*0.4*L
, np
.sin(rad_phi
)*0.4*L
,
122 head_width
=hw
, shape
='full', color
='red')
123 ax
.arrow(cofx
, cofy
, np
.cos(rad_transport
)*0.4*L
,
124 np
.sin(rad_transport
)*0.4*L
, head_width
=hw
,
126 ax
.plot(psi_plot_x
, psi_plot_y
, color
='black')
127 ax
.arrow(cofx
, cofy
, np
.cos(rad_alpha
)*0.4*L
, np
.sin(rad_alpha
)*0.4*L
,
128 head_width
=hw
, shape
='full', color
='blue')
129 ax
.arrow(cofx
, cofy
, -np
.cos(rad_alpha
)*0.4*L
, -np
.sin(rad_alpha
)*0.4*L
,
130 head_width
=hw
, shape
='full', color
='blue')
132 plt
.text(cofx
+np
.cos(rad_phi
+0.025)*0.4*L
,
133 cofy
+np
.sin(rad_phi
+0.025)*0.4*L
,
134 r
'$F\vec{e}_{\phi}$',{'color' : 'k', 'fontsize' :
136 plt
.text(cofx
+np
.cos(rad_transport
-0.05)*0.4*L
,
137 cofy
+np
.sin(rad_transport
-0.05)*0.4*L
, r
'$\vec{v}$',
138 {'color': 'k', 'fontsize' : fs_labels
})
139 plt
.text(0.5*L
,0.65*L
, r
'$\psi$', {'color' : 'k', 'fontsize' : fs_labels
})
140 plt
.text(0.65*L
,0.65*L
, r
'$\varphi$', {'color' : 'k', 'fontsize' :
142 plt
.text(cofx
+np
.cos(rad_alpha
-0.025)*0.4*L
, cofy
+np
.sin(rad_alpha
-0.025)*0.4*L
,
143 r
'$A\vec{e}_{\alpha}$', {'color' : 'k', 'fontsize' :
146 ax
.set_xlabel(xlabel
, size
=fs_labels
)
147 ax
.set_ylabel(ylabel
, size
=fs_labels
)
148 ax
.set_xticks(xticks
)
149 ax
.set_yticks(yticks
)
150 ax
.set_xlim(limx_min
,limx_max
)
151 ax
.set_ylim(limy_min
,limy_max
)
152 ax
.set_xticklabels(tlabel
, size
=fs_ticks
)
153 ax
.set_yticklabels(tlabel
, size
=fs_ticks
)
156 print "saving to file.."
160 if (show_plot
is True):
161 print "showing plot..."