Changeset 3801 for trunk


Ignore:
Timestamp:
Jan 27, 2019 9:04:12 AM (6 years ago)
Author:
vondreele
Message:

combine cell2AB & Gmat2AB in G2lat
fixes to mag. str. fctr. math. Correct sym. op. transformation of moments & fix moment to cartesian axis problem

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIlattice.py

    r3783 r3801  
    590590
    591591    """
    592     cellstar = Gmat2cell(G)
     592#    cellstar = Gmat2cell(G)
    593593    g = nl.inv(G)
    594594    cell = Gmat2cell(g)
    595     A = np.zeros(shape=(3,3))
    596     # from Giacovazzo (Fundamentals 2nd Ed.) p.75
    597     A[0][0] = cell[0]                # a
    598     A[0][1] = cell[1]*cosd(cell[5])  # b cos(gamma)
    599     A[0][2] = cell[2]*cosd(cell[4])  # c cos(beta)
    600     A[1][1] = cell[1]*sind(cell[5])  # b sin(gamma)
    601     A[1][2] = -cell[2]*cosd(cellstar[3])*sind(cell[4]) # - c cos(alpha*) sin(beta)
    602     A[2][2] = 1./cellstar[2]         # 1/c*
    603     B = nl.inv(A)
    604     return A,B
     595#    A = np.zeros(shape=(3,3))
     596    return cell2AB(cell)
     597#    # from Giacovazzo (Fundamentals 2nd Ed.) p.75
     598#    A[0][0] = cell[0]                # a
     599#    A[0][1] = cell[1]*cosd(cell[5])  # b cos(gamma)
     600#    A[0][2] = cell[2]*cosd(cell[4])  # c cos(beta)
     601#    A[1][1] = cell[1]*sind(cell[5])  # b sin(gamma)
     602#    A[1][2] = -cell[2]*cosd(cellstar[3])*sind(cell[4]) # - c cos(alpha*) sin(beta)
     603#    A[2][2] = 1./cellstar[2]         # 1/c*
     604#    B = nl.inv(A)
     605#    return A,B
    605606   
    606607def cell2AB(cell):
  • TabularUnified trunk/GSASIIstrMath.py

    r3795 r3801  
    976976        return
    977977    Mag = np.array([np.sqrt(np.inner(mag,np.inner(mag,Ginv))) for mag in Gdata.T])
    978     Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
     978    Gdata = np.inner(Gdata.T,np.swapaxes(SGMT,1,2)).T            #apply sym. ops.
    979979    if SGData['SGInv'] and not SGData['SGFixed']:
    980980        Gdata = np.hstack((Gdata,-Gdata))       #inversion if any
     
    982982    Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata   #flip vectors according to spin flip * det(opM)
    983983    Mag = np.tile(Mag[:,nxs],Nops).T  #make Mag same length as Gdata
    984     VGi = np.sqrt(nl.det(Ginv))
    985     Kdata = np.inner(Gdata.T,uAmat).T*VGi/Mag     #Cartesian unit vectors
     984    Kdata = np.inner(Gdata.T,uAmat.T).T/Mag     #Cartesian unit vectors
    986985    Uij = np.array(G2lat.U6toUij(Uijdata))
    987986    bij = Mast*Uij.T
     
    11301129    Mag = np.array([np.sqrt(np.inner(mag,np.inner(mag,Ginv))) for mag in Gdata.T])
    11311130    Gones = np.ones_like(Gdata)
    1132     Gdata = np.inner(Gdata.T,SGMT).T            #apply sym. ops.
     1131    Gdata = np.inner(Gdata.T,np.swapaxes(SGMT,1,2)).T            #apply sym. ops.
    11331132    Gones = np.inner(Gones.T,SGMT).T
    11341133    if SGData['SGInv'] and not SGData['SGFixed']:
     
    11401139    Gones = SGData['MagMom'][nxs,:,nxs]*Gones   #flip vectors according to spin flip
    11411140    Mag = np.tile(Mag[:,nxs],Nops).T  #make Mag same length as Gdata
    1142     VGi = np.sqrt(nl.det(Ginv))
    1143     Kdata = np.inner(Gdata.T,uAmat).T*VGi/Mag       #make unit vectors in Cartesian space
     1141    Kdata = np.inner(Gdata.T,uAmat.T).T/Mag     #Cartesian unit vectors
    11441142    Uij = np.array(G2lat.U6toUij(Uijdata))
    11451143    bij = Mast*Uij.T
     
    14171415    GS = G/np.outer(ast,ast)
    14181416    Ginv = g/np.outer(ainv,ainv)
    1419     VGi = np.sqrt(nl.det(Ginv))
    14201417    uAmat = G2lat.Gmat2AB(GS)[0]
    14211418    Mast = twopisq*np.multiply.outer(ast,ast)   
     
    14421439
    14431440    if parmDict[pfx+'isMag']:       #TODO: fix the math
    1444         GSdata = Gdata[:,nxs,:]+Mmod.T
    1445         GSdata = np.inner(GSdata.T,SGMT).T            #apply sym. ops.
     1441        GSdata = Gdata[:,nxs,:]+Mmod.T                  #Mxyz,Ntau,nAtm
     1442        GSdata = np.inner(GSdata.T,np.swapaxes(SGMT,1,2)).T            #apply sym. ops.
    14461443        if SGData['SGInv'] and not SGData['SGFixed']:
    14471444            GSdata = np.hstack((GSdata,-GSdata))       #inversion if any
     
    14491446        GSdata = SGData['MagMom'][nxs,:,nxs,nxs]*GSdata   #flip vectors according to spin flip * det(opM)
    14501447        SMag = np.sqrt(np.sum((np.inner(GSdata.T,Ginv)*GSdata.T),axis=-1)).T
    1451         Kdata = np.inner(GSdata.T,uAmat).T*VGi/SMag[nxs,:,:,:]     #Cartesian unit vectors = 0.9626 for hexagonal???
     1448        Kdata = np.inner(Gdata.T,uAmat.T).T/SMag[nxs,:,:,:]     #Cartesian unit vectors
    14521449
    14531450    FF = np.zeros(len(Tdata))
Note: See TracChangeset for help on using the changeset viewer.