Changeset 1951 for trunk/GSASIImath.py


Ignore:
Timestamp:
Aug 7, 2015 11:54:12 AM (8 years ago)
Author:
vondreele
Message:

implement drawing of incommensurate structures - live variation wrt tau
required careful attention to siteSym text & some reorganization of modules
more work on special pos code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r1935 r1951  
    289289    return newAtoms
    290290       
    291 def FindAtomIndexByIDs(atomData,IDs,Draw=True):
     291def FindAtomIndexByIDs(atomData,loc,IDs,Draw=True):
    292292    '''finds the set of atom array indices for a list of atom IDs. Will search
    293293    either the Atom table or the drawAtom table.
    294294   
    295295    :param list atomData: Atom or drawAtom table containting coordinates, etc.
     296    :param int loc: location of atom id in atomData record
    296297    :param list IDs: atom IDs to be found
    297298    :param bool Draw: True if drawAtom table to be searched; False if Atom table
     
    303304    indx = []
    304305    for i,atom in enumerate(atomData):
    305         if Draw and atom[-3] in IDs:
     306        if Draw and atom[loc] in IDs:
    306307            indx.append(i)
    307         elif atom[-1] in IDs:
     308        elif atom[loc] in IDs:
    308309            indx.append(i)
    309310    return indx
     
    918919    return Xanom
    919920   
     921################################################################################
     922#### Modulation math
     923################################################################################
     924   
    920925def Modulation(waveTypes,SSUniq,SSPhi,FSSdata,XSSdata,USSdata):
    921926    import scipy.special as sp
     
    976981    B = np.array([fc[:,np.newaxis]*np.cos(2.*np.pi*(i+1)*tau) for i,fc in enumerate(fcos)])
    977982    return np.sum(A,axis=0)+np.sum(B,axis=0)
     983   
     984def ApplyModulation(data,tau):
     985    '''Applies modulation to drawing atom positions & Uijs for given tau
     986    '''
     987    generalData = data['General']
     988    SGData = generalData['SGData']
     989    cx,ct,cs,cia = generalData['AtomPtrs']
     990    drawingData = data['Drawing']
     991    dcx,dct,dcs,dci = drawingData['atomPtrs']
     992    atoms = data['Atoms']
     993    drawAtoms = drawingData['Atoms']
     994    for atom in atoms:   
     995        atxyz = np.array(atom[cx:cx+3])
     996        waveType = atom[-1]['SS1']['waveType']
     997        Spos = atom[-1]['SS1']['Spos']
     998        wave = np.zeros(3)
     999        if len(Spos):
     1000            scof = []
     1001            ccof = []
     1002            for i,spos in enumerate(Spos):
     1003                if waveType in ['Sawtooth','ZigZag'] and not i:
     1004                    Toff = spos[0][0]
     1005                    slopes = np.array(spos[0][1:])
     1006                    if waveType == 'Sawtooth':
     1007                        wave = posSawtooth(tau,Toff,slopes)
     1008                    elif waveType == 'ZigZag':
     1009                        wave = posZigZag(tau,Toff,slopes)
     1010                else:
     1011                    scof.append(spos[0][:3])
     1012                    ccof.append(spos[0][3:])
     1013            wave += np.sum(posFourier(tau,np.array(scof),np.array(ccof)),axis=1)
     1014        indx = FindAtomIndexByIDs(drawAtoms,dci,[atom[cia+8],],True)
     1015        for ind in indx:
     1016            drawatom = drawAtoms[ind]
     1017            opr = drawatom[dcs-1]
     1018            if atom[cia] == 'A':                   
     1019                X,U = G2spc.ApplyStringOps(opr,SGData,atxyz+wave,atom[cia+2:cia+8])
     1020                drawatom[dcx:dcx+3] = X
     1021#                drawatom[dci-6:dci] = U
     1022            else:
     1023                X = G2spc.ApplyStringOps(opr,SGData,atxyz+wave)
     1024                drawatom[dcx:dcx+3] = X
     1025    return drawAtoms
     1026   
    9781027   
    9791028################################################################################
Note: See TracChangeset for help on using the changeset viewer.