Changeset 2062


Ignore:
Timestamp:
Nov 21, 2015 9:45:03 AM (8 years ago)
Author:
vondreele
Message:

exclude non variable SS parms from constraint lists
define ZigZag? & Block position modulations; eliminate Sawtooth (it's a variant of ZigZag?)
fix SS names in constraint lists
implement ZigZag? & Block position wave plots
implement ZigZag? & Block atom motion in structure plots
add movie making option (hidden - no file output for it yet)
fix LS I/O for ZigZag? & Block waves

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r1943 r2062  
    227227    rbIds = rigidbodyDict.get('RBIds',{'Vector':[],'Residue':[]})
    228228    rbVary,rbDict = G2stIO.GetRigidBodyModels(rigidbodyDict,Print=False)
     229    badPhaseParms = ['Ax','Ay','Az','Amul','AI/A','Atype','SHorder','mV0','mV1','mV2','waveType','Vol',]
    229230    globalList = rbDict.keys()
    230231    globalList.sort()
     
    240241    phaseList = []
    241242    for item in phaseDict:
    242         if item.split(':')[2] not in ['Ax','Ay','Az','Amul','AI/A','Atype','SHorder']:
     243        if item.split(':')[2] not in badPhaseParms:
    243244            phaseList.append(item)
    244245    phaseList.sort()
  • trunk/GSASIImath.py

    r2061 r2062  
    10981098    return A
    10991099
    1100 def posZigZag(tau,Toff,slopes):
    1101     Tau = (tau-Toff)%1.
    1102     A = np.where(Tau <= 0.5,slopes[:,np.newaxis]*Tau,slopes[:,np.newaxis]*(1.-Tau))
     1100def posZigZag(tau,Tmm,XYZmax):
     1101    DT = Tmm[1]-Tmm[0]
     1102    slopeUp = 2.*XYZmax/DT
     1103    slopeDn = 2.*XYZmax/(1.-DT)
     1104    A = np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-XYZmax+slopeUp*((t-Tmm[0])%1.),XYZmax-slopeDn*((t-Tmm[1])%1.)) for t in tau])
     1105    return A
     1106
     1107def posBlock(tau,Tmm,XYZmax):
     1108    A = np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-XYZmax,XYZmax) for t in tau])
    11031109    return A
    11041110   
     
    11581164                ccof = []
    11591165                for i,spos in enumerate(Spos):
    1160                     if waveType in ['Sawtooth','ZigZag'] and not i:
    1161                         Toff = spos[0][0]
    1162                         slopes = np.array(spos[0][1:])
    1163                         if waveType == 'Sawtooth':
    1164                             wave = posSawtooth(tauT,Toff,slopes)
     1166                    if waveType in ['ZigZag','Block'] and not i:
     1167                        Tminmax = spos[0][:2]
     1168                        XYZmax = np.array(spos[0][2:])
     1169                        if waveType == 'Block':
     1170                            wave = np.array(posBlock([tauT,],Tminmax,XYZmax))[0]
    11651171                        elif waveType == 'ZigZag':
    1166                             wave = posZigZag(tauT,Toff,slopes)
     1172                            wave = np.array(posZigZag([tauT,],Tminmax,XYZmax))[0]
    11671173                    else:
    11681174                        scof.append(spos[0][:3])
    11691175                        ccof.append(spos[0][3:])
    1170                 wave += np.sum(posFourier(tauT,np.array(scof),np.array(ccof),smul),axis=1)
     1176                if len(scof):
     1177                    wave += np.sum(posFourier(tauT,np.array(scof),np.array(ccof),smul),axis=1)
    11711178            if len(Sadp):
    11721179                scof = []
  • trunk/GSASIIobj.py

    r1924 r2062  
    11871187            s = 'Hist='+ShortHistNames.get(l[1],'? #'+str(l[1]))
    11881188            l[-1] += ' #'+str(l[3])
    1189         elif l[4] is not None: # rigid body parameter
     1189        elif l[4] is not None: # rigid body parameter or modulation parm
    11901190            lbl = ShortPhaseNames.get(l[0],'phase?')
    1191             s = "Res #"+str(l[3])+" body #"+str(l[4])+" in "+str(lbl)
     1191            if 'RB' in l[2]:    #rigid body parm
     1192                s = "Res #"+str(l[3])+" body #"+str(l[4])+" in "+str(lbl)
     1193            else: #modulation parm
     1194                s = 'Atom %s wave %s in %s'%(LookupAtomLabel(l[0],l[3])[0],l[4],lbl)
    11921195        elif l[3] is not None: # atom parameter,
    11931196            lbl = ShortPhaseNames.get(l[0],'phase?')
     
    13241327        'Fsin'  :   'Sin site fraction modulation',
    13251328        'Fcos'  :   'Cos site fraction modulation',
    1326         'Fzero'  :   'Crenel function offset',
     1329        'Fzero'  :   'Crenel function offset',      #may go away
    13271330        'Fwid'   :   'Crenel function width',
    1328         'Tzero'  :   'Sawtooth/ZigZag location',
    1329         '([XYZ])slope': 'Sawtooth/ZigZag slope for \\1',
     1331        'Tmin'   :   'ZigZag/Block min location',
     1332        'Tmax'   :   'ZigZag/Block max location',
     1333        '([XYZ])max': 'ZigZag/Block max value for \\1',
    13301334        '([XYZ])sin'  : 'Sin position wave for \\1',
    13311335        '([XYZ])cos'  : 'Cos position wave for \\1',
  • trunk/GSASIIphsGUI.py

    r2050 r2062  
    23772377                iatm,item = Indx[Obj.GetId()]
    23782378                nt = numVals[Stype]
    2379                 if not len(atomData[iatm][-1][SS][item]) and waveType in ['Sawtooth',] and Stype == 'Spos':
    2380                     nt = 4
     2379                if not len(atomData[iatm][-1][SS][item]) and waveType in ['ZigZag','Block'] and Stype == 'Spos':
     2380                    nt = numVals[waveType]
    23812381                atomData[iatm][-1][SS][item].append([[0.0 for i in range(nt)],False])
    23822382                UpdateWavesData()
     
    23872387                try:
    23882388                    val = float(Obj.GetValue())
     2389                    if waveType in ['ZigZag','Block'] and Stype == 'Spos' and ival < 2:
     2390                        if ival == 1: #Tmax
     2391                            val = min(1.0,max(0.0,val))
     2392                        elif ival == 0: #Tmin
     2393                            val = max(-1.,min(val,atomData[iatm][-1][SS][item][iwave][0][1]))
    23892394                except ValueError:
    23902395                    val = atomData[iatm][-1][SS][item][iwave][0][ival]
     
    24102415            Indx[waveAdd.GetId()] = [iatm,Stype]
    24112416            waveHead.Add(waveAdd,0,WACV)
     2417            waveAdd.Bind(wx.EVT_CHECKBOX, OnAddWave)
     2418                Indx[waveAdd.GetId()] = [iatm,Stype]
     2419                waveHead.Add(waveAdd,0,WACV)
    24122420            waveSizer.Add(waveHead)
     2421#            print atm[0],waveBlk
    24132422            if len(waveBlk):
    24142423                nFour = 0
     
    24292438                        Waves = wx.FlexGridSizer(0,4,5,5)
    24302439                    elif Stype == 'Spos':
    2431                         if waveType in ['Sawtooth',] and not iwave:
     2440                        if waveType in ['ZigZag','Block'] and not iwave:
    24322441                            names = Names[6:]
    2433                             Waves = wx.FlexGridSizer(0,6,5,5)
     2442                            Waves = wx.FlexGridSizer(0,7,5,5)
    24342443                            waveName = waveType
    24352444                        else:
     
    24822491        mainSizer = wx.BoxSizer(wx.VERTICAL)
    24832492        typeNames = {'Sfrac':' Site fraction','Spos':' Position','Sadp':' Thermal motion','Smag':' Magnetic moment'}
    2484         numVals = {'Sfrac':2,'Spos':6,'Sadp':12,'Smag':6}
    2485         posNames = ['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tzero','Xslope','Yslope','Zslope']
     2493        numVals = {'Sfrac':2,'Spos':6,'Sadp':12,'Smag':6,'ZigZag':5,'Block':5}
     2494        posNames = ['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tmin','Tmax','Xmax','Ymax','Zmax']
    24862495        adpNames = ['U11sin','U22sin','U33sin','U12sin','U13sin','U23sin',
    24872496            'U11cos','U22cos','U33cos','U12cos','U13cos','U23cos']
    24882497        magNames = ['MXsin','MYsin','MZsin','MXcos','MYcos','MZcos']
    24892498        fracNames = ['Fsin','Fcos','Fzero','Fwid']
    2490         waveTypes = ['Fourier','Sawtooth','Crenel/Fourier']
     2499        waveTypes = ['Fourier','ZigZag','Block','Crenel/Fourier']
    24912500        Labels = {'Spos':posNames,'Sfrac':fracNames,'Sadp':adpNames,'Smag':magNames}
    24922501        mainSizer.Add(wx.StaticText(waveData,label=' Incommensurate propagation wave data:'),0,WACV)
     
    24992508                    mainSizer.Add(AtomSizer(SS,atm))
    25002509                    for Stype in ['Sfrac','Spos','Sadp','Smag']:
    2501                         if atm[cia] != 'A' and Stype == 'Sadp':    #Uiso can't have modulations!
     2510                        if atm[cia] != 'A' and Stype == 'Sadp':    #Uiso can't have modulations! (why not?)
    25022511                            continue
    25032512                        if generalData['Type'] != 'magnetic' and Stype == 'Smag':
     
    30223031                                Uij = G2spc.U2Uij(np.inner(np.inner(M,G2spc.Uij2U(Uij)),M))
    30233032                                atom[cuij:cuij+6] = Uij
    3024                             atomData.append(atom)
     3033                            atomData.append(atom[:cuij+9])  #not SS stuff
    30253034            finally:
    30263035                dlg.Destroy()
     
    30923101            numAtoms = len(atomData)
    30933102            cx,ct,cs,ci = data['Drawing']['atomPtrs']
     3103            cij = ci+2
    30943104            generalData = data['General']
    30953105            SGData = generalData['SGData']
     
    31153125                                    newAtom[cx:cx+3] = xyz
    31163126                                    newAtom[cx+3] = G2spc.StringOpsProd(oprB,newOp,SGData)
    3117                                     atomData.append(newAtom)
     3127                                    atomData.append(newAtom[:cij+9])  #not SS stuff
    31183128            finally:
    31193129                wx.EndBusyCursor()
     
    31553165                                    atom[cx:cx+3] = Opp[key]
    31563166                                    atom[cx+3] = cell
    3157                                     atomData.append(atom[:])
     3167                                    atomData.append(atom[:cuij+9])  #not SS stuff
    31583168                    else:
    31593169                        result = G2spc.GenAtom(XYZ,SGData,False,Move=True)
     
    31703180                                    atom[cx:cx+3] = Opp[key]
    31713181                                    atom[cx+3] = cell
    3172                                     atomData.append(atom[:])               
     3182                                    atomData.append(atom[:cuij+9])  #not SS stuff
    31733183                    data['Drawing']['Atoms'] = atomData
    31743184            finally:
  • trunk/GSASIIplot.py

    r2060 r2062  
    31113111        ccof = []
    31123112        for i,spos in enumerate(Spos):
    3113             if waveType in ['Sawtooth','ZigZag'] and not i:
    3114                 Toff = spos[0][0]
    3115                 slopes = np.array(spos[0][1:])
    3116                 if waveType == 'Sawtooth':
    3117                     wave = G2mth.posSawtooth(tau,Toff,slopes)
     3113            if waveType in ['ZigZag','Block'] and not i:
     3114                Tminmax = spos[0][:2]
     3115                XYZmax = np.array(spos[0][2:])
     3116                if waveType == 'Block':
     3117                    wave = G2mth.posBlock(tau,Tminmax,XYZmax).T
    31183118                elif waveType == 'ZigZag':
    3119                     wave = G2mth.posZigZag(tau,Toff,slopes)
     3119                    wave = G2mth.posZigZag(tau,Tminmax,XYZmax).T
    31203120            else:
    31213121                scof.append(spos[0][:3])
     
    45134513            SetPeakRoll(dirDict[key])
    45144514            SetMapPeaksText(mapPeaks)
     4515        elif key in ['M',]and generalData['Type'] in ['modulated','magnetic']:  #make a movie file
     4516            G2frame.tau = 0.
     4517            for i in range(10):
     4518                G2frame.tau += 0.1
     4519                G2frame.G2plotNB.status.SetStatusText('Modulation tau = %.2f'%(G2frame.tau),1)
     4520                data['Drawing']['Atoms'],Fade = G2mth.ApplyModulation(data,G2frame.tau)     #modifies drawing atom array!         
     4521                SetDrawAtomsText(data['Drawing']['Atoms'])
     4522                G2phG.FindBondsDraw(data)           #rebuild bonds & polygons
     4523                if not np.any(Fade):
     4524                    Fade += 1
     4525                Draw('key down',Fade)
    45154526        elif key in ['+','-','=','0'] and generalData['Type'] in ['modulated','magnetic']:
    45164527            if keyBox:
     
    53525363        choice = [' save as/key:','jpeg','tiff','bmp','c: center on 1/2,1/2,1/2','n: next','p: previous']
    53535364    if generalData['Type'] in ['modulated','magnetic',] and len(drawAtoms):
    5354         choice += ['+: increase tau','-: decrease tau','0: set tau = 0']
     5365        choice += ['+: increase tau','-: decrease tau','0: set tau = 0']    #add 'm: make modulation movie'
    53555366
    53565367    Tx,Ty,Tz = drawingData['viewPoint'][0]
  • trunk/GSASIIspc.py

    r2061 r2062  
    14931493        return A
    14941494   
    1495     def posZigZag(tau,Toff,slopes):
    1496         Tau = (tau-Toff)%1.
    1497         A = np.where(Tau <= 0.5,slopes[:,np.newaxis]*Tau,slopes[:,np.newaxis]*(1.-Tau))
     1495    def posZigZag(tau,Tmm,XYZmax):
     1496        DT = Tmm[1]-Tmm[0]
     1497        slopeUp = 2.*XYZmax/DT
     1498        slopeDn = 2.*XYZmax/(1.-DT)
     1499        A = np.array([np.where(Tmm[0] < t%1. <= Tmm[1],-XYZmax+slopeUp*((t-Tmm[0])%1.),XYZmax-slopeDn*((t-Tmm[1])%1.)) for t in tau])
     1500        return A
     1501
     1502    def posBlock(tau,Tmm,XYZmax):
     1503        A = np.array([np.where(Tmm[0] < t <= Tmm[1],XYZmax,-XYZmax) for t in tau])
    14981504        return A
    14991505       
     
    15491555    def DoXYZ():
    15501556        delt4 = np.ones(4)*0.001
     1557        delt5 = np.ones(5)*0.001
    15511558        delt6 = np.eye(6)*0.001
    15521559        if 'Fourier' in waveType:
     
    15581565            CSI = [np.array([[1,0,0],[2,0,0],[3,0,0],[4,0,0]]),
    15591566                np.array([[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0]])]
    1560         elif waveType == 'ZigZag':
    1561             dX = posZigZag(tau,delt4[0],delt4[1:])
    1562             CSI = [np.array([[1,0,0],[2,0,0],[3,0,0],[4,0,0]]),
    1563                 np.array([[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0]])]
     1567        elif waveType in ['ZigZag','Block']:
     1568            if waveType == 'ZigZag':
     1569                dX = posZigZag(tau,delt5[:2],delt5[2:])
     1570            else:
     1571                dX = posBlock(tau,delt5[:2],delt5[2:])
     1572            CSI = [np.array([[1,0,0],[2,0,0],[3,0,0],[4,0,0],[5,0,0]]),
     1573                np.array([[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0],[1.0,.0,.0]])]
    15641574        XSC = np.ones(6,dtype='i')
    15651575        dXTP = []
     
    15741584                dXT = posSawtooth(tauT,delt4[0],delt4[1:])+np.array(XYZ)[:,np.newaxis,np.newaxis]
    15751585            elif waveType == 'ZigZag':
    1576                 dXT = posZigZag(tauT,delt4[0],delt4[1:])+np.array(XYZ)[:,np.newaxis,np.newaxis]
     1586                dXT = posZigZag(tauT,delt5[:2],delt5[2:])+np.array(XYZ)[:,np.newaxis,np.newaxis]
     1587            elif waveType == 'Block':
     1588                dXT = posBlock(tauT,delt5[:2],delt5[2:])+np.array(XYZ)[:,np.newaxis,np.newaxis]
    15771589            dXT = np.inner(sop[0],dXT.T)    # X modulations array(3x6x49) -> array(3x49x6)
    15781590            dXT = np.swapaxes(dXT,1,2)      # back to array(3x6x49)
  • trunk/GSASIIstrIO.py

    r1996 r2062  
    11681168                            stiw = str(i)+':'+str(iw)
    11691169                            if Stype == 'Spos':
    1170                                 if waveType in ['Sawtooth',] and not iw:
    1171                                     names = [pfx+'Tzero:'+stiw,pfx+'Xslope:'+stiw,pfx+'Yslope:'+stiw,pfx+'Zslope:'+stiw]
    1172                                     equivs = [[], [],[],[]]
     1170                                if waveType in ['ZigZag','Block',] and not iw:
     1171                                    names = [pfx+'Tmin:'+stiw,pfx+'Tmax:'+stiw,pfx+'Xmax:'+stiw,pfx+'Ymax:'+stiw,pfx+'Zmax:'+stiw]
     1172                                    equivs = [[],[], [],[],[]]
    11731173                                else:
    11741174                                    names = [pfx+'Xsin:'+stiw,pfx+'Ysin:'+stiw,pfx+'Zsin:'+stiw,
     
    15651565        cx,ct,cs,cia = General['AtomPtrs']
    15661566        print >>pFile,'\n Modulation waves'
    1567         names = {'Sfrac':['Fsin','Fcos','Fzero','Fwid'],'Spos':['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tzero','Xslope','Yslope','Zslope'],
     1567        names = {'Sfrac':['Fsin','Fcos','Fzero','Fwid'],'Spos':['Xsin','Ysin','Zsin','Xcos','Ycos','Zcos','Tmin','Tmax','Xmax','Ymax','Zmax'],
    15681568            'Sadp':['U11sin','U22sin','U33sin','U12sin','U13sin','U23sin','U11cos','U22cos',
    15691569            'U33cos','U12cos','U13cos','U23cos'],'Smag':['MXsin','MYsin','MZsin','MXcos','MYcos','MZcos']}
     
    15861586                            nt = 6
    15871587                            ot = 0
    1588                             if waveType in ['Sawtooth',] and not iw:
    1589                                 nt = 4
     1588                            if waveType in ['ZigZag','Block',] and not iw:
     1589                                nt = 5
    15901590                                ot = 6
    15911591                            for j in range(nt):
     
    19051905                            stiw = str(i)+':'+str(iw)
    19061906                            if Stype == 'Spos':
    1907                                 if waveType in ['Sawtooth',] and not iw:
    1908                                     names = ['Tzero:'+stiw,'Xslope:'+stiw,'Yslope:'+stiw,'Zslope:'+stiw]
     1907                                if waveType in ['ZigZag','Block',] and not iw:
     1908                                    names = ['Tmin:'+stiw,'Tmax:'+stiw,'Xmax:'+stiw,'Ymax:'+stiw,'Zmax:'+stiw]
    19091909                                else:
    19101910                                    names = ['Xsin:'+stiw,'Ysin:'+stiw,'Zsin:'+stiw,
Note: See TracChangeset for help on using the changeset viewer.