Changeset 1604


Ignore:
Timestamp:
Dec 11, 2014 3:27:57 PM (8 years ago)
Author:
vondreele
Message:

make modulation wave maps
fix atom index bugs
begin modulated structure imput to least squares

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r1601 r1604  
    215215    return indx
    216216
    217 def FillAtomLookUp(atomData):
     217def FillAtomLookUp(atomData,indx):
    218218    '''create a dictionary of atom indexes with atom IDs as keys
    219219   
     
    225225    atomLookUp = {}
    226226    for iatm,atom in enumerate(atomData):
    227         atomLookUp[atom[-1]] = iatm
     227        atomLookUp[atom[indx]] = iatm
    228228    return atomLookUp
    229229
  • trunk/GSASIIobj.py

    r1600 r1604  
    12541254        'A([0-5])' : 'Reciprocal metric tensor component \\1',
    12551255        'Vol' : 'Unit cell volume',
    1256         'mV([0-2])' : 'Modulation vector component \\1',
    12571256        # Atom vars (p::<var>:a)
    12581257        'dA([xyz])$' : 'change to atomic coordinate, \\1',
     
    12941293        'RBRTr;.*' : 'Residue rigid body torsion parameter',
    12951294        'RBR([TLS])([123AB][123AB])' : 'Residue rigid body group disp. param.',
    1296         # Global vars (::<var>)
    12971295        'constr([0-9]*)' : 'Parameter from constraint',
     1296        # supersymmetry parameters
     1297        'mV([0-2])' : 'Modulation vector component \\1',
     1298#        'Flen','Fcent','Fsin','Fcos'
     1299        '[XYZ]sin'  : 'Sin position wave for \\1',
     1300        '[XYZ]cos'  : 'Cos position wave for \\1',
     1301        'U[123][123]sin' :  'Sin thermal wave for U\\1',
     1302        'U[123][123]cos' :  'Cos thermal wave for U\\1',
     1303        'M[XYZ]sin' :  'Sin mag. moment wave for \\1',
     1304        'M[XYZ]cos' :  'Cos mag. moment wave for \\1',
    12981305        # SASD vars (l:<var>;l = component)
    12991306        'Aspect ratio' : 'Particle aspect ratio',
  • trunk/GSASIIphsGUI.py

    r1601 r1604  
    110110            generalData['POhkl'] = [0,0,1]
    111111        if 'Map' not in generalData:
    112             generalData['Map'] = mapDefault
     112            generalData['Map'] = {}
     113            generalData['Map'].update(mapDefault)
    113114        if 'Flip' not in generalData:
    114115            generalData['Flip'] = {'RefList':'','Resolution':0.5,'Norm element':'None',
     
    135136                generalData['SSGData'] = {}
    136137            if '4DmapData' not in generalData:
    137                 generalData['4DmapData'] = mapDefault
     138                generalData['4DmapData'] = {}
     139                generalData['4DmapData'].update(mapDefault)
    138140                generalData['4DmapData'].update({'MapType':'Fobs'})
    139141# end of patches
     
    19701972               
    19711973            def OnShowWave(event):
    1972                 mapBtn.SetValue(False)
    1973                 G2plt.ModulationPlot(G2frame,data,atom)
     1974                Obj = event.GetEventObject()
     1975                atom = Indx[Obj.GetId()]               
     1976                Ax = Obj.GetValue()
     1977                G2plt.ModulationPlot(G2frame,data,atom,Ax)
    19741978               
    19751979            atomSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    19791983            waveType.Bind(wx.EVT_COMBOBOX,OnWaveType)
    19801984            atomSizer.Add(waveType,0,WACV)
    1981             mapBtn = wx.CheckBox(waveData,label='Show contour map?')
    1982             mapBtn.Bind(wx.EVT_CHECKBOX, OnShowWave)
    1983             Indx[mapBtn.GetId()] = atom
    1984             atomSizer.Add(mapBtn,0,WACV)
     1985            axchoice = ['x','y','z']
     1986            atomSizer.Add(wx.StaticText(waveData,label=' Show contour map for axis:'),0,WACV)
     1987            mapSel = wx.ComboBox(waveData,value=' ',choices=axchoice,
     1988                style=wx.CB_READONLY|wx.CB_DROPDOWN)
     1989            mapSel.Bind(wx.EVT_COMBOBOX,OnShowWave)
     1990            Indx[mapSel.GetId()] = atom
     1991            atomSizer.Add(mapSel,0,WACV)
    19851992            return atomSizer
    19861993           
     
    20592066               
    20602067            Map = generalData['4DmapData']
     2068            Map['Resolution'] = 0.25
    20612069            refList = data['Histograms'].keys()
    20622070            mapSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    20842092        typeNames = {'Sfrac':' Site fraction','Spos':' Position','Sadp':' Thermal motion','Smag':' Magnetic moment'}
    20852093        numVals = {'Sfrac':2,'Spos':6,'Sadp':12,'Smag':6}
    2086         posNames = ['Xsin','Ysin','Zsin','Xcos','Ysin','Zsin']
     2094        posNames = ['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos']
    20872095        adpNames = ['U11sin','U22sin','U33sin','U12sin','U13sin','U23sin',
    20882096            'U11cos','U22cos','U33cos','U12cos','U13cos','U23cos']
  • trunk/GSASIIplot.py

    r1601 r1604  
    27662766
    27672767################################################################################
    2768 #####
     2768##### Modulation Plot
    27692769################################################################################
    27702770
    2771 def ModulationPlot(G2frame,data,atom):
     2771def ModulationPlot(G2frame,data,atom,Ax):
    27722772   
    27732773    print 'modulation plot for',atom[0]
     
    27852785#        Page.canvas.mpl_connect('motion_notify_event', OnMotion)
    27862786
     2787    General = data['General']
     2788    cx,ct,cs,cia = General['AtomPtrs']
     2789    Map = General['4DmapData']
     2790    MapType = Map['MapType']
     2791    rhoSize = np.array(Map['rho'].shape)
     2792    atxyz = np.array(atom[cx:cx+3])
     2793    Title = MapType+' modulation map for atom '+atom[0]+    \
     2794        ' at %.4f %.4f %.4f'%(atxyz[0],atxyz[1],atxyz[2])
     2795    ix = -np.array(np.rint(rhoSize[:3]*atxyz),dtype='i')
     2796    ix += (rhoSize[:3]/2)
     2797    ix = ix%rhoSize[:3]
     2798    print 'roll',ix,atxyz
     2799    rho = np.roll(np.roll(np.roll(Map['rho'],ix[0],axis=0),ix[1],axis=1),ix[2],axis=2)
     2800    ix = rhoSize[:3]/2
     2801    print 'slab',ix,rhoSize
     2802    ib = 4
     2803    if Ax == 'x':
     2804        slab = np.sum(np.sum(rho[:,ix[1]-ib:ix[1]+ib,ix[2]-ib:ix[2]+ib,:],axis=2),axis=1)
     2805    elif Ax == 'y':
     2806        slab = np.sum(np.sum(rho[ix[0]-ib:ix[0]+ib,:,ix[2]-ib:ix[2]+ib,:],axis=2),axis=0)
     2807    elif Ax == 'z':
     2808        slab = np.sum(np.sum(rho[ix[0]-ib:ix[0]+ib,ix[1]-ib:ix[1]+ib,:,:],axis=1),axis=0)
     2809    Plot.set_title(Title)
     2810    Plot.set_xlabel('t')
     2811    Plot.set_ylabel(r'$\mathsf{\Delta}$%s'%(Ax))
     2812    Plot.contour(slab,20,extent=(0.,1.,-.5,.5))
     2813    Page.canvas.draw()
    27872814   
    27882815################################################################################
  • trunk/GSASIIstrIO.py

    r1597 r1604  
    963963        BLtables.update(BLtable)
    964964        Atoms = PhaseData[name]['Atoms']
    965         AtLookup = G2mth.FillAtomLookUp(Atoms)
     965        if Atoms and not General.get('doPawley'):
     966            cx,ct,cs,cia = General['AtomPtrs']
     967            AtLookup = G2mth.FillAtomLookUp(Atoms,cia+8)
    966968        PawleyRef = PhaseData[name].get('Pawley ref',[])
    967969        SGData = General['SGData']
     
    10011003        if Atoms and not General.get('doPawley'):
    10021004            cx,ct,cs,cia = General['AtomPtrs']
    1003             if General['Type'] in ['nuclear','macromolecular']:
    1004                 Natoms[pfx] = len(Atoms)
    1005                 for i,at in enumerate(Atoms):
    1006                     atomIndx[at[-1]] = [pfx,i]      #lookup table for restraints
    1007                     phaseDict.update({pfx+'Atype:'+str(i):at[ct],pfx+'Afrac:'+str(i):at[cx+3],pfx+'Amul:'+str(i):at[cs+1],
    1008                         pfx+'Ax:'+str(i):at[cx],pfx+'Ay:'+str(i):at[cx+1],pfx+'Az:'+str(i):at[cx+2],
    1009                         pfx+'dAx:'+str(i):0.,pfx+'dAy:'+str(i):0.,pfx+'dAz:'+str(i):0.,         #refined shifts for x,y,z
    1010                         pfx+'AI/A:'+str(i):at[cia],})
     1005            Natoms[pfx] = len(Atoms)
     1006            for i,at in enumerate(Atoms):
     1007                atomIndx[at[cia+8]] = [pfx,i]      #lookup table for restraints
     1008                phaseDict.update({pfx+'Atype:'+str(i):at[ct],pfx+'Afrac:'+str(i):at[cx+3],pfx+'Amul:'+str(i):at[cs+1],
     1009                    pfx+'Ax:'+str(i):at[cx],pfx+'Ay:'+str(i):at[cx+1],pfx+'Az:'+str(i):at[cx+2],
     1010                    pfx+'dAx:'+str(i):0.,pfx+'dAy:'+str(i):0.,pfx+'dAz:'+str(i):0.,         #refined shifts for x,y,z
     1011                    pfx+'AI/A:'+str(i):at[cia],})
     1012                if at[cia] == 'I':
     1013                    phaseDict[pfx+'AUiso:'+str(i)] = at[cia+1]
     1014                else:
     1015                    phaseDict.update({pfx+'AU11:'+str(i):at[cia+2],pfx+'AU22:'+str(i):at[cia+3],pfx+'AU33:'+str(i):at[cia+4],
     1016                        pfx+'AU12:'+str(i):at[cia+5],pfx+'AU13:'+str(i):at[cia+6],pfx+'AU23:'+str(i):at[cia+7]})
     1017                if 'F' in at[ct+1]:
     1018                    phaseVary.append(pfx+'Afrac:'+str(i))
     1019                if 'X' in at[ct+1]:
     1020                    try:    #patch for sytsym name changes
     1021                        xId,xCoef = G2spc.GetCSxinel(at[cs])
     1022                    except KeyError:
     1023                        Sytsym = G2spc.SytSym(at[cx:cx+3],SGData)[0]
     1024                        at[cs] = Sytsym
     1025                        xId,xCoef = G2spc.GetCSxinel(at[cs])
     1026                    xId,xCoef = G2spc.GetCSxinel(at[cs])
     1027                    names = [pfx+'dAx:'+str(i),pfx+'dAy:'+str(i),pfx+'dAz:'+str(i)]
     1028                    equivs = [[],[],[]]
     1029                    for j in range(3):
     1030                        if xId[j] > 0:                               
     1031                            phaseVary.append(names[j])
     1032                            equivs[xId[j]-1].append([names[j],xCoef[j]])
     1033                    for equiv in equivs:
     1034                        if len(equiv) > 1:
     1035                            name = equiv[0][0]
     1036                            coef = equiv[0][1]
     1037                            for eqv in equiv[1:]:
     1038                                eqv[1] /= coef
     1039                                G2mv.StoreEquivalence(name,(eqv,))
     1040                if 'U' in at[ct+1]:
    10111041                    if at[cia] == 'I':
    1012                         phaseDict[pfx+'AUiso:'+str(i)] = at[cia+1]
     1042                        phaseVary.append(pfx+'AUiso:'+str(i))
    10131043                    else:
    1014                         phaseDict.update({pfx+'AU11:'+str(i):at[cia+2],pfx+'AU22:'+str(i):at[cia+3],pfx+'AU33:'+str(i):at[cia+4],
    1015                             pfx+'AU12:'+str(i):at[cia+5],pfx+'AU13:'+str(i):at[cia+6],pfx+'AU23:'+str(i):at[cia+7]})
    1016                     if 'F' in at[ct+1]:
    1017                         phaseVary.append(pfx+'Afrac:'+str(i))
    1018                     if 'X' in at[ct+1]:
    10191044                        try:    #patch for sytsym name changes
    1020                             xId,xCoef = G2spc.GetCSxinel(at[cs])
     1045                            uId,uCoef = G2spc.GetCSuinel(at[cs])[:2]
    10211046                        except KeyError:
    10221047                            Sytsym = G2spc.SytSym(at[cx:cx+3],SGData)[0]
    10231048                            at[cs] = Sytsym
    1024                             xId,xCoef = G2spc.GetCSxinel(at[cs])
    1025                         xId,xCoef = G2spc.GetCSxinel(at[cs])
    1026                         names = [pfx+'dAx:'+str(i),pfx+'dAy:'+str(i),pfx+'dAz:'+str(i)]
    1027                         equivs = [[],[],[]]
    1028                         for j in range(3):
    1029                             if xId[j] > 0:                               
     1049                            uId,uCoef = G2spc.GetCSuinel(at[cs])[:2]
     1050                        uId,uCoef = G2spc.GetCSuinel(at[cs])[:2]
     1051                        names = [pfx+'AU11:'+str(i),pfx+'AU22:'+str(i),pfx+'AU33:'+str(i),
     1052                            pfx+'AU12:'+str(i),pfx+'AU13:'+str(i),pfx+'AU23:'+str(i)]
     1053                        equivs = [[],[],[],[],[],[]]
     1054                        for j in range(6):
     1055                            if uId[j] > 0:                               
    10301056                                phaseVary.append(names[j])
    1031                                 equivs[xId[j]-1].append([names[j],xCoef[j]])
     1057                                equivs[uId[j]-1].append([names[j],uCoef[j]])
    10321058                        for equiv in equivs:
    10331059                            if len(equiv) > 1:
     
    10361062                                for eqv in equiv[1:]:
    10371063                                    eqv[1] /= coef
    1038                                     G2mv.StoreEquivalence(name,(eqv,))
    1039                     if 'U' in at[ct+1]:
    1040                         if at[cia] == 'I':
    1041                             phaseVary.append(pfx+'AUiso:'+str(i))
    1042                         else:
    1043                             try:    #patch for sytsym name changes
    1044                                 uId,uCoef = G2spc.GetCSuinel(at[cs])[:2]
    1045                             except KeyError:
    1046                                 Sytsym = G2spc.SytSym(at[cx:cx+3],SGData)[0]
    1047                                 at[cs] = Sytsym
    1048                                 uId,uCoef = G2spc.GetCSuinel(at[cs])[:2]
    1049                             uId,uCoef = G2spc.GetCSuinel(at[cs])[:2]
    1050                             names = [pfx+'AU11:'+str(i),pfx+'AU22:'+str(i),pfx+'AU33:'+str(i),
    1051                                 pfx+'AU12:'+str(i),pfx+'AU13:'+str(i),pfx+'AU23:'+str(i)]
    1052                             equivs = [[],[],[],[],[],[]]
    1053                             for j in range(6):
    1054                                 if uId[j] > 0:                               
    1055                                     phaseVary.append(names[j])
    1056                                     equivs[uId[j]-1].append([names[j],uCoef[j]])
    1057                             for equiv in equivs:
    1058                                 if len(equiv) > 1:
    1059                                     name = equiv[0][0]
    1060                                     coef = equiv[0][1]
    1061                                     for eqv in equiv[1:]:
    1062                                         eqv[1] /= coef
    1063                                     G2mv.StoreEquivalence(name,equiv[1:])
    1064 #            elif General['Type'] == 'magnetic':
    1065 #            elif General['Type'] == 'macromolecular':
     1064                                G2mv.StoreEquivalence(name,equiv[1:])
     1065                if General['Type'] in ['modulated','magnetic']:
     1066                    AtomSS = at[-1]['SS1']
     1067                    print AtomSS
    10661068            textureData = General['SH Texture']
    10671069            if textureData['Order']:
     
    15551557        SGData = General['SGData']
    15561558        Atoms = Phase['Atoms']
    1557         AtLookup = G2mth.FillAtomLookUp(Atoms)
     1559        if Atoms and not General.get('doPawley'):
     1560            cx,ct,cs,cia = General['AtomPtrs']
     1561            AtLookup = G2mth.FillAtomLookUp(Atoms,cia+8)
    15581562        cell = General['Cell']
    15591563        pId = Phase['pId']
  • trunk/GSASIIstrMath.py

    r1597 r1604  
    6666        Phase = Phases[phase]
    6767        General = Phase['General']
     68        cx,ct,cs,cia = General['AtomPtrs']
    6869        cell = General['Cell'][1:7]
    6970        Amat,Bmat = G2lat.cell2AB(cell)
    70         AtLookup = G2mth.FillAtomLookUp(Phase['Atoms'])
     71        AtLookup = G2mth.FillAtomLookUp(Phase['Atoms'],cia+8)
    7172        pfx = str(Phase['pId'])+'::'
    7273        if Update:
     
    159160            dFdvDict[item] = 0.        #NB: this is a vector which is no. refl. long & must be filled!
    160161    General = Phase['General']
     162    cx,ct,cs,cia = General['AtomPtrs']
    161163    cell = General['Cell'][1:7]
    162164    Amat,Bmat = G2lat.cell2AB(cell)
     
    166168    gvec = np.sqrt(np.array([g[0][0]**2,g[1][1]**2,g[2][2]**2,
    167169        g[0][0]*g[1][1],g[0][0]*g[2][2],g[1][1]*g[2][2]]))
    168     AtLookup = G2mth.FillAtomLookUp(Phase['Atoms'])
     170    AtLookup = G2mth.FillAtomLookUp(Phase['Atoms'],cia+8)
    169171    pfx = str(Phase['pId'])+'::'
    170172    RBModels =  Phase['RBModels']
     
    312314        negWt[pId] = Phases[phase]['General']['Pawley neg wt']
    313315        General = Phases[phase]['General']
     316        cx,ct,cs,cia = General['AtomPtrs']
    314317        textureData = General['SH Texture']
    315318        SGData = General['SGData']
    316         AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms'])
     319        AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms'],cia+8)
    317320        cell = General['Cell'][1:7]
    318321        Amat,Bmat = G2lat.cell2AB(cell)
     
    415418        pId = Phases[phase]['pId']
    416419        General = Phases[phase]['General']
     420        cx,ct,cs,cia = General['AtomPtrs']
    417421        SGData = General['SGData']
    418         AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms'])
     422        AtLookup = G2mth.FillAtomLookUp(Phases[phase]['Atoms'],cia+8)
    419423        cell = General['Cell'][1:7]
    420424        Amat,Bmat = G2lat.cell2AB(cell)
     
    21062110        for iref,ref in enumerate(refDict['RefList']):
    21072111            if ref[5+im] > 0.:
    2108                 dervDict = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1]
     2112                dervDict = SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varylist+dependentVars)[1]
    21092113                Fo = np.sqrt(ref[5+im])
    21102114                Fc = np.sqrt(ref[7+im])
     
    23502354                for i,ref in enumerate(refDict['RefList']):
    23512355                    if ref[6+im] > 0:
    2352                         ref[11+im] = SCExtinction(ref,phfx,hfx,pfx,calcControls,parmDict,varylist)[0]
     2356                        ref[11+im] = SCExtinction(ref,im,phfx,hfx,pfx,calcControls,parmDict,varylist)[0]
    23532357                        w = 1.0/ref[6+im]
    23542358                        ref[7+im] = parmDict[phfx+'Scale']*ref[9+im]*ref[11+im]  #correct Fc^2 for extinction
Note: See TracChangeset for help on using the changeset viewer.