Changeset 2512


Ignore:
Timestamp:
Nov 3, 2016 2:43:21 PM (5 years ago)
Author:
vondreele
Message:

remove 'constraint' and 'restraint' from Consraints & Restraints tabs
work on automatic nucl-mag constraints
allow selection of possible mag atoms to use in new mag phase
fix issues with chemical composition restraints

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r2506 r2512  
    3737import GSASIIplot as G2plt
    3838import GSASIIobj as G2obj
     39import GSASIIspc as G2spc
    3940VERY_LIGHT_GREY = wx.Colour(235,235,235)
    4041
     
    229230    rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
    230231    rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False)
    231     badPhaseParms = ['Ax','Ay','Az','Amul','AI/A','Atype','SHorder','mV0','mV1','mV2','waveType','Vol',]
     232    badPhaseParms = ['Ax','Ay','Az','Amul','AI/A','Atype','SHorder','mV0','mV1','mV2','waveType','Vol','isMag',]
    232233    globalList = rbDict.keys()
    233234    globalList.sort()
     
    10911092        G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,False)
    10921093#        G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_ADDRIDING,False)
    1093         if text == 'Histogram/Phase constraints':
     1094        if text == 'Histogram/Phase':
    10941095            G2frame.Page = [page,'hap']
    10951096            UpdateConstraintPanel(HAPConstr,'HAP')
    1096         elif text == 'Histogram constraints':
     1097        elif text == 'Histogram':
    10971098            G2frame.Page = [page,'hst']
    10981099            UpdateConstraintPanel(HistConstr,'Hist')
    1099         elif text == 'Phase constraints':
     1100        elif text == 'Phase':
    11001101            G2frame.Page = [page,'phs']
    11011102            G2frame.dataFrame.ConstraintEdit.Enable(G2gd.wxID_EQUIVALANCEATOMS,True)
     
    11061107                return
    11071108            UpdateConstraintPanel(PhaseConstr,'Phase')
    1108         elif text == 'Global constraints':
     1109        elif text == 'Global':
    11091110            G2frame.Page = [page,'glb']
    11101111            UpdateConstraintPanel(GlobalConstr,'Global')
     
    11501151    # note that order of pages is hard-coded in RaisePage
    11511152    PhaseConstr = wx.ScrolledWindow(G2frame.dataDisplay)
    1152     G2frame.dataDisplay.AddPage(PhaseConstr,'Phase constraints')
     1153    G2frame.dataDisplay.AddPage(PhaseConstr,'Phase')
    11531154    HAPConstr = wx.ScrolledWindow(G2frame.dataDisplay)
    1154     G2frame.dataDisplay.AddPage(HAPConstr,'Histogram/Phase constraints')
     1155    G2frame.dataDisplay.AddPage(HAPConstr,'Histogram/Phase')
    11551156    HistConstr = wx.ScrolledWindow(G2frame.dataDisplay)
    1156     G2frame.dataDisplay.AddPage(HistConstr,'Histogram constraints')
     1157    G2frame.dataDisplay.AddPage(HistConstr,'Histogram')
    11571158    GlobalConstr = wx.ScrolledWindow(G2frame.dataDisplay)
    1158     G2frame.dataDisplay.AddPage(GlobalConstr,'Global constraints')
     1159    G2frame.dataDisplay.AddPage(GlobalConstr,'Global')
    11591160    wx.CallAfter(OnPageChanged,None)
    11601161    G2frame.dataDisplay.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, OnPageChanged)
     
    11781179################################################################################       
    11791180       
    1180 def MagConstraints(G2frame,oldPhase,newPhase,Trans,Vec):
     1181def MagConstraints(G2frame,oldPhase,newPhase,Trans,Vec,atCodes):
    11811182    '''Add constraints for new magnetic phase created via transformation of old
    11821183    nuclear one
     1184    NB: A = [G11,G22,G33,2*G12,2*G13,2*G23]
    11831185    '''
    11841186    Histograms,Phases = G2frame.GetUsedHistogramsAndPhasesfromTree()
    11851187    UseList = newPhase['Histograms']
    11861188    detTrans = np.abs(nl.det(Trans))
     1189    invTrans = nl.inv(Trans)
     1190    oCell = oldPhase['General']['Cell'][1:7]
     1191    nCell = newPhase['General']['Cell'][1:7]
     1192    oGmat = G2lat.cell2Gmat(oldPhase['General']['Cell'][1:7])[0]
     1193    nGmat = G2lat.cell2Gmat(newPhase['General']['Cell'][1:7])[0]
     1194    Gtrans = np.inner(nGmat,nl.inv(oGmat))
     1195    print 'oA',G2lat.cell2A(oldPhase['General']['Cell'][1:7])
     1196    print 'nA',G2lat.cell2A(newPhase['General']['Cell'][1:7])
     1197    print 'oGmat',oGmat
     1198    print 'nGmat',nGmat
     1199    print 'Gtrans',Gtrans
     1200    nAcof = G2lat.cell2A(newPhase['General']['Cell'][1:7])
     1201   
    11871202    opId = oldPhase['pId']
    11881203    npId = newPhase['pId']
     1204    oph = '%d::'%(opId)
     1205    nph = '%d::'%(npId)
     1206    cx,ct,cs,cia = newPhase['General']['AtomPtrs']
     1207    nAtoms = newPhase['Atoms']
     1208    oSGData = oldPhase['General']['SGData']
     1209    nSGData = newPhase['General']['SGData']
    11891210    item = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,'Constraints')
    11901211    constraints = G2frame.PatternTree.GetItemPyData(item)
    1191     GSASIIpath.IPyBreak()
    1192     for hist in UseList:    #HAP
    1193         UseList[hist]['Scale'] /= detTrans      #scale by 1/volume ratio
    1194         UseList[hist]['Mustrain'][4:6] = [NShkl*[0.01,],NShkl*[False,]]
    1195         UseList[hist]['HStrain'] = [NDij*[0.0,],NDij*[False,]]
    1196     print 'make nuclear-magnetic phase constraints here'
     1212#    GSASIIpath.IPyBreak()
     1213    for ia,code in enumerate(atCodes):
     1214        atom = nAtoms[ia]
     1215        siteSym = G2spc.SytSym(atom[cx:cx+3],nSGData)[0]
     1216        CSX = G2spc.GetCSxinel(siteSym)
     1217        item = code.split('+')[0]
     1218        iat,opr = item.split(':')
     1219        Nop = abs(int(opr))%100-1
     1220        if '-' in opr:
     1221            Nop *= -1
     1222        Opr = oldPhase['General']['SGData']['SGOps'][abs(Nop)][0]
     1223        if Nop < 0:         #inversion
     1224            Opr *= -1
     1225        XOpr = np.inner(Opr,Trans.T)
     1226        names = ['dAx','dAy','dAz']
     1227        for ix,name in enumerate(names):
     1228            IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(opId,name,iat))]
     1229            DepCons = []
     1230            for iop,opval in enumerate(XOpr[ix]):
     1231                if opval and CSX[0][ix]:    #-opval from defn of dAx, etc.
     1232                    DepCons.append([-opval,G2obj.G2VarObj('%d::%s:%d'%(npId,names[iop],ia))])
     1233            if len(DepCons) == 1:
     1234                constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])
     1235            elif len(DepCons) > 1:
     1236                for Dep in DepCons:
     1237                    Dep[0] *= -1
     1238                constraints['Phase'].append([IndpCon]+DepCons+[0.0,None,'c'])
     1239        for name in ['Afrac','AUiso']:
     1240            IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(opId,name,iat))]
     1241            DepCons = [1.0,G2obj.G2VarObj('%d::%s:%d'%(npId,name,ia))]
     1242            constraints['Phase'].append([IndpCon,DepCons,None,None,'e'])
     1243        #how do I do Uij's for most Trans?
     1244    Anames = [['A0','A3','A4'],['A3','A1','A5'],['A4','A5','A2']]
     1245    Aids = [[0,0,'A0'],[1,1,'A1'],[2,2,'A2'],[0,1,'A3'],[0,2,'A4'],[1,2,'A5']]
     1246    Axes = ['a','b','c']
     1247    Holds = []
     1248    #how do I invoke Laue symmetry matches for Laue symm change?
     1249    for iA,Aid in enumerate(Aids):       
     1250        IndpCon = [1.0,G2obj.G2VarObj('%d::%s'%(npId,Aid[2]))]
     1251        DepCons = []
     1252        for iat in range(3):
     1253            if nSGData['SGLaue'] in ['-1','2/m']:
     1254                if (abs(nAcof[iA]) < 1.e-8) and (abs(Gtrans[iat][Aid[0]]) < 1.e-8):
     1255                    if Axes[iat] != oSGData['SGUniq'] and oSGData['SGLaue'] != nSGData['SGLaue']:
     1256                        HoldObj = G2obj.G2VarObj('%d::%s'%(npId,Aid[2]))
     1257                        if not HoldObj in Holds:
     1258                            constraints['Phase'].append([[0.0,HoldObj],None,None,'h'])
     1259                            Holds.append(HoldObj)
     1260                            print constraints['Phase'][-1]
     1261            if abs(Gtrans[iat][Aid[0]]) > 1.e-8 and abs(nAcof[iA]) > 1.e-8:
     1262                print iat,Aid,Gtrans[iat][Aid[1]],'%d::%s'%(opId,Anames[iat][Aid[1]])
     1263                DepCons.append([Gtrans[iat][Aid[1]],G2obj.G2VarObj('%d::%s'%(opId,Anames[iat][Aid[1]]))])
     1264        if len(DepCons) == 1:
     1265            constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])
     1266        elif len(DepCons) > 1:       
     1267            for Dep in DepCons:
     1268                Dep[0] *= -1
     1269            constraints['Phase'].append([IndpCon]+DepCons+[0.0,None,'c'])
     1270    for hId,hist in enumerate(UseList):    #HAP - seems OK
     1271        ohapkey = '%d:%d:'%(opId,hId)
     1272        nhapkey = '%d:%d:'%(npId,hId)
     1273        IndpCon = [1.0,G2obj.G2VarObj(ohapkey+'Scale')]
     1274        DepCons = [detTrans,G2obj.G2VarObj(nhapkey+'Scale')]
     1275        constraints['HAP'].append([IndpCon,DepCons,None,None,'e'])
     1276        for name in ['Size;i','Mustrain;i']:
     1277            IndpCon = [1.0,G2obj.G2VarObj(ohapkey+name)]
     1278            DepCons = [1.0,G2obj.G2VarObj(nhapkey+name)]
     1279            constraints['HAP'].append([IndpCon,DepCons,None,None,'e'])
    11971280       
    11981281################################################################################
  • trunk/GSASIIgrid.py

    r2509 r2512  
    208208        btnsizer = wx.StdDialogButtonSizer()
    209209        OKbtn = wx.Button(self.panel, wx.ID_OK)
     210        OKbtn.Bind(wx.EVT_BUTTON, self.OnOk)
    210211        OKbtn.SetDefault()
    211212        btnsizer.AddButton(OKbtn)
     
    224225        self.ShowModal()
    225226        return
     227
     228    def OnOk(self,event):
     229        parent = self.GetParent()
     230        parent.Raise()
     231        self.EndModal(wx.ID_OK)
    226232
    227233class SGMagSpinBox(wx.Dialog):
     
    584590            event.Skip()
    585591            Flds = SGTxt.GetValue().split()
     592            Flds[0] = Flds[0].upper()
    586593            #get rid of extra spaces between fields first
    587594            for fld in Flds: fld = fld.strip()
     
    716723       
    717724    def GetSelection(self):
    718         self.Phase['General']['Name'] += ' %s'%(self.Common)
     725        if self.ifMag:
     726            self.Phase['General']['Name'] += ' mag'
     727        else:
     728            self.Phase['General']['Name'] += ' %s'%(self.Common)
    719729        self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans)           
    720730        return self.Phase,self.Trans,self.Vec,self.ifMag,self.ifConstr
     
    729739        parent.Raise()
    730740        self.EndModal(wx.ID_CANCEL)
    731        
     741################################################################################
     742class UseMagAtomDialog(wx.Dialog):
     743    '''Get user selected magnetic atoms after cell transformation
     744    '''
     745    def __init__(self,parent,Atoms,atCodes):
     746        wx.Dialog.__init__(self,parent,wx.ID_ANY,'Magnetic atom selection',
     747            pos=wx.DefaultPosition,style=wx.DEFAULT_DIALOG_STYLE)
     748        self.panel = wx.Panel(self)         #just a dummy - gets destroyed in Draw!
     749        self.Atoms = Atoms
     750        self.atCodes = atCodes
     751        self.Use = len(self.Atoms)*[True,]
     752        self.Draw()
     753       
     754    def Draw(self):
     755       
     756        def OnUseChk(event):
     757            Obj = event.GetEventObject()
     758            iuse = Indx[Obj.GetId()]
     759            self.Use[iuse] = not self.Use[iuse]
     760            Obj.SetValue(self.Use[iuse])
     761       
     762        self.panel.Destroy()
     763        self.panel = wx.Panel(self)
     764        Indx = {}
     765        mainSizer = wx.BoxSizer(wx.VERTICAL)
     766       
     767        mainSizer.Add(wx.StaticText(self.panel,label=' Name, x, y, z:'),0,WACV)
     768        atmSizer = wx.FlexGridSizer(0,2,5,5)
     769        for iuse,[use,atom] in enumerate(zip(self.Use,self.Atoms)):
     770            useChk = wx.CheckBox(self.panel,label='Use?')
     771            Indx[useChk.GetId()] = iuse
     772            useChk.SetValue(use)
     773            useChk.Bind(wx.EVT_CHECKBOX, OnUseChk)
     774            atmSizer.Add(useChk,0,WACV)
     775            text = ' %s %10.5f %10.5f %10.5f'%(atom[0],atom[3],atom[4],atom[5])
     776            atmSizer.Add(wx.StaticText(self.panel,label=text),0,WACV)
     777        mainSizer.Add(atmSizer)
     778       
     779        OkBtn = wx.Button(self.panel,-1,"Ok")
     780        OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     781        cancelBtn = wx.Button(self.panel,-1,"Use All")
     782        cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
     783        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
     784        btnSizer.Add((20,20),1)
     785        btnSizer.Add(OkBtn)
     786        btnSizer.Add((20,20),1)
     787        btnSizer.Add(cancelBtn)
     788        btnSizer.Add((20,20),1)
     789       
     790        mainSizer.Add(btnSizer,0,wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
     791        self.panel.SetSizer(mainSizer)
     792        self.panel.Fit()
     793        self.Fit()
     794       
     795    def GetSelection(self):
     796        useAtoms = []
     797        useatCodes = []
     798        for use,atom,code in zip(self.Use,self.Atoms,self.atCodes):
     799            if use:
     800                useAtoms.append(atom)
     801                useatCodes.append(code)
     802        return useAtoms,useatCodes
     803
     804    def OnOk(self,event):
     805        parent = self.GetParent()
     806        parent.Raise()
     807        self.EndModal(wx.ID_OK)
     808
     809    def OnCancel(self,event):
     810        parent = self.GetParent()
     811        parent.Raise()
     812        self.EndModal(wx.ID_CANCEL)
     813           
     814               
    732815################################################################################
    733816class RotationDialog(wx.Dialog):
  • trunk/GSASIIlattice.py

    r2486 r2512  
    232232def TransformPhase(oldPhase,newPhase,Trans,Vec,ifMag):
    233233    '''Transform atoms from oldPhase to newPhase by Trans & Vec
    234     NB: doesnt transform moments correctly - TBD
    235234   
    236235    :param oldPhase: dict G2 phase info for old phase
     
    242241        if True all nonmagnetic atoms will be removed
    243242       
    244     This needs to properly transform magnetic moments for mag - mag transforms
    245243    '''
    246244   
     
    253251    SGData = newPhase['General']['SGData']
    254252    invTrans = nl.inv(Trans)
    255     newAtoms = FillUnitCell(oldPhase)
     253    newAtoms,atCodes = FillUnitCell(oldPhase)
     254#    GSASIIpath.IPyBreak()
    256255    Unit =[abs(int(max(unit))-1) for unit in Trans]
    257256    for i,unit in enumerate(Unit):
     
    259258            for j in range(unit):
    260259                moreAtoms = copy.deepcopy(newAtoms)
    261                 for atom in moreAtoms:
     260                moreCodes = []
     261                for atom,code in zip(moreAtoms,atCodes):
    262262                    atom[cx+i] += 1.
     263                    if '+' in code:
     264                        cell = list(eval(code.split('+')[1]))
     265                        ops = code.split('+')[0]
     266                    else:
     267                        cell = [0,0,0]
     268                        ops = code
     269                    cell[i] += 1
     270                    moreCodes.append('%s+%d,%d,%d'%(ops,cell[0],cell[1],cell[2]))
    263271                newAtoms += moreAtoms
     272                atCodes += moreCodes
    264273    if ifMag:
    265274        cia += 3
     
    268277        newPhase['General']['AtomPtrs'] = [cx,ct,cs,cia]
    269278        magAtoms = []
     279        magatCodes = []
    270280        Landeg = 2.0
    271         for atom in newAtoms:
     281        for iat,atom in enumerate(newAtoms):
    272282            if len(G2elem.GetMFtable([atom[ct],],[Landeg,])):
    273283                magAtoms.append(atom[:cx+4]+[0.,0.,0.]+atom[cx+4:])
     284                magatCodes.append(atCodes[iat])
    274285        newAtoms = magAtoms
     286        atCodes = magatCodes
    275287        newPhase['Draw Atoms'] = []
    276288    for atom in newAtoms:
     
    289301                atom[cm:cm+3] = mom*mag
    290302    newPhase['Atoms'] = newAtoms
    291     newPhase['Atoms'] = GetUnique(newPhase)
     303    newPhase['Atoms'],atCodes = GetUnique(newPhase,atCodes)
    292304    newPhase['Drawing']['Atoms'] = []
    293     return newPhase
     305    newPhase['ranId'] = ran.randint(0,sys.maxint)
     306    return newPhase,atCodes
    294307   
    295308def FillUnitCell(Phase):
    296309    Atoms = Phase['Atoms']
    297310    atomData = []
     311    atCodes = []
    298312    SGData = Phase['General']['SGData']
    299313    SpnFlp = SGData.get('SpnFlp',[])
     
    304318        cm = cx+4
    305319    unit = np.zeros(3)
    306     for atom in Atoms:
     320    for iat,atom in enumerate(Atoms):
    307321        XYZ = np.array(atom[cx:cx+3])
    308322        xyz = XYZ%1.
    309         unit = XYZ-xyz
    310323        if atom[cia] == 'A':
    311324            Uij = atom[cia+2:cia+8]
     
    321334                    mom = np.inner(np.array(atom[cm:cm+3]),Bmat)
    322335                    atom[cm:cm+3] = np.inner(np.inner(mom,M),Amat)*nl.det(M)*SpnFlp[opNum-1]
     336                atCodes.append('%d:%s'%(iat,str(item[2])))
    323337                atomData.append(atom[:cia+9])  #not SS stuff
    324338        else:
     
    334348                    atom[cm:cm+3] = np.inner(np.inner(mom,M),Amat)*nl.det(M)*SpnFlp[opNum-1]
    335349#                GSASIIpath.IPyBreak()
     350                atCodes.append('%d:%s'%(iat,str(item[1])))
    336351                atomData.append(atom[:cia+9])  #not SS stuff
    337352           
    338     return atomData
     353    return atomData,atCodes
    339354       
    340 def GetUnique(Phase):
     355def GetUnique(Phase,atCodes):
    341356   
    342357    def noDuplicate(xyzA,XYZ,Amat):
     
    352367    Ind = len(Atoms)
    353368    newAtoms = []
     369    newAtCodes = []
    354370    Indx = {}
    355371    XYZ = {}
     
    369385        if Indx[ind]:
    370386            newAtoms.append(Atoms[ind])
    371     return newAtoms
     387            newAtCodes.append(atCodes[ind])
     388    return newAtoms,newAtCodes
    372389           
    373390def calc_rVsq(A):
  • trunk/GSASIIphsGUI.py

    r2504 r2512  
    13881388            dlg.Destroy()
    13891389        phaseName = newPhase['General']['Name']
    1390         if ifMag:
    1391             phaseName += ' mag'
    1392         newPhase = G2lat.TransformPhase(data,newPhase,Trans,Vec,ifMag)
     1390        newPhase,atCodes = G2lat.TransformPhase(data,newPhase,Trans,Vec,ifMag)
    13931391        detTrans = np.abs(nl.det(Trans))
    13941392
    13951393        generalData = newPhase['General']
    13961394        SGData = generalData['SGData']
     1395        Atoms = newPhase['Atoms']
     1396        if ifMag:
     1397            dlg = G2gd.UseMagAtomDialog(G2frame,Atoms,atCodes)
     1398            try:
     1399                if dlg.ShowModal() == wx.ID_OK:
     1400                    newPhase['Atoms'],atCodes = dlg.GetSelection()
     1401            finally:
     1402                dlg.Destroy()
     1403            SGData['GenSym'],SGData['GenFlg'] = G2spc.GetGenSym(SGData)
     1404            SGData['MagSpGrp'] = G2spc.MagSGSym(SGData)
     1405            SGData['OprNames'],SGData['SpnFlp'] = G2spc.GenMagOps(SGData)
     1406            generalData['Lande g'] = len(generalData['AtomTypes'])*[2.,]
     1407           
    13971408        NShkl = len(G2spc.MustrainNames(SGData))
    13981409        NDij = len(G2spc.HStrainNames(SGData))
     
    14071418        G2frame.PatternTree.SetItemPyData(sub,newPhase)
    14081419        if ifMag and ifConstr:
    1409             G2cnstG.MagConstraints(G2frame,data,newPhase,Trans,Vec,)     #data is old phase
     1420            G2cnstG.MagConstraints(G2frame,data,newPhase,Trans,Vec,atCodes)     #data is old phase
    14101421        G2frame.PatternTree.SelectItem(sub)
    1411 #        G2gd.MovePatternTreeToGrid(G2frame,sub) #bring up new phase General tab
    14121422       
    14131423################################################################################
  • trunk/GSASIIrestrGUI.py

    r2487 r2512  
    16781678                    mulfrac = mul*frac
    16791679                    calcs = mul*frac*factors
    1680                     chisq += chiralRestData['wtFactor']*((obs-np.sum(calcs))/esd)**2
     1680                    chisq += chemcompRestData['wtFactor']*((obs-np.sum(calcs))/esd)**2
    16811681                    for iatm,[atom,mf,fr,clc] in enumerate(zip(atoms,mulfrac,factors,calcs)):
    16821682                        table.append([atom,mf,fr,clc,'',''])
     
    18161816        text = G2frame.dataDisplay.GetPageText(page)
    18171817        G2frame.dataFrame.RestraintEdit.SetLabel(G2gd.wxID_RESRCHANGEVAL,'Change value')
    1818         if text == 'Bond restraints':
     1818        if text == 'Bond':
    18191819            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18201820            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,True)
     
    18221822            bondRestData = restrData['Bond']
    18231823            UpdateBondRestr(bondRestData)
    1824         elif text == 'Angle restraints':
     1824        elif text == 'Angle':
    18251825            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18261826            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,True)
     
    18281828            angleRestData = restrData['Angle']
    18291829            UpdateAngleRestr(angleRestData)
    1830         elif text == 'Plane restraints':
     1830        elif text == 'Plane':
    18311831            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18321832            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,True)
     
    18341834            planeRestData = restrData['Plane']
    18351835            UpdatePlaneRestr(planeRestData)
    1836         elif text == 'Chiral restraints':
     1836        elif text == 'Chiral':
    18371837            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18381838            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,False)
     
    18401840            chiralRestData = restrData['Chiral']
    18411841            UpdateChiralRestr(chiralRestData)
    1842         elif text == 'Torsion restraints':
     1842        elif text == 'Torsion':
    18431843            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18441844            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,False)
     
    18471847            torsionRestData = restrData['Torsion']
    18481848            UpdateTorsionRestr(torsionRestData)
    1849         elif text == 'Ramachandran restraints':
     1849        elif text == 'Ramachandran':
    18501850            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18511851            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,False)
     
    18551855            UpdateRamaRestr(ramaRestData)
    18561856            wx.CallAfter(G2plt.PlotRama,G2frame,phaseName,rama,ramaName)
    1857         elif text == 'Chem. comp. restraints':
     1857        elif text == 'Chem. comp.':
    18581858            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18591859            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,True)
     
    18631863            chemcompRestData = restrData['ChemComp']
    18641864            UpdateChemcompRestr(chemcompRestData)
    1865         elif text == 'Texture restraints':
     1865        elif text == 'Texture':
    18661866            G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.RestraintMenu)
    18671867            G2frame.dataFrame.RestraintEdit.Enable(G2gd.wxID_RESTRAINTADD,True)
     
    19081908        G2frame.dataFrame.RestraintTab.DestroyItem(i)       
    19091909
    1910     txt = 'Bond restraints'
     1910    txt = 'Bond'
    19111911    BondRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19121912    G2frame.dataDisplay.AddPage(BondRestr,txt)
     
    19181918    tabIndex[item.GetId()] = tabcount
    19191919
    1920     txt = 'Angle restraints'
     1920    txt = 'Angle'
    19211921    AngleRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19221922    G2frame.dataDisplay.AddPage(AngleRestr,txt)
     
    19281928    tabIndex[item.GetId()] = tabcount
    19291929   
    1930     txt = 'Plane restraints'
     1930    txt = 'Plane'
    19311931    PlaneRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19321932    G2frame.dataDisplay.AddPage(PlaneRestr,txt)
     
    19381938    tabIndex[item.GetId()] = tabcount
    19391939
    1940     txt = 'Chiral restraints'
     1940    txt = 'Chiral'
    19411941    ChiralRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19421942    G2frame.dataDisplay.AddPage(ChiralRestr,txt)
     
    19491949
    19501950    if 'macro' in General['Type']:
    1951         txt = 'Torsion restraints'
     1951        txt = 'Torsion'
    19521952        TorsionRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19531953        G2frame.dataDisplay.AddPage(TorsionRestr,txt)
     
    19591959        tabIndex[item.GetId()] = tabcount
    19601960
    1961         txt = 'Ramachandran restraints'
     1961        txt = 'Ramachandran'
    19621962        RamaRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19631963        G2frame.dataDisplay.AddPage(RamaRestr,txt)
     
    19691969        tabIndex[item.GetId()] = tabcount
    19701970
    1971     txt = 'Chem. comp. restraints'
     1971    txt = 'Chem. comp.'
    19721972    ChemCompRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19731973    G2frame.dataDisplay.AddPage(ChemCompRestr,txt)
     
    19801980   
    19811981    if General['SH Texture']['Order']:
    1982         txt = 'Texture restraints'
     1982        txt = 'Texture'
    19831983        TextureRestr = wx.ScrolledWindow(G2frame.dataDisplay)
    19841984        G2frame.dataDisplay.AddPage(TextureRestr,txt)
  • trunk/GSASIIstrMath.py

    r2508 r2512  
    320320        textureData = General['SH Texture']
    321321        SGData = General['SGData']
     322        Atoms = Phases[phase]['Atoms']
    322323        AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms'],cia+8)
    323324        cell = General['Cell'][1:7]
     
    368369                    for i,[indx,factors,obs,esd] in enumerate(itemRest[rest]):
    369370                        pNames.append(str(pId)+':'+name+':'+str(i))
    370                         mul = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cs+1))
    371                         frac = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cs-1))
     371                        mul = np.array(G2mth.GetAtomItemsById(Atoms,AtLookup,indx,cs+1))
     372                        frac = np.array(G2mth.GetAtomItemsById(Atoms,AtLookup,indx,cs-1))
    372373                        calc = np.sum(mul*frac*factors)
    373374                        pVals.append(obs-calc)
     
    455456        cx,ct,cs,cia = General['AtomPtrs']
    456457        SGData = General['SGData']
     458        Atoms = Phases[phase]['Atoms']
    457459        AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms'],cia+8)
    458460        cell = General['Cell'][1:7]
     
    511513                    for ind in indx:
    512514                        dNames += [str(pId)+'::Afrac:'+str(AtLookup[ind])]
    513                         mul = np.array(G2mth.GetAtomItemsById(Atoms,AtLookUp,indx,cs+1))
     515                        mul = np.array(G2mth.GetAtomItemsById(Atoms,AtLookup,indx,cs+1))
    514516                        deriv = mul*factors
    515517                elif 'Texture' in name:
     
    12871289        eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0)
    12881290        Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm = BPM in magstrfc.for OK
     1291#there is still something wrong with the next three lines = dF/dmag not corect yet
    12891292        dqdm = np.array([np.outer(hm,hm)-np.eye(3) for hm in HM.T]).T   #Mxyz,Mxyz,Nref (3x3 matrix)
    12901293        dqmx = np.sum(dqdm[:,:,:,nxs,nxs]*dGdm[:,nxs,nxs,:,:],axis=0)   #matrix * vector = vector
    12911294        dmx = Q*dGdM[:,nxs,:,:]+dqmx                                    #*Mag canceled out of dqmx term
     1295#
    12921296        fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:]    #Mxyz,Nref,Nop,Natm
    12931297        fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:]
     
    13001304        dfadx = np.sum(-twopi*Uniq[nxs,:,:,nxs,:]*famx[:,:,:,:,nxs],axis=2)          #deriv OK
    13011305        dfadmx = np.sum(TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*dmx,axis=2)
    1302         dfadui = np.sum(-SQfactor[:,nxs,nxs]*fam,axis=2) #array(Ops,refBlk,nAtoms)  OK
    1303         dfadua = np.sum(-Hij[nxs,:,:,nxs,:]*fam[:,:,:,:,nxs],axis=2)    #OK? not U12 & U23 in sarc
     1306        dfadui = np.sum(-SQfactor[:,nxs,nxs]*fam,axis=2) #array(Ops,refBlk,nAtoms)  deriv OK
     1307        dfadua = np.sum(-Hij[nxs,:,:,nxs,:]*fam[:,:,:,:,nxs],axis=2)    #deriv OK? not U12 & U23 in sarc
    13041308        # imaginary part; array(3,refBlk,nAtom,3) & array(3,refBlk,nAtom,6)
    13051309        dfbdfr = np.sum(fbm/occ,axis=2)        #array(mxyz,refBlk,nAtom) Fdata != 0 avoids /0. problem
Note: See TracChangeset for help on using the changeset viewer.