def get_eint_c(filename): # Reads conformers from a file xyz, typ, Eact = hdt.readncdat(filename, np.float32) energies = ani_energy_conf(xyz, typ) return abs((energies - Eact).sum() / float(len(energies))) * 627.5095
def plot_irc_data(axes, file, rcf, title, ntwl, cnstfile, saefile, dir, idx): xyz, typ, Eact = hdt.readncdat(file, np.float32) Rc = np.load(rcf) # Shift reference to reactant #Eact = Eact[::-1] Eact = hdt.hatokcal * (Eact - Eact[0]) # Plot reference results axes.plot(Rc['x'][:, 1], Eact, color='black', linewidth=3) # Plot ANI results color = cm.rainbow(np.linspace(0, 1, len(ntwl))) terr = np.zeros(len(ntwl)) derr = np.zeros(len(ntwl)) berr = np.zeros(len(ntwl)) for i, (nt, c) in enumerate(zip(ntwl, color)): ncr = pync.conformers(dir + cnstfile, dir + saefile, rcdir + nt[0] + 'networks/', 0) # Set the conformers in NeuroChem ncr.setConformers(confs=xyz, types=list(typ)) # Compute Energies of Conformations E1 = ncr.energy() # Shift ANI E to reactant E1 = hdt.hatokcal * (E1 - E1[0]) # Calculate error errn = hdt.calculaterootmeansqrerror(E1, Eact) terr[i] = errn derr[i] = np.abs( np.abs((E1[0] - E1[-1])) - np.abs((Eact[0] - Eact[-1]))) berr[i] = np.abs(E1.max() - Eact.max()) # Plot axes.plot(Rc['x'][:, 1], E1, 'r--', color=c, label="[" + nt[1] + "]: " + "{:.2f}".format(errn), linewidth=2) #axes.plot([Rc['x'][:,1].min(),Rc['x'][:,1].max()],[E1[-1],E1[-1]], 'r--', color=c) #axes.plot([Rc['x'][:,1].min(),Rc['x'][:,1].max()],[E1[0],E1[0]], 'r--', color=c) axes.set_xlim([Rc['x'][:, 1].min(), Rc['x'][:, 1].max()]) axes.legend(loc="upper left", fontsize=12) if idx < 6: axes.set_title(title, color='green', fontdict={'weight': 'bold'}) else: axes.set_title(title, color='red', fontdict={'weight': 'bold'}) return terr, derr, berr
def pyNCcomputeTestSet(cnstfile1, saefile1, nnfdir1, dtdir, P=1.0): # Construct pyNeuroChem classes nc = pync.conformers(cnstfile1, saefile1, nnfdir1, 0) files = os.listdir(dtdir) Eact = [] Ecmp = [] Ndat = 0 Nmol = 0 t = 0.0 for i in files: print('|----- File ' + str(i) + ' -----|') print('Name: ' + dtdir + i) rv = bool(np.random.binomial(1, P)) if rv: xyz, species, energy = gt.readncdat(dtdir + i, np.float32) shiftlsttomin(energy) Eact.extend(energy) Nmol += 1 Ndat += energy.shape[0] # Set the conformers in NeuroChem nc.setConformers(confs=xyz, types=list(species)) # Compute Forces of Conformations print('Computing energies...') _t1b = tm.time() energy_comp = nc.energy() _t2b = (tm.time() - _t1b) * 1000.0 t += _t2b print('Computation complete. Time: ' + "{:.4f}".format(_t2b) + 'ms') shiftlsttomin(energy_comp) Ecmp.extend(energy_comp) # for j,k in zip(energy,energy_comp): # print(' ',j, ':', k) Eact = np.concatenate([Eact]) Ecmp = np.concatenate([Ecmp]) return Eact, Ecmp, Ndat, Nmol, t
plt.rc('font', **font) # Set required files for pyNeuroChem wkdir = '/home/jujuman/Dropbox/ChemSciencePaper.AER/ANI-1-ntwk/' # Network Files cnstfile = wkdir + 'rHCNO-4.6A_32-3.1A_a8-8.params' saefile = wkdir + 'sae_6-31gd.dat' nnfdir = wkdir + 'networks/' # Construct pyNeuroChem classes nc = pync.conformers(cnstfile, saefile, nnfdir, 0) # Read nc DATA xyz, typ, Eact = gt.readncdat( '/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/Retinol/data/retinolconformer_DFT.dat', np.float32) xyz1, typ1, Eact1 = gt.readncdat( '/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/Retinol/data/retinolconformer_DFTB.dat' ) # Set the conformers in NeuroChem nc.setConformers(confs=xyz, types=list(typ)) # Print some data from the NeuroChem print('Number of Atoms Loaded: ' + str(nc.getNumAtoms())) print('Number of Confs Loaded: ' + str(nc.getNumConfs())) # Compute Forces of Conformations print('Computing energies...') _t1b = tm.time()
# Import pyNeuroChem import pyNeuroChem as pync import numpy as np import hdnntools as hdt import matplotlib.pyplot as plt file = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnnts_rxns/benz_dbm_rxns/scans_dbm_benz_1/irc.dat' xyz,typ,Eact = hdt.readncdat(file,np.float32) # Set required files for pyNeuroChem wkdir = '/home/jujuman/Dropbox/ChemSciencePaper.AER/networks/ANI-c08f-ntwk-cv/' cnstfile = 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile = 'sae_6-31gd.dat' nc = [pync.conformers(wkdir + cnstfile, wkdir + saefile, wkdir + 'cv_c08e_ntw_' + str(l) + '/networks/', 0) for l in range(5)] rcdir = '/home/jujuman/Research/ANI-DATASET/RXN1_TNET/ani_benz_rxn1_ntwk/' ncr1 = pync.conformers(rcdir + '../' + cnstfile, rcdir + '../' + saefile, rcdir + '/networks/', 0) # Set the conformers in NeuroChem ncr1.setConformers(confs=xyz, types=list(typ)) # Compute Energies of Conformations E1 = ncr1.energy() # Plot plt.plot(hdt.hatokcal * (E1), color='red', label='ANI', linewidth=2) plt.plot (hdt.hatokcal*(Eact), color='black', label='DFT', linewidth=2) for net in nc:
ircf = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnnts_rxns/benz_dbm_rxns/scans_dbm_benz_4/irc.dat' # Set required files for pyNeuroChem rcdir = '/home/jujuman/Research/ANI-DATASET/RXN1_TNET/training/rxn1to6/ani_benz_rxn_ntwk/' cnstfile = 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile = 'sae_6-31gd.dat' files = os.listdir(ddir) nc = pync.conformers(rcdir + '../../' + cnstfile, rcdir + '../../' + saefile, rcdir + '/networks/', 0) files = list({("_".join(f.split("_")[:-1])) for f in files}) files = sorted(files, key=lambda x: int(x.split('-')[1].split('.')[0])) files = [i + '_train.dat' for i in files] datairc = hdt.readncdat(ircf, type=np.float32) atm = 9 xr = datairc[0][0][atm] print(xr) E1 = [] EA = [] dx = [] for f in files: print(ddir + f) data = hdt.readncdat(ddir + f, type=np.float32) # Set the conformers in NeuroChem nc.setConformers(confs=data[0], types=list(data[1]))
import hdnntools as gt from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import os import matplotlib as mpl # Set required files for pyNeuroChem anipath = '/home/jujuman/Dropbox/ChemSciencePaper.AER/ANI-c08e-ntwk' cnstfile = anipath + '/rHCNO-4.6A_16-3.1A_a4-8.params' saefile = anipath + '/sae_6-31gd.dat' nnfdir = anipath + '/networks/' #dtdir = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnntsgdb11_01/data/' #xyz,typ,Eact,tmp = gt.readncdat(dtdir + 'gdb11_s01-1_test.dat',np.float32) file = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnntsgdb11_02/testdata/gdb11_s02-0_test.dat' xyz,typ,Eact = gt.readncdat(file,np.float32) file2 = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnntsgdb11_02/testdata/gdb11_s02-3_test.dat' xyz2,typ2,Eact2 = gt.readncdat(file2,np.float32) file3 = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnntsgdb11_02/testdata/gdb11_s02-7_test.dat' xyz3,typ3,Eact3 = gt.readncdat(file3,np.float32) # Construct pyNeuroChem class nc = pync.conformers(cnstfile, saefile, nnfdir, 0) # Set the conformers in NeuroChem nc.setConformers(confs=xyz,types=list(typ)) # Compute Energies of Conformations E1 = nc.energy()
def produce_scan(ax,title,xlabel,cnstfile,saefile,nnfdir,dtdir,dt1,dt2,dt3,smin,smax,iscale,ishift): xyz, typ, Eact = gt.readncdat(dtdir + dt1,np.float32) xyz2, typ2, Eact2 = gt.readncdat(dtdir + dt2) xyz3, typ3, Eact3 = 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.conformers(cnstfile, saefile, nnfdir, 0) # Set the conformers in NeuroChem nc1.setConformers(confs=xyz, types=list(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(Ecmp1) 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: ' + gt.to_precision(rmse1,2) + ' kcal/mol', linewidth=2, markersize=5) ax.plot(IDX, Eact2, ':', marker=r'v', color='blue', label='DFTB RMSE: ' + gt.to_precision(rmse3,2) + ' kcal/mol', linewidth=2, markersize=5) ax.plot(IDX, Eact3, ':', marker=r'*', color='orange', label='PM6 RMSE: ' + gt.to_precision(rmse4,2) + ' 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 plot_irc_data(axes, file, rcf, title): xyz, typ, Eact = hdt.readncdat(file, np.float32) Rc = np.load(rcf) # Set required files for pyNeuroChem wkdir = '/home/jujuman/Dropbox/ChemSciencePaper.AER/networks/ANI-c08f-ntwk-cv/' cnstfile = 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile = 'sae_6-31gd.dat' nc = [ pync.conformers(wkdir + cnstfile, wkdir + saefile, wkdir + 'cv_c08e_ntw_' + str(l) + '/networks/', 0) for l in range(5) ] rcdir = '/home/jujuman/Research/ANI-DATASET/RXN1_TNET/training/rxn1to6/ani_benz_rxn_ntwk/' ncr1 = pync.conformers(rcdir + '../../' + cnstfile, rcdir + '../../' + saefile, rcdir + '/networks/', 0) ncr2 = pync.molecule(rcdir + '../../' + cnstfile, rcdir + '../../' + saefile, rcdir + '/networks/', 0) ncr3 = pync.molecule(rcdir + '../../' + cnstfile, rcdir + '../../' + saefile, rcdir + '/networks/', 0) # Compute reactant E ncr2.setMolecule(coords=xyz[0], types=list(typ)) Er = ncr2.energy() # Compute product E ncr3.setMolecule(coords=xyz[-1], types=list(typ)) Ep = ncr3.energy() #Eact = Eact[::-1] dE_ani = hdt.hatokcal * (Er - Ep) dE_dft = hdt.hatokcal * (Eact[0] - Eact[-1]) print('Delta E R/P ANI:', dE_ani, 'Delta E R/P ANI:', dE_dft, 'Diff:', abs(dE_ani - dE_dft)) # Set the conformers in NeuroChem ncr1.setConformers(confs=xyz, types=list(typ)) # Compute Energies of Conformations E1 = ncr1.energy() # Shift E1 = E1 - E1[0] Eact = Eact - Eact[0] # Plot errn = hdt.calculaterootmeansqrerror(hdt.hatokcal * E1, hdt.hatokcal * Eact) axes.plot(Rc['x'][:, 1], hdt.hatokcal * (E1), color='red', label="{:.2f}".format(errn), linewidth=2) axes.plot(Rc['x'][:, 1], hdt.hatokcal * (Eact), 'r--', color='black', linewidth=3) err = [] for n, net in enumerate(nc): # Set the conformers in NeuroChem net.setConformers(confs=xyz, types=list(typ)) # Compute Energies of Conformations E1 = net.energy() E1 = E1 - E1[0] err.append( hdt.calculaterootmeansqrerror(hdt.hatokcal * E1, hdt.hatokcal * Eact)) # Plot if n == len(nc) - 1: mean = np.mean(np.asarray(err)) axes.plot(Rc['x'][:, 1], hdt.hatokcal * (E1), color='blue', label="{:.2f}".format(mean), linewidth=1) else: axes.plot(Rc['x'][:, 1], hdt.hatokcal * (E1), color='blue', linewidth=1) axes.plot(Rc['x'][:, 1], hdt.hatokcal * (E1), color='blue', linewidth=1) axes.set_xlim([Rc['x'][:, 1].min(), Rc['x'][:, 1].max()]) axes.legend(loc="upper right", fontsize=8) axes.set_title(title) return np.array([errn, np.mean(err)])
# Import pyNeuroChem import pyNeuroChem as pync import numpy as np import hdnntools as hdt import matplotlib.pyplot as plt from matplotlib.pyplot import cm wkdir = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnnts_rxns/benz_dbm_rxns_full/irc_dbm_benz_1/' file = wkdir + 'irc.dat' Rc = np.load(wkdir + 'reaction_coordinate.npz') #xyz,typ,Na = hdt.readxyz2(file1) xyz, typ, Ea = hdt.readncdat(file, type=np.float32) # Set required files for pyNeuroChem rcdir = '/home/jujuman/Research/ANI-DATASET/RXN1_TNET/training/rxn1to6/ani_benz_rxn_ntwk/' cnstfile = '../../rHCNO-4.6A_16-3.1A_a4-8.params' saefile = '../../sae_6-31gd.dat' ncr = pync.conformers(rcdir + cnstfile, rcdir + saefile, rcdir + 'networks/', 1) # Set the conformers in NeuroChem ncr.setConformers(confs=xyz, types=list(typ)) # Compute Energies of Conformations E1 = ncr.energy() # Shift ANI E to reactant E1 = E1[0:][::-1] Ea = Ea[0:][::-1]
def get_eint_m(filename): xyz, typ, Eact = hdt.readncdat(filename, np.float32) energies = [ani_energy_bad(m, typ) for m in xyz] return abs((energies - Eact).sum() / float(len(energies))) * 627.5095
print(data[1]) xyz.append(data[0]) nc.setMolecule(coords=data[0][0], types=list(data[1])) Eact.append(nc.energy()[0]) xyz = np.vstack(xyz) #print(xyz) hdt.writexyzfile( '/home/jujuman/Dropbox/ChemSciencePaper.AER/JustinsDocuments/ACS_april_2017/DipeptidePhiPsi/data.xyz', xyz, list(data[1])) data2 = hdt.readncdat( '/home/jujuman/Dropbox/ChemSciencePaper.AER/JustinsDocuments/ACS_april_2017/DipeptidePhiPsi/data.dat', type=np.float32) Eact = np.array(Eact) Edft = data2[2] z = np.array(hdt.hatokcal * (Eact - Eact.min()), dtype=np.float32).reshape(x.shape[0], x.shape[0]) z2 = np.array(hdt.hatokcal * (Edft - Edft.min()), dtype=np.float32).reshape(x.shape[0], x.shape[0]) rmse = hdt.calculaterootmeansqrerror(z, z2) print('RMSE: ', rmse) Spline1 = scipy.interpolate.RectBivariateSpline(x, x, z) Spline2 = scipy.interpolate.RectBivariateSpline(x, x, z2)
def sortbyother(Y, X): xy = zip(X, Y) xy = sorted(xy, key=lambda x: x[0]) X, Y = zip(*xy) return np.array(Y) wkdir = '/home/jujuman/Research/wB97X-631gd-train-highgarden/train_08-a3.1A_r4.6_AEV384_1/' cnstfile1 = wkdir + 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile1 = wkdir + '../sae_6-31gd.dat' nnfdir1 = wkdir + 'networks/' dtdir = '/home/jujuman/Dropbox/ChemSciencePaper.AER/TestCases/C10H20Isomers/' #xyz,typ,Eact = gt.readncdat('../data_irc.dat') xyz, typ, Eact = gt.readncdat(dtdir + 'isomer_structures_DFT.dat', type=np.float32) #xyz,typ,Eact = gt.readncdat('/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnntsgdb11_01/testdata/gdb11_s01-2_test.dat',type=np.float32) #xyz2,typ2,Eact2,tmp = gt.readncdat(dtdir + 'isomer_structures_DFTB.dat') #xyz3,typ3,Eact3,tmp = gt.readncdat(dtdir + 'isomer_structures_PM6.dat') #xyz = [xyz[0],xyz[1]] #xyz2 = [xyz2[0],xyz2[1]] #xyz3 = [xyz3[0],xyz3[1]] #xyz = np.asarray(xyz,dtype=np.float32) #xyz = xyz.reshape((xyz.shape[0],len(typ),3)) Eact = np.array(Eact) #Eact2 = np.array(Eact2) #Eact3 = np.array(Eact3)
files = sorted(files, key=lambda x: int(x.split('-')[1].split('.')[0])) print(files) allarr = [] Natoms = [] Nconfs = [] typarr = [] for i in files: print(d + i) nc = 0 for k in namelist: try: _timeloop = tm.time() readarrays = gt.readncdat(d + i + k) _timeloop2 = (tm.time() - _timeloop) totaltime += _timeloop2 #print('Computation complete. Time: ' + "{:.4f}".format(_timeloop2) + 'ms') shapesarr = [x.shape for x in readarrays] typ = readarrays[1] except FileNotFoundError: readarrays = [np.zeros((0, *x[1:])) for x in shapesarr] ncsub, nat, ndim = readarrays[0].shape nc += ncsub readarrays[0] = readarrays[0].reshape(ncsub * nat, ndim) allarr.append(readarrays) Natoms.append(nat)
def pyNCcomputeTestSet(cnstfile1, saefile1, nnfdir1, dtdir, dtdftpref, dtpm6dir, dtpm6pref, N, P=1.0): # Construct pyNeuroChem classes nc = pync.conformers(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 = gt.readncdat( dtdir + dtdftpref + str(i) + '_test.dat', np.float32) xyz1, typ1, Eotr_t = gt.readncdat( dtpm6dir + dtpm6pref + str(i) + '_test.dat', np.float32) if len(Eact_t) == len(Eotr_t): #print ('|----- File ' + str(i) + ' -----|') #print ('Name: ' + dtdir + dtdftpref + str(i) + '_test.dat') Eact.append(shiftlsttomin(Eact_t)) Eotr.append(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=list(typ)) # Compute Forces of Conformations print(' ' + str(Nmol) + ') Computing ' + str(len(Eact_t)) + ' energies...') _t1b = tm.time() Ecmp_t = nc.energy() _t2b = (tm.time() - _t1b) * 1000.0 t += _t2b #print('Computation complete. Time: ' + "{:.4f}".format(_t2b) + 'ms') Ecmp.append(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) Eact = np.concatenate(Eact) Eotr = np.concatenate(Eotr) Ecmp = np.concatenate(Ecmp) return Eact, Ecmp, Eotr, Ndat, Nmol, t
#for i in range(tmol): # rmtot[i] = cnt[] #print(rmtot) dp = pyt.datapacker(h5dir) #print('Diff data:',ddif,'tmol:',tmol) tmol = 0 gcount = 0 bcount = 0 for i, f in enumerate(files): X = [] E = [] tmol += 1 for e in ends: data = hdn.readncdat(dtdir + f + e + '.dat') X.append(np.array(data[0], dtype=np.float32)) E.append(np.array(data[2], dtype=np.float64)) S = data[1] X = np.concatenate(X) E = np.concatenate(E) pr, dl = boltzmann_prob_ratio(E.min(), E, T) #gid = np.where(E - E.min() <= 300.0/hdn.hatokcal) #bid = np.where(E - E.min() > 300.0/hdn.hatokcal) #gid = gid[0][0:E[gid].size-rmtot[i]] #print(gid.size) bid = list(np.where(pr > R))
cnstfile = wkdir + 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile = wkdir + 'sae_6-31gd.dat' nnfdir = wkdir + 'networks/' #Network 1 Files wkdir2 = '/home/jujuman/Dropbox/ChemSciencePaper.AER/ANI-c08e-ccdissotest1-ntwk/' cnstfile2 = wkdir2 + 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile2 = wkdir2 + 'sae_6-31gd.dat' nnfdir2 = wkdir2 + 'networks/' # Construct pyNeuroChem classes nc = pync.conformers(cnstfile, saefile, nnfdir, 1) nc2 = pync.conformers(cnstfile2, saefile2, nnfdir2, 1) scan = hdt.readncdat( '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnnts_testdata/waterdimerscan/ethene_diss.dat', type=np.float32) sdat = [hdt.ncdata(hdt.generatedmatsd3(scan[0]), scan[1], scan[0].shape[1])] sae = hdt.compute_sae(saefile, scan[1]) serg = scan[2] - sae # Set the conformers in NeuroChem nc.setConformers(confs=scan[0], types=list(scan[1])) nc2.setConformers(confs=scan[0], types=list(scan[1])) x = 0.05 * np.array(range(serg.shape[0]), dtype=np.float64) + 0.6 print(len(x)) popt = np.load('mp_ani_params_test.npz')['param']
#dtdir = '/home/jujuman/Research/GDB-11-wB97X-6-31gd/dnntsgdb11_' + p + '/testdata/' dtdir = '/home/jujuman/Python/PycharmProjects/HD-AtomNNP/Data-ANI-1-Figures/data/minimized/GDB-' + p + '/' files = listdir(dtdir) _timeloop = tm.time() data = np.empty((0,3),dtype=np.float) spec = np.empty((0,3),dtype=np.float) enrg = np.empty((0),dtype=np.float) for en,i in enumerate(files): #if 'gdb11' in i and '_test.dat' in i: if 'gdb11' in i: # Read NC data print("Reading file (", en, " of ", len(files) ,"): ", i) xyz,spc,t_enrg = gt.readncdat(dtdir + i) sae = compute_sae(spc) t_enrg = t_enrg - sae t_data,t_spec = generate_angular_data(xyz,spc,len(spc),1.0) t_data = t_data.reshape((t_data.shape[0]*t_data.shape[1],3)) t_spec = t_spec.reshape((t_spec.shape[0]*t_spec.shape[1],3)) #print('data shape: ', t_data.shape) #print('spec shape: ', t_spec.shape) #for l in t_spec: # print(l)
import hdnntools as hdt import numpy as np import matplotlib.pyplot as plt #Network 1 Files wkdir = '/home/jujuman/Dropbox/ChemSciencePaper.AER/networks/ANI-c08f-ntwk/' cnstfile = wkdir + 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile = wkdir + 'sae_6-31gd.dat' nnfdir = wkdir + 'networks/' wkdir = '/home/jujuman/Research/CrossValidation/GDB-09-Retrain/' cnstfile = wkdir + 'rHCNO-4.6A_16-3.1A_a4-8.params' saefile = wkdir + 'sae_6-31gd.dat' traj = hdt.readncdat( '/home/jujuman/Dropbox/ChemSciencePaper.AER/JustinsDocuments/ACS_april_2017/ANI-MD-vDFT/benzeneMD/benzene_dft.dat', type=np.float32) nc = pync.conformers(cnstfile, saefile, nnfdir, 0) ncl = [ pync.conformers(cnstfile, saefile, wkdir + 'cv_c08e_ntw_' + str(l) + '/networks/', 0) for l in range(5) ] nc.setConformers(confs=traj[0], types=list(traj[1])) Ecv = [] for comp in ncl: comp.setConformers(confs=traj[0], types=list(traj[1])) E = comp.energy()