- Timestamp:
- Jun 5, 2020 9:32:31 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIphsGUI.py
r4462 r4464 1261 1261 return neighborArray 1262 1262 1263 # def FindCoordination(ind,data,cmx=0,targets=None):1264 #'Find atoms coordinating atom ind, somewhat faster version'1265 #time1 = time.time()1266 #generalData = data['General']1267 #Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])1268 #atomTypes,radii = getAtomRadii(data)1269 #atomData = data['Drawing']['Atoms']1270 #numAtoms = len(atomData)1271 #cx,ct,cs,ci = data['Drawing']['atomPtrs']1272 #cij = ci+21273 #SGData = generalData['SGData']1274 #cellArray = G2lat.CellBlock(1)1263 def FindCoordination2(ind,data,cmx=0,targets=None): 1264 'Find atoms coordinating atom ind, somewhat faster version' 1265 time1 = time.time() 1266 generalData = data['General'] 1267 Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7]) 1268 atomTypes,radii = getAtomRadii(data) 1269 atomData = data['Drawing']['Atoms'] 1270 numAtoms = len(atomData) 1271 cx,ct,cs,ci = data['Drawing']['atomPtrs'] 1272 cij = ci+2 1273 SGData = generalData['SGData'] 1274 cellArray = G2lat.CellBlock(1) 1275 1275 1276 #newAtomList = []1277 #atomA = atomData[ind]1278 #xyzA = np.array(atomA[cx:cx+3])1279 #indA = atomTypes.index(atomA[ct])1280 #for atomB in atomData:1281 #if targets and atomB[ct] not in targets:1282 #continue1283 #indB = atomTypes.index(atomB[ct])1284 #sumR = radii[indA]+radii[indB]1285 #xyzB = np.array(atomB[cx:cx+3])1286 #Uij = atomB[cs+5:cs+5+6]1287 #for item in G2spc.GenAtom(xyzB,SGData,False,Uij,True):1288 #atom = copy.copy(atomB)1289 #atom[cx:cx+3] = item[0]1290 #Opr = abs(item[2])%1001291 #M = SGData['SGOps'][Opr-1][0]1292 #if cmx:1293 #opNum = G2spc.GetOpNum(item[2],SGData)1294 #mom = np.array(atom[cmx:cmx+3])1295 #if SGData['SGGray']:1296 #atom[cmx:cmx+3] = np.inner(mom,M)*nl.det(M)1297 #else:1298 #atom[cmx:cmx+3] = np.inner(mom,M)*nl.det(M)*SpnFlp[opNum-1]1299 #atom[cs-1] = str(item[2])+'+'1300 #atom[cs+5:cs+5+6] = item[1]1301 #posInAllCells = cellArray+np.array(atom[cx:cx+3])1302 #dists = np.sqrt(np.sum(np.inner(Amat,posInAllCells-xyzA)**2,axis=0))1303 #bonded = np.logical_and(dists < data['Drawing']['radiusFactor']*sumR, dists !=0)1304 #for xyz in posInAllCells[bonded]:1305 #if True in [np.allclose(np.array(xyz),np.array(atom[cx:cx+3]),atol=0.0002) for atom in atomData]: continue1306 #C = xyz-atom[cx:cx+3]+item[3]1307 #newAtom = atom[:]1308 #newAtom[cx:cx+3] = xyz1309 #newAtom[cs-1] += str(int(round(C[0])))+','+str(int(round(C[1])))+','+str(int(round(C[2])))1310 #newAtomList.append(newAtom)1311 #print ('Search time: %.2fs'%(time.time()-time1))1312 #return newAtomList1276 newAtomList = [] 1277 atomA = atomData[ind] 1278 xyzA = np.array(atomA[cx:cx+3]) 1279 indA = atomTypes.index(atomA[ct]) 1280 for atomB in atomData: 1281 if targets and atomB[ct] not in targets: 1282 continue 1283 indB = atomTypes.index(atomB[ct]) 1284 sumR = radii[indA]+radii[indB] 1285 xyzB = np.array(atomB[cx:cx+3]) 1286 Uij = atomB[cs+5:cs+5+6] 1287 for item in G2spc.GenAtom(xyzB,SGData,False,Uij,True): 1288 atom = copy.copy(atomB) 1289 atom[cx:cx+3] = item[0] 1290 Opr = abs(item[2])%100 1291 M = SGData['SGOps'][Opr-1][0] 1292 if cmx: 1293 opNum = G2spc.GetOpNum(item[2],SGData) 1294 mom = np.array(atom[cmx:cmx+3]) 1295 if SGData['SGGray']: 1296 atom[cmx:cmx+3] = np.inner(mom,M)*nl.det(M) 1297 else: 1298 atom[cmx:cmx+3] = np.inner(mom,M)*nl.det(M)*SpnFlp[opNum-1] 1299 atom[cs-1] = str(item[2])+'+' 1300 atom[cs+5:cs+5+6] = item[1] 1301 posInAllCells = cellArray+np.array(atom[cx:cx+3]) 1302 dists = np.sqrt(np.sum(np.inner(Amat,posInAllCells-xyzA)**2,axis=0)) 1303 bonded = np.logical_and(dists < data['Drawing']['radiusFactor']*sumR, dists !=0) 1304 for xyz in posInAllCells[bonded]: 1305 if True in [np.allclose(np.array(xyz),np.array(atom[cx:cx+3]),atol=0.0002) for atom in atomData]: continue 1306 C = xyz-atom[cx:cx+3]+item[3] 1307 newAtom = atom[:] 1308 newAtom[cx:cx+3] = xyz 1309 newAtom[cs-1] += str(int(round(C[0])))+','+str(int(round(C[1])))+','+str(int(round(C[2]))) 1310 newAtomList.append(newAtom) 1311 print ('Search time: %.2fs'%(time.time()-time1)) 1312 return newAtomList 1313 1313 1314 1314 def FindCoordination(ind,data,neighborArray,coordsArray,cmx=0,targets=None): … … 8018 8018 if 'Mx' in colLabels: 8019 8019 cmx = colLabels.index('Mx') 8020 SGData = generalData['SGData']8021 cellArray = G2lat.CellBlock(1)8022 8020 neighborArray = FindCoordinationByLabel(data) 8023 8021 … … 8036 8034 added = 0 8037 8035 targets = [item for item in atomTypes if params[item]] 8036 cx,ct,cs,ci = getAtomPtrs(data,draw=True) 8038 8037 for rep in range(params['maxrep']): 8039 8038 startlen = len(data['Drawing']['Atoms']) 8040 coordsArray = np.array([a[cx:cx+3] for a in atomData])8039 coordsArray = np.array([a[cx:cx+3] for a in data['Drawing']['Atoms']]) 8041 8040 addedAtoms = [] 8042 8041 for Ind,ind in enumerate(indx): … … 8091 8090 pgbar.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5)) 8092 8091 for Ind,ind in enumerate(indx): 8093 atomData += FindCoordination (ind,data,cmx)8092 atomData += FindCoordination2(ind,data,cmx) 8094 8093 GoOn = pgbar.Update(Ind,newmsg='Atoms done=%d'%(Ind)) 8095 8094 if not GoOn[0]: break
Note: See TracChangeset
for help on using the changeset viewer.