Changeset 3777
- Timestamp:
- Jan 9, 2019 10:51:24 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r3774 r3777 3490 3490 dlg = wx.FileDialog(self, 'Choose sum image filename', pth,outname.split('IMG ')[1], 3491 3491 'G2img files (*.G2img)|*.G2img', 3492 wx. SAVE|wx.FD_OVERWRITE_PROMPT)3492 wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) 3493 3493 if dlg.ShowModal() == wx.ID_OK: 3494 3494 newimagefile = dlg.GetPath() -
trunk/GSASIImath.py
r3774 r3777 1346 1346 Umod = 1.0 1347 1347 if nWaves[3]: 1348 tauM = np.arange(1.,nWaves[ 1]+1-nx)[:,nxs]*glTau #Mwaves x ngl1348 tauM = np.arange(1.,nWaves[3]+1-nx)[:,nxs]*glTau #Mwaves x ngl 1349 1349 MmodA = Am[:,:,:,nxs]*np.sin(twopi*tauM[nxs,:,nxs,:]) #atoms X waves X 3 X ngl 1350 1350 MmodB = Bm[:,:,:,nxs]*np.cos(twopi*tauM[nxs,:,nxs,:]) #ditto … … 1359 1359 H: array nRefBlk x ops X hklt 1360 1360 HP: array nRefBlk x ops X hklt proj to hkl 1361 nWaves: list number of waves for frac, pos, uij & mag 1361 1362 Fmod: array 2 x atoms x waves (sin,cos terms) 1362 1363 Xmod: array atoms X 3 X ngl … … 1366 1367 ''' 1367 1368 1368 if nWaves[2]: 1369 if nWaves[2]: #uij (adp) waves 1369 1370 if len(HP.shape) > 2: 1370 1371 HbH = np.exp(-np.sum(HP[:,:,nxs,nxs,:]*np.inner(HP,Umod),axis=-1)) # refBlk x ops x atoms x ngl add Overhauser corr.? -
trunk/GSASIIstrMath.py
r3774 r3777 1412 1412 ''' 1413 1413 phfx = pfx.split(':')[0]+hfx 1414 g = nl.inv(G) 1414 1415 ast = np.sqrt(np.diag(G)) 1416 ainv = np.sqrt(np.diag(g)) 1417 GS = G/np.outer(ast,ast) 1418 Ginv = g/np.outer(ainv,ainv) 1419 VGi = np.sqrt(nl.det(Ginv)) 1420 uAmat = G2lat.Gmat2AB(GS)[0] 1415 1421 Mast = twopisq*np.multiply.outer(ast,ast) 1416 1422 SGInv = SGData['SGInv'] … … 1431 1437 if not Xdata.size: #no atoms in phase! 1432 1438 return 1433 1434 if parmDict[pfx+'isMag']: #TODO: fix the math1435 Mag = np.sqrt(np.sum(Gdata**2,axis=0)) #magnitude of moments for uniq atoms1436 Gdata = np.where(Mag>0.,Gdata/Mag,0.) #normalze mag. moments1437 Gdata = np.inner(Gdata.T,SGMT).T #apply sym. ops.1438 if SGData['SGInv'] and not SGData['SGFixed']:1439 Gdata = np.hstack((Gdata,-Gdata)) #inversion if any1440 Gdata = np.hstack([Gdata for icen in range(Ncen)]) #dup over cell centering1441 Gdata = SGData['MagMom'][nxs,:,nxs]*Gdata #flip vectors according to spin flip * det(opM)1442 Mag = np.tile(Mag[:,nxs],len(SGMT)*Ncen).T1443 if SGData['SGInv'] and not SGData['SGFixed']:1444 Mag = np.repeat(Mag,2,axis=0) #Mag same shape as Gdata1445 1446 1447 1439 waveTypes,FSSdata,XSSdata,USSdata,MSSdata = GetAtomSSFXU(pfx,calcControls,parmDict) 1448 1440 ngl,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt = G2mth.makeWaves(waveTypes,FSSdata,XSSdata,USSdata,MSSdata,Mast) 1449 1441 modQ = np.array([parmDict[pfx+'mV0'],parmDict[pfx+'mV1'],parmDict[pfx+'mV2']]) 1442 1443 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. 1446 if SGData['SGInv'] and not SGData['SGFixed']: 1447 GSdata = np.hstack((GSdata,-GSdata)) #inversion if any 1448 GSdata = np.hstack([GSdata for icen in range(Ncen)]) #dup over cell centering 1449 GSdata = SGData['MagMom'][nxs,:,nxs,nxs]*GSdata #flip vectors according to spin flip * det(opM) 1450 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??? 1452 1450 1453 FF = np.zeros(len(Tdata)) 1451 1454 if 'NC' in calcControls[hfx+'histType']: … … 1456 1459 Uij = np.array(G2lat.U6toUij(Uijdata)).T 1457 1460 bij = Mast*Uij 1458 blkSize = 32#no. of reflections in a block1461 blkSize = 48 #no. of reflections in a block 1459 1462 nRef = refDict['RefList'].shape[0] 1460 1463 SQ = 1./(2.*refDict['RefList'].T[5])**2 … … 1511 1514 Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[1] #refBlk x ops x atoms 1512 1515 GfpuA = G2mth.Modulation(Uniq,UniqP,nWaves,Fmod,Xmod,Umod,Mmod,glTau,glWt) #2 x refBlk x sym X atoms 1513 fams = np.zeros(32)1514 fbms = np.zeros(32)1516 fams = 0. 1517 fbms = 0. 1515 1518 1516 1519 if 'N' in calcControls[hfx+'histType'] and parmDict[pfx+'isMag']: #TODO: mag math here?? … … 1525 1528 sinm = np.sin(mphase) #ditto - match magstrfc.for 1526 1529 cosm = np.cos(mphase) #ditto 1530 1527 1531 HM = np.inner(Bmat,HP.T) #put into cartesian space 1528 1532 HM = HM/np.sqrt(np.sum(HM**2,axis=0)) #Gdata = MAGS & HM = UVEC in magstrfc.for both OK 1529 eDotK = np.sum(HM[:,:,nxs,nxs]*Gdata[:,nxs,:,:],axis=0) 1530 Q = HM[:,:,nxs,nxs]*eDotK[nxs,:,:,:]-Gdata[:,nxs,:,:] #xyz,Nref,Nop,Natm = BPM in magstrfc.for OK 1531 fam = Q*TMcorr[nxs,:,nxs,:]*cosm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 1532 fbm = Q*TMcorr[nxs,:,nxs,:]*sinm[nxs,:,:,:]*Mag[nxs,nxs,:,:] #ditto 1533 fagm = fam*GfpuA[0]-fbm*GfpuA[1] #real; 2 x refBlk x sym x atoms 1534 fbgm = fbm*GfpuA[0]+fam*GfpuA[1] 1535 fams = np.sum(np.sum(fagm,axis=-1),axis=-1) #xyz,Nref 1536 fbms = np.sum(np.sum(fbgm,axis=-1),axis=-1) #ditto 1537 1533 eDotK = np.sum(HM[:,:,nxs,nxs,nxs]*Kdata[:,nxs,:,:,:],axis=0) 1534 Q = HM[:,:,nxs,nxs,nxs]*eDotK[nxs,:,:,:,:]-Kdata[:,nxs,:,:,:] #Mxyz,Nref,Nop,Ntau,Natm 1535 1536 fam = Q*TMcorr[nxs,:,nxs,nxs,:]*cosm[nxs,:,:,nxs,:]*SMag[nxs,nxs,:,:,:] #ditto 1537 fbm = Q*TMcorr[nxs,:,nxs,nxs,:]*sinm[nxs,:,:,nxs,:]*SMag[nxs,nxs,:,:,:] #ditto 1538 1539 fams = np.sum(np.sum(fam,axis=2),axis=-1) #xyz,Nref,ntau 1540 fbms = np.sum(np.sum(fbm,axis=2),axis=-1) #ditto 1541 1542 fams = np.sum(np.sum(fams**2,axis=0)*glWt[nxs,:],axis=-1) 1543 fbms = np.sum(np.sum(fbms**2,axis=0)*glWt[nxs,:],axis=-1) 1538 1544 1539 1545 if 'T' in calcControls[hfx+'histType']: … … 1547 1553 fas = np.sum(np.sum(fag,axis=-1),axis=-1) #2 x refBlk; sum sym & atoms 1548 1554 fbs = np.sum(np.sum(fbg,axis=-1),axis=-1) 1549 refl.T[10] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2+ np.sum(fams,axis=0)**2+np.sum(fbms,axis=0)**2#square of sums1555 refl.T[10] = np.sum(fas,axis=0)**2+np.sum(fbs,axis=0)**2+fams+fbms #square of sums 1550 1556 refl.T[11] = atan2d(fbs[0],fas[0]) #ignore f' & f" 1551 1557 if 'P' not in calcControls[hfx+'histType']: … … 1676 1682 Tuij = np.where(HbH<1.,np.exp(HbH),1.0) 1677 1683 Tcorr = np.reshape(Tiso,Tuij.shape)*Tuij*Mdata*Fdata/Uniq.shape[1] #refBlk x ops x atoms 1678 # GSASIIpath.IPyBreak()1679 1684 if 'T' in calcControls[hfx+'histType']: 1680 1685 fa = np.array([np.reshape(((FF+FP).T-Bab).T,cosp.shape)*cosp*Tcorr,-np.reshape(Flack*FPP,sinp.shape)*sinp*Tcorr]) … … 1758 1763 dFdGf = np.zeros((nRef,mSize,FSSdata.shape[1],2)) 1759 1764 dFdGx = np.zeros((nRef,mSize,XSSdata.shape[1],6)) 1760 # dFdGz = np.zeros((nRef,mSize,5))1761 1765 dFdGu = np.zeros((nRef,mSize,USSdata.shape[1],12)) 1762 1766 Flack = 1.0 … … 1910 1914 dFdvDict[pfx+'U23cos:'+str(i)+':'+str(j)] = 2.*dFdGu.T[11][j][i] 1911 1915 1912 # GSASIIpath.IPyBreak()1913 1916 dFdvDict[phfx+'Flack'] = 4.*dFdfl.T 1914 1917 dFdvDict[phfx+'BabA'] = dFdbab.T[0] … … 1942 1945 if parm == '0': 1943 1946 continue 1944 if parm.split(':')[2] in ['Tmin','Tmax','Xmax','Ymax','Zmax','Fzero','Fwid',]: 1947 if parm.split(':')[2] in ['Tmin','Tmax','Xmax','Ymax','Zmax','Fzero','Fwid', 1948 'MXsin','MXcos','MYsin','MYcos','MZsin','MZcos','AMx','AMy','AMz',]: 1945 1949 parmDict[parm] += dM 1946 1950 prefList = SStructureFactor(trefDict,G,hfx,pfx,SGData,SSGData,calcControls,parmDict) … … 3326 3330 aname = name.split(pfx)[1][:2] 3327 3331 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3328 'Tm','Xm','Ym','Zm','U1','U2','U3' ]: continue # skip anything not an atom or rigid body param3332 'Tm','Xm','Ym','Zm','U1','U2','U3','MX','MY','MZ']: continue # skip anything not an atom or rigid body param 3329 3333 except IndexError: 3330 3334 continue … … 3336 3340 aname = name.split(pfx)[1][:2] 3337 3341 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3338 'Tm','Xm','Ym','Zm','U1','U2','U3' ]: continue # skip anything not an atom or rigid body param3342 'Tm','Xm','Ym','Zm','U1','U2','U3','MX','MY','MZ']: continue # skip anything not an atom or rigid body param 3339 3343 except IndexError: 3340 3344 continue
Note: See TracChangeset
for help on using the changeset viewer.