Changeset 4143
- Timestamp:
- Sep 11, 2019 8:30:14 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIstrMath.py
r4140 r4143 1482 1482 phfx = pfx.split(':')[0]+hfx 1483 1483 ast = np.sqrt(np.diag(G)) 1484 g = nl.inv(G) 1485 ainv = np.sqrt(np.diag(g)) 1486 GS = G/np.outer(ast,ast) 1487 uAmat = G2lat.Gmat2AB(GS)[0] 1488 Ginv = g/np.outer(ainv,ainv) 1484 # GS = G/np.outer(ast,ast) 1485 # uAmat = G2lat.Gmat2AB(GS)[0] 1489 1486 Mast = twopisq*np.multiply.outer(ast,ast) 1490 1487 SGInv = SGData['SGInv'] 1491 1488 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1492 #Ncen = len(SGData['SGCen'])1489 Ncen = len(SGData['SGCen']) 1493 1490 Nops = len(SGMT)*(1+SGData['SGInv']) 1494 1491 SSGMT = np.array([ops[0].T for ops in SSGData['SSGOps']]) … … 1514 1511 mXYZ = np.array([[xyz[0] for xyz in list(G2spc.GenAtom(xyz,SGData,All=True,Move=True))] for xyz in (Xdata+dXdata).T])%1. #Natn,Nop,xyz 1515 1512 MmodA,MmodB = G2mth.MagMod(glTau,mXYZ,modQ,MSSdata,SGData,SSGData) #Ntau,Nops,Natm,Mxyz sum matches drawing 1516 Mmod = MmodA+MmodB1517 1513 1518 1514 if not SGData['SGGray']: #for fixed Mx,My,Mz … … 1523 1519 GSdata = SGData['MagMom'][nxs,:,nxs]*GSdata #flip vectors according to spin flip * det(opM) 1524 1520 GSdata = np.swapaxes(GSdata,0,1) #Nop,Natm,Mxyz 1525 Mmod += GSdata[nxs,:,:,:]1526 1527 Mag = np.array([np.sqrt(np.inner(mag,np.inner(mag,Ginv))) for mag in Mmod]) #Ntau,Nop,Natm1528 Kdata = np.inner(Mmod,uAmat) #Cartesian vectors; Mxyz,Natm,Nop,Ntau1529 Kmean = np.sqrt(np.sum(Kdata**2,axis=-1))1530 Kdata /= Kmean[:,:,:,nxs] #normalized cartesian mag. moment Ntau,Nop,Natm,Mxyz1531 1521 1532 1522 FF = np.zeros(len(Tdata)) … … 1603 1593 MF = refDict['FF']['MF'][iBeg:iFin].T[Tindx].T #Nref,Natm 1604 1594 TMcorr = 0.539*(np.reshape(Tiso,Tuij.shape)*Tuij)[:,0,:]*Mdata*Fdata*MF/(2.*Nops) #Nref,Natm 1605 # 1606 HM = np.inner(Bmat,HP.T) #put into cartesian space 1607 eM = (HM/np.sqrt(np.sum(HM**2,axis=0))).T #& normalize; Nref,Mhkl 1608 eDotK = np.sum(eM[:,nxs,nxs,nxs,:]*Kdata[nxs,:,:,:,:],axis=-1) #Nref,Ntau,Nops,Natm 1609 Q = eM[:,nxs,nxs,nxs,:]*eDotK[:,:,:,:,nxs]-Kdata[nxs,:,:,:,:] #Nref,Ntau,Nops,Natm,Mxyz 1610 Q = 1.0 1611 1595 1596 HM = np.inner(Bmat.T,HP.T) #put into cartesian space 1597 eM = HM/np.sqrt(np.sum(HM**2,axis=0)) #& normalize 1598 #for fixed moments --> m=0 reflections 1612 1599 fam0 = 0. 1613 1600 fbm0 = 0. 1614 1601 if not SGData['SGGray']: #correct -fixed Mx,My,Mz contribution 1615 fam0 = Q*TMcorr[:,nxs,nxs,:,nxs]*GSdata[nxs,nxs,:,:,:]*cosm[:,nxs,:,:,nxs] #Nref,Ntau,Nops,Natm,Mxyz1616 fbm0 = Q*TMcorr[:,nxs,nxs,:,nxs]*GSdata[nxs,nxs,:,:,:]*sinm[:,nxs,:,:,nxs]1602 fam0 = TMcorr[:,nxs,:,nxs]*GSdata[nxs,:,:,:]*cosm[:,:,:,nxs] #Nref,Nops,Natm,Mxyz 1603 fbm0 = TMcorr[:,nxs,:,nxs]*GSdata[nxs,:,:,:]*sinm[:,:,:,nxs] 1617 1604 #for modulated moments --> m != 0 reflections 1618 1605 1619 fams = Q*TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*cosm[i,nxs,:,:,nxs]- \1606 fams = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*cosm[i,nxs,:,:,nxs]- \ 1620 1607 np.sign(H[3,i])*MmodB*sinm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Nref,Ntau,Nops,Natm,Mxyz 1621 1608 1622 fbms = Q*TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*sinm[i,nxs,:,:,nxs]+ \1609 fbms = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*sinm[i,nxs,:,:,nxs]+ \ 1623 1610 np.sign(H[3,i])*MmodB*cosm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Nref,Ntau,Nops,Natm,Mxyz 1624 1611 1625 1612 if not SGData['SGGray']: 1626 fams *= .5 1627 fbms *= .5 1628 fams += fam0 1629 fbms += fbm0 1630 1631 # do GL integral before making mag F's - less correct; gives F's where there shouldn't be any 1632 # 1633 # fass = np.sum(glWt[nxs,:,nxs,nxs,nxs]*fams,axis=1) #GL integration 1634 # fbss = np.sum(glWt[nxs,:,nxs,nxs,nxs]*fbms,axis=1) 1635 # 1636 # fas = np.sum(np.sum(fass,axis=-1),axis=-1) #Nref,Ntau,Mxyz; sum ops & atoms 1637 # fbs = np.sum(np.sum(fbss,axis=-1),axis=-1) 1638 # refl.T[10] = np.sum(fas**2,axis=1)+np.sum(fbs**2,axis=1) 1639 # refl.T[11] = atan2d(fbs[:,0],fas[:,0]) 1640 ## 1641 # do GL integral after making mag. F's - better but not right 1642 1613 fams *= 0.5 1614 fbms *= 0.5 1615 fams += fam0[:,nxs,:,:,:] 1616 fbms += fbm0[:,nxs,:,:,:] 1617 1643 1618 famqs = np.sum(np.sum(fams,axis=-2),axis=-2) #Nref,Ntau,Mxyz; sum ops & atoms 1644 1619 fbmqs = np.sum(np.sum(fbms,axis=-2),axis=-2) … … 1653 1628 fbmcs = np.nan_to_num(fbmcs) 1654 1629 1655 fass = np.sum(famqs**2,axis=-1)*(1.-np.sum(eM [:,nxs,:]*famcs,axis=-1)**2) #mag intensity calc F^2-(e.F)^21656 fbss = np.sum(fbmqs**2,axis=-1)*(1.-np.sum(eM [:,nxs,:]*fbmcs,axis=-1)**2) #WRONG - needs mag. moment not F!1630 fass = np.sum(famqs**2,axis=-1)*(1.-np.sum(eM.T[:,nxs,:]*famcs,axis=-1)**2) #mag intensity calc F^2-(e.F)^2 1631 fbss = np.sum(fbmqs**2,axis=-1)*(1.-np.sum(eM.T[:,nxs,:]*fbmcs,axis=-1)**2) 1657 1632 1658 fas = np.sum(glWt*fass,axis=1) #GL integration1633 fas = np.sum(glWt*fass,axis=1) 1659 1634 fbs = np.sum(glWt*fbss,axis=1) 1660 1635 1661 1636 refl.T[10] = fas+fbs 1662 1637 refl.T[11] = atan2d(fbs,fas) 1663 # 1638 1664 1639 else: 1665 1640 GfpuA = G2mth.Modulation(Uniq,UniqP,nWaves,Fmod,Xmod,Umod,glTau,glWt) #2 x refBlk x sym X atoms
Note: See TracChangeset
for help on using the changeset viewer.