Changeset 3004 for trunk/GSASIIstrMath.py
 Timestamp:
 Aug 13, 2017 8:12:26 PM (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIstrMath.py
r3000 r3004 3548 3548 # print 'end getPowderProfileDerv t=',time.time()starttime 3549 3549 return dMdv 3550 3551 def getPowderProfileDervMP(args): 3552 '''Computes the derivatives of the computed powder pattern with respect to all 3553 refined parameters. 3554 Multiprocessing version. 3555 ''' 3556 parmDict,x,varylist,Histogram,Phases,rigidbodyDict,calcControls,pawleyLookup = args[:8] 3557 prc=0 3558 tprc=1 3559 if len(args) >= 9: prc=args[8] 3560 if len(args) >= 10: tprc=args[9] 3561 def cellVaryDerv(pfx,SGData,dpdA): 3562 if SGData['SGLaue'] in ['1',]: 3563 return [[pfx+'A0',dpdA[0]],[pfx+'A1',dpdA[1]],[pfx+'A2',dpdA[2]], 3564 [pfx+'A3',dpdA[3]],[pfx+'A4',dpdA[4]],[pfx+'A5',dpdA[5]]] 3565 elif SGData['SGLaue'] in ['2/m',]: 3566 if SGData['SGUniq'] == 'a': 3567 return [[pfx+'A0',dpdA[0]],[pfx+'A1',dpdA[1]],[pfx+'A2',dpdA[2]],[pfx+'A5',dpdA[5]]] 3568 elif SGData['SGUniq'] == 'b': 3569 return [[pfx+'A0',dpdA[0]],[pfx+'A1',dpdA[1]],[pfx+'A2',dpdA[2]],[pfx+'A4',dpdA[4]]] 3570 else: 3571 return [[pfx+'A0',dpdA[0]],[pfx+'A1',dpdA[1]],[pfx+'A2',dpdA[2]],[pfx+'A3',dpdA[3]]] 3572 elif SGData['SGLaue'] in ['mmm',]: 3573 return [[pfx+'A0',dpdA[0]],[pfx+'A1',dpdA[1]],[pfx+'A2',dpdA[2]]] 3574 elif SGData['SGLaue'] in ['4/m','4/mmm']: 3575 return [[pfx+'A0',dpdA[0]],[pfx+'A2',dpdA[2]]] 3576 elif SGData['SGLaue'] in ['6/m','6/mmm','3m1', '31m', '3']: 3577 return [[pfx+'A0',dpdA[0]],[pfx+'A2',dpdA[2]]] 3578 elif SGData['SGLaue'] in ['3R', '3mR']: 3579 return [[pfx+'A0',dpdA[0]+dpdA[1]+dpdA[2]],[pfx+'A3',dpdA[3]+dpdA[4]+dpdA[5]]] 3580 elif SGData['SGLaue'] in ['m3m','m3']: 3581 return [[pfx+'A0',dpdA[0]]] 3582 3583 # create a list of dependent variables and set up a dictionary to hold their derivatives 3584 dependentVars = G2mv.GetDependentVars() 3585 depDerivDict = {} 3586 for j in dependentVars: 3587 depDerivDict[j] = np.zeros(shape=(len(x))) 3588 #print 'dependent vars',dependentVars 3589 hId = Histogram['hId'] 3590 hfx = ':%d:'%(hId) 3591 bakType = calcControls[hfx+'bakType'] 3592 dMdv = np.zeros(shape=(len(varylist),len(x))) 3593 dMdb,dMddb,dMdpk = G2pwd.getBackgroundDerv(hfx,parmDict,bakType,calcControls[hfx+'histType'],x) 3594 if prc == 0 and hfx+'Back;0' in varylist: # for now assume that Back;x vars to not appear in constraints 3595 bBpos = varylist.index(hfx+'Back;0') 3596 dMdv[bBpos:bBpos+len(dMdb)] += dMdb #TODO crash if bck parms tossed 3597 names = [hfx+'DebyeA',hfx+'DebyeR',hfx+'DebyeU'] 3598 for name in varylist: 3599 if prc == 0 and 'Debye' in name: 3600 id = int(name.split(';')[1]) 3601 parm = name[:int(name.rindex(';'))] 3602 ip = names.index(parm) 3603 dMdv[varylist.index(name)] += dMddb[3*id+ip] 3604 names = [hfx+'BkPkpos',hfx+'BkPkint',hfx+'BkPksig',hfx+'BkPkgam'] 3605 for name in varylist: 3606 if prc == 0 and 'BkPk' in name: 3607 parm,id = name.split(';') 3608 id = int(id) 3609 if parm in names: 3610 ip = names.index(parm) 3611 dMdv[varylist.index(name)] += dMdpk[4*id+ip] 3612 cw = np.diff(ma.getdata(x)) 3613 cw = np.append(cw,cw[1]) 3614 Ka2 = False #also for TOF! 3615 if 'C' in calcControls[hfx+'histType']: 3616 shl = max(parmDict[hfx+'SH/L'],0.002) 3617 if hfx+'Lam1' in parmDict.keys(): 3618 wave = parmDict[hfx+'Lam1'] 3619 Ka2 = True 3620 lamRatio = 360*(parmDict[hfx+'Lam2']parmDict[hfx+'Lam1'])/(np.pi*parmDict[hfx+'Lam1']) 3621 kRatio = parmDict[hfx+'I(L2)/I(L1)'] 3622 else: 3623 wave = parmDict[hfx+'Lam'] 3624 for phase in Histogram['Reflection Lists']: 3625 refDict = Histogram['Reflection Lists'][phase] 3626 if phase not in Phases: #skips deleted or renamed phases silently! 3627 continue 3628 Phase = Phases[phase] 3629 SGData = Phase['General']['SGData'] 3630 SGMT = np.array([ops[0].T for ops in SGData['SGOps']]) 3631 im = 0 3632 if Phase['General'].get('Modulated',False): 3633 SSGData = Phase['General']['SSGData'] 3634 im = 1 #offset in SS reflection list 3635 #?? 3636 pId = Phase['pId'] 3637 pfx = '%d::'%(pId) 3638 phfx = '%d:%d:'%(pId,hId) 3639 Dij = GetDij(phfx,SGData,parmDict) 3640 A = [parmDict[pfx+'A%d'%(i)]+Dij[i] for i in range(6)] 3641 G,g = G2lat.A2Gmat(A) #recip & real metric tensors 3642 GA,GB = G2lat.Gmat2AB(G) #Orthogonalization matricies 3643 if not Phase['General'].get('doPawley') and not parmDict[phfx+'LeBail']: 3644 if im: 3645 dFdvDict = SStructureFactorDerv(refDict,im,G,hfx,pfx,SGData,SSGData,calcControls,parmDict) 3646 else: 3647 if Phase['General']['Type'] == 'magnetic': 3648 dFdvDict = StructureFactorDervMag(refDict,G,hfx,pfx,SGData,calcControls,parmDict) 3649 else: 3650 dFdvDict = StructureFactorDerv2(refDict,G,hfx,pfx,SGData,calcControls,parmDict) 3651 ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) 3652 # determine the parameters that will have derivatives computed only at end 3653 nonatomvarylist = [] 3654 for name in varylist: 3655 if '::RBV;' not in name: 3656 try: 3657 aname = name.split(pfx)[1][:2] 3658 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3659 'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param 3660 except IndexError: 3661 continue 3662 nonatomvarylist.append(name) 3663 nonatomdependentVars = [] 3664 for name in dependentVars: 3665 if '::RBV;' not in name: 3666 try: 3667 aname = name.split(pfx)[1][:2] 3668 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3669 'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param 3670 except IndexError: 3671 continue 3672 nonatomdependentVars.append(name) 3673 #========================================================================================== 3674 #========================================================================================== 3675 for iref in range(prc,len(refDict['RefList']),tprc): 3676 refl = refDict['RefList'][iref] 3677 if im: 3678 h,k,l,m = refl[:4] 3679 else: 3680 h,k,l = refl[:3] 3681 Uniq = np.inner(refl[:3],SGMT) 3682 if 'T' in calcControls[hfx+'histType']: 3683 wave = refl[14+im] 3684 dIdsh,dIdsp,dIdpola,dIdPO,dFdODF,dFdSA,dFdAb,dFdEx = GetIntensityDerv(refl,im,wave,Uniq,G,g,pfx,phfx,hfx,SGData,calcControls,parmDict) 3685 if 'C' in calcControls[hfx+'histType']: #CW powder 3686 Wd,fmin,fmax = G2pwd.getWidthsCW(refl[5+im],refl[6+im],refl[7+im],shl) 3687 else: #'T'OF 3688 Wd,fmin,fmax = G2pwd.getWidthsTOF(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im]) 3689 iBeg = np.searchsorted(x,refl[5+im]fmin) 3690 iFin = np.searchsorted(x,refl[5+im]+fmax) 3691 if not iBeg+iFin: #peak below low limit  skip peak 3692 continue 3693 elif not iBegiFin: #peak above high limit  done 3694 break 3695 pos = refl[5+im] 3696 if 'C' in calcControls[hfx+'histType']: 3697 tanth = tand(pos/2.0) 3698 costh = cosd(pos/2.0) 3699 lenBF = iFiniBeg 3700 dMdpk = np.zeros(shape=(6,lenBF)) 3701 dMdipk = G2pwd.getdFCJVoigt3(refl[5+im],refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg:iFin])) 3702 for i in range(5): 3703 dMdpk[i] += 100.*cw[iBeg:iFin]*refl[11+im]*refl[9+im]*dMdipk[i] 3704 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'sig':dMdpk[2],'gam':dMdpk[3],'shl':dMdpk[4],'L1/L2':np.zeros_like(dMdpk[0])} 3705 if Ka2: 3706 pos2 = refl[5+im]+lamRatio*tanth # + 360/pi * Dlam/lam * tan(th) 3707 iBeg2 = np.searchsorted(x,pos2fmin) 3708 iFin2 = np.searchsorted(x,pos2+fmax) 3709 if iBeg2iFin2: 3710 lenBF2 = iFin2iBeg2 3711 dMdpk2 = np.zeros(shape=(6,lenBF2)) 3712 dMdipk2 = G2pwd.getdFCJVoigt3(pos2,refl[6+im],refl[7+im],shl,ma.getdata(x[iBeg2:iFin2])) 3713 for i in range(5): 3714 dMdpk2[i] = 100.*cw[iBeg2:iFin2]*refl[11+im]*refl[9+im]*kRatio*dMdipk2[i] 3715 dMdpk2[5] = 100.*cw[iBeg2:iFin2]*refl[11+im]*dMdipk2[0] 3716 dervDict2 = {'int':dMdpk2[0],'pos':dMdpk2[1],'sig':dMdpk2[2],'gam':dMdpk2[3],'shl':dMdpk2[4],'L1/L2':dMdpk2[5]*refl[9]} 3717 else: #'T'OF 3718 lenBF = iFiniBeg 3719 if lenBF < 0: #bad peak coeff 3720 break 3721 dMdpk = np.zeros(shape=(6,lenBF)) 3722 dMdipk = G2pwd.getdEpsVoigt(refl[5+im],refl[12+im],refl[13+im],refl[6+im],refl[7+im],ma.getdata(x[iBeg:iFin])) 3723 for i in range(6): 3724 dMdpk[i] += refl[11+im]*refl[9+im]*dMdipk[i] #cw[iBeg:iFin]* 3725 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4],'gam':dMdpk[5]} 3726 if Phase['General'].get('doPawley'): 3727 dMdpw = np.zeros(len(x)) 3728 try: 3729 if im: 3730 pIdx = pfx+'PWLref:'+str(pawleyLookup[pfx+'%d,%d,%d,%d'%(h,k,l,m)]) 3731 else: 3732 pIdx = pfx+'PWLref:'+str(pawleyLookup[pfx+'%d,%d,%d'%(h,k,l)]) 3733 idx = varylist.index(pIdx) 3734 dMdpw[iBeg:iFin] = dervDict['int']/refl[9+im] 3735 if Ka2: #not for TOF either 3736 dMdpw[iBeg2:iFin2] += dervDict2['int']/refl[9+im] 3737 dMdv[idx] = dMdpw 3738 except: # ValueError: 3739 pass 3740 if 'C' in calcControls[hfx+'histType']: 3741 dpdA,dpdw,dpdZ,dpdSh,dpdTr,dpdX,dpdY,dpdV = GetReflPosDerv(refl,im,wave,A,pfx,hfx,calcControls,parmDict) 3742 names = {hfx+'Scale':[dIdsh,'int'],hfx+'Polariz.':[dIdpola,'int'],phfx+'Scale':[dIdsp,'int'], 3743 hfx+'U':[tanth**2,'sig'],hfx+'V':[tanth,'sig'],hfx+'W':[1.0,'sig'], 3744 hfx+'X':[1.0/costh,'gam'],hfx+'Y':[tanth,'gam'],hfx+'SH/L':[1.0,'shl'], 3745 hfx+'I(L2)/I(L1)':[1.0,'L1/L2'],hfx+'Zero':[dpdZ,'pos'],hfx+'Lam':[dpdw,'pos'], 3746 hfx+'Shift':[dpdSh,'pos'],hfx+'Transparency':[dpdTr,'pos'],hfx+'DisplaceX':[dpdX,'pos'], 3747 hfx+'DisplaceY':[dpdY,'pos'],} 3748 if 'Bragg' in calcControls[hfx+'instType']: 3749 names.update({hfx+'SurfRoughA':[dFdAb[0],'int'], 3750 hfx+'SurfRoughB':[dFdAb[1],'int'],}) 3751 else: 3752 names.update({hfx+'Absorption':[dFdAb,'int'],}) 3753 else: #'T'OF 3754 dpdA,dpdZ,dpdDC,dpdDA,dpdDB,dpdV = GetReflPosDerv(refl,im,0.0,A,pfx,hfx,calcControls,parmDict) 3755 names = {hfx+'Scale':[dIdsh,'int'],phfx+'Scale':[dIdsp,'int'], 3756 hfx+'difC':[dpdDC,'pos'],hfx+'difA':[dpdDA,'pos'],hfx+'difB':[dpdDB,'pos'], 3757 hfx+'Zero':[dpdZ,'pos'],hfx+'X':[refl[4+im],'gam'],hfx+'Y':[refl[4+im]**2,'gam'], 3758 hfx+'alpha':[1./refl[4+im],'alp'],hfx+'beta0':[1.0,'bet'],hfx+'beta1':[1./refl[4+im]**4,'bet'], 3759 hfx+'betaq':[1./refl[4+im]**2,'bet'],hfx+'sig0':[1.0,'sig'],hfx+'sig1':[refl[4+im]**2,'sig'], 3760 hfx+'sig2':[refl[4+im]**4,'sig'],hfx+'sigq':[1./refl[4+im]**2,'sig'], 3761 hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],} 3762 for name in names: 3763 item = names[name] 3764 if name in varylist: 3765 dMdv[varylist.index(name)][iBeg:iFin] += item[0]*dervDict[item[1]] 3766 if Ka2 and iFin2iBeg2: 3767 dMdv[varylist.index(name)][iBeg2:iFin2] += item[0]*dervDict2[item[1]] 3768 elif name in dependentVars: 3769 depDerivDict[name][iBeg:iFin] += item[0]*dervDict[item[1]] 3770 if Ka2 and iFin2iBeg2: 3771 depDerivDict[name][iBeg2:iFin2] += item[0]*dervDict2[item[1]] 3772 for iPO in dIdPO: 3773 if iPO in varylist: 3774 dMdv[varylist.index(iPO)][iBeg:iFin] += dIdPO[iPO]*dervDict['int'] 3775 if Ka2 and iFin2iBeg2: 3776 dMdv[varylist.index(iPO)][iBeg2:iFin2] += dIdPO[iPO]*dervDict2['int'] 3777 elif iPO in dependentVars: 3778 depDerivDict[iPO][iBeg:iFin] += dIdPO[iPO]*dervDict['int'] 3779 if Ka2 and iFin2iBeg2: 3780 depDerivDict[iPO][iBeg2:iFin2] += dIdPO[iPO]*dervDict2['int'] 3781 for i,name in enumerate(['omega','chi','phi']): 3782 aname = pfx+'SH '+name 3783 if aname in varylist: 3784 dMdv[varylist.index(aname)][iBeg:iFin] += dFdSA[i]*dervDict['int'] 3785 if Ka2 and iFin2iBeg2: 3786 dMdv[varylist.index(aname)][iBeg2:iFin2] += dFdSA[i]*dervDict2['int'] 3787 elif aname in dependentVars: 3788 depDerivDict[aname][iBeg:iFin] += dFdSA[i]*dervDict['int'] 3789 if Ka2 and iFin2iBeg2: 3790 depDerivDict[aname][iBeg2:iFin2] += dFdSA[i]*dervDict2['int'] 3791 for iSH in dFdODF: 3792 if iSH in varylist: 3793 dMdv[varylist.index(iSH)][iBeg:iFin] += dFdODF[iSH]*dervDict['int'] 3794 if Ka2 and iFin2iBeg2: 3795 dMdv[varylist.index(iSH)][iBeg2:iFin2] += dFdODF[iSH]*dervDict2['int'] 3796 elif iSH in dependentVars: 3797 depDerivDict[iSH][iBeg:iFin] += dFdODF[iSH]*dervDict['int'] 3798 if Ka2 and iFin2iBeg2: 3799 depDerivDict[iSH][iBeg2:iFin2] += dFdODF[iSH]*dervDict2['int'] 3800 cellDervNames = cellVaryDerv(pfx,SGData,dpdA) 3801 for name,dpdA in cellDervNames: 3802 if name in varylist: 3803 dMdv[varylist.index(name)][iBeg:iFin] += dpdA*dervDict['pos'] 3804 if Ka2 and iFin2iBeg2: 3805 dMdv[varylist.index(name)][iBeg2:iFin2] += dpdA*dervDict2['pos'] 3806 elif name in dependentVars: #need to scale for mixed phase constraints? 3807 depDerivDict[name][iBeg:iFin] += dpdA*dervDict['pos'] 3808 if Ka2 and iFin2iBeg2: 3809 depDerivDict[name][iBeg2:iFin2] += dpdA*dervDict2['pos'] 3810 dDijDict = GetHStrainShiftDerv(refl,im,SGData,phfx,hfx,calcControls,parmDict) 3811 for name in dDijDict: 3812 if name in varylist: 3813 dMdv[varylist.index(name)][iBeg:iFin] += dDijDict[name]*dervDict['pos'] 3814 if Ka2 and iFin2iBeg2: 3815 dMdv[varylist.index(name)][iBeg2:iFin2] += dDijDict[name]*dervDict2['pos'] 3816 elif name in dependentVars: 3817 depDerivDict[name][iBeg:iFin] += dDijDict[name]*dervDict['pos'] 3818 if Ka2 and iFin2iBeg2: 3819 depDerivDict[name][iBeg2:iFin2] += dDijDict[name]*dervDict2['pos'] 3820 for i,name in enumerate([pfx+'mV0',pfx+'mV1',pfx+'mV2']): 3821 if name in varylist: 3822 dMdv[varylist.index(name)][iBeg:iFin] += dpdV[i]*dervDict['pos'] 3823 if Ka2 and iFin2iBeg2: 3824 dMdv[varylist.index(name)][iBeg2:iFin2] += dpdV[i]*dervDict2['pos'] 3825 elif name in dependentVars: 3826 depDerivDict[name][iBeg:iFin] += dpdV[i]*dervDict['pos'] 3827 if Ka2 and iFin2iBeg2: 3828 depDerivDict[name][iBeg2:iFin2] += dpdV[i]*dervDict2['pos'] 3829 if 'C' in calcControls[hfx+'histType']: 3830 sigDict,gamDict = GetSampleSigGamDerv(refl,im,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict) 3831 else: #'T'OF 3832 sigDict,gamDict = GetSampleSigGamDerv(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict) 3833 for name in gamDict: 3834 if name in varylist: 3835 dMdv[varylist.index(name)][iBeg:iFin] += gamDict[name]*dervDict['gam'] 3836 if Ka2 and iFin2iBeg2: 3837 dMdv[varylist.index(name)][iBeg2:iFin2] += gamDict[name]*dervDict2['gam'] 3838 elif name in dependentVars: 3839 depDerivDict[name][iBeg:iFin] += gamDict[name]*dervDict['gam'] 3840 if Ka2 and iFin2iBeg2: 3841 depDerivDict[name][iBeg2:iFin2] += gamDict[name]*dervDict2['gam'] 3842 for name in sigDict: 3843 if name in varylist: 3844 dMdv[varylist.index(name)][iBeg:iFin] += sigDict[name]*dervDict['sig'] 3845 if Ka2 and iFin2iBeg2: 3846 dMdv[varylist.index(name)][iBeg2:iFin2] += sigDict[name]*dervDict2['sig'] 3847 elif name in dependentVars: 3848 depDerivDict[name][iBeg:iFin] += sigDict[name]*dervDict['sig'] 3849 if Ka2 and iFin2iBeg2: 3850 depDerivDict[name][iBeg2:iFin2] += sigDict[name]*dervDict2['sig'] 3851 for name in ['BabA','BabU']: 3852 if refl[9+im]: 3853 if phfx+name in varylist: 3854 dMdv[varylist.index(phfx+name)][iBeg:iFin] += parmDict[phfx+'Scale']*dFdvDict[phfx+name][iref]*dervDict['int']/refl[9+im] 3855 if Ka2 and iFin2iBeg2: 3856 dMdv[varylist.index(phfx+name)][iBeg2:iFin2] += parmDict[phfx+'Scale']*dFdvDict[phfx+name][iref]*dervDict2['int']/refl[9+im] 3857 elif phfx+name in dependentVars: 3858 depDerivDict[phfx+name][iBeg:iFin] += parmDict[phfx+'Scale']*dFdvDict[phfx+name][iref]*dervDict['int']/refl[9+im] 3859 if Ka2 and iFin2iBeg2: 3860 depDerivDict[phfx+name][iBeg2:iFin2] += parmDict[phfx+'Scale']*dFdvDict[phfx+name][iref]*dervDict2['int']/refl[9+im] 3861 if not Phase['General'].get('doPawley') and not parmDict[phfx+'LeBail']: 3862 #do atom derivatives  for RB,F,X & U so far  how do I scale mixed phase constraints? 3863 corr = 0. 3864 corr2 = 0. 3865 if refl[9+im]: 3866 corr = dervDict['int']/refl[9+im] 3867 #if Ka2 and iFin2iBeg2: 3868 # corr2 = dervDict2['int']/refl[9+im] 3869 for name in nonatomvarylist: 3870 dMdv[varylist.index(name)][iBeg:iFin] += dFdvDict[name][iref]*corr 3871 if Ka2 and iFin2iBeg2: 3872 dMdv[varylist.index(name)][iBeg2:iFin2] += dFdvDict[name][iref]*corr2 3873 for name in nonatomdependentVars: 3874 depDerivDict[name][iBeg:iFin] += dFdvDict[name][iref]*corr 3875 if Ka2 and iFin2iBeg2: 3876 depDerivDict[name][iBeg2:iFin2] += dFdvDict[name][iref]*corr2 3877 # now process derivatives in constraints 3878 dMdv[:,ma.getmaskarray(x)] = 0. # instead of masking, zero out masked values 3879 G2mv.Dict2Deriv(varylist,depDerivDict,dMdv) 3880 return dMdv 3550 3881 3551 3882 def UserRejectHKL(ref,im,userReject): … … 3746 4077 xB = np.searchsorted(x,Limits[0]) 3747 4078 xF = np.searchsorted(x,Limits[1])+1 3748 dMdvh = getPowderProfileDerv(parmDict,x[xB:xF], 3749 varylist,Histogram,Phases,rigidbodyDict,calcControls,pawleyLookup) 3750 # print 'HessRefine getPowderProfileDerv' 3751 # import cPickle 3752 # fp = open('/tmp/hess.pkl','w') 3753 # cPickle.dump(dMdvh,fp,1) 3754 # fp.close() 4079 ###################################################################### 4080 #import GSASIImpsubs as G2mp 4081 #G2mp.InitMP() 4082 useMP = False 4083 ncores = 0 4084 #useMP = G2mp.useMP #and len(refDict['RefList']) > 100 4085 if GSASIIpath.GetConfigValue('debug'): 4086 starttime = time.time() 4087 print 'starting getPowderProfileDerv' 4088 #useMP = True 4089 if useMP and ncores > 1: 4090 import multiprocessing as mp 4091 print 'mp with ',ncores,'cores' 4092 MPpool = mp.Pool(ncores) 4093 dMdvh = None 4094 profArgs = [ 4095 (parmDict,x[xB:xF],varylist,Histogram,Phases,rigidbodyDict,calcControls,pawleyLookup, 4096 i,ncores) for i in range(ncores)] 4097 for dmdv in MPpool.imap_unordered(getPowderProfileDervMP,profArgs): 4098 if dMdvh is None: 4099 dMdvh = dmdv 4100 else: 4101 dMdvh += dmdv 4102 else: 4103 #dMdvh = getPowderProfileDervMP([parmDict,x[xB:xF], 4104 # varylist,Histogram,Phases,rigidbodyDict,calcControls,pawleyLookup]) 4105 dMdvh = getPowderProfileDerv(parmDict,x[xB:xF], 4106 varylist,Histogram,Phases,rigidbodyDict,calcControls,pawleyLookup) 4107 if GSASIIpath.GetConfigValue('debug'): 4108 print 'end getPowderProfileDerv t=',time.time()starttime 4109 #import cPickle 4110 #fp = open('/tmp/hess.pkl','w') 4111 #cPickle.dump(dMdvh,fp,1) 4112 #fp.close() 4113 ###################################################################### 3755 4114 Wt = ma.sqrt(W[xB:xF])[nxs,:] 3756 4115 Dy = dy[xB:xF][nxs,:]
Note: See TracChangeset
for help on using the changeset viewer.