Guest User

Untitled

a guest
Jan 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #!/usr/bin/env python3
  2.  
  3. import numpy as np
  4. import os
  5. import argparse
  6. import matplotlib.pyplot as plt
  7. import ase.units
  8.  
  9. plt.switch_backend('Agg')
  10.  
  11.  
  12. if __name__=='__main__':
  13. parser = argparse.ArgumentParser()
  14. parser.add_argument("-d", "--detail-file", default="./results",type=str, help="The file containing details of energy force and virial accuracy")
  15. args = parser.parse_args()
  16.  
  17. folder=args.detail_file
  18.  
  19. f=np.concatenate([np.loadtxt(os.path.join(folder,filename)) for filename in os.listdir(folder) if filename.endswith('f.out')])
  20. f*=ase.units.eV/(ase.units.kcal/ase.units.mol)
  21.  
  22. #np.save("f.npy",f)
  23. #f=np.load("f.npy")
  24. #e=np.concatenate([np.loadtxt(os.path.join(folder,filename),ndmin=2) for filename in os.listdir(folder) if filename.endswith('e.out')])
  25. f_error=f[:,:3]-f[:,3:6]
  26. f_mae=np.mean(np.abs(f_error))
  27. f_rmse=np.sqrt(np.mean(np.square(f_error)))
  28.  
  29. #e_rmse=np.sqrt(np.mean(np.square(e[:,:1]-e[:,1:2])))
  30. #print("No of energy: ",e.shape[0],"RMSE: ",e_rmse)
  31. print("No of force: ",f.shape[0],"MAE",f_mae,"RMSE: ",f_rmse)
  32.  
  33. plt.scatter(f[:,:3].ravel(),f[:,3:6].ravel(),s=1)
  34. plt.xlabel('DFT forces (kcal/(mol·Å))')
  35. plt.ylabel('DL forces (kcal/(mol·Å))')
  36.  
  37. lims = [
  38. np.min([plt.xlim(), plt.ylim()]), # min of both axes
  39. np.max([plt.xlim(), plt.ylim()]), # max of both axes
  40. ]
  41.  
  42. # now plot both limits against eachother
  43. plt.plot(lims, lims, 'k-', alpha=0.75, color='r')
  44. plt.axes().set_aspect('equal')
  45. plt.xlim(lims)
  46. plt.ylim(lims)
  47.  
  48. plt.text(lims[0]*0.1,lims[0]*0.9,f"MAE={f_mae:.4f} kcal/(mol·Å)\nRMSE={f_rmse:.4f} kcal/(mol·Å)")
  49.  
  50. plt.axes([0.3, 0.6, 0.2, 0.2])
  51. plt.scatter(f[:,:3].ravel(),f[:,3:6].ravel(),s=1)
  52. plt.plot([-250,250],[-250,250],'k-', alpha=0.75, color='r')
  53. plt.xlim([-250,250])
  54. plt.ylim([-250,250])
  55.  
  56.  
  57. plt.savefig("f.png")
Add Comment
Please, Sign In to add comment