def pyNCcomputeTestSet(cnstfile1, saefile1, nnfdir1, dtdir, dtdftpref, dtpm6dir, dtpm6pref, N, P=1.0): # Construct pyNeuroChem classes nc = pync.pyNeuroChem(cnstfile1, saefile1, nnfdir1, 0) Eact = [] Ecmp = [] Eotr = [] Ndat = 0 Nmol = 0 t = 0.0 for i in range(0, N): print('|----- File ' + str(i) + ' -----|') print('Name: ' + dtdir + dtdftpref + str(i) + '_test.dat') rv = bool(np.random.binomial(1, P)) if (os.path.isfile(dtdir + dtdftpref + str(i) + '_test.dat') and rv): xyz, typ, Eact_t = gt.readncdat(dtdir + dtdftpref + str(i) + '_test.dat') xyz1, typ1, Eotr_t = gt.readncdat(dtpm6dir + dtpm6pref + str(i) + '_test.dat') if len(Eact_t) == len(Eotr_t): Eact += shiftlsttomin(Eact_t) Eotr += shiftlsttomin(Eotr_t) #Eact += Eact_t #Eotr += Eotr_t Nmol += 1 Ndat += len(Eact_t) # Set the conformers in NeuroChem nc.setConformers(confs=xyz, types=typ) # Compute Forces of Conformations print('Computing energies 1...') _t1b = tm.time() Ecmp_t = nc.computeEnergies() _t2b = (tm.time() - _t1b) * 1000.0 t += _t2b print('Computation complete 1. Time: ' + "{:.4f}".format(_t2b) + 'ms') Ecmp += shiftlsttomin(Ecmp_t) #Ecmp += Ecmp_t Eact = np.array(Eact, dtype=float) Eotr = np.array(Eotr, dtype=float) Ecmp = np.array(Ecmp, dtype=float) return Eact, Ecmp, Eotr, Ndat, Nmol, t
def pyNCcomputeTestSet(cnstfile1,saefile1,nnfdir1,dtdir,dtdftpref,dtpm6dir,dtpm6pref,N,P=1.0): # Construct pyNeuroChem classes nc = pync.pyNeuroChem(cnstfile1,saefile1,nnfdir1,0) Eact = [] Ecmp = [] Eotr = [] Ndat = 0 Nmol = 0 t = 0.0 for i in range(0,N): rv = bool(np.random.binomial(1,P)) if (os.path.isfile(dtdir + dtdftpref + str(i) + '_test.dat') and rv): xyz,typ,Eact_t,chk = gt.readncdat(dtdir + dtdftpref + str(i) + '_test.dat') xyz1,typ1,Eotr_t,chk = gt.readncdat(dtpm6dir + dtpm6pref + str(i) + '_test.dat') if len(Eact_t) == len(Eotr_t): #print ('|----- File ' + str(i) + ' -----|') #print ('Name: ' + dtdir + dtdftpref + str(i) + '_test.dat') Eact += shiftlsttomin( Eact_t ) Eotr += shiftlsttomin( Eotr_t ) #Eact += Eact_t #Eotr += Eotr_t Nmol += 1 Ndat += len( Eact_t ) # Set the conformers in NeuroChem nc.setConformers(confs=xyz,types=typ) # Compute Forces of Conformations print(' ' + str(Nmol) + ') Computing ' + str(len( Eact_t )) + ' energies...') _t1b = tm.time() Ecmp_t = nc.computeEnergies() _t2b = (tm.time() - _t1b) * 1000.0 t += _t2b #print('Computation complete. Time: ' + "{:.4f}".format(_t2b) + 'ms') Ecmp += shiftlsttomin( Ecmp_t ) #Ecmp += Ecmp_t99 else: print (str(len(Eact_t)) + '!=' + str(len(Eotr_t)) + ' File: ' + dtdir + dtdftpref + str(i) + '_test.dat') else: print('File not found: ' + dtdir + dtdftpref + str(i) + '_test.dat') Eact = np.array(Eact,dtype=float) Eotr = np.array(Eotr,dtype=float) Ecmp = np.array(Ecmp,dtype=float) return Eact,Ecmp,Eotr,Ndat,Nmol,t
y += 1.0 z += 1.0 return xyz, typ, Na # Set required files for pyNeuroChem wkdir1 = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/train_08_1/' #Network 1 Files cnstfile1 = wkdir1 + 'rHCNO-4.5A_32-3.1A_a8-8.params' saefile1 = wkdir1 + 'sae_6-31gd.dat' nnfdir1 = wkdir1 + 'networks/' # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile1, saefile1, nnfdir1, 0) idx = [] tme = [] for i in range(1, 20): xyz, typ, Na = generatemolgrid(['H', 'C', 'N', 'O'], 10, 10) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=typ) # Print some data from the NeuroChem print('1) Number of Atoms Loaded: ' + str(nc1.getNumAtoms())) print('1) Number of Confs Loaded: ' + str(nc1.getNumConfs())) # Compute Forces of Conformations
font = {'family': 'Bitstream Vera Sans', 'weight': 'normal', 'size': 14} plt.rc('font', **font) # Set required files for pyNeuroChem wkdir = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/train_08_5/' # Network Files cnstfile = wkdir + 'rHCNO-4.7A_32-3.2A_a8-8.params' saefile = wkdir + 'sae_6-31gd.dat' nnfdir = wkdir + 'networks/' # Construct pyNeuroChem classes nc = pync.pyNeuroChem(cnstfile, saefile, nnfdir, 0) # Read nc DATA xyz, typ, Eact = gt.readncdat( '/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/Retinol/data/retinolconformer_DFT.dat' ) xyz1, typ1, Eact1 = gt.readncdat( '/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/Retinol/data/retinolconformer_DFTB.dat' ) Eact = np.array(Eact) Eact1 = np.array(Eact1) # Set the conformers in NeuroChem nc.setConformers(confs=xyz, types=typ)
cnstfile = wkdir + 'rHCNO-4.6A_32-3.1A_a8-8.params' saefile = wkdir + 'sae_6-31gd.dat' nnfdir = wkdir + 'networks/' xyz = [[0.00000,0.00000,0.37124,0.00000, 0.00000,-0.37124] ,[0.00000,0.372635,0.00000,0.00000,-0.372635, 0.00000]] #,[0.00000,0.00000,0.41000,0.00000, 0.00000,-0.41000]] xyz = [[0.0, 0.0, 0.118604, 0.0, 0.67007291, -0.40437055, 0.0, -0.75981897, -0.474415], [0.0, 0.0, 0.118604, 0.0, 0.67007291, -0.4043705, 0.0, -0.75981897, -0.474415]] typ = ['O','H','H'] #xyz,typ,Na = gt.readxyz('/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/Ranolazine/optimization/test_AO2.xyz') # Construct pyNeuroChem class nc = pync.pyNeuroChem(cnstfile, saefile, nnfdir, 0) # Set the conformers in NeuroChem nc.setConformers(confs=xyz,types=typ[0]) # Print some data from the NeuroChem print( 'Number of Atoms Loaded: ' + str(nc.getNumAtoms()) ) print( 'Number of Confs Loaded: ' + str(nc.getNumConfs()) ) # Compute Energies of Conformations E = nc.computeEnergies() F = nc.computeAnalyticalForces() print ('-----------------DATA---------------') #E = gt.hatokcal*E print (E) print (F)
def produce_scan(ax,title,xlabel,cnstfile,saefile,nnfdir,dtdir,dt1,dt2,dt3,smin,smax,iscale,ishift): xyz, typ, Eact, chk = gt.readncdat(dtdir + dt1,np.float32) xyz2, typ2, Eact2, chk = gt.readncdat(dtdir + dt2) xyz3, typ3, Eact3, chk = gt.readncdat(dtdir + dt3) #gt.writexyzfile("/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/Dihedrals/4-Cyclohexyl-1-butanol/optimization/dihedral_"+dt1+".xyz",xyz,typ) #Eact = np.array(Eact) #Eact2 = np.array(Eact2) #Eact3 = np.array(Eact3) # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile, saefile, nnfdir, 1) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=typ) # Print some data from the NeuroChem print('1) Number of Atoms Loaded: ' + str(nc1.getNumAtoms())) print('1) Number of Confs Loaded: ' + str(nc1.getNumConfs())) # Compute Forces of Conformations print('Computing energies 1...') _t1b = tm.time() Ecmp1 = nc1.energy() print('Computation complete 1. Time: ' + "{:.4f}".format((tm.time() - _t1b) * 1000.0) + 'ms') n = smin m = smax Ecmp1 = gt.hatokcal * Ecmp1 Eact = gt.hatokcal * Eact Eact2 = gt.hatokcal * Eact2 Eact3 = gt.hatokcal * Eact3 IDX = np.arange(0, Eact.shape[0], 1, dtype=float) * iscale + ishift IDX = IDX[n:m] Eact = Eact[n:m] Eact2 = Eact2[n:m] Eact3 = Eact3[n:m] Ecmp1 = Ecmp1[n:m] Ecmp1 = Ecmp1 - Ecmp1.min() Eact = Eact - Eact.min() Eact2 = Eact2 - Eact2.min() Eact3 = Eact3 - Eact3.min() rmse1 = gt.calculaterootmeansqrerror(Eact, Ecmp1) rmse3 = gt.calculaterootmeansqrerror(Eact, Eact2) rmse4 = gt.calculaterootmeansqrerror(Eact, Eact3) print("Spearman corr. 1: " + "{:.3f}".format(st.spearmanr(Ecmp1, Eact)[0])) print("Spearman corr. 2: " + "{:.3f}".format(st.spearmanr(Eact2, Eact)[0])) print("Spearman corr. 3: " + "{:.3f}".format(st.spearmanr(Eact3, Eact)[0])) ax.plot(IDX, Eact, '-', marker=r'o', color='black', label='DFT', linewidth=2, markersize=7) ax.plot(IDX, Ecmp1, ':', marker=r'D', color='red', label='ANI-1 RMSE: ' + '%s' % float('%.3g' % rmse1) + ' kcal/mol', linewidth=2, markersize=5) ax.plot(IDX, Eact2, ':', marker=r'v', color='blue', label='DFTB RMSE: ' + '%s' % float('%.3g' % rmse3) + ' kcal/mol', linewidth=2, markersize=5) ax.plot(IDX, Eact3, ':', marker=r'*', color='orange', label='PM6 RMSE: ' + '%s' % float('%.3g' % rmse4) + ' kcal/mol', linewidth=2, markersize=7) #ax.plot(IDX, Eact, color='black', label='DFT', linewidth=3) #ax.scatter(IDX, Eact, marker='o', color='black', linewidth=4) th = ax.set_title(title,fontsize=16) th.set_position([0.5,1.005]) # Set Limits ax.set_xlim([ IDX.min(),IDX.max()]) ax.set_ylim([Eact.min()-1.0,Eact.max()+1.0]) ax.set_ylabel('$\Delta$E calculated (kcal/mol)') ax.set_xlabel(xlabel) ax.legend(bbox_to_anchor=(0.2, 0.98), loc=2, borderaxespad=0., fontsize=14)
x += 1.0 y += 1.0 z += 1.0 return xyz,typ,Na # Set required files for pyNeuroChem wkdir1 = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/train_08_1/' #Network 1 Files cnstfile1 = wkdir1 + 'rHCNO-4.5A_32-3.1A_a8-8.params' saefile1 = wkdir1 + 'sae_6-31gd.dat' nnfdir1 = wkdir1 + 'networks/' # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile1,saefile1,nnfdir1,0) idx = [] tme = [] for i in range(1,20): xyz,typ,Na = generatemolgrid(['H','C','N','O'],10,10) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz,types=typ) # Print some data from the NeuroChem print( '1) Number of Atoms Loaded: ' + str(nc1.getNumAtoms()) ) print( '1) Number of Confs Loaded: ' + str(nc1.getNumConfs()) ) # Compute Forces of Conformations
def produce_scan(ax, title, xlabel, cnstfile, saefile, nnfdir, dtdir, dt1, dt2, dt3, smin, smax, iscale, ishift): xyz, typ, Eact, chk = gt.readncdat(dtdir + dt1) xyz2, typ2, Eact2, chk = gt.readncdat(dtdir + dt2) xyz3, typ3, Eact3, chk = gt.readncdat(dtdir + dt3) Eact = np.array(Eact) Eact2 = np.array(Eact2) Eact3 = np.array(Eact3) # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile, saefile, nnfdir, 1) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=typ) # Print some data from the NeuroChem print('1) Number of Atoms Loaded: ' + str(nc1.getNumAtoms())) print('1) Number of Confs Loaded: ' + str(nc1.getNumConfs())) # Compute Forces of Conformations print('Computing energies 1...') _t1b = tm.time() Ecmp1 = np.array(nc1.computeEnergies()) print('Computation complete 1. Time: ' + "{:.4f}".format((tm.time() - _t1b) * 1000.0) + 'ms') n = smin m = smax Ecmp1 = gt.hatokcal * Ecmp1 Eact = gt.hatokcal * Eact Eact2 = gt.hatokcal * Eact2 Eact3 = gt.hatokcal * Eact3 IDX = np.arange(0, Eact.shape[0], 1, dtype=float) * iscale + ishift IDX = IDX[n:m] Eact = Eact[n:m] Eact2 = Eact2[n:m] Eact3 = Eact3[n:m] Ecmp1 = Ecmp1[n:m] Ecmp1 = Ecmp1 - Ecmp1.min() Eact = Eact - Eact.min() Eact2 = Eact2 - Eact2.min() Eact3 = Eact3 - Eact3.min() rmse1 = gt.calculaterootmeansqrerror(Eact, Ecmp1) rmse3 = gt.calculaterootmeansqrerror(Eact, Eact2) rmse4 = gt.calculaterootmeansqrerror(Eact, Eact3) print("Spearman corr. 1: " + "{:.3f}".format(st.spearmanr(Ecmp1, Eact)[0])) print("Spearman corr. 2: " + "{:.3f}".format(st.spearmanr(Eact2, Eact)[0])) print("Spearman corr. 3: " + "{:.3f}".format(st.spearmanr(Eact3, Eact)[0])) ax.plot(IDX, Eact, '-', marker=r'o', color='black', label='DFT', linewidth=2, markersize=7) ax.plot(IDX, Ecmp1, ':', marker=r'D', color='red', label='ANI-1 RMSE: ' + '%s' % float('%.3g' % rmse1) + ' kcal/mol', linewidth=2, markersize=5) ax.plot(IDX, Eact2, ':', marker=r'v', color='blue', label='DFTB RMSE: ' + '%s' % float('%.3g' % rmse3) + ' kcal/mol', linewidth=2, markersize=5) ax.plot(IDX, Eact3, ':', marker=r'*', color='orange', label='PM6 RMSE: ' + '%s' % float('%.3g' % rmse4) + ' kcal/mol', linewidth=2, markersize=7) #ax.plot(IDX, Eact, color='black', label='DFT', linewidth=3) #ax.scatter(IDX, Eact, marker='o', color='black', linewidth=4) th = ax.set_title(title, fontsize=16) th.set_position([0.5, 1.005]) # Set Limits ax.set_xlim([IDX.min(), IDX.max()]) ax.set_ylim([Eact.min() - 1.0, Eact.max() + 1.0]) ax.set_ylabel('$\Delta$E calculated (kcal/mol)') ax.set_xlabel(xlabel) ax.legend(bbox_to_anchor=(0.2, 0.98), loc=2, borderaxespad=0., fontsize=14)
def produce_scan(title, xlabel, cnstfile, saefile, nnfdir, dtdir, dt1, smin, smax, iscale, ishift, atm): xyz, frc, typ, Eact, chk = gt.readncdatwforce(dtdir + dt1) xyz = np.asarray(xyz, dtype=np.float32) xyz = xyz.reshape((xyz.shape[0], len(typ), 3)) print(xyz) frc = np.asarray(frc, dtype=np.float32) frc = frc.reshape((frc.shape[0], len(typ), 3)) Eact = np.array(Eact) # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile, saefile, nnfdir, 0) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=typ) # Print some data from the NeuroChem print("1) Number of Atoms Loaded: " + str(nc1.getNumAtoms())) print("1) Number of Confs Loaded: " + str(nc1.getNumConfs())) # Compute Energies of Conformations print("Computing energies...") _t1b = tm.time() Ecmp1 = nc1.energy() print("Energy computation complete. Time: " + "{:.4f}".format((tm.time() - _t1b) * 1000.0) + "ms") # Compute Forces of Conformations print("Compute forces...") _t1b = tm.time() F = nc1.force() print("Force computation complete. Time: " + "{:.4f}".format((tm.time() - _t1b) * 1000.0) + "ms") # Fn = np.array(nc1.computeNumericalForces(dr=0.0001)) n = smin m = smax Ecmp1 = gt.hatokcal * Ecmp1 Eact = gt.hatokcal * Eact IDX = np.arange(0, Eact.shape[0], 1, dtype=float) * iscale + ishift IDX = IDX Eact = Eact Ecmp1 = Ecmp1 Ecmp1 = Ecmp1 - Ecmp1.min() Eact = Eact - Eact.min() rmse1 = gt.calculaterootmeansqrerror(Eact, Ecmp1) print("Spearman corr. 1: " + "{:.3f}".format(st.spearmanr(Ecmp1, Eact)[0])) fig, axes = plt.subplots(nrows=2, ncols=2) axes.flat[0].plot(IDX, Eact, "-", color="black", label="DFT", linewidth=6) axes.flat[0].plot(IDX, Ecmp1, "--", color="red", label="ANI-1", linewidth=6) # ax.plot(IDX, Eact, color='black', label='DFT', linewidth=3) # ax.scatter(IDX, Eact, marker='o', color='black', linewidth=4) th = axes.flat[0].set_title(title, fontsize=13) th.set_position([0.5, 1.00]) # Set Limits axes.flat[0].set_xlim([IDX.min(), IDX.max()]) # axes.flat[0].set_ylim([Eact.min()-1.0,Eact.max()+1.0]) axes.flat[0].set_ylabel("$\Delta$E calculated (kcal/mol)") axes.flat[0].set_xlabel(xlabel) axes.flat[0].legend(bbox_to_anchor=(0.2, 0.98), loc=2, borderaxespad=0.0, fontsize=12) # print (Fn) for i in range(0, 3): Fq = F[:, :, i][:, atm] # Fnq = Fn[:,i] Faq = 1.8897259885789 * np.array(frc)[:, :, i][:, atm] print(Fq) print(Faq) th = axes.flat[i + 1].set_title("Force for atom " + str(atm) + ": coordinate " + str(i), fontsize=13) th.set_position([0.5, 1.00]) axes.flat[i + 1].set_xlim([IDX.min(), IDX.max()]) axes.flat[i + 1].plot(IDX, Faq, "-", color="black", label="DFT", linewidth=6) # axes.flat[i+1].plot(IDX, Fnq, '-', color='blue', label='ANI Numerical', # linewidth=6) axes.flat[i + 1].plot(IDX, Fq, "--", color="red", label="ANI Analytical", linewidth=6) axes.flat[i + 1].set_ylabel("Force (Ha/A)") axes.flat[i + 1].set_xlabel(xlabel) axes.flat[i + 1].legend(bbox_to_anchor=(0.2, 0.98), loc=2, borderaxespad=0.0, fontsize=12) font = {"family": "Bitstream Vera Sans", "weight": "normal", "size": 12} plt.rc("font", **font) plt.show()
# Set required files for pyNeuroChem wkdir1 = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/train_08_2/' wkdir2 = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/train_08_3/' #Network 1 Files cnstfile1 = wkdir1 + 'rHCNO-4.6A_32-3.1A_a8-8.params' saefile1 = wkdir1 + 'sae_6-31gd.dat' nnfdir1 = wkdir1 + 'networks/' # Network 2 Files cnstfile2 = wkdir2 + 'rHCNO-4.6A_32-3.1A_a8-8.params' saefile2 = wkdir2 + 'sae_6-31gd.dat' nnfdir2 = wkdir2 + 'networks/' # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile1, saefile1, nnfdir1, 0) nc2 = pync.pyNeuroChem(cnstfile2, saefile2, nnfdir2, 0) xyz, typ, Eact = gt.readncdat( '/home/jujuman/Dropbox/Research/ChemSciencePaper/TestCases/C10H20Isomers/isomer_structures_DFT.dat' ) Eact = np.array(Eact) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=typ) nc2.setConformers(confs=xyz, types=typ) # Print some data from the NeuroChem print('Number of Atoms Loaded: ' + str(nc1.getNumAtoms())) print('Number of Confs Loaded: ' + str(nc1.getNumConfs()))
def produce_scan(title, xlabel, cnstfile, saefile, nnfdir, dtdir, dt1, smin, smax, iscale, ishift, atm): xyz, frc, typ, Eact, chk = gt.readncdatwforce(dtdir + dt1) xyz = np.asarray(xyz, dtype=np.float32) xyz = xyz.reshape((xyz.shape[0], len(typ), 3)) print(xyz) frc = np.asarray(frc, dtype=np.float32) frc = frc.reshape((frc.shape[0], len(typ), 3)) Eact = np.array(Eact) # Construct pyNeuroChem classes nc1 = pync.pyNeuroChem(cnstfile, saefile, nnfdir, 0) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=typ) # Print some data from the NeuroChem print('1) Number of Atoms Loaded: ' + str(nc1.getNumAtoms())) print('1) Number of Confs Loaded: ' + str(nc1.getNumConfs())) # Compute Energies of Conformations print('Computing energies...') _t1b = tm.time() Ecmp1 = nc1.energy() print('Energy computation complete. Time: ' + "{:.4f}".format((tm.time() - _t1b) * 1000.0) + 'ms') # Compute Forces of Conformations print('Compute forces...') _t1b = tm.time() F = nc1.force() print('Force computation complete. Time: ' + "{:.4f}".format((tm.time() - _t1b) * 1000.0) + 'ms') #Fn = np.array(nc1.computeNumericalForces(dr=0.0001)) n = smin m = smax Ecmp1 = gt.hatokcal * Ecmp1 Eact = gt.hatokcal * Eact IDX = np.arange(0, Eact.shape[0], 1, dtype=float) * iscale + ishift IDX = IDX Eact = Eact Ecmp1 = Ecmp1 Ecmp1 = Ecmp1 - Ecmp1.min() Eact = Eact - Eact.min() rmse1 = gt.calculaterootmeansqrerror(Eact, Ecmp1) print("Spearman corr. 1: " + "{:.3f}".format(st.spearmanr(Ecmp1, Eact)[0])) fig, axes = plt.subplots(nrows=2, ncols=2) axes.flat[0].plot(IDX, Eact, '-', color='black', label='DFT', linewidth=6) axes.flat[0].plot(IDX, Ecmp1, '--', color='red', label='ANI-1', linewidth=6) #ax.plot(IDX, Eact, color='black', label='DFT', linewidth=3) #ax.scatter(IDX, Eact, marker='o', color='black', linewidth=4) th = axes.flat[0].set_title(title, fontsize=13) th.set_position([0.5, 1.00]) # Set Limits axes.flat[0].set_xlim([IDX.min(), IDX.max()]) #axes.flat[0].set_ylim([Eact.min()-1.0,Eact.max()+1.0]) axes.flat[0].set_ylabel('$\Delta$E calculated (kcal/mol)') axes.flat[0].set_xlabel(xlabel) axes.flat[0].legend(bbox_to_anchor=(0.2, 0.98), loc=2, borderaxespad=0., fontsize=12) #print (Fn) for i in range(0, 3): Fq = F[:, :, i][:, atm] #Fnq = Fn[:,i] Faq = (1.8897259885789 * np.array(frc)[:, :, i][:, atm]) print(Fq) print(Faq) th = axes.flat[i + 1].set_title("Force for atom " + str(atm) + ": coordinate " + str(i), fontsize=13) th.set_position([0.5, 1.00]) axes.flat[i + 1].set_xlim([IDX.min(), IDX.max()]) axes.flat[i + 1].plot(IDX, Faq, '-', color='black', label='DFT', linewidth=6) #axes.flat[i+1].plot(IDX, Fnq, '-', color='blue', label='ANI Numerical', # linewidth=6) axes.flat[i + 1].plot(IDX, Fq, '--', color='red', label='ANI Analytical', linewidth=6) axes.flat[i + 1].set_ylabel('Force (Ha/A)') axes.flat[i + 1].set_xlabel(xlabel) axes.flat[i + 1].legend(bbox_to_anchor=(0.2, 0.98), loc=2, borderaxespad=0., fontsize=12) font = {'family': 'Bitstream Vera Sans', 'weight': 'normal', 'size': 12} plt.rc('font', **font) plt.show()