def compute_alpha_splines(TT,minT,ibrav,splinesoptions):
"""
This function calculates the thermal expansions alphaT at different temperatures
as the previous function but using spline interpolation as implemented in
scipy.interpolate.
"""
alphaT = np.zeros(len(TT)*6)
alphaT.shape = (len(TT),6)
x = np.array(TT)
y0 = np.array(minT[:,0])
y1 = np.array(minT[:,1])
y2 = np.array(minT[:,2])
if (splinesoptions=={}):
tck0 = interpolate.splrep(x, y0)
tck1 = interpolate.splrep(x, y1)
tck2 = interpolate.splrep(x, y2)
else:
tck0 = interpolate.splrep(x, y0, k=splinesoptions['k0'], s=splinesoptions['s0'])
tck1 = interpolate.splrep(x, y1, k=splinesoptions['k1'], s=splinesoptions['s1'])
tck2 = interpolate.splrep(x, y2, k=splinesoptions['k2'], s=splinesoptions['s2'])
ynew0 = interpolate.splev(x, tck0, der=0)
alphaT[:,0] = interpolate.splev(x, tck0, der=1)
ynew1 = interpolate.splev(x, tck1, der=0)
alphaT[:,1] = interpolate.splev(x, tck1, der=1)
ynew2 = interpolate.splev(x, tck2, der=0)
alphaT[:,2] = interpolate.splev(x, tck2, der=1)
# now normalize the alphaTs properly. It must be different for different ibrav
# to avoid a divide by 0 error (minT is zero for lattice parameters not defined
# in the system)
if ibrav==4:
alphaT[:,0] = alphaT[:,0]/minT[:,0]
alphaT[:,2] = alphaT[:,2]/minT[:,2]
return alphaT
################################################################################
评论列表
文章目录