Changeset 4125
- Timestamp:
- Aug 30, 2019 2:03:45 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImath.py
r4073 r4125 1360 1360 return ngl,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt 1361 1361 1362 def MagMod( ngl,XYZ,modQ,MSSdata,SGData,SSGData):1362 def MagMod(glTau,XYZ,modQ,MSSdata,SGData,SSGData): 1363 1363 ''' 1364 1364 this needs to make magnetic moment modulations & magnitudes as 1365 fxn of ngl tau points1365 fxn of gTau points 1366 1366 ''' 1367 1367 Am = np.array(MSSdata[:3]).T #atoms x waves x sin pos mods 1368 1368 Bm = np.array(MSSdata[3:]).T #...cos pos mods 1369 1369 nWaves = Am.shape[1] 1370 tau = np.arange(ngl)/ngl1371 if not nWaves:1372 return 0.0,0.01373 1370 SGMT = np.array([ops[0] for ops in SGData['SGOps']]) #not .T!! 1374 1371 Sinv = np.array([nl.inv(ops[0]) for ops in SSGData['SSGOps']]) … … 1386 1383 phi = np.inner(XYZ,modQ).T 1387 1384 TA = np.sum(mst[nxs,:,:]*(XYZ-SGT[:,:3][nxs,:,:]),axis=-1).T 1388 tauT = TA[nxs,:,:] + epsinv[nxs,:,nxs]*( tau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:])1385 tauT = TA[nxs,:,:] + epsinv[nxs,:,nxs]*(glTau[:,nxs,nxs]-SGT[:,3][nxs,:,nxs]+phi[nxs,:,:]) 1389 1386 modind = np.arange(nWaves)+1. 1390 1387 phase = (modind[:,nxs,nxs]*tauT) #Nops,Natm,Nwave 1391 1388 psin = np.sin(twopi*phase) 1392 1389 pcos = np.cos(twopi*phase) 1393 Mmod B= np.sum(Bm[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs],axis=3)1394 Mmod A= np.sum(Am[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3)1390 MmodA = np.sum(Bm[nxs,nxs,:,:,:]*pcos[:,:,:,nxs,nxs],axis=3) 1391 MmodB = np.sum(Am[nxs,nxs,:,:,:]*psin[:,:,:,nxs,nxs],axis=3) 1395 1392 if SGData['SGGray']: 1396 1393 MmodA = -np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*detSM[nxs,:,nxs,nxs] … … 1399 1396 MmodA = np.sum(SGMT[nxs,:,nxs,:,:]*MmodA[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs] 1400 1397 MmodB = np.sum(SGMT[nxs,:,nxs,:,:]*MmodB[:,:,:,nxs,:],axis=-1)*SGData['MagMom'][nxs,:,nxs,nxs] 1401 Mmod = MmodA+MmodB 1402 return Mmod,MmodA,MmodB #Ntau,Nops,Natm,,Mxyz; sum,sin & cos parts 1398 return MmodA,MmodB #Ntau,Nops,Natm,,Mxyz; cos & sin parts; sum matches drwa 1403 1399 1404 1400 def MagMod2(XYZ,modQ,MSSdata,SGData,SSGData): … … 1425 1421 epsinv = Sinv[:,3,3] #Nops 1426 1422 kdr = np.inner(XYZ,modQ).T #Nops,Natm 1427 # phase = kdr+(epsinv*(np.inner(SGT[:,:3],modQ)-SGT[:,3]))[:,nxs] #Nops,Natm1428 1423 1429 1424 phase = (np.sum(mst*(XYZ-SGT[nxs,:,:3]),axis=-1)).T+epsinv[:,nxs]*(kdr-SGT[:,nxs,3]) … … 1431 1426 psin = np.sin(twopi*phase) #Nops,Natm 1432 1427 pcos = np.cos(twopi*phase) 1433 MmodA = np.sum( Am[nxs,:,:,:]*psin[:,:,nxs,nxs],axis=2) #Nops,Natm,31434 MmodB = np.sum( Bm[nxs,:,:,:]*pcos[:,:,nxs,nxs],axis=2)1428 MmodA = np.sum(Bm[nxs,:,:,:]*pcos[:,:,nxs,nxs],axis=2) 1429 MmodB = np.sum(Am[nxs,:,:,:]*psin[:,:,nxs,nxs],axis=2) #Nops,Natm,3 1435 1430 MmodA = np.sum(SGMT[:,nxs,:,:]*MmodA[:,:,nxs,:],axis=-1) 1436 1431 MmodB = np.sum(SGMT[:,nxs,:,:]*MmodB[:,:,nxs,:],axis=-1) … … 1442 1437 MmodB = MmodB*SGData['MagMom'][:,nxs,nxs] 1443 1438 #MmodA+MmodB matches drawn tau=0 atom moments 1444 return MmodA,MmodB #Nops,Natm,Mxyz; sin & cosparts1439 return MmodA,MmodB #Nops,Natm,Mxyz; cos & sin parts 1445 1440 1446 1441 def Modulation(H,HP,nWaves,Fmod,Xmod,Umod,glTau,glWt): -
trunk/GSASIIstrMath.py
r4068 r4125 1510 1510 1511 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 1512 TmagA,TmagB = G2mth.MagMod2(mXYZ,modQ,MSSdata,SGData,SSGData) #Nops,Natm,Mxyz-Tmag matches drawing moments 1512 # TmagA,TmagB = G2mth.MagMod2(mXYZ,modQ,MSSdata,SGData,SSGData) #Nops,Natm,Mxyz-TmagA+TmagB matches drawing moments @ tau=0. 1513 MmodA,MmodB = G2mth.MagMod(glTau,mXYZ,modQ,MSSdata,SGData,SSGData) #Ntau,Nops,Natm,Mxyz sum matches drawing 1513 1514 1514 1515 if not SGData['SGGray']: #for fixed Mx,My,Mz … … 1606 1607 M = np.array(np.abs(H[3]),dtype=np.int)-1 1607 1608 1608 fam = .5*TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(TmagB*cosm[i,:,:,nxs]- \ 1609 np.sign(H[3,i])*TmagA*sinm[i,:,:,nxs]),0.) for i in range(mRef)])+fam0 #Nref,Nops,Natm,Mxyz 1609 fams = .5*TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA*cosm[i,nxs,:,:,nxs]- \ 1610 np.sign(H[3,i])*MmodB*sinm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Ntau,Nref,Nops,Natm,Mxyz 1611 1612 fbms = .5*TMcorr[:,nxs,nxs,:,nxs]*np.array([np.where(M[i]>=0,(MmodA*sinm[i,nxs,:,:,nxs]+ \ 1613 np.sign(H[3,i])*MmodB*cosm[i,nxs,:,:,nxs]),0.) for i in range(mRef)]) #Ntau,Nref,Nops,Natm,Mxyz 1610 1614 1611 fbm = .5*TMcorr[:,nxs,:,nxs]*np.array([np.where(M[i]>=0,(TmagB*sinm[i,:,:,nxs]+ \ 1612 np.sign(H[3,i])*TmagA*cosm[i,:,:,nxs]),0.) for i in range(mRef)])+fbm0 1613 1614 famq = np.sum(np.sum(fam,axis=-2),axis=-2) #Nref,Mxyz; sum ops & atoms 1615 fbmq = np.sum(np.sum(fbm,axis=-2),axis=-2) 1615 if not SGData['SGGray']: 1616 fams += fam0[:,nxs,:,:,:] 1617 fbms += fbm0[:,nxs,:,:,:] 1618 1619 famqs = np.sum(np.sum(fams,axis=-2),axis=-2) #Ntau,Nref,Mxyz; sum ops & atoms 1620 fbmqs = np.sum(np.sum(fbms,axis=-2),axis=-2) 1616 1621 1617 fas = np.sum(famq,axis=-1)**2-np.sum(eM.T*famq,axis=-1)**2 #mag intensity calc F^2-(e.F)^21618 fbs = np.sum(fbmq,axis=-1)**2-np.sum(eM.T*fbmq,axis=-1)**21622 fass = np.sum(famqs,axis=-1)**2-np.sum(eM.T[:,nxs,:]*famqs,axis=-1)**2 #mag intensity calc F^2-(e.F)^2 1623 fbss = np.sum(fbmqs,axis=-1)**2-np.sum(eM.T[:,nxs,:]*fbmqs,axis=-1)**2 1619 1624 1620 # refl.T[10] = np.where(H[3],fas+fbs,fas0+fbs0) 1621 # refl.T[11] = np.where(H[3],atan2d(fbs,fas),atan2d(fbs0,fas0)) 1625 fas = np.sum(glWt*fass,axis=1) 1626 fbs = np.sum(glWt*fbss,axis=1) 1627 1622 1628 refl.T[10] = fas+fbs 1623 1629 refl.T[11] = atan2d(fbs,fas)
Note: See TracChangeset
for help on using the changeset viewer.