Changeset 803 for trunk/GSASIIpwd.py
 Timestamp:
 Nov 21, 2012 1:30:38 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIpwd.py
r801 r803 450 450 yb = np.zeros_like(xdata) 451 451 nBak = 0 452 cw = np.diff(xdata) 453 cw = np.append(cw,cw[1]) 452 454 while True: 453 455 key = pfx+'Back:'+str(nBak) … … 534 536 dyddb = np.zeros(shape=(3*parmDict[pfx+'nDebye'],len(xdata))) 535 537 dydpk = np.zeros(shape=(4*parmDict[pfx+'nPeaks'],len(xdata))) 536 dx = xdata[1]xdata[0] 538 cw = np.diff(xdata) 539 cw = np.append(cw,cw[1]) 537 540 538 541 if bakType in ['chebyschev','cosine']: … … 559 562 bakPos[0] = xdata[0] 560 563 bakPos[1] = xdata[1] 561 dx = bakPos[1]bakPos[0]562 564 for i,pos in enumerate(bakPos): 563 565 if i == 0: … … 589 591 cqr = np.cos(q*dbR) 590 592 temp = np.exp(dbU*q**2) 591 dyddb[3*iD] = ff*sqr*temp/(np.pi* dx)592 dyddb[3*iD+1] = ff*dbA*temp*(cqrsqr)/(np.pi*dbR* dx)593 dyddb[3*iD+2] = ff*dbA*sqr*temp*q**2/(np.pi* dx)593 dyddb[3*iD] = ff*sqr*temp/(np.pi*cw) 594 dyddb[3*iD+1] = ff*dbA*temp*(cqrsqr)/(np.pi*dbR*cw) 595 dyddb[3*iD+2] = ff*dbA*sqr*temp*q**2/(np.pi*cw) 594 596 iD += 1 #ff*dbA*np.sin(q*dbR)*np.exp(dbU*q**2)/(q*dbR) 595 597 except KeyError: … … 607 609 iFin = np.searchsorted(xdata,pkP+fmax) 608 610 Df,dFdp,dFds,dFdg,dFdsh = getdFCJVoigt3(pkP,pkS,pkG,shl,xdata[iBeg:iFin]) 609 dydpk[4*iD][iBeg:iFin] += 100.* dx*pkI*dFdp610 dydpk[4*iD+1][iBeg:iFin] += 100.* dx*Df611 dydpk[4*iD+2][iBeg:iFin] += 100.* dx*pkI*dFds612 dydpk[4*iD+3][iBeg:iFin] += 100.* dx*pkI*dFdg611 dydpk[4*iD][iBeg:iFin] += 100.*cw[iBeg:iFin]*pkI*dFdp 612 dydpk[4*iD+1][iBeg:iFin] += 100.*cw[iBeg:iFin]*Df 613 dydpk[4*iD+2][iBeg:iFin] += 100.*cw[iBeg:iFin]*pkI*dFds 614 dydpk[4*iD+3][iBeg:iFin] += 100.*cw[iBeg:iFin]*pkI*dFdg 613 615 iD += 1 614 616 except KeyError: … … 672 674 yb = getBackground('',parmDict,bakType,xdata) 673 675 yc = np.zeros_like(yb) 676 cw = np.diff(xdata) 677 cw = np.append(cw,cw[1]) 674 678 if 'C' in dataType: 675 dx = xdata[1]xdata[0]676 679 U = parmDict['U'] 677 680 V = parmDict['V'] … … 705 708 Wd,fmin,fmax = getWidthsCW(pos,sig,gam,shl) 706 709 iBeg = np.searchsorted(xdata,posfmin) 707 lenX = len(xdata) 708 if not iBeg: 709 iFin = np.searchsorted(xdata,pos+fmin) 710 elif iBeg == lenX: 711 iFin = iBeg 712 else: 713 iFin = min(lenX,iBeg+int((fmin+fmax)/dx)) 710 iFin = np.searchsorted(xdata,pos+fmin) 714 711 if not iBeg+iFin: #peak below low limit 715 712 iPeak += 1 … … 720 717 if Ka2: 721 718 pos2 = pos+lamRatio*tand(pos/2.0) # + 360/pi * Dlam/lam * tan(th) 722 kdelt = int((pos2pos)/dx) 723 iBeg = min(lenX,iBeg+kdelt) 724 iFin = min(lenX,iFin+kdelt) 719 iBeg = np.searchsorted(xdata,pos2fmin) 720 iFin = np.searchsorted(xdata,pos2+fmin) 725 721 if iBegiFin: 726 722 yc[iBeg:iFin] += intens*kRatio*getFCJVoigt3(pos2,sig,gam,shl,xdata[iBeg:iFin]) … … 810 806 ip = names.index(parm) 811 807 dMdv[varyList.index(name)] = dMdpk[4*int(id)+ip] 808 cw = np.diff(xdata) 809 cw = np.append(cw,cw[1]) 812 810 if 'C' in dataType: 813 dx = xdata[1]xdata[0]814 811 U = parmDict['U'] 815 812 V = parmDict['V'] … … 850 847 Wd,fmin,fmax = getWidthsCW(pos,sig,gam,shl) 851 848 iBeg = np.searchsorted(xdata,posfmin) 852 lenX = len(xdata) 853 if not iBeg: 854 iFin = np.searchsorted(xdata,pos+fmin) 855 elif iBeg == lenX: 856 iFin = iBeg 857 else: 858 iFin = min(lenX,iBeg+int((fmin+fmax)/dx)) 849 iFin = np.searchsorted(xdata,pos+fmin) 859 850 if not iBeg+iFin: #peak below low limit 860 851 iPeak += 1 … … 865 856 dMdipk = getdFCJVoigt3(pos,sig,gam,shl,xdata[iBeg:iFin]) 866 857 for i in range(1,5): 867 dMdpk[i][iBeg:iFin] += 100.* dx*intens*dMdipk[i]868 dMdpk[0][iBeg:iFin] += 100.* dx*dMdipk[0]858 dMdpk[i][iBeg:iFin] += 100.*cw[iBeg:iFin]*intens*dMdipk[i] 859 dMdpk[0][iBeg:iFin] += 100.*cw[iBeg:iFin]*dMdipk[0] 869 860 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'sig':dMdpk[2],'gam':dMdpk[3],'shl':dMdpk[4]} 870 861 if Ka2: 871 862 pos2 = pos+lamRatio*tand(pos/2.0) # + 360/pi * Dlam/lam * tan(th) 872 kdelt = int((pos2pos)/dx) 873 iBeg = min(lenX,iBeg+kdelt) 874 iFin = min(lenX,iFin+kdelt) 863 iBeg = np.searchsorted(xdata,pos2fmin) 864 iFin = np.searchsorted(xdata,pos2+fmin) 875 865 if iBegiFin: 876 866 dMdipk2 = getdFCJVoigt3(pos2,sig,gam,shl,xdata[iBeg:iFin]) 877 867 for i in range(1,5): 878 dMdpk[i][iBeg:iFin] += 100.* dx*intens*kRatio*dMdipk2[i]879 dMdpk[0][iBeg:iFin] += 100.* dx*kRatio*dMdipk2[0]880 dMdpk[5][iBeg:iFin] += 100.* dx*dMdipk2[0]868 dMdpk[i][iBeg:iFin] += 100.*cw[iBeg:iFin]*intens*kRatio*dMdipk2[i] 869 dMdpk[0][iBeg:iFin] += 100.*cw[iBeg:iFin]*kRatio*dMdipk2[0] 870 dMdpk[5][iBeg:iFin] += 100.*cw[iBeg:iFin]*dMdipk2[0] 881 871 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'sig':dMdpk[2],'gam':dMdpk[3],'shl':dMdpk[4],'L1/L2':dMdpk[5]*intens} 882 872 for parmName in ['pos','int','sig','gam']: … … 970 960 dMdpk = np.zeros(shape=(7,len(xdata))) 971 961 dMdipk = getdEpsVoigt(pos,alp,bet,sig,gam,xdata[iBeg:iFin]) 972 cw = np.diff(xdata[iBeg:iFin])973 cw = np.append(cw,cw[1])974 962 for i in range(1,6): 975 dMdpk[i][iBeg:iFin] += intens*cw *dMdipk[i]976 dMdpk[0][iBeg:iFin] += cw *dMdipk[0]963 dMdpk[i][iBeg:iFin] += intens*cw[iBeg:iFin]*dMdipk[i] 964 dMdpk[0][iBeg:iFin] += cw[iBeg:iFin]*dMdipk[0] 977 965 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4],'gam':dMdpk[5]} 978 966 for parmName in ['pos','int','alp','bet','sig','gam']:
Note: See TracChangeset
for help on using the changeset viewer.