def berry_phase(H,path,ns):
'''
Calculate the Berry phase of some bands of a Hamiltonian along a certain path.
Parameters
----------
H : callable
Input function which returns the Hamiltonian as a 2D array.
path : iterable
The path along which to calculate the Berry phase.
ns : iterable of int
The sequences of bands whose Berry phases are wanted.
Returns
-------
1d ndarray
The wanted Berry phase of the selected bands.
'''
ns=np.array(ns)
for i,parameters in enumerate(path):
new=eigh(H(**parameters))[1][:,ns]
if i==0:
result=np.ones(len(ns),new.dtype)
evs=new
else:
for j in xrange(len(ns)):
result[j]*=np.vdot(old[:,j],new[:,j])
old=new
else:
for j in xrange(len(ns)):
result[j]*=np.vdot(old[:,j],evs[:,j])
return np.angle(result)/np.pi
评论列表
文章目录