Changeset 4464


Ignore:
Timestamp:
Jun 5, 2020 9:32:31 AM (16 months ago)
Author:
vondreele
Message:

reinstate the old FindCoordination? as FindCoordination2 - was used in FillCoordSphere?; new one incompatible.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r4462 r4464  
    12611261    return neighborArray
    12621262   
    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+2
    1273 #     SGData = generalData['SGData']
    1274 #     cellArray = G2lat.CellBlock(1)
     1263def 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)
    12751275   
    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 #             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
     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            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
    13131313
    13141314def FindCoordination(ind,data,neighborArray,coordsArray,cmx=0,targets=None):
     
    80188018        if 'Mx' in colLabels:
    80198019            cmx = colLabels.index('Mx')
    8020         SGData = generalData['SGData']
    8021         cellArray = G2lat.CellBlock(1)
    80228020        neighborArray = FindCoordinationByLabel(data)
    80238021
     
    80368034        added = 0
    80378035        targets = [item for item in atomTypes if params[item]]
     8036        cx,ct,cs,ci = getAtomPtrs(data,draw=True)     
    80388037        for rep in range(params['maxrep']):
    80398038            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']])
    80418040            addedAtoms = []
    80428041            for Ind,ind in enumerate(indx):
     
    80918090            pgbar.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    80928091        for Ind,ind in enumerate(indx):
    8093             atomData += FindCoordination(ind,data,cmx)
     8092            atomData += FindCoordination2(ind,data,cmx)
    80948093            GoOn = pgbar.Update(Ind,newmsg='Atoms done=%d'%(Ind))
    80958094            if not GoOn[0]: break
Note: See TracChangeset for help on using the changeset viewer.