Changeset 4533
- Timestamp:
- Jul 23, 2020 12:28:51 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r4526 r4533 1437 1437 fxn of gTau points; NB: this allows only 1 mag. wave fxn. 1438 1438 ''' 1439 Am = np.array(MSSdata[3:]).T #atoms x waves x cos pos mods 1440 Bm = np.array(MSSdata[:3]).T #...sin pos mods 1441 nWaves = Am.shape[1] 1439 Am = np.array(MSSdata[3:]).T[:,0,:] #atoms x cos pos mods; only 1 wave used 1440 Bm = np.array(MSSdata[:3]).T[:,0,:] #...sin pos mods 1442 1441 SGMT = np.array([ops[0] for ops in SGData['SGOps']]) #not .T!! 1443 1442 Sinv = np.array([nl.inv(ops[0]) for ops in SSGData['SSGOps']]) … … 1453 1452 SGMT = np.vstack((SGMT,SGMT)) 1454 1453 Sinv = np.vstack((Sinv,Sinv)) 1455 SGT = np.vstack((SGT,SGT+ .5))%1.1454 SGT = np.vstack((SGT,SGT+np.array([0.,0.,0.,.5])))%1. 1456 1455 mst = Sinv[:,3,:3] 1457 1456 epsinv = Sinv[:,3,3] 1458 1457 phi = np.inner(XYZ,modQ).T 1459 1458 TA = np.sum(mst[nxs,:,:]*(XYZ-SGT[:,:3][nxs,:,:]),axis=-1).T 1460 tauT = TA[nxs,:,:] + epsinv[nxs,:,nxs]*(glTau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:]) 1461 modind = np.arange(nWaves)+1. 1462 phase = modind[:,nxs,nxs]*tauT #Nops,Natm,Nwave 1463 psin = np.sin(twopi*phase) 1464 pcos = np.cos(twopi*phase) 1465 MmodA = np.sum(Am[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs],axis=3)/2. #cos term 1466 MmodB = np.sum(Bm[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)/2. #sin term 1467 MmodA = np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*SGData['SpnFlp'][nxs,:,nxs,nxs] 1468 MmodB = np.sum(SGMT[nxs,:,nxs,:,:]*MmodB[:,:,:,nxs,:],axis=-1)*SGData['SpnFlp'][nxs,:,nxs,nxs] 1469 return MmodA,MmodB #Ntau,Nops,Natm,Mxyz; cos & sin parts; sum matches drawn atom moments 1470 1471 def MagMod2(m,XYZ,modQ,MSSdata,SGData,SSGData): 1472 ''' 1473 this needs to make magnetic moment modulations & magnitudes as 1474 fxn of gTau points; NB: this allows only 1 mag. wave fxn. 1475 ''' 1476 Am = np.array(MSSdata[3:]).T[:,0,:] #atoms x cos pos mods; only 1 wave 1477 Bm = np.array(MSSdata[:3]).T[:,0,:] #...sin pos mods 1478 SGMT = np.array([ops[0] for ops in SGData['SGOps']]) #not .T!! 1479 SSGMT = np.array([ops[0] for ops in SSGData['SSGOps']]) #not .T!! 1480 Sinv = np.array([nl.inv(ops[0]) for ops in SSGData['SSGOps']]) 1481 SGT = np.array([ops[1] for ops in SSGData['SSGOps']]) 1482 if SGData['SGInv']: 1483 SGMT = np.vstack((SGMT,-SGMT)) 1484 SSGMT = np.vstack((SSGMT,-SSGMT)) 1485 Sinv = np.vstack((Sinv,-Sinv)) 1486 SGT = np.vstack((SGT,-SGT)) 1487 SGMT = np.vstack([SGMT for cen in SGData['SGCen']]) 1488 SSGMT = np.vstack([SSGMT for cen in SGData['SGCen']]) 1489 Sinv = np.vstack([Sinv for cen in SGData['SGCen']]) 1490 SGT = np.vstack([SGT+cen for cen in SSGData['SSGCen']])%1. 1491 if SGData['SGGray']: 1492 SGMT = np.vstack((SGMT,SGMT)) 1493 SSGMT = np.vstack((SSGMT,SSGMT)) 1494 Sinv = np.vstack((Sinv,Sinv)) 1495 SGT = np.vstack((SGT,SGT+.5))%1. 1496 epsinv = Sinv[:,3,3] 1497 phi = np.inner(XYZ,modQ).T 1498 TA = phi+(epsinv*(np.inner(modQ,SGT[:,:3])-SGT[:,3]))[:,nxs] #Nops,Natm 1499 phase = phi+(np.inner(modQ,SGT[:,:3])-SGT[:,3])[:,nxs] 1500 1501 pcos = np.cos(-twopi*m[:,nxs,nxs]*phase[nxs,:,:]) #Nref,Nops,Natm 1502 psin = np.sin(-twopi*m[:,nxs,nxs]*phase[nxs,:,:]) 1503 MmodA = TA[nxs,:,:,nxs]*(Am[nxs,nxs,:,:]*pcos[:,:,:,nxs]-Bm[nxs,nxs,:,:]*psin[:,:,:,nxs])/2. #Nref,Nops,Natm,Mxyz 1504 MmodB = TA[nxs,:,:,nxs]*(Am[nxs,nxs,:,:]*psin[:,:,:,nxs]+Bm[nxs,nxs,:,:]*pcos[:,:,:,nxs])/2. #Nref,Nops,Natm,Mxyz 1505 MmodA = np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*SGData['SpnFlp'][nxs,:,nxs,nxs] 1506 MmodB = np.sum(SGMT[nxs,:,nxs,:,:]*MmodB[:,:,:,nxs,:],axis=-1)*SGData['SpnFlp'][nxs,:,nxs,nxs] 1507 return MmodA,MmodB #Nref,Nops,Natm,Mxyz; cos & sin parts 1508 1459 phase = TA[nxs,:,:] + epsinv[nxs,:,nxs]*(glTau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:]) 1460 pcos = np.cos(twopi*phase*epsinv[nxs,:,nxs]) #Ntau,Nops,Natm 1461 psin = np.sin(twopi*phase*epsinv[nxs,:,nxs]) 1462 1463 MmodAp = (Am[nxs,nxs,:,:]*pcos[:,:,:,nxs]+epsinv[nxs,:,nxs,nxs]*Bm[nxs,nxs,:,:]*psin[:,:,:,nxs])/2. #Ntau,Nops,Natm,Mxyz 1464 MmodBp = (Am[nxs,nxs,:,:]*psin[:,:,:,nxs]+epsinv[nxs,:,nxs,nxs]*Bm[nxs,nxs,:,:]*pcos[:,:,:,nxs])/2. 1465 MmodAm = (Am[nxs,nxs,:,:]*pcos[:,:,:,nxs]+epsinv[nxs,:,nxs,nxs]*Bm[nxs,nxs,:,:]*psin[:,:,:,nxs])/2. 1466 MmodBm = (Am[nxs,nxs,:,:]*psin[:,:,:,nxs]+epsinv[nxs,:,nxs,nxs]*Bm[nxs,nxs,:,:]*pcos[:,:,:,nxs])/2. 1467 MmodAp = np.sum(SGMT[nxs,:,nxs,:,:]*MmodAp[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs] 1468 MmodBp = np.sum(SGMT[nxs,:,nxs,:,:]*MmodBp[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs] 1469 MmodAm = np.sum(SGMT[nxs,:,nxs,:,:]*MmodAm[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs] 1470 MmodBm = np.sum(SGMT[nxs,:,nxs,:,:]*MmodBm[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs] 1471 return MmodAp,MmodBp,MmodAm,MmodBm #Ntau,Nops,Natm,Mxyz; cos & sin parts 1472 1509 1473 def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt): 1510 1474 ''' -
trunk/GSASIIstrMath.py
r4531 r4533 1516 1516 if SGData['SGGray']: 1517 1517 mXYZ = np.hstack((mXYZ,mXYZ)) 1518 # this done in wrong place - should be 1519 MmodA ,MmodB= G2mth.MagMod(glTau,mXYZ,modQ,MSSdata,SGData,SSGData) #Ntau,Nops,Natm,Mxyz cos,sim parts sum matches drawing1520 Mmod = MmodA+MmodB 1518 1519 MmodAp,MmodBp,MmodAm,MmodBm = G2mth.MagMod(glTau,mXYZ,modQ,MSSdata,SGData,SSGData) #Ntau,Nops,Natm,Mxyz cos,sim parts sum matches drawing 1520 # MmodAp,MmodBp,MmodAm,MmodBm = G2mth.MagMod2(mXYZ,modQ,MSSdata,SGData,SSGData) #Nops,Natm,Mxyz cos,sim parts sum matches drawing 1521 1521 1522 1522 if not SGData['SGGray']: #for fixed Mx,My,Mz … … 1527 1527 GSdata = SGData['MagMom'][nxs,:,nxs]*GSdata #flip vectors according to spin flip * det(opM) 1528 1528 GSdata = np.swapaxes(GSdata,0,1) #Nop,Natm,Mxyz 1529 Mmod += GSdata[nxs,:,:,:]1530 1531 # Kdata = np.inner(Mmod,uAmat) #Ntau,Nops,Natm,Mxyz1532 # Kmean = np.mean(np.sqrt(np.sum(Kdata**2,axis=0)),axis=0)1533 # Kdata /= Kmean #Ntau,Nops,Natm,Mxyz Cartesian unit vectors along mag moments1534 1529 1535 1530 FF = np.zeros(len(Tdata)) … … 1608 1603 eM = (HM/np.sqrt(np.sum(HM**2,axis=0))).T # normalize HP Nref,hkl=Unit vectors || Q 1609 1604 1610 fam0 = 0.1611 fbm0 = 0.1605 # fam0 = 0. 1606 # fbm0 = 0. 1612 1607 if not SGData['SGGray']: #correct -fixed Mx,My,Mz contribution 1613 1608 fam0 = TMcorr[:,nxs,:,nxs]*GSdata[nxs,:,:,:]*cosm[:,:,:,nxs] #Nref,Nops,Natm,Mxyz 1614 1609 fbm0 = TMcorr[:,nxs,:,nxs]*GSdata[nxs,:,:,:]*sinm[:,:,:,nxs] 1615 1610 # calc mag. structure factors; Nref,Ntau,Nops,Natm,Mxyz 1616 fams = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*cosm[i,nxs,:,:,nxs]+ 1617 H[3,i]*MmodB*sinm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Nref,Ntau,Nops,Natm,Mxyz 1611 # fams = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*cosm[i,nxs,:,:,nxs]+ 1612 # H[3,i]*MmodB*sinm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Nref,Ntau,Nops,Natm,Mxyz 1613 # 1614 # fbms = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*sinm[i,nxs,:,:,nxs]+ 1615 # H[3,i]*MmodB*cosm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Nref,Ntau,Nops,Natm,Mxyz 1616 # 1617 # if not SGData['SGGray']: 1618 # fams += fam0[:,nxs,:,:,:] 1619 # fbms += fbm0[:,nxs,:,:,:] 1620 1621 fams = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,np.where(H[3,i]>0, 1622 (MmodAp*cosm[i,nxs,:,:,nxs]+MmodBp*sinm[i,nxs,:,:,nxs]), 1623 (MmodAm*cosm[i,nxs,:,:,nxs]+MmodBm*sinm[i,nxs,:,:,nxs])),0.) for i in range(mRef)]) #Nref,Nops,Natm,Mxyz 1618 1624 1619 fbms = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,(MmodA*sinm[i,nxs,:,:,nxs]+ 1620 H[3,i]*MmodB*cosm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Nref,Ntau,Nops,Natm,Mxyz 1625 fbms = TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(H[3,i]!=0,np.where(H[3,i]>0, 1626 (MmodAp*sinm[i,nxs,:,:,nxs]+MmodBp*cosm[i,nxs,:,:,nxs]), 1627 (MmodAm*sinm[i,nxs,:,:,nxs]+MmodBm*cosm[i,nxs,:,:,nxs])),0.) for i in range(mRef)]) #Nref,Nops,Natm,Mxyz 1621 1628 1622 1629 if not SGData['SGGray']: … … 1624 1631 fbms += fbm0[:,nxs,:,:,:] 1625 1632 1626 # this is the best, but not exactly right1627 1633 #sum ops & atms 1628 fasm = np.sum(np.sum(fams,axis=-2),axis=-2) #Nref, Ntau,Mxyz; sum ops & atoms1634 fasm = np.sum(np.sum(fams,axis=-2),axis=-2) #Nref,Mxyz; sum ops & atoms 1629 1635 fbsm = np.sum(np.sum(fbms,axis=-2),axis=-2) 1630 1636 #put into cartesian space … … 1635 1641 eDotFb = np.sum(eM[:,nxs,:]*fbcm,axis=-1) 1636 1642 #intensity Halpern & Johnson 1637 # fass = np.sum((facm-eM[:,nxs,:]*eDotFa[:,:,nxs])**2,axis=-1) 1638 # fbss = np.sum((fbcm-eM[:,nxs,:]*eDotFb[:,:,nxs])**2,axis=-1) 1639 fass = np.sum(facm**2,axis=-1)-eDotFa**2 1640 fbss = np.sum(fbcm**2,axis=-1)-eDotFb**2 1643 fass = np.sum((facm-eM[:,nxs,:]*eDotFa[:,:,nxs])**2,axis=-1) 1644 fbss = np.sum((fbcm-eM[:,nxs,:]*eDotFb[:,:,nxs])**2,axis=-1) 1641 1645 ## #do integration 1642 1646 fas = np.sum(fass*glWt[nxs,:],axis=1)
Note: See TracChangeset
for help on using the changeset viewer.