def compute_alpha(minT,ibrav):
"""
This function calculates the thermal expansion alphaT at different temperatures
from the input minT matrix by computing the numerical derivatives with numpy.
The input matrix minT has shape nT*6, where the first index is the temperature
and the second the lattice parameter. For example, minT[i,0] and minT[i,2] are
the lattice parameters a and c at the temperature i.
More ibrav types must be implemented
"""
grad=np.gradient(np.array(minT)) # numerical derivatives with numpy
alphaT = np.array(grad[0]) # grad[0] contains the derivatives with respect to T, which is the first axis in minT
# also convert to np.array format
# now normalize the alpha 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
################################################################################
评论列表
文章目录