fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from scipy.integrate import quad
  4.  
  5. R=8.314
  6. theta_e=428
  7. theta_d=428
  8.  
  9. T=np.linspace(1,500,500)
  10.  
  11. def dulong_petit(T):
  12. return np.full_like(T,3*R)
  13.  
  14. def einstien_model(T,theta_e):
  15. x=theta_e/T
  16. return 3*R*(x**2*np.exp(x))/((np.exp(x)-1)**2)
  17.  
  18. def debye_integral(x):
  19. return (x**4*np.exp(x))/((np.exp(x)-1)**2)
  20.  
  21. def debye_model(T, theta_d):
  22. CV=[]
  23. for temp in T:
  24. x_D=theta_d/temp
  25. integral,_=quad(debye_integral,0,x_D)
  26. CV.append(9*R*(temp/theta_d)**3*integral)
  27. return np.array(CV)
  28.  
  29.  
  30. cv_dulong=dulong_petit(T)
  31. cv_einstien=einstien_model(T,theta_e)
  32. cv_debye=debye_model(T, theta_d)
  33.  
  34. plt.figure(figsize=(10,6))
  35. plt.plot(T,cv_dulong, label='Dulong Petit')
  36. plt.plot(T,cv_einstien, label='Einstien')
  37. plt.plot(T,cv_debye, label='Debye')
  38. plt.xlabel('Temperature (K)')
  39. plt.ylabel('Specific heat (J/mol.K)')
  40. plt.legend()
  41. plt.grid(True)
  42. plt.show()
  43.  
Success #stdin #stdout #stderr 1.14s 70864KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog:16: RuntimeWarning: overflow encountered in square
  
prog:19: RuntimeWarning: overflow encountered in double_scalars