def compute_grun_along_one_direction(nq,modes,ngeo,cgeo,celldmsx,freqgeo,rangegeo,xindex=0):
"""
Compute the Gruneisen parameters along one direction.
This function uses a 1-dimensional polynomial of fourth degree to fit the
frequencies along a certain direction (along a and c axis in hexagonal systems
for example).
"""
# set a numpy array of volumes for the fit (n=5)
xtemp=[]
for igeo in rangegeo:
xtemp.append(celldmsx[igeo,xindex])
x=np.array(xtemp)
grun=[]
for iq in range(0,nq):
grunq=[]
for ifreq in range(0,modes):
ytemp=[]
for igeo in rangegeo:
ytemp.append(freqgeo[igeo,iq,ifreq])
y=np.array(ytemp)
z=np.polyfit(x, y, 4)
p=np.poly1d(z)
pderiv=np.polyder(p)
if freqgeo[cgeo[xindex],iq,ifreq]<1E-3:
grunq.append(0.0)
else:
grunq.append(pderiv(celldmsx[cgeo[xindex],xindex])/freqgeo[cgeo[xindex],iq,ifreq]) #*celldmsx[cgeo[xindex],xindex])
grun.append(grunq)
return np.array(grun)
################################################################################
评论列表
文章目录