Changeset 3406


Ignore:
Timestamp:
May 28, 2018 11:03:32 AM (3 years ago)
Author:
vondreele
Message:

fix Transform to create correct(?) constraints between lattices, atom positions & anisotropic thermal parameters.
Checked for axes permutations in orthorhombic.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r3397 r3406  
    544544        errmsg,warnmsg = CheckConstraints(allcons)
    545545        if errmsg:
    546             res = G2frame.ErrorDialog('Constraint Error',
     546            G2frame.ErrorDialog('Constraint Error',
    547547                'Error with newly added constraint:\n'+errmsg+
    548548                '\nIgnoring newly added constraint',parent=G2frame)
     
    573573        errmsg,warnmsg = CheckConstraints(allcons)
    574574        if errmsg:
    575             res = G2frame.ErrorDialog('Constraint Error',
     575            G2frame.ErrorDialog('Constraint Error',
    576576                'Error after editing constraint:\n'+errmsg+
    577577                '\nDiscarding last constraint edit',parent=G2frame)
    578578            # reset error status
    579             errmsg,warnmsg = CheckConstraints(allcons1)
     579            errmsg,warnmsg = CheckConstraints(allcons)
    580580            if errmsg:
    581581                print (errmsg)
     
    10881088        else: # called directly, get current page
    10891089            page = G2frame.constr.GetSelection()
    1090         #G2frame.constr.SetSize(G2frame.dataWindow.GetClientSize())    #TODO -almost right
    10911090        G2frame.constr.ChangeSelection(page)
    10921091        text = G2frame.constr.GetPageText(page)
     
    11921191
    11931192################################################################################
    1194 #### Make nuclear-magnetic phase constraints - called by OnTransform in G2phsGUI
     1193#### Make nuclear/magnetic phase transition constraints - called by OnTransform in G2phsGUI
    11951194################################################################################       
    11961195       
    1197 def MagConstraints(G2frame,oldPhase,newPhase,Trans,Vec,atCodes):
     1196def TransConstraints(G2frame,oldPhase,newPhase,Trans,Vec,atCodes):
    11981197    '''Add constraints for new magnetic phase created via transformation of old
    11991198    nuclear one
     
    12011200    '''
    12021201   
    1203     def SetUniqAj(pId,iA,Aname,SGLaue):
     1202    def SetUniqAj(pId,Aname,SGLaue):
    12041203        if SGLaue in ['4/m','4/mmm'] and iA in [0,1]:
    12051204            parm = '%d::%s'%(pId,'A0')
     
    12381237    parmDict = {}
    12391238    varyList = []
     1239    xnames = ['dAx','dAy','dAz']
     1240    unames = [['U11','U12','U13'],['U12','U22','U23'],['U13','U23','U33']]
     1241#    Us = ['U11','U22','U33','U12','U13','U23']
     1242    Uids = [[0,0,'U11'],[1,1,'U22'],[2,2,'U33'],[0,1,'U12'],[0,2,'U13'],[1,2,'U23']]
    12401243    for ia,code in enumerate(atCodes):
    12411244        atom = nAtoms[ia]
    12421245        siteSym = G2spc.SytSym(atom[cx:cx+3],nSGData)[0]
    12431246        CSX = G2spc.GetCSxinel(siteSym)
     1247        CSU = G2spc.GetCSuinel(siteSym)
    12441248        item = code.split('+')[0]
    12451249        iat,opr = item.split(':')
     
    12501254        if Nop < 0:         #inversion
    12511255            Opr *= -1
    1252         XOpr = np.inner(Opr,Trans.T)
    1253         names = ['dAx','dAy','dAz']
    1254         for ix,name in enumerate(names):
    1255             IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(opId,name,iat))]
     1256        XOpr = np.inner(Opr,invTrans)
     1257        for ix,name in enumerate(xnames):
     1258            IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(npId,name,iat))]
    12561259            DepCons = []
    12571260            for iop,opval in enumerate(XOpr[ix]):
    1258                 if opval and CSX[0][ix]:    #-opval from defn of dAx, etc.
    1259                     DepCons.append([-opval,G2obj.G2VarObj('%d::%s:%d'%(npId,names[iop],ia))])
     1261                if opval and CSX[0][ix]:
     1262                    DepCons.append([opval,G2obj.G2VarObj('%d::%s:%d'%(opId,xnames[iop],ia))])
    12601263            if len(DepCons) == 1:
    12611264                constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])
     
    12651268                constraints['Phase'].append([IndpCon]+DepCons+[0.0,None,'c'])
    12661269        for name in ['Afrac','AUiso']:
    1267             IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(opId,name,iat))]
    1268             DepCons = [1.0,G2obj.G2VarObj('%d::%s:%d'%(npId,name,ia))]
     1270            IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(npId,name,iat))]
     1271            DepCons = [1.0,G2obj.G2VarObj('%d::%s:%d'%(opId,name,ia))]
    12691272            constraints['Phase'].append([IndpCon,DepCons,None,None,'e'])
     1273        for iu,Uid in enumerate(Uids):
     1274            if not CSU[0][iu]:
     1275                continue
     1276            IndpCon = [1.0,G2obj.G2VarObj('%d::%s:%s'%(npId,Uid[2],ia))]
     1277            DepCons = []
     1278            for iat in range(3):
     1279                for ibt in range(3):
     1280                    if abs(Trans[Uid[0],iat]) > 1.e-4 and abs(Trans[Uid[1],ibt]) > 1.e-4:
     1281                        parm = '%d::%s:%d'%(opId,unames[ibt][iat],ia)
     1282                        if not parm in varyList:
     1283                            varyList.append(parm)
     1284                        DepCons.append([Trans[ibt,iat]/detTrans,G2obj.G2VarObj(parm)])
     1285            if len(DepCons) == 1:
     1286                constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])
     1287            elif len(DepCons) > 1:       
     1288                for Dep in DepCons:
     1289                    Dep[0] *= -1
     1290                constraints['Phase'].append([IndpCon]+DepCons+[0.0,None,'c'])
     1291           
    12701292        #how do I do Uij's for most Trans?
    12711293    Anames = [['A0','A3','A4'],['A3','A1','A5'],['A4','A5','A2']]
    12721294    As = ['A0','A1','A2','A3','A4','A5']
    1273     Aids = [[0,0,'A0',-1],[1,1,'A1',-1],[2,2,'A2',-1],[0,1,'A3',2],[0,2,'A4',1],[1,2,'A5',0]]
     1295    Aids = [[0,0,'A0'],[1,1,'A1'],[2,2,'A2'],[0,1,'A3'],[0,2,'A4'],[1,2,'A5']]
    12741296    Axes = ['a','b','c']
    12751297    Holds = []
    12761298    for iA,Aid in enumerate(Aids):
    1277         parm = SetUniqAj(opId,iA,Aid[2],oSGData['SGLaue'])
    1278         parmDict[parm] = oAcof[iA]
     1299        parm = SetUniqAj(npId,Aid[2],nSGData['SGLaue'])
     1300        parmDict[parm] = nAcof[iA]
    12791301        varyList.append(parm)
    12801302        IndpCon = [1.0,G2obj.G2VarObj(parm)]
     
    12831305            if nSGData['SGLaue'] in ['-1','2/m']:       #set holds
    12841306                if (abs(nAcof[iA]) < 1.e-8) and (abs(Trans[Aid[0],Aid[1]]) < 1.e-8):
    1285                     if Axes[iat] != oSGData['SGUniq'] and oSGData['SGLaue'] != nSGData['SGLaue']:
     1307                    if Axes[iat] != nSGData['SGUniq'] and nSGData['SGLaue'] != oSGData['SGLaue']:
    12861308                        HoldObj = G2obj.G2VarObj('%d::%s'%(npId,Aid[2]))
    12871309                        if not HoldObj in Holds:
     
    12891311                            Holds.append(HoldObj)
    12901312                            continue
    1291 #            print iA,Aid,iat,invTrans[iat][Aid[0]],invTrans[Aid[1]][iat],Anames[Aid[0]][Aid[1]],parm
    1292             if abs(invTrans[iat,Aid[1]]) > 1.e-8 and abs(nAcof[iA]) > 1.e-8:
    1293                 parm = SetUniqAj(npId,iA,Anames[Aid[0]][Aid[1]],nSGData['SGLaue'])
    1294                 parmDict[parm] = nAcof[As.index(Aid[2])]
    1295                 if not parm in varyList:
    1296                     varyList.append(parm)
    1297                 DepCons.append([Trans[Aid[0],Aid[0]]*Trans[Aid[1],Aid[1]],G2obj.G2VarObj(parm)])
     1313            for ibt in range(3):
     1314                if abs(Trans[Aid[0],iat]) > 1.e-4 and abs(Trans[Aid[1],ibt]) > 1.e-4 and abs(oAcof[iA]) > 1.e-8:
     1315                    parm = SetUniqAj(opId,Anames[ibt][iat],nSGData['SGLaue'])
     1316                    parmDict[parm] = oAcof[As.index(Anames[ibt][iat])]
     1317                    if not parm in varyList:
     1318                        varyList.append(parm)
     1319                    DepCons.append([Trans[ibt,iat],G2obj.G2VarObj(parm)])
    12981320        if len(DepCons) == 1:
    12991321            constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])
     
    13521374        else:
    13531375            page = G2frame.rbBook.GetSelection()
    1354         #G2frame.rbBook.SetSize(G2frame.dataWindow.GetClientSize())    #TODO -almost right
    13551376        G2frame.rbBook.ChangeSelection(page)
    13561377        text = G2frame.rbBook.GetPageText(page)
  • trunk/GSASIIlattice.py

    r3403 r3406  
    271271   
    272272def TransformU6(U6,Trans):
    273     Uij = np.inner(Trans,np.inner(U6toUij(U6),Trans).T)
     273    Uij = np.inner(Trans,np.inner(U6toUij(U6),Trans).T)/nl.det(Trans)
    274274    return UijtoU6(Uij)
    275275   
    276276def TransformPhase(oldPhase,newPhase,Trans,Uvec,Vvec,ifMag):
    277     '''Transform atoms from oldPhase to newPhase by Trans & Vec
     277    '''Transform atoms from oldPhase to newPhase
     278    M' is inv(M)
     279    does X' = (X-U)M'+V transformation for coordinates and U' = MUM/det(M)
     280    for anisotropic thermal parameters
    278281   
    279282    :param oldPhase: dict G2 phase info for old phase
    280283    :param newPhase: dict G2 phase info for new phase; with new cell & space group
    281284            atoms are from oldPhase & will be transformed
    282     :param Trans: array transformation matrix
    283     :param Vec: array transformation vector
     285    :param Trans: lattice transformation matrix M
     286    :param Uvec: array parent coordinates transformation vector U
     287    :param Vvec: array child coordinate transformation vector V
    284288    :param ifMag: bool True if convert to magnetic phase;
    285289        if True all nonmagnetic atoms will be removed
  • trunk/GSASIIphsGUI.py

    r3402 r3406  
    24242424            newPhase['Drawing'] = []
    24252425           
    2426             if ifMag and ifConstr:
    2427                 G2frame.GetUsedHistogramsAndPhasesfromTree()
    2428                 G2cnstG.MagConstraints(G2frame,data,newPhase,Trans,Vvec,atCodes)     #data is old phase
     2426            if ifConstr:
     2427                G2cnstG.TransConstraints(G2frame,data,newPhase,Trans,Vvec,atCodes)     #data is old phase
    24292428            G2frame.GPXtree.SelectItem(sub)
    24302429       
Note: See TracChangeset for help on using the changeset viewer.