Changeset 3618


Ignore:
Timestamp:
Sep 24, 2018 3:11:34 PM (5 years ago)
Author:
vondreele
Message:

comment out creation of Uij constraints for new mag phases - not working correctly & rarely needed (for now)
add meand of refreshing Keep flags in mag cell list without recalling Bilbao

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r3617 r3618  
    12271227    sub = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Constraints')
    12281228    Constraints = G2frame.GPXtree.GetItemPyData(sub)
    1229     fracConstr = False
    12301229    for c in Constraints.get('HAP',[]):
    12311230        if c[-1] != 'c': continue
     
    12371236            # got a constraint, this is OK
    12381237            return
    1239     dlg = wx.MessageDialog(G2frame,
    1240                             'You are refining the scale factor and all phase fractions for histogram #'+
    1241                             histStr+'. This will produce an unstable refinement. '+
    1242                             'Do you want to constrain the sum of phase fractions?',
    1243                             'Create constraint?',
    1244                             wx.OK|wx.CANCEL)
     1238    dlg = wx.MessageDialog(G2frame,'You are refining the scale factor and all phase fractions for histogram #'+
     1239        histStr+'. This will produce an unstable refinement. '+
     1240        'Do you want to constrain the sum of phase fractions?','Create constraint?',wx.OK|wx.CANCEL)
    12451241    if dlg.ShowModal() != wx.ID_OK:
    12461242        dlg.Destroy()
     
    12921288    cx,ct,cs,cia = newPhase['General']['AtomPtrs']
    12931289    nAtoms = newPhase['Atoms']
    1294     oSGData = oldPhase['General']['SGData']
    12951290    nSGData = newPhase['General']['SGData']
    12961291    oAcof = G2lat.cell2A(oldPhase['General']['Cell'][1:7])
     
    13031298    varyList = []
    13041299    xnames = ['dAx','dAy','dAz']
    1305     unames = [['AU11','AU12','AU13'],['AU12','AU22','AU23'],['AU13','AU23','AU33']]
    1306 #    Us = ['U11','U22','U33','U12','U13','U23']
    1307     Uids = [[0,0,'AU11'],[1,1,'AU22'],[2,2,'AU33'],[0,1,'AU12'],[0,2,'AU13'],[1,2,'AU23']]
     1300#    Us = ['AU11','AU22','AU33','AU12','AU13','AU23']
     1301#    Uids = [[0,0,'AU11'],[1,1,'AU22'],[2,2,'AU33'],[0,1,'AU12'],[0,2,'AU13'],[1,2,'AU23']]
    13081302    for ia,code in enumerate(atCodes):
    13091303        atom = nAtoms[ia]
     1304        if not ia and atom[cia] == 'A':
     1305            wx.MessageDialog(G2frame,
     1306                'Anisotropic thermal motion constraints are not developed at the present time',
     1307                'Anisotropic thermal constraint?',style=wx.ICON_INFORMATION).ShowModal()
    13101308        siteSym = G2spc.SytSym(atom[cx:cx+3],nSGData)[0]
    13111309        CSX = G2spc.GetCSxinel(siteSym)
    1312         CSU = G2spc.GetCSuinel(siteSym)
     1310#        CSU = G2spc.GetCSuinel(siteSym)
    13131311        item = code.split('+')[0]
    13141312        iat,opr = item.split(':')
     
    13391337            DepCons = [1.0,G2obj.G2VarObj('%d::%s:%s'%(opId,name,iat))]
    13401338            constraints['Phase'].append([DepCons,IndpCon,None,None,'e'])
    1341 #        for iu,Uid in enumerate(Uids): Not right
     1339       
     1340#        DepConsDict = dict(zip(Us,[[],[],[],[],[],[]]))
     1341#        for iu,Uid in enumerate(Uids):
     1342#            UMT = np.zeros((3,3))
     1343#            UMT[Uid[0],Uid[1]] = 1
     1344#            nUMT = G2lat.prodMGMT(UMT,invTrans)
     1345#            nUT = G2lat.UijtoU6(nUMT)
     1346#            for iu,nU in enumerate(nUT):
     1347#                if abs(nU) > 1.e-8:
     1348#                    parm = '%d::%s;%s'%(opId,Us[iu],iat)
     1349#                    DepConsDict[Uid[2]].append([abs(nU%1.),G2obj.G2VarObj(parm)])
     1350#        nUcof = atom[iu:iu+6]
     1351#        for iU,Usi in enumerate(Us):
     1352#            parm = '%d::%s;%d'%(npId,Usi,ia)
     1353#            parmDict[parm] = nUcof[iU]
     1354#            varyList.append(parm)
     1355#            IndpCon = [1.0,G2obj.G2VarObj(parm)]
     1356#            if len(DepConsDict[Usi]) == 1:
     1357#                if DepConsDict[Usi][0]:
     1358#                    constraints['Phase'].append([IndpCon,DepConsDict[Usi][0],None,None,'e'])
     1359#            elif len(DepConsDict[Usi]) > 1:       
     1360#                for Dep in DepConsDict[Usi]:
     1361#                    Dep[0] *= -1
     1362#                constraints['Phase'].append([IndpCon]+DepConsDict[Usi]+[0.0,None,'c'])
     1363           
     1364
     1365
     1366
     1367
    13421368#        for iu in list(set(CSU[0])):
    13431369#            if not iu:
     
    13631389    As = ['A0','A1','A2','A3','A4','A5']
    13641390    Aids = [[0,0,'A0'],[1,1,'A1'],[2,2,'A2'],[0,1,'A3'],[0,2,'A4'],[1,2,'A5']]
    1365     Axes = ['a','b','c']
    1366     Holds = []
    13671391    DepConsDict = dict(zip(As,[[],[],[],[],[],[]]))
    13681392    for iA,Aid in enumerate(Aids):
     
    13761400                    parm = SetUniqAj(opId,As[ia],nSGData['SGLaue'])
    13771401                    DepConsDict[Aid[2]].append([nA,G2obj.G2VarObj(parm)])
    1378     for Asi in As:
     1402    for iA,Asi in enumerate(As):
    13791403        parm = SetUniqAj(npId,Asi,nSGData['SGLaue'])
    13801404        parmDict[parm] = nAcof[iA]
     
    13881412                Dep[0] *= -1
    13891413            constraints['Phase'].append([IndpCon]+DepConsDict[Asi]+[0.0,None,'c'])
    1390        
    1391        
    1392    
    1393    
    1394    
    1395    
    1396    
    1397    
    1398 #    for iA,Aid in enumerate(Aids):      #TODO: this is not generally correct - ok for orthonormal cases
    1399 #        parm = SetUniqAj(npId,Aid[2],nSGData['SGLaue'])
    1400 #        parmDict[parm] = nAcof[iA]
    1401 #        varyList.append(parm)
    1402 #        IndpCon = [1.0,G2obj.G2VarObj(parm)]
    1403 #        DepCons = []
    1404 #        for iat in range(3):
    1405 #            if nSGData['SGLaue'] in ['-1','2/m']:       #set holds
    1406 #                if (abs(nAcof[iA]) < 1.e-8) and (abs(invTrans[Aid[0],Aid[1]]) < 1.e-8):
    1407 #                    if Axes[iat] != nSGData['SGUniq'] and nSGData['SGLaue'] != oSGData['SGLaue']:
    1408 #                        HoldObj = G2obj.G2VarObj('%d::%s'%(npId,Aid[2]))
    1409 #                        if not HoldObj in Holds:
    1410 #                            constraints['Phase'].append([[0.0,HoldObj],None,None,'h'])
    1411 #                            Holds.append(HoldObj)
    1412 #                            continue
    1413 #            for ibt in range(3):
    1414 #                if abs(Trans[Aid[0],iat]) > 1.e-4 and abs(invTrans[Aid[1],ibt]) > 1.e-4 and abs(oAcof[iA]) > 1.e-8:
    1415 #                    parm = SetUniqAj(opId,As[iat],nSGData['SGLaue'])
    1416 #                    parmDict[parm] = oAcof[iat]
    1417 #                    if not parm in varyList:
    1418 #                        varyList.append(parm)
    1419 #                    DepCons.append([invTrans[ibt,iat]*invTrans[iat,ibt],G2obj.G2VarObj(parm)])
    1420 #        if len(DepCons) == 1:
    1421 #            constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])
    1422 #        elif len(DepCons) > 1:       
    1423 #            for Dep in DepCons:
    1424 #                Dep[0] *= -1
    1425 #            constraints['Phase'].append([IndpCon]+DepCons+[0.0,None,'c'])
    1426 #    constDict,fixedList,ignored = G2stIO.ProcessConstraints(constraints['Phase'])
    1427 #    groups,parmlist = G2mv.GroupConstraints(constDict)
    1428 #    G2mv.GenerateConstraints(groups,parmlist,varyList,constDict,fixedList,parmDict)
    1429 #    print 'old',parmDict
    1430 #    G2mv.Dict2Map(parmDict,varyList)
    1431 #    print 'new',parmDict
    14321414    for hId,hist in enumerate(UseList):    #HAP - seems OK
    14331415        ohapkey = '%d:%d:'%(opId,hId)
  • trunk/GSASIIpwdGUI.py

    r3617 r3618  
    33943394            data[5] = magcells
    33953395            G2frame.GPXtree.SetItemPyData(UnitCellsId,data)
     3396           
     3397    def OnRefreshKeep(event):
     3398        controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(UnitCellsId)
     3399        c =  event.GetCol()
     3400        E,SGData = G2spc.SpcGroup(controls[13])
     3401        if c == 2:
     3402            for phase in magcells:
     3403                Uvec = phase['Uvec']
     3404                Trans = phase['Trans']
     3405                allmom = phase['allmom']
     3406                invTrans = nl.inv(Trans)
     3407                magAtms = phase['magAtms']
     3408                TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom)
     3409            data = controls,bravais,cells,dminx,ssopt,magcells
     3410            G2frame.GPXtree.SetItemPyData(UnitCellsId,data)
     3411            wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
    33963412       
    33973413    def MakeNewPhase(event):
     
    35003516        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
    35013517       
     3518    def TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom):
     3519        found = False
     3520        if not magAtms:
     3521            phase['Keep'] = True
     3522            return
     3523        for matm in magAtms:
     3524            xyzs = G2spc.GenAtom(matm[3:6],SGData,False,Move=True)
     3525            for x in xyzs:
     3526                xyz = G2lat.TransformXYZ(x[0]-Uvec,invTrans.T,np.zeros(3))%1.
     3527                SytSym,Mul,Nop,dupDir = G2spc.SytSym(xyz,phase['SGData'])
     3528                CSI = G2spc.GetCSpqinel(phase['SGData']['SpnFlp'],dupDir)
     3529                if any(CSI[0]):     #found one - can quit looking
     3530                    phase['Keep'] = True
     3531                if allmom:
     3532                    if not any(CSI[0]):
     3533                        phase['Keep'] = False
     3534                        found = True
     3535                        break
     3536            if found:   #found one
     3537                break
     3538       
    35023539    def OnRunSubsMag(event):
    35033540        import kSUBGROUPSMAG as kMAG
     
    35613598                phase['Cell'] = G2lat.TransformCell(controls[6:12],Trans)   
    35623599                phase['aType'] = atype
    3563                 found = False
    3564                 if not magAtms:
    3565                     phase['Keep'] = True
    3566                 for matm in magAtms:
    3567                     xyzs = G2spc.GenAtom(matm[3:6],SGData,False,Move=True)
    3568                     for x in xyzs:
    3569                         xyz = G2lat.TransformXYZ(x[0]-Uvec,invTrans.T,np.zeros(3))%1.
    3570                         SytSym,Mul,Nop,dupDir = G2spc.SytSym(xyz,phase['SGData'])
    3571                         CSI = G2spc.GetCSpqinel(phase['SGData']['SpnFlp'],dupDir)
    3572                         if any(CSI[0]):     #found one - can quit looking
    3573                             phase['Keep'] = True
    3574                         if allmom:
    3575                             if not any(CSI[0]):
    3576                                 phase['Keep'] = False
    3577                                 found = True
    3578                                 break
    3579                     if found:   #found one
    3580                         break
     3600                phase['allmom'] = allmom
     3601                phase['magAtms'] = magAtms
     3602                TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom)
    35813603                magcells.append(phase)
    35823604            magcells[0]['Use'] = True
     
    38813903            table.append(row)
    38823904        MagCellsTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types)
     3905        G2frame.GetStatusBar().SetStatusText('Double click Keep to refresh Keep flags',1)
    38833906        magDisplay = G2G.GSGrid(G2frame.dataWindow)
    38843907        magDisplay.SetTable(MagCellsTable, True)
    38853908        magDisplay.Bind(wg.EVT_GRID_CELL_LEFT_CLICK,RefreshMagCellsGrid)
     3909        magDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK,OnRefreshKeep)
    38863910        magDisplay.AutoSizeColumns(False)
    38873911        for r in range(magDisplay.GetNumberRows()):
Note: See TracChangeset for help on using the changeset viewer.