Changeset 3830


Ignore:
Timestamp:
Feb 27, 2019 10:20:33 AM (5 years ago)
Author:
vondreele
Message:

modify makeRing to allow optionally a multiplier on number of steps around diffraction ring.
Used to make 5x (i.e. 0.2mm steps) number of steps for ring intensity plot
fix error in modulated magnetic centering ops 4th dimension
math for making mag modulations now correct in SStructureFactor

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIimage.py

    r3815 r3830  
    229229        return 0,0,0,0     
    230230   
    231 def makeRing(dsp,ellipse,pix,reject,scalex,scaley,image):
     231def makeRing(dsp,ellipse,pix,reject,scalex,scaley,image,mul=1):
    232232    'Needs a doc string'
    233233    def ellipseC():
     
    245245    sphi = sind(phi-90.)
    246246    ring = []
    247     C = int(ellipseC())         #ring circumference
     247    C = int(ellipseC())*mul         #ring circumference in mm
    248248    azm = []
    249249    for i in range(0,C,1):      #step around ring in 1mm increments
     
    11291129        if len(Ring):
    11301130            ellipse = FitEllipse(R['ImxyObs'].T)
    1131             ringxy,ringazm = makeRing(ring['Dcalc'],ellipse,0,0.,scalex,scaley,Image)
     1131            ringxy,ringazm = makeRing(ring['Dcalc'],ellipse,0,0.,scalex,scaley,Image,5)
    11321132            ring['ImxyCalc'] = np.array(ringxy).T[:2]
    11331133            ringint = np.array([float(Image[int(x*scalex),int(y*scaley)]) for y,x in np.array(ringxy)[:,:2]])
    11341134            ringint /= np.mean(ringint)
    1135             print (' %s %.3f %s %.3f'%('d-spacing',ring['Dcalc'],'sig(MRD):',np.sqrt(np.var(ringint))))
     1135            print (' %s %.3f %s %.3f %s %d'%('d-spacing',ring['Dcalc'],'sig(MRD):',np.sqrt(np.var(ringint)),'# points:',len(ringint)))
    11361136            RingsAI.append(np.array(zip(ringazm,ringint)).T)
    11371137    return RingsAI
  • trunk/GSASIIspc.py

    r3795 r3830  
    16621662    for icen,cen in enumerate(SGData['SGCen']):
    16631663        SSCen[icen,0:3] = cen
    1664     SSGData['SSGCen'] = SSCen
     1664    if 'BNSlattsym' in SGData and '_' in SGData['BNSlattsym'][0]:
     1665        Ncen = len(SGData['SGCen'])
     1666        for icen in range(Ncen//2,Ncen):
     1667            SSCen[icen,3] = 0.5
     1668    SSGData['SSGCen'] = SSCen%1.
    16651669    SSGData['SSGOps'] = []
    16661670    for iop,op in enumerate(SGData['SGOps']):
  • trunk/GSASIIstrMath.py

    r3825 r3830  
    14831483    '''
    14841484    phfx = pfx.split(':')[0]+hfx
    1485     g = nl.inv(G)
    14861485    ast = np.sqrt(np.diag(G))
    1487     ainv = np.sqrt(np.diag(g))
    14881486    GS = G/np.outer(ast,ast)
    1489     Ginv = g/np.outer(ainv,ainv)
    14901487    uAmat = G2lat.Gmat2AB(GS)[0]
    14911488    Mast = twopisq*np.multiply.outer(ast,ast)   
     
    14961493    SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']])
    14971494    SSGT = np.array([ops[1] for ops in SSGData['SSGOps']])
     1495    SSCen = SSGData['SSGCen']
    14981496    FFtables = calcControls['FFtables']
    14991497    BLtables = calcControls['BLtables']
     
    15111509    modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']])
    15121510
    1513     if parmDict[pfx+'isMag']:       #TODO: fix the math
     1511    if parmDict[pfx+'isMag']:       #This part correct for making modulated mag moments on equiv atoms
    15141512        GSdata = np.inner(Gdata.T,np.swapaxes(SGMT,1,2))  #apply sym. ops.--> Natm,Nops,Nxyz
    1515         MSmod = np.array([np.roll(Mmod,int(ngl*ssgt[3]),2) for ssgt in SSGT])   #Nops,Natm,Ntau,Mxyz
     1513        MSmod = np.array([np.roll(Mmod+Gdata.T[:,nxs,:],-int(round(ngl*ssgt[3])),2) for ssgt in SSGT])   #Nops,Natm,Ntau,Mxyz
    15161514        if SGData['SGInv'] and not SGData['SGFixed']:   #inversion if any
    15171515            GSdata = np.hstack((GSdata,-GSdata))     
    15181516            MSmod = np.vstack((MSmod,-MSmod))
    1519         GSdata = np.hstack([GSdata for icen in range(Ncen)])        #dup over cell centering
    1520         MSmod = np.vstack([MSmod for icen in range(Ncen)])        #dup over cell centering - right??
     1517        GSdata = np.hstack([GSdata for cen in SSCen])        #dup over cell centering - Natm,Nops,Mxyz
     1518        MSmod = np.vstack([np.roll(MSmod,-int(round(ngl*cen[3])),2) for cen in SSCen])        #dup over cell centering - right??
    15211519       
    1522         GSdata = GSdata[:,:,nxs,:]+np.swapaxes(MSmod,0,1)         #Natm,Nops,Ntau,Mxyz
    1523         GSdata = SGData['MagMom'][nxs,:,nxs,nxs]*GSdata   #flip vectors according to spin flip * det(opM)
    1524         mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T])
    1525         mXYZ = np.array(np.inner(mXYZ,modQ)*ngl,dtype=int)
    1526         RGSdata = np.array([[np.roll(GSdata[i,j],mXYZ[i,j],0) for j in range(mXYZ.shape[1])] for i in range(mXYZ.shape[0])])
    1527         Kdata = np.inner(RGSdata,uAmat).T     #Cartesian unit vectors
    1528         SMag = np.sqrt(np.sum(Kdata**2,axis=0))
    1529         Kdata /= SMag      #mxyz,ntau,nops,natm
     1520#another try - keep MSmod separated & calc Kdata without modulation
     1521        GSdata = SGData['MagMom'][nxs,:,nxs]*GSdata   #flip vectors according to spin flip * det(opM)
     1522        Kdata = np.inner(GSdata,uAmat).T     #Cartesian unit vectors
     1523        SMag = np.sqrt(np.sum(Kdata**2,axis=0))     #magnitude of fixed part of moment
     1524        Kdata /= SMag      #mxyz,nops,natm- unit Cart. vector for fixed component of moment
     1525       
     1526# GSMdata has modulation       
     1527        GSMdata = np.swapaxes(MSmod,0,1)         #Natm,Nops,Ntau,Mxyz
     1528        mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T])%1.
     1529        mXYZ = np.array(np.rint(ngl*np.inner(mXYZ,modQ)),dtype=int)
     1530        RGSdata = np.array([[np.roll(GSMdata[i,j],-mXYZ[i,j],0) for j in range(mXYZ.shape[1])] for i in range(mXYZ.shape[0])])
     1531        KMdata = np.inner(RGSdata,uAmat).T     #Cartesian unit vectors
     1532        SMMag = np.sqrt(np.sum(KMdata**2,axis=0))
     1533        KMdata /= SMMag      #mxyz,ntau,nops,natm
    15301534
    15311535    FF = np.zeros(len(Tdata))
     
    16031607            HM = np.inner(Bmat,HP.T)                             #put into cartesian space
    16041608            HM = HM/np.sqrt(np.sum(HM**2,axis=0))               #Gdata = MAGS & HM = UVEC in magstrfc.for both OK
    1605             eDotK = np.sum(HM[:,:,nxs,nxs,nxs]*Kdata[:,nxs,:,:,:],axis=0)
    1606             Q = HM[:,:,nxs,nxs,nxs]*eDotK[nxs,:,:,:,:]-Kdata[:,nxs,:,:,:] #Mxyz,Nref,Ntau,Nop,Natm
     1609#            eDotK = np.sum(HM[:,:,nxs,nxs]*Kdata[:,nxs,:,:],axis=0)
     1610            eDotKM = np.sum(HM[:,:,nxs,nxs,nxs]*KMdata[:,nxs,:,:,:],axis=0)
     1611#            Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Kdata[:,nxs,:,:] #Mxyz,Nref,Nop,Natm
     1612            QM = HM[:,:,nxs,nxs,nxs]*eDotKM[nxs,:,:,:,:]-KMdata[:,nxs,:,:,:] #Mxyz,Nref,Nop,Natm
    16071613
    1608             fam = (Q*TMcorr[nxs,:,nxs,nxs,:]*cosm[nxs,:,nxs,:,:]*SMag[nxs,nxs,:,:,:])   #Mxyz,Nref,Ntau,Nop,Natm
    1609             fbm = (Q*TMcorr[nxs,:,nxs,nxs,:]*sinm[nxs,:,nxs,:,:]*SMag[nxs,nxs,:,:,:])
     1614#            fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*SMag[nxs,nxs,:,:]  #Mxyz,Nref,Nop,Natm
     1615#            fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*SMag[nxs,nxs,:,:]
    16101616           
    1611             fas = np.sum(np.sum(fam,axis=-1),axis=-1)/ngl      #xyz,Nref,ntau; sum ops & atoms
    1612             fbs = np.sum(np.sum(fbm,axis=-1),axis=-1)/ngl      #ditto
     1617            fam = QM*TMcorr[nxs,:,nxs,nxs,:]*cosm[nxs,:,nxs,:,:]*SMMag[nxs,nxs,:,:,:]/2.    #Mxyz,Nref,Ntau,Nops,Natm
     1618            fbm = QM*TMcorr[nxs,:,nxs,nxs,:]*sinm[nxs,:,nxs,:,:]*SMMag[nxs,nxs,:,:,:]/2.
    16131619           
    1614             refl.T[10] = np.sum(np.sum(fas,axis=-1),axis=0)**2+np.sum(np.sum(fbs,axis=-1),axis=0)**2    #square of sums
     1620            fams = np.sum(fam**2,axis=2)/ngl
     1621            fbms = np.sum(fbm**2,axis=2)/ngl
     1622           
     1623            fas = np.sum(np.sum(fams,axis=-1),axis=-1)      #xyz,Nref; sum ops & atoms
     1624            fbs = np.sum(np.sum(fbms,axis=-1),axis=-1)
     1625           
     1626            refl.T[10] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2    #square of sums
    16151627#            refl.T[11] = mphase[:,0,0]  #ignore f' & f"
    16161628           
Note: See TracChangeset for help on using the changeset viewer.