Ignore:
Timestamp:
Apr 14, 2016 3:44:39 PM (6 years ago)
Author:
vondreele
Message:

Implement 'abc*' as one of the 'Common' cell transformations.
Transformations now transforms atom positions & Uijs
Fix problem in ImageGUI where load controls didn't update the image plot correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIlattice.py

    r2154 r2212  
    3131########### SVN repository information ###################
    3232import math
     33import copy
     34import sys
     35import random as ran
    3336import numpy as np
    3437import numpy.linalg as nl
     
    225228    Uij = np.inner(Trans,np.inner(U6toUij(U6),Trans))
    226229    return UijtoU6(Uij)
    227            
     230   
     231def TransformPhase(oldPhase,newPhase,Trans,Vec):
     232    '''Transform atoms from oldPhase to newPhase by Trans & Vec
     233   
     234    :param oldPhase: dict G2 phase info for old phase
     235    :param newPhase: dict G2 phase info for new phase; with new cell & space group
     236            atoms are from oldPhase & will be transformed
     237    :param Trans: array transformation matrix
     238    :param Vec: array transformation vector
     239    '''
     240   
     241    cx,ct,cs,cia = oldPhase['General']['AtomPtrs']
     242    SGData = newPhase['General']['SGData']
     243    invTrans = nl.inv(Trans)
     244    newAtoms = FillUnitCell(oldPhase)
     245    for atom in newAtoms:
     246        atom[cx:cx+3] = TransformXYZ(atom[cx:cx+3],invTrans.T,Vec)
     247        if atom[cia] == 'A':
     248            atom[cia+2:cia+8] = TransformU6(atom[cia+2:cia+8],invTrans)
     249        atom[cs:cs+2] = G2spc.SytSym(atom[cx:cx+3],SGData)
     250        atom[cia+8] = ran.randint(0,sys.maxint)
     251    newPhase['Atoms'] = newAtoms
     252#   GetUnique(newPhase)
     253    return newPhase
     254   
     255   
     256def FillUnitCell(Phase):
     257    atomData = copy.deepcopy(Phase['Atoms'])
     258    nAtoms = len(atomData)
     259    SGData = Phase['General']['SGData']
     260    cx,ct,cs,cia = Phase['General']['AtomPtrs']
     261    for atom in atomData[:nAtoms]:
     262        XYZ = np.array(atom[cx:cx+3])
     263        if atom[cia] == 'A':
     264            Uij = atom[cia+2:cia+8]
     265            result = G2spc.GenAtom(XYZ,SGData,False,Uij,True)
     266            for item in result:
     267                atom[cx:cx+3] = item[0]
     268                atom[cia+2:cia+8] = item[1]
     269                atomData.append(atom[:cia+9])  #not SS stuff
     270        else:
     271            result = G2spc.GenAtom(XYZ,SGData,False,Move=True)
     272            for item in result:
     273                atom[cx:cx+3] = item[0]
     274                atomData.append(atom[:cia+9])  #not SS stuff
     275    return atomData
     276       
     277def GetUnique(Phase):
     278    pass
     279#    def noDuplicate(xyz,peaks,Amat):
     280#        if True in [np.allclose(np.inner(Amat,xyz),np.inner(Amat,peak),atol=0.5) for peak in peaks]:
     281#            return False
     282#        return True
     283#                           
     284#    generalData = data['General']
     285#    cell = generalData['Cell'][1:7]
     286#    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     287#    A = G2lat.cell2A(cell)
     288#    SGData = generalData['SGData']
     289#    mapPeaks = data['Map Peaks']
     290#    Indx = {}
     291#    XYZ = {}
     292#    for ind in Ind:
     293#        XYZ[ind] = np.array(mapPeaks[ind][1:4])
     294#        Indx[ind] = True
     295#    for ind in Ind:
     296#        if Indx[ind]:
     297#            xyz = XYZ[ind]
     298#            for jnd in Ind:
     299#                if ind != jnd and Indx[jnd]:                       
     300#                    Equiv = G2spc.GenAtom(XYZ[jnd],SGData,Move=True)
     301#                    xyzs = np.array([equiv[0] for equiv in Equiv])
     302#                    Indx[jnd] = noDuplicate(xyz,xyzs,Amat)
     303#    Ind = []
     304#    for ind in Indx:
     305#        if Indx[ind]:
     306#            Ind.append(ind)
     307#    return Ind
     308
     309
     310           
    228311def calc_rVsq(A):
    229312    """Compute the square of the reciprocal lattice volume (1/V**2) from A'
Note: See TracChangeset for help on using the changeset viewer.