Changeset 1926 for trunk/GSASIIphsGUI.py


Ignore:
Timestamp:
Jul 13, 2015 4:10:42 PM (8 years ago)
Author:
vondreele
Message:

Work on add Hydrogens

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r1925 r1926  
    15581558            atomData = data['Atoms']
    15591559            AtNames = [atom[ct-1] for atom in atomData]
    1560             colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())]
     1560            AtLookUp = G2mth.FillAtomLookUp(atomData,cia+8)
    15611561            Neigh = []
     1562            AddHydIds = []
    15621563            for ind in indx:
    15631564                atom = atomData[ind]
     
    15651566                    continue
    15661567                neigh = [atom[ct-1],G2mth.FindNeighbors(data,atom[ct-1],AtNames),0]
    1567                 if len(neigh[1]) > 3 or (atom[ct] == 'O' and len(neigh[1]) > 1):
     1568                if len(neigh[1][0]) > 3 or (atom[ct] == 'O' and len(neigh[1][0]) > 1):
    15681569                    continue
     1570                nH = 1      #for O atom
     1571                if 'C' in neigh[0] or 'N' in neigh[0]:
     1572                    nH = 4-len(neigh[1][0])
     1573                bonds = dict(neigh[1][0])
     1574                for bond in bonds:
     1575                    if 'C' in neigh[0]:
     1576                        if 'C' in bond and bonds[bond] < 1.42:
     1577                            nH -= 1
     1578                            break
     1579                        elif 'O' in bond and bonds[bond] < 1.3:
     1580                            nH -= 1
     1581                            break
     1582                    elif 'O' in neigh[0] and 'C' in bonds and bonds[bond] < 1.3:
     1583                        nH -= 1
     1584                        break
     1585                neigh[2] = max(0,nH)  #set expected no. H's needed
     1586                AddHydIds.append(neigh[1][1])
    15691587                Neigh.append(neigh)
    15701588            if Neigh:
    15711589                dlg = G2gd.AddHatomDialog(G2frame,Neigh,data)
    15721590                if dlg.ShowModal() == wx.ID_OK:
     1591                    Nat = len(atomData)
    15731592                    Neigh = dlg.GetData()
    1574                     for neigh in Neigh:
    1575                         print neigh
    1576                    
     1593                    for ineigh,neigh in enumerate(Neigh):
     1594                        AddHydIds[ineigh].append(neigh[2])
     1595                        Hxyz = G2mth.AddHydrogens(AtLookUp,generalData,atomData,AddHydIds[ineigh])
     1596                        for X in Hxyz:
     1597                            Nat += 1
     1598                            AtomAdd(X[0],X[1],X[2],'H','H(%d)'%(Nat))
     1599
     1600                SetupGeneral()
     1601                FillAtomsGrid(Atoms)
    15771602                dlg.Destroy()
     1603                G2plt.PlotStructure(G2frame,data)
    15781604            else:
    15791605                wx.MessageBox('No candidates found',caption='Add H atom Error',style=wx.ICON_EXCLAMATION)
Note: See TracChangeset for help on using the changeset viewer.