saver = tf.train.Saver(tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)) sess.run(tf.global_variables_initializer()) saver.restore(sess, "./log/model.ckpt") for i in range(len(R_surf)): # for Rs in R_surf[:10]: Rl = R_surf[i] - R_Cu dl = np.sqrt(np.sum(Rl**2, axis=-1)) dl[dl > Router] = 0 coord = np.zeros((np.sum(dl > 0), 3)) coord = Rl[dl > 0] coord = np.concatenate((np.zeros((1, 3)), coord), axis=0) feat = pyu.getFeat(len(coord), coord, featParams["n2b"], featParams["n3b"]) feedDict = {tf_feat: pyf.scaleFeat(featParams, feat)} Ei[i] = sess.run(L3, feed_dict=feedDict) print("{}/{}".format(i, len(R_surf)), Ei[i]) # pyu.saveXYZ([coord], ["Cu"], "test.xyz") Ei = Ei - 0.5 idx = np.zeros(len(Ei)) for k in range(3): idx[np.abs(R_surf[:, k]) < 2] = 1
dC1O1 = np.mean(dC1O1) dC0H = np.mean(dC0H) aOCH = np.mean(aOCH)*np.pi/180 randomIdx = np.random.permutation(len(R_surf))[:nCase] Rs = R_surf[randomIdx] for iCase in range(nCase): print(iCase) d_sq = np.sum((Rs[iCase] - R_Cu)**2,axis=1) Rcluster = R_Cu[d_sq < Rcut**2] RNN = R_Cu[(d_sq < Rcut2**2) & (d_sq != 0)] Rcluster2 = np.concatenate([(Rs[iCase])[np.newaxis,:],R_Cu[(d_sq < Rcut3**2) & (d_sq !=0)]],axis=0) feat=pyu.getFeat(len(Rcluster2), Rcluster2-Rs[iCase],featParams['n2b'],featParams['n3b']) E0 = pyf.getE(feat[np.newaxis,:], featParams, nnParams)[0] print(E0) if E0 < -0.5: R_surfNN = pyu.getSurfNN(RNN, Rcluster, Rnb=Rcut2, chunkSize=100) R_surf = pyu.getSurfVector(R_surfNN, Rcluster, Rnb=Rcut4, angleCutoff=angleCutoff) feat = np.zeros([len(R_surf), featParams['nFeat']]) for iNN in range(len(R_surf)): # print(R_surf[iNN] - Rs[iCase]) diNN_sq = np.sum((R_surf[iNN] - Rcluster)**2,axis=1) RiNN = np.zeros((np.sum(diNN_sq < Rcut3**2), 3)) RiNN[1:] = Rcluster[(diNN_sq != 0.0 ) & (diNN_sq < Rcut3**2)]-R_surf[iNN] # pyu.saveXYZ([RiNN], ['Cu'], 'CuOCCOH_poscar/Cu'+str(iNN)+'.xyz') feat[iNN] = pyu.getFeat(len(RiNN), RiNN,featParams['n2b'],featParams['n3b'])