Changeset 1924
- Timestamp:
- Jul 9, 2015 5:00:23 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r1915 r1924 30 30 import GSASIIstrIO as G2stIO 31 31 import GSASIImapvars as G2mv 32 import GSASIImath as G2mth 33 import GSASIIlattice as G2lat 32 34 import GSASIIgrid as G2gd 33 35 import GSASIIctrls as G2G … … 702 704 legend = "Select atoms to ride (only one of the atom variables will be varied when all are set to be varied)" 703 705 GetAddAtomVars(page,title1,title2,varList,constrDictEnt,'riding') 704 705 706 706 707 707 def OnAddFunction(event): … … 759 759 OnPageChanged(None) 760 760 761 def FindNeighbors(phase,FrstName,AtNames): 762 General = phase['General'] 763 cx,ct,cs,cia = General['AtomPtrs'] 764 Atoms = phase['Atoms'] 765 atNames = [atom[ct-1] for atom in Atoms] 766 Cell = General['Cell'][1:7] 767 Amat,Bmat = G2lat.cell2AB(Cell) 768 atTypes = General['AtomTypes'] 769 Radii = np.array(General['BondRadii']) 770 AtInfo = dict(zip(atTypes,Radii)) #or General['BondRadii'] 771 Orig = atNames.index(FrstName.split()[1]) 772 OType = Atoms[Orig][ct] 773 XYZ = G2mth.getAtomXYZ(Atoms,cx) 774 Neigh = [] 775 Dx = np.inner(Amat,XYZ-XYZ[Orig]).T 776 dist = np.sqrt(np.sum(Dx**2,axis=1)) 777 sumR = AtInfo[OType]+0.5 778 IndB = ma.nonzero(ma.masked_greater(dist-0.85*sumR,0.)) 779 for j in IndB[0]: 780 if j != Orig: 781 Neigh.append(AtNames[j]) 782 return Neigh 783 761 784 def GetAddAtomVars(page,title1,title2,varList,constrDictEnt,constType): 762 785 '''Get the atom variables to be added for OnAddAtomEquiv. Then create and 763 check the constraints. 786 check the constraints. Riding for H atoms only. 764 787 ''' 765 788 Atoms = {G2obj.VarDescr(i)[0]:[] for i in varList if 'Atom' in G2obj.VarDescr(i)[0]} … … 778 801 sel = dlg.GetSelection() 779 802 FrstAtom = AtNames[sel] 780 AtNames.remove(FrstAtom) 803 if 'riding' in constType: 804 phaseName = (FrstAtom.split(' in ')[1]).strip() 805 phase = Phases[phaseName] 806 AtNames = FindNeighbors(phase,FrstAtom,AtNames) 807 else: 808 AtNames.remove(FrstAtom) 781 809 dlg.Destroy() 782 810 if FrstAtom == '': … … 796 824 for name in Atoms[FrstAtom]: 797 825 newcons = [] 798 constr = [[1.0,G2obj.G2VarObj(name)]] 826 constr = [] 827 if 'riding' in constType: 828 if 'AU11' in name or 'AUiso' in name: 829 parts = name.split('AU11').split('AUiso') 830 constr = [[1.0,G2obj.G2VarObj(parts[0]+'AUiso'+parts[1])]] 831 elif 'AU' not in name: 832 constr = [[1.0,G2obj.G2VarObj(name)]] 833 else: 834 constr = [[1.0,G2obj.G2VarObj(name)]] 799 835 pref = name.rsplit(':',1)[0] 800 if 'riding' in constType and 'U' in pref:801 continue802 836 for sel in Selections: 803 837 id = Atoms[AtNames[sel]][0].rsplit(':',1)[-1] 804 constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]] 838 if 'riding' in constType: 839 if 'AU11' in pref or 'AUiso' in pref: 840 constr += [[1.2,G2obj.G2VarObj('%s:%s'%(parts[0]+'AUiso',id))]] 841 elif 'AU' not in pref: 842 constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]] 843 else: 844 constr += [[1.0,G2obj.G2VarObj('%s:%s'%(pref,id))]] 845 if not constr: 846 continue 805 847 if 'frac' in pref and 'riding' not in constType: 806 848 newcons = [constr+[1.0,None,'c']] -
trunk/GSASIIgrid.py
r1917 r1924 622 622 help='Add equivalences between atom parameter values') 623 623 self.ConstraintEdit.Enable(wxID_EQUIVALANCEATOMS,False) 624 self.ConstraintEdit.Append(id=wxID_ADDRIDING, kind=wx.ITEM_NORMAL,text='Add riding constraints',625 help='Add riding constraints between atom parameter values')624 self.ConstraintEdit.Append(id=wxID_ADDRIDING, kind=wx.ITEM_NORMAL,text='Add H riding constraints', 625 help='Add H atom riding constraints between atom parameter values') 626 626 self.ConstraintEdit.Enable(wxID_ADDRIDING,False) 627 627 wxID_ADDRIDING -
trunk/GSASIIobj.py
r1915 r1924 996 996 PhaseIdLookup[pId] = (ph,ranId) 997 997 PhaseRanIdLookup[ranId] = pId 998 shortname = ph [:10]998 shortname = ph #[:10] 999 999 while shortname in ShortPhaseNames.values(): 1000 1000 shortname = ph[:8] + ' ('+ pId + ')' -
trunk/GSASIIphsGUI.py
r1918 r1924 1540 1540 indx = Atoms.GetSelectedRows() 1541 1541 if indx: 1542 DisAglData['OrigIndx'] = indx1542 generalData = data['General'] 1543 1543 if 'DisAglCtls' in generalData: 1544 1544 DisAglCtls = generalData['DisAglCtls'] … … 1552 1552 generalData['DisAglCtls'] = DisAglCtls 1553 1553 atomData = data['Atoms'] 1554 generalData = data['General']1555 1554 colLabels = [Atoms.GetColLabelValue(c) for c in range(Atoms.GetNumberCols())] 1556 1555 for ind in indx: -
trunk/GSASIIstrMath.py
r1923 r1924 602 602 if parm in parmDict: 603 603 keys[key][iatm] = parmDict[parm] 604 Fdata = np.where(Fdata,Fdata,1.e-8) #avoid divide by zero in derivative calc. ?604 Fdata = np.where(Fdata,Fdata,1.e-8) #avoid divide by zero in derivative calc. 605 605 return Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata 606 606 -
trunk/imports/G2sfact.py
r1917 r1924 196 196 else: 197 197 if Tw != '1': #fix reversed twin ids 198 if first: 199 self.warnings += '\nPrimary twin id changed to 1\nNB: multiple primary twins not working' 200 first = False 198 201 Tw = '1' 199 202 TwId = int(Tw)-1
Note: See TracChangeset
for help on using the changeset viewer.