Changeset 3232


Ignore:
Timestamp:
Jan 18, 2018 3:56:37 PM (4 years ago)
Author:
vondreele
Message:

fix magnetic math in G2strMath

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIstrMath.py

    r3231 r3232  
    686686    if parmDict[pfx+'isMag']:       #TODO: fix the math - mag moments now along crystal axes
    687687        Mag = np.sqrt(np.sum(Gdata**2,axis=0))      #magnitude of moments for uniq atoms
     688#        Mag = np.sqrt(np.inner(np.inner(Gdata.T,G),Gdata.T))
    688689        Gdata = np.where(Mag>0.,Gdata/Mag,0.)       #normalze mag. moments
    689         Gdata = np.inner(Bmat,Gdata.T)              #convert to crystal space
     690#        Gdata = np.inner(Bmat,Gdata.T)              #convert to crystal space
    690691        Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
    691         if SGData['SGInv']:
     692        if SGData['SGInv'] and not SGData['SGFixed']:
    692693            Gdata = np.hstack((Gdata,-Gdata))       #inversion if any
    693694        Gdata = np.hstack([Gdata for icen in range(Ncen)])        #dup over cell centering
    694695        Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata   #flip vectors according to spin flip * det(opM)
    695         Gdata = np.inner(Amat,Gdata.T)              #convert back to cart. space MXYZ, Natoms, NOps*Inv*Ncen
    696         Gdata = np.swapaxes(Gdata,1,2)              # put Natoms last
     696#        Gdata = np.inner(Amat,Gdata.T)              #convert back to cart. space MXYZ, Natoms, NOps*Inv*Ncen
     697#        Gdata = np.swapaxes(Gdata,1,2)              # put Natoms last
    697698        Mag = np.tile(Mag[:,nxs],len(SGMT)*Ncen).T
    698         if SGData['SGInv']:
     699        if SGData['SGInv'] and not SGData['SGFixed']:
    699700            Mag = np.repeat(Mag,2,axis=0)                  #Mag same shape as Gdata
    700701    if 'NC' in calcControls[hfx+'histType']:
     
    763764            MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T   #Nref,Natm
    764765            TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops)     #Nref,Natm
    765             if SGData['SGInv']:
     766            if SGData['SGInv'] and not SGData['SGFixed']:
    766767                mphase = np.hstack((phase,-phase))
    767768            else:
     
    995996    SGT = np.array([ops[1] for ops in SGData['SGOps']])
    996997    Ncen = len(SGData['SGCen'])
    997     Nops = len(SGMT)*Ncen*(1+SGData['SGInv'])
     998    if SGData['SGFixed']:
     999        Nops = len(SGMT)*Ncen
     1000    else:
     1001        Nops = len(SGMT)*Ncen*(1+SGData['SGInv'])
    9981002    Amat,Bmat = G2lat.Gmat2AB(G)
    9991003    nRef = len(refDict['RefList'])
     
    10041008    mSize = len(Mdata)
    10051009    Mag = np.sqrt(np.sum(Gdata**2,axis=0))      #magnitude of moments for uniq atoms
    1006     Gdata = np.where(Mag>0.,Gdata/Mag,0.)       #normalze mag. moments
     1010#    Gdata = np.where(Mag>0.,Gdata/Mag,0.)       #normalze mag. moments
    10071011    dGdM = np.repeat(Gdata[:,nxs,:],Nops,axis=1)
    1008     Gdata = np.inner(Bmat,Gdata.T)              #convert to crystal space
     1012#    Gdata = np.inner(Bmat,Gdata.T)              #convert to crystal space
    10091013    Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
    1010     if SGData['SGInv']:
     1014    if SGData['SGInv'] and not SGData['SGFixed']:
    10111015        Gdata = np.hstack((Gdata,-Gdata))       #inversion if any
    10121016    Gdata = np.hstack([Gdata for icen in range(Ncen)])        #dup over cell centering
    10131017    Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata   #flip vectors according to spin flip
    1014     Gdata = np.inner(Amat,Gdata.T)              #convert back to cart. space MXYZ, Natoms, NOps
    1015     Gdata = np.swapaxes(Gdata,1,2)              # put Natoms last - Mxyz,Nops,Natms
     1018#    Gdata = np.inner(Amat,Gdata.T)              #convert back to cart. space MXYZ, Natoms, NOps
     1019#    Gdata = np.swapaxes(Gdata,1,2)              # put Natoms last - Mxyz,Nops,Natms
    10161020    Mag = np.tile(Mag[:,nxs],Nops).T  #make Mag same length as Gdata
    10171021    dGdm = (1.-Gdata**2)                        #1/Mag removed - canceled out in dqmx=sum(dqdm*dGdm)
     
    10481052        MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T   #Nref,Natm
    10491053        TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Fdata*Mdata*MF/(2*Nops)     #Nref,Natm
    1050         if SGData['SGInv']:
     1054        if SGData['SGInv'] and not SGData['SGFixed']:
    10511055            mphase = np.hstack((phase,-phase))
    10521056            Uniq = np.hstack((Uniq,-Uniq))      #Nref,Nops,hkl
     
    10961100        dFdui[iBeg:iFin] = 2.*np.sum(fams[:,:,nxs]*dfadui+fbms[:,:,nxs]*dfbdui,axis=0)              #ok
    10971101        dFdua[iBeg:iFin] = 2.*np.sum(fams[:,:,nxs,nxs]*dfadua+fbms[:,:,nxs,nxs]*dfbdua,axis=0)      #problems U12 & U23 in sarc
    1098 #        GSASIIpath.IPyBreak()
    10991102        iBeg += blkSize
    11001103    print (' %d derivative time %.4f\r'%(nRef,time.time()-time0))
     
    11151118        dFdvDict[pfx+'AU13:'+str(i)] = dFdua.T[4][i]
    11161119        dFdvDict[pfx+'AU23:'+str(i)] = dFdua.T[5][i]
    1117 #    GSASIIpath.IPyBreak()
    11181120    return dFdvDict
    11191121       
  • trunk/testDeriv.py

    r3166 r3232  
    2727import numpy as np
    2828import GSASIIpath
     29GSASIIpath.SetBinaryPath()
    2930import GSASIIstrMath as G2stMth
    3031import GSASIItestplot as plot
Note: See TracChangeset for help on using the changeset viewer.