Changeset 3877 for trunk/GSASIImath.py


Ignore:
Timestamp:
Apr 5, 2019 3:36:26 PM (5 years ago)
Author:
vondreele
Message:

micsf again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r3867 r3877  
    13871387    psin = np.sin(twopi*phase)
    13881388    pcos = np.cos(twopi*phase)
    1389     Mmod = np.sum(Am[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs]+Bm[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)
     1389    MmodA = np.sum(Am[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs],axis=3)
     1390    MmodB = np.sum(Bm[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)
    13901391    if SGData['SGGray']:
    1391         Mmod = -np.sum(SGMT[nxs,:,nxs,:,:]*Mmod[:,:,:,nxs,:],axis=-1)*detSM[nxs,:,nxs,nxs]
     1392        MmodA = -np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*detSM[nxs,:,nxs,nxs]
     1393        MmodB = -np.sum(SGMT[nxs,:,nxs,:,:]*MmodB[:,:,:,nxs,:],axis=-1)*detSM[nxs,:,nxs,nxs]
    13921394    else:
    1393         Mmod = np.sum(SGMT[nxs,:,nxs,:,:]*Mmod[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs]
    1394     return Mmod    #Ntau,Nops,Natm,,Mxyz
     1395        MmodA = np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs]
     1396        MmodB = np.sum(SGMT[nxs,:,nxs,:,:]*MmodB[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs]
     1397    Mmod = MmodA+MmodB
     1398    return Mmod,MmodA,MmodB    #Ntau,Nops,Natm,,Mxyz; sum,Re & Im parts
    13951399       
    13961400def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt):
     
    14231427    return np.array([cosHA,sinHA])             # 2 x refBlk x SGops x atoms
    14241428   
     1429def MagModulation(H,HP,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt):
     1430    '''
     1431    H: array nRefBlk x ops X hklt
     1432    HP: array nRefBlk x ops X hklt proj to hkl
     1433    nWaves: list number of waves for frac, pos, uij & mag
     1434    Fmod: array 2 x atoms x waves    (sin,cos terms)
     1435    Xmod: array atoms X 3 X ngl
     1436    Umod: array atoms x 3x3 x ngl
     1437    glTau,glWt: arrays Gauss-Lorentzian pos & wts
     1438    '''
     1439   
     1440    if nWaves[2]:       #uij (adp) waves
     1441        if len(HP.shape) > 2:
     1442            HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.?
     1443        else:
     1444            HbH = np.exp(-np.sum(HP[:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.?
     1445    else:
     1446        HbH = 1.0
     1447    HdotX = np.inner(HP,Xmod)                   #refBlk x ops x atoms X ngl
     1448    if len(H.shape) > 2:
     1449        D = H[:,:,3:]*glTau[nxs,nxs,:]              #m*e*tau; refBlk x ops X ngl
     1450        HdotXD = twopi*(HdotX+D[:,:,nxs,:])
     1451    else:
     1452        D = H[:,3:]*glTau[nxs,:]              #m*e*tau; refBlk x ops X ngl
     1453        HdotXD = twopi*(HdotX+D[:,nxs,:])
     1454    M = np.swapaxes(Mmod,1,2)
     1455    cosHA = np.sum(M[nxs,nxs,:,:,:]*(Fmod*HbH*np.cos(HdotXD)[:,:,:,nxs,:]*glWt),axis=-1)       #real part; refBlk X ops x atoms; sum for G-L integration
     1456    sinHA = np.sum(M[nxs,nxs,:,:,:]*(Fmod*HbH*np.sin(HdotXD)[:,:,:,nxs,:]*glWt),axis=-1)       #imag part; ditto
     1457    return np.array([cosHA,sinHA])             # 2 x refBlk x SGops x atoms
     1458
    14251459def ModulationTw(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt):
    14261460    '''
Note: See TracChangeset for help on using the changeset viewer.