Changeset 1110
- Timestamp:
- Oct 16, 2013 11:52:06 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIIO.py
r1106 r1110 1582 1582 self.InitParameters() 1583 1583 self.InitControls() 1584 self.RefDict = {'RefList':[],' Uniq':[],'Phi':[],'FF':[]}1584 self.RefDict = {'RefList':[],'FF':[]} 1585 1585 1586 1586 def InitControls(self): -
trunk/GSASIIgrid.py
r1106 r1110 3093 3093 data[0] = {'wtFactor':1.0} 3094 3094 if isinstance(data[1],list) and kind == 'HKLF': 3095 RefData = {'RefList':[],' Uniq':[],'Phi':[],'FF':[]}3095 RefData = {'RefList':[],'FF':[]} 3096 3096 for ref in data[1]: 3097 3097 RefData['RefList'].append(ref[:11]+[ref[13],]) 3098 RefData['Uniq'].append(ref[11])3099 RefData['Phi'].append(ref[12])3100 3098 RefData['FF'].append(ref[14]) 3101 3099 data[1] = RefData -
trunk/GSASIImath.py
r1106 r1110 1357 1357 dmin = mapData['Resolution'] 1358 1358 SGData = generalData['SGData'] 1359 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1360 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 1359 1361 cell = generalData['Cell'][1:8] 1360 1362 A = G2lat.cell2A(cell[:6]) … … 1366 1368 if ref[4] >= dmin: 1367 1369 Fosq,Fcsq,ph = ref[8:11] 1368 for i,hkl in enumerate(reflDict['Uniq']): #uses uniq 1370 Uniq = np.inner(ref[:3],SGMT) 1371 Phi = np.inner(ref[:3],SGT) 1372 for i,hkl in enumerate(Uniq): #uses uniq 1369 1373 hkl = np.asarray(hkl,dtype='i') 1370 dp = 360.* reflDict['Phi'][i] #and phi1374 dp = 360.*Phi[i] #and phi 1371 1375 a = cosd(ph+dp) 1372 1376 b = sind(ph+dp) … … 1401 1405 dmin = mapData['Resolution'] 1402 1406 SGData = generalData['SGData'] 1407 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1408 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 1403 1409 cell = generalData['Cell'][1:8] 1404 1410 A = G2lat.cell2A(cell[:6]) … … 1411 1417 if ref[4] >= dmin: 1412 1418 Fosq,Fcsq,ph = ref[8:11] 1413 for i,hkl in enumerate(reflDict['Uniq'][iref]): #uses uniq 1419 Uniq = np.inner(ref[:3],SGMT) 1420 Phi = np.inner(ref[:3],SGT) 1421 for i,hkl in enumerate(Uniq): #uses uniq 1414 1422 hkl = np.asarray(hkl,dtype='i') 1415 dp = 360.* reflDict['Phi'][iref][i] #and phi1423 dp = 360.*Phi[i] #and phi 1416 1424 a = cosd(ph+dp) 1417 1425 b = sind(ph+dp) … … 1570 1578 dmin = flipData['Resolution'] 1571 1579 SGData = generalData['SGData'] 1580 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1581 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 1572 1582 cell = generalData['Cell'][1:8] 1573 1583 A = G2lat.cell2A(cell[:6]) … … 1590 1600 ph = ref[10] 1591 1601 ph = rn.uniform(0.,360.) 1592 for i,hkl in enumerate(reflDict['Uniq'][iref]): #uses uniq 1602 Uniq = np.inner(ref[:3],SGMT) 1603 Phi = np.inner(ref[:3],SGT) 1604 for i,hkl in enumerate(Uniq): #uses uniq 1593 1605 hkl = np.asarray(hkl,dtype='i') 1594 dp = 360.* reflDict['Phi'][iref][i] #and phi1606 dp = 360.*Phi[i] #and phi 1595 1607 a = cosd(ph+dp) 1596 1608 b = sind(ph+dp) … … 1797 1809 xyz = np.array(mapPeaks[ind][1:4]) 1798 1810 xyzs = np.array([equiv[0] for equiv in G2spc.GenAtom(xyz,SGData,Move=True)]) 1799 # for x in xyzs: print x1800 1811 for jnd,xyz in enumerate(XYZ): 1801 1812 Indx[jnd] = Duplicate(xyz,xyzs,Amat) -
trunk/GSASIIphsGUI.py
r1107 r1110 3117 3117 ref[4] = np.sqrt(1./G2lat.calc_rDsq2(H,G)) 3118 3118 iabsnt,ref[3],Uniq,phi = G2spc.GenHKLf(H,SGData) 3119 reflData['Uniq'][iref] = Uniq3120 reflData['Phi'][iref] = phi3121 3119 G2frame.PatternTree.SetItemPyData(Id,[refDict,reflData]) 3122 3120 … … 4892 4890 reflData = reflSets[phaseName] 4893 4891 if isinstance(reflData,list): #patch for old reflection data 4894 RefData = {'RefList':[],' Uniq':[],'Phi':[],'FF':[]}4892 RefData = {'RefList':[],'FF':[]} 4895 4893 for ref in reflData: 4896 4894 RefData['RefList'].append(ref[:11]+[ref[13],]) 4897 RefData['Uniq'].append(ref[11])4898 RefData['Phi'].append(ref[12])4899 4895 RefData['FF'].append(ref[14]) 4900 4896 RefData['RefList'] = np.array(RefData['RefList']) … … 4986 4982 reflDict = reflSets[phaseName] 4987 4983 if isinstance(reflDict,list): #patch for old reflection data 4988 RefData = {'RefList':[],' Uniq':[],'Phi':[],'FF':[]}4984 RefData = {'RefList':[],'FF':[]} 4989 4985 for ref in reflDict: 4990 4986 RefData['RefList'].append(ref[:11]+[ref[13],]) 4991 RefData['Uniq'].append(ref[11])4992 RefData['Phi'].append(ref[12])4993 4987 RefData['FF'].append(ref[14]) 4994 4988 RefData['RefList'] = np.array(RefData['RefList']) -
trunk/GSASIIstrIO.py
r1107 r1110 297 297 #patch 298 298 if isinstance(datum[1][1],list): 299 RefData = {'RefList':[],' Uniq':[],'Phi':[],'FF':[]}299 RefData = {'RefList':[],'FF':[]} 300 300 for ref in datum[1][1]: 301 301 RefData['RefList'].append(ref[:11]+[ref[13],]) 302 RefData['Uniq'].append(ref[11])303 RefData['Phi'].append(ref[12])304 302 RefData['FF'].append(ref[14]) 305 303 RefData['RefList'] = np.array(RefData['RefList']) … … 1773 1771 else: 1774 1772 raise ValueError 1775 Histogram['Reflection Lists'][phase] = {'RefList':np.array(refList), 1776 'Uniq':Uniq,'Phi':Phi,'FF':FF} 1773 Histogram['Reflection Lists'][phase] = {'RefList':np.array(refList),'FF':FF} 1777 1774 elif 'HKLF' in histogram: 1778 1775 inst = Histogram['Instrument Parameters'][0] -
trunk/GSASIIstrMath.py
r1107 r1110 535 535 :param dict refDict: where 536 536 'RefList' list where each ref = h,k,l,m,d,... 537 'Uniq' list of [equiv h,k,l]538 'Phi' list of phase[equiv]539 537 'FF' dict of form factors - filed in below 540 538 :param np.array G: reciprocal metric tensor … … 550 548 ast = np.sqrt(np.diag(G)) 551 549 Mast = twopisq*np.multiply.outer(ast,ast) 550 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 551 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 552 552 FFtables = calcControls['FFtables'] 553 553 BLtables = calcControls['BLtables'] … … 574 574 for i,El in enumerate(Tdata): 575 575 FF[i] = refDict['FF'][iref][El] 576 phase = twopi*(np.inner(refDict['Uniq'][iref],(dXdata.T+Xdata.T))+refDict['Phi'][iref][:,np.newaxis]) 576 Uniq = np.inner(H,SGMT) 577 Phi = np.inner(H,SGT) 578 phase = twopi*(np.inner(Uniq,(dXdata.T+Xdata.T))+Phi[:,np.newaxis]) 577 579 sinp = np.sin(phase) 578 580 cosp = np.cos(phase) 579 occ = Mdata*Fdata/len( refDict['Uniq'][iref])581 occ = Mdata*Fdata/len(Uniq) 580 582 biso = -SQfactor*Uisodata 581 583 Tiso = np.where(biso<1.,np.exp(biso),1.0) 582 HbH = np.array([-np.inner(h,np.inner(bij,h)) for h in refDict['Uniq'][iref]])584 HbH = np.array([-np.inner(h,np.inner(bij,h)) for h in Uniq]) 583 585 Tuij = np.where(HbH<1.,np.exp(HbH),1.0) 584 586 Tcorr = Tiso*Tuij … … 593 595 refl[10] = atan2d(fbs[0],fas[0]) 594 596 595 def StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 596 ''' Compute structure factors for all h,k,l for phase 597 puts the result, F^2, in each ref[8] in refList 598 input: 599 600 :param dict refDict: where 601 'RefList' list where each ref = h,k,l,m,d,... 602 'Uniq' list of [equiv h,k,l] 603 'Phi' list of phase[equiv] 604 'FF' dict of form factors - filed in below 605 :param np.array G: reciprocal metric tensor 606 :param str pfx: phase id string 607 :param dict SGData: space group info. dictionary output from SpcGroup 608 :param dict calcControls: 609 :param dict ParmDict: 610 611 ''' 597 def StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 598 'Needs a doc string' 612 599 twopi = 2.0*np.pi 613 600 twopisq = 2.0*np.pi**2 … … 615 602 ast = np.sqrt(np.diag(G)) 616 603 Mast = twopisq*np.multiply.outer(ast,ast) 617 FFtables = calcControls['FFtables'] 618 BLtables = calcControls['BLtables'] 619 Tdata,Mdata,Fdata,Xdata,dXdata,IAdata,Uisodata,Uijdata = GetAtomFXU(pfx,calcControls,parmDict) 620 FF = np.zeros(len(Tdata)) 621 if 'N' in calcControls[hfx+'histType']: 622 FP,FPP = G2el.BlenRes(Tdata,BLtables,parmDict[hfx+'Lam']) 623 else: 624 FP = np.array([FFtables[El][hfx+'FP'] for El in Tdata]) 625 FPP = np.array([FFtables[El][hfx+'FPP'] for El in Tdata]) 626 Uij = np.array(G2lat.U6toUij(Uijdata)) 627 bij = Mast*Uij.T 628 for iref,refl in enumerate(refDict['RefList']): 629 fbs = np.array([0,0]) 630 H = refl[:3] 631 SQ = 1./(2.*refl[4])**2 632 SQfactor = 4.0*SQ*twopisq 633 Bab = parmDict[phfx+'BabA']*np.exp(-parmDict[phfx+'BabU']*SQfactor) 634 if not len(refDict['FF'][iref]): #no form factors 635 if 'N' in calcControls[hfx+'histType']: 636 refDict['FF'][iref] = G2el.getBLvalues(BLtables) 637 else: #'X' 638 refDict['FF'][iref] = G2el.getFFvalues(FFtables,SQ) 639 for i,El in enumerate(Tdata): 640 FF[i] = refDict['FF'][iref][El] 641 phase = twopi*(np.inner(refDict['Uniq'][iref],(dXdata.T+Xdata.T))+refDict['Phi'][iref][:,np.newaxis]) 642 sinp = np.sin(phase) 643 cosp = np.cos(phase) 644 occ = Mdata*Fdata/len(refDict['Uniq'][iref]) 645 biso = -SQfactor*Uisodata 646 Tiso = np.where(biso<1.,np.exp(biso),1.0) 647 HbH = np.array([-np.inner(h,np.inner(bij,h)) for h in refDict['Uniq'][iref]]) 648 Tuij = np.where(HbH<1.,np.exp(HbH),1.0) 649 Tcorr = Tiso*Tuij 650 fa = np.array([(FF+FP-Bab)*occ*cosp*Tcorr,-FPP*occ*sinp*Tcorr]) 651 fas = np.sum(np.sum(fa,axis=1),axis=1) #real 652 if not SGData['SGInv']: 653 fb = np.array([(FF+FP-Bab)*occ*sinp*Tcorr,FPP*occ*cosp*Tcorr]) 654 fbs = np.sum(np.sum(fb,axis=1),axis=1) 655 fasq = fas**2 656 fbsq = fbs**2 #imaginary 657 refl[9] = np.sum(fasq)+np.sum(fbsq) 658 refl[10] = atan2d(fbs[0],fas[0]) 659 660 def StructureFactorDerv(refDict,G,hfx,pfx,SGData,calcControls,parmDict): 661 'Needs a doc string' 662 twopi = 2.0*np.pi 663 twopisq = 2.0*np.pi**2 664 phfx = pfx.split(':')[0]+hfx 665 ast = np.sqrt(np.diag(G)) 666 Mast = twopisq*np.multiply.outer(ast,ast) 604 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 605 SGT = np.array([ops[1] for ops in SGData['SGOps']]) 667 606 FFtables = calcControls['FFtables'] 668 607 BLtables = calcControls['BLtables'] … … 691 630 for i,El in enumerate(Tdata): 692 631 FF[i] = refDict['FF'][iref][El] 693 phase = twopi*(np.inner((dXdata.T+Xdata.T),refDict['Uniq'][iref])+refDict['Phi'][iref][np.newaxis,:]) 632 Uniq = np.inner(H,SGMT) 633 Phi = np.inner(H,SGT) 634 phase = twopi*(np.inner((dXdata.T+Xdata.T),Uniq)+Phi[np.newaxis,:]) 694 635 sinp = np.sin(phase) 695 636 cosp = np.cos(phase) 696 occ = Mdata*Fdata/len( refDict['Uniq'][iref])637 occ = Mdata*Fdata/len(Uniq) 697 638 biso = -SQfactor*Uisodata 698 639 Tiso = np.where(biso<1.,np.exp(biso),1.0) 699 640 HbH = -np.inner(H,np.inner(bij,H)) 700 Hij = np.array([Mast*np.multiply.outer(U,U) for U in refDict['Uniq'][iref]])641 Hij = np.array([Mast*np.multiply.outer(U,U) for U in Uniq]) 701 642 Hij = np.array([G2lat.UijtoU6(Uij) for Uij in Hij]) 702 643 Tuij = np.where(HbH<1.,np.exp(HbH),1.0) … … 713 654 #sum below is over Uniq 714 655 dfadfr = np.sum(fa/occ[:,np.newaxis],axis=2) 715 dfadx = np.sum(twopi* refDict['Uniq'][iref]*fax[:,:,:,np.newaxis],axis=2)656 dfadx = np.sum(twopi*Uniq*fax[:,:,:,np.newaxis],axis=2) 716 657 dfadui = np.sum(-SQfactor*fa,axis=2) 717 658 dfadua = np.sum(-Hij*fa[:,:,:,np.newaxis],axis=2) 718 659 dfadba = np.sum(-cosp*(occ*Tcorr)[:,np.newaxis],axis=1) 719 660 #NB: the above have been checked against PA(1:10,1:2) in strfctr.for 720 dFdfr[iref] = 2.*(fas[0]*dfadfr[0]+fas[1]*dfadfr[1])*Mdata/len( refDict['Uniq'][iref])661 dFdfr[iref] = 2.*(fas[0]*dfadfr[0]+fas[1]*dfadfr[1])*Mdata/len(Uniq) 721 662 dFdx[iref] = 2.*(fas[0]*dfadx[0]+fas[1]*dfadx[1]) 722 663 dFdui[iref] = 2.*(fas[0]*dfadui[0]+fas[1]*dfadui[1]) … … 725 666 if not SGData['SGInv']: 726 667 dfbdfr = np.sum(fb/occ[:,np.newaxis],axis=2) #problem here if occ=0 for some atom 727 dfbdx = np.sum(twopi* refDict['Uniq'][iref]*fbx[:,:,:,np.newaxis],axis=2)668 dfbdx = np.sum(twopi*Uniq*fbx[:,:,:,np.newaxis],axis=2) 728 669 dfbdui = np.sum(-SQfactor*fb,axis=2) 729 670 dfbdua = np.sum(-Hij*fb[:,:,:,np.newaxis],axis=2) 730 671 dfbdba = np.sum(-sinp*(occ*Tcorr)[:,np.newaxis],axis=1) 731 dFdfr[iref] += 2.*(fbs[0]*dfbdfr[0]-fbs[1]*dfbdfr[1])*Mdata/len( refDict['Uniq'][iref])672 dFdfr[iref] += 2.*(fbs[0]*dfbdfr[0]-fbs[1]*dfbdfr[1])*Mdata/len(Uniq) 732 673 dFdx[iref] += 2.*(fbs[0]*dfbdx[0]+fbs[1]*dfbdx[1]) 733 674 dFdui[iref] += 2.*(fbs[0]*dfbdui[0]-fbs[1]*dfbdui[1]) … … 1361 1302 hfx = ':%d:'%(hId) 1362 1303 SGData = Phase['General']['SGData'] 1304 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1363 1305 A = [parmDict[pfx+'A%d'%(i)] for i in range(6)] 1364 1306 G,g = G2lat.A2Gmat(A) #recip & real metric tensors … … 1370 1312 print 'sf calc time: %.3fs'%(time.time()-time0) 1371 1313 time0 = time.time() 1372 Uniq = refDict['Uniq']1373 1314 for iref,refl in enumerate(refDict['RefList']): 1374 1315 if 'C' in calcControls[hfx+'histType']: 1375 1316 h,k,l = refl[:3] 1317 Uniq = np.inner(refl[:3],SGMT) 1376 1318 refl[5] = GetReflPos(refl,wave,G,hfx,calcControls,parmDict) #corrected reflection position 1377 1319 Lorenz = 1./(2.*sind(refl[5]/2.)**2*cosd(refl[5]/2.)) #Lorentz correction 1378 1320 refl[5] += GetHStrainShift(refl,SGData,phfx,parmDict) #apply hydrostatic strain shift 1379 1321 refl[6:8] = GetReflSigGam(refl,wave,G,GB,hfx,phfx,calcControls,parmDict) #peak sig & gam 1380 GetIntensityCorr(refl,Uniq [iref],G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) #puts corrections in refl[11]1322 GetIntensityCorr(refl,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) #puts corrections in refl[11] 1381 1323 refl[11] *= Vst*Lorenz 1382 1324 if Phase['General'].get('doPawley'): … … 1484 1426 Phase = Phases[phase] 1485 1427 SGData = Phase['General']['SGData'] 1428 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 1486 1429 pId = Phase['pId'] 1487 1430 pfx = '%d::'%(pId) … … 1496 1439 ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) 1497 1440 time0 = time.time() 1498 Uniq = refDict['Uniq']1499 1441 for iref,refl in enumerate(refDict['RefList']): 1500 1442 if 'C' in calcControls[hfx+'histType']: #CW powder 1501 1443 h,k,l = refl[:3] 1502 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb = GetIntensityDerv(refl,Uniq[iref],G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 1444 Uniq = np.inner(refl[:3],SGMT) 1445 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb = GetIntensityDerv(refl,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 1503 1446 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5],refl[6],refl[7],shl) 1504 1447 iBeg = np.searchsorted(x,refl[5]-fmin) -
trunk/imports/G2sfact.py
r1107 r1110 52 52 # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,... 53 53 self.RefDict['RefList'].append([h,k,l,0,0,Fo**2,2.*Fo*sigFo,0,Fo**2,0,0,0]) 54 self.RefDict['Uniq'].append([])55 self.RefDict['Phi'].append([])56 54 self.RefDict['FF'].append({}) 57 55 self.RefDict['RefList'] = np.array(self.RefDict['RefList']) … … 102 100 # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,... 103 101 self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0]) 104 self.RefDict['Uniq'].append([])105 self.RefDict['Phi'].append([])106 102 self.RefDict['FF'].append({}) 107 103 self.RefDict['RefList'] = np.array(self.RefDict['RefList']) -
trunk/imports/G2sfact_CIF.py
r1107 r1110 213 213 pass 214 214 self.RefDict['RefList'].append(ref) 215 self.RefDict['Uniq'].append([])216 self.RefDict['Phi'].append([])217 215 self.RefDict['FF'].append({}) 218 216 self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
Note: See TracChangeset
for help on using the changeset viewer.