Changeset 2480


Ignore:
Timestamp:
Sep 28, 2016 12:16:00 PM (7 years ago)
Author:
vondreele
Message:

add make magnetic phase to General/Transform? option
trap missing rigid bodies to define torsion seq option
fix lighting issues for polygons
fix xye importer to stop on trailing blank lines rather than crashing
fix error in powder structure factor calc
add magnetic structure factor calc. (some error still & no derivatives yet)

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r2473 r2480  
    11971197            G2frame.dataFrame.Bind(wx.EVT_MENU, AddResidueRB, id=G2gd.wxID_RIGIDBODYADD)
    11981198            G2frame.dataFrame.Bind(wx.EVT_MENU, OnImportRigidBody, id=G2gd.wxID_RIGIDBODYIMPORT)
    1199             G2frame.dataFrame.Bind(wx.EVT_MENU, OnDefineTorsSeq, id=G2gd.wxID_RESIDUETORSSEQ)
     1199            G2frame.dataFrame.Bind(wx.EVT_MENU, OnDefineTorsSeq, id=G2gd.wxID_RESIDUETORSSEQ) #enable only if residue RBs exist?
    12001200            G2frame.Page = [page,'rrb']
    12011201            UpdateResidueRB()
     
    14181418        rbNames.sort()
    14191419        rbId = 0
    1420         if len(rbNames) > 1:
     1420        if len(rbNames) == 0:
     1421            print 'There are no rigid bodies defined'
     1422            G2frame.ErrorDialog('No rigid bodies','There are no rigid bodies defined',
     1423                                parent=G2frame.dataFrame)
     1424            return
     1425        elif len(rbNames) > 1:
    14211426            dlg = wx.SingleChoiceDialog(G2frame,'Select rigid body for torsion sequence','Torsion sequence',rbNames)
    14221427            if dlg.ShowModal() == wx.ID_OK:
  • trunk/GSASIIgrid.py

    r2466 r2480  
    530530        self.newCell = self.Phase['General']['Cell'][1:8]
    531531        self.Common = 'abc'
     532        self.ifMag = False
    532533        self.Draw()
    533534
     
    616617            self.newCell = G2lat.TransformCell(self.oldCell[:6],self.Trans)
    617618            wx.CallAfter(self.Draw)
     619           
     620        def OnMag(event):
     621            self.ifMag = mag.GetValue()
    618622
    619623        self.panel.Destroy()
     
    673677        sgSizer.Add(SGTxt,0,WACV)
    674678        mainSizer.Add(sgSizer,0,WACV)
     679        if 'magnetic' not in self.Phase['General']['Type']:
     680            mag = wx.CheckBox(self.panel,label=' Make magnetic phase?')
     681            mag.Bind(wx.EVT_CHECKBOX,OnMag)
     682            mainSizer.Add(mag,0,WACV)
    675683
    676684        TestBtn = wx.Button(self.panel,-1,"Test")
     
    697705        self.Phase['General']['Name'] += ' %s'%(self.Common)
    698706        self.Phase['General']['Cell'][1:] = G2lat.TransformCell(self.oldCell[:6],self.Trans)           
    699         return self.Phase,self.Trans,self.Vec
     707        return self.Phase,self.Trans,self.Vec,self.ifMag
    700708
    701709    def OnOk(self,event):
  • trunk/GSASIIlattice.py

    r2476 r2480  
    229229    return UijtoU6(Uij)
    230230   
    231 def TransformPhase(oldPhase,newPhase,Trans,Vec):
     231def TransformPhase(oldPhase,newPhase,Trans,Vec,ifMag):
    232232    '''Transform atoms from oldPhase to newPhase by Trans & Vec
    233233    NB: doesnt transform moments correctly - TBD
     
    238238    :param Trans: array transformation matrix
    239239    :param Vec: array transformation vector
     240    :param ifMag: bool True if convert to magnetic phase
    240241    '''
    241242   
     
    252253                    atom[cx+i] += 1.
    253254                newAtoms += moreAtoms
     255    if ifMag:
     256        cia += 3
     257        cs += 3
     258        newPhase['General']['Type'] = 'magnetic'
     259        newPhase['General']['AtomPtrs'] = [cx,ct,cs,cia]
     260        magAtoms = []
     261        for atom in newAtoms:
     262            magAtoms.append(atom[:cx+4]+[0.,0.,0.]+atom[cx+4:])
     263        newAtoms = magAtoms
     264        newPhase['Draw Atoms'] = []
    254265    for atom in newAtoms:
    255266        atom[cx:cx+3] = TransformXYZ(atom[cx:cx+3],invTrans.T,Vec)%1.
  • trunk/GSASIIphsGUI.py

    r2476 r2480  
    13771377        try:
    13781378            if dlg.ShowModal() == wx.ID_OK:
    1379                 newPhase,Trans,Vec = dlg.GetSelection()
     1379                newPhase,Trans,Vec,ifMag = dlg.GetSelection()
    13801380            else:
    13811381                return
     
    13831383            dlg.Destroy()
    13841384        phaseName = newPhase['General']['Name']
    1385         newPhase = G2lat.TransformPhase(data,newPhase,Trans,Vec)
     1385        newPhase = G2lat.TransformPhase(data,newPhase,Trans,Vec,ifMag)
    13861386        newPhase['General']['Map'] = mapDefault.copy()
    13871387        sub = G2frame.PatternTree.AppendItem(parent=
  • trunk/GSASIIplot.py

    r2479 r2480  
    51175117        glEnable(GL_LIGHT0)
    51185118        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,0)
    5119         glLightfv(GL_LIGHT0,GL_AMBIENT,[.8,.8,.8,1])
     5119        glLightfv(GL_LIGHT0,GL_AMBIENT,[.1,.1,.1,1])
    51205120        glLightfv(GL_LIGHT0,GL_DIFFUSE,[.8,.8,.8,1])
    51215121#        glLightfv(GL_LIGHT0,GL_SPECULAR,[1,1,1,1])
     
    54435443        glPushMatrix()
    54445444        glTranslate(x,y,z)
    5445         glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,color)
     5445        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color)
    54465446        glShadeModel(GL_SMOOTH)
    54475447        glMultMatrixf(B4mat.T)
  • trunk/GSASIIstrMath.py

    r2478 r2480  
    599599        'AU11:':Uijdata[0],'AU22:':Uijdata[1],'AU33:':Uijdata[2],
    600600        'AU12:':Uijdata[3],'AU13:':Uijdata[4],'AU23:':Uijdata[5],
    601         'AMx':Gdata[0],'AMy':Gdata[1],'AMz':Gdata[2],}
     601        'AMx:':Gdata[0],'AMy:':Gdata[1],'AMz:':Gdata[2],}
    602602    for iatm in range(Natoms):
    603603        for key in keys:
     
    668668    SGMT = np.array([ops[0].T for ops in SGData['SGOps']])
    669669    SGT = np.array([ops[1] for ops in SGData['SGOps']])
     670    Ncen = len(SGData['SGCen'])
    670671    FFtables = calcControls['FFtables']
    671672    BLtables = calcControls['BLtables']
    672673    MFtables = calcControls['MFtables']
     674    Amat,Bmat = G2lat.Gmat2AB(G)
    673675    Flack = 1.0
    674676    if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict:
     
    684686    Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata,Gdata = \
    685687        GetAtomFXU(pfx,calcControls,parmDict)
     688    if parmDict[pfx+'isMag']:
     689        Mag = np.sqrt(np.sum(Gdata**2,axis=0))      #magnitude of moments for uniq atoms
     690        Gdata = np.where(Mag>0.,Gdata/Mag,0.)       #normalze mag. moments
     691        Gdata = np.inner(Bmat,Gdata.T)              #convert to crystal space
     692        Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
     693        if SGData['SGInv']:
     694            Gdata = np.hstack((Gdata,-Gdata))       #inversion if any
     695        Gdata = np.repeat(Gdata,Ncen,axis=1)    #dup over cell centering
     696        Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata   #flip vectors according to spin flip
     697        Gdata = np.inner(Amat,Gdata.T)              #convert back to cart. space MXYZ, Natoms, NOps*Inv*Ncen
     698        Gdata = np.swapaxes(Gdata,1,2)              # put Natoms last
     699#        GSASIIpath.IPyBreak()
     700        Mag = np.tile(Mag[:,nxs],len(SGMT)*Ncen).T
     701        if SGData['SGInv']:
     702            Mag = np.repeat(Mag,2,axis=0)                  #Mag same length as Gdata
    686703    if 'NC' in calcControls[hfx+'histType']:
    687704        FP,FPP = G2el.BlenResCW(Tdata,BLtables,parmDict[hfx+'Lam'])
     
    709726            for iel,El in enumerate(refDict['FF']['El']):
    710727                refDict['FF']['FF'].T[iel] = G2el.ScatFac(FFtables[El],SQ)
    711 #    GSASIIpath.IPyBreak()
    712728#reflection processing begins here - big arrays!
    713729    iBeg = 0
     
    750766        FF = np.repeat(refDict['FF']['FF'][iBeg:iFin].T[Tindx].T,len(SGT)*len(TwinLaw),axis=0)
    751767        if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']:
    752             MF = np.repeat(refDict['FF']['MF'][iBeg:iFin].T[Tindx].T,len(SGT)*len(TwinLaw),axis=0)
    753             #calc fam & fbm here
     768            MF = np.repeat(refDict['FF']['MF'][iBeg:iFin].T[Tindx].T,len(TwinLaw),axis=0)   #Nref,Natm
     769            TMcorr = 0.539*Tcorr[:,0,:]*MF                                                  #Nref,Natm
     770            if SGData['SGInv']:
     771                mphase = np.hstack((phase,-phase))
     772            else:
     773                mphase = phase
     774            mphase = np.array([mphase+twopi*np.inner(cen,H)[:,nxs,nxs] for cen in SGData['SGCen']])
     775            mphase = np.concatenate(mphase,axis=1)              #Nref,Nop,Natm
     776            sinm = np.sin(mphase)                               #ditto - match magstrfc.for
     777            cosm = np.cos(mphase)                               #ditto
     778            HM = np.inner(Bmat.T,H)                             #put into cartesian space
     779            HM = HM/np.sqrt(np.sum(HM**2,axis=0))               #Gdata = MAGS & HM = UVEC in magstrfc.for both OK
     780            eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0)
     781            Q = -HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]+Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK
     782            fam = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*cosm[nxs,:,:,:]    #ditto
     783            fbm = Q*TMcorr[nxs,:,nxs,:]*SGData['MagMom'][nxs,nxs,:,nxs]*sinm[nxs,:,:,:]    #ditto
     784            fams = np.sum(np.sum(fam,axis=-1),axis=-1)                          #xyz,Nref
     785            fbms = np.sum(np.sum(fbm,axis=-1),axis=-1)                          #ditto
     786            GSASIIpath.IPyBreak()
    754787        if 'T' in calcControls[hfx+'histType']: #fa,fb are 2 X blkSize X nTwin X nOps x nAtoms
    755788            fa = np.array([np.reshape(((FF+FP).T-Bab).T,cosp.shape)*cosp*Tcorr,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr])
     
    763796            fbs[0] *= 0.
    764797            fas[1] *= 0.
    765         if 'PWDR' in calcControls[hfx+'histType']:     #PWDR: F^2 = A[0]^2 + A[1]^2 + B[0]^2 + B[1]^2
     798        if 'P' in calcControls[hfx+'histType']:     #PXC, PNC & PNT: F^2 = A[0]^2 + A[1]^2 + B[0]^2 + B[1]^2
    766799            refl.T[9] = np.sum(fas**2,axis=0)+np.sum(fbs**2,axis=0) #add fam**2 & fbm**2 here   
    767800            refl.T[10] = atan2d(fbs[0],fas[0])  #ignore f' & f"
     801            if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']:
     802                refl.T[9] += np.sum(fams**2,axis=0)+np.sum(fbms**2,axis=0)
    768803        else:                                       #HKLF: F^2 = (A[0]+A[1])^2 + (B[0]+B[1])^2
    769804            if len(TwinLaw) > 1:
  • trunk/imports/G2pwd_xye.py

    r2463 r2480  
    3838        self.GSAS = False
    3939        for i,S in enumerate(filepointer):
     40            if not S:
     41                break
    4042            if i > 1000: break
    4143            if begin:
Note: See TracChangeset for help on using the changeset viewer.