Changeset 2894 for trunk/GSASIIstrMath.py
 Timestamp:
 Jul 2, 2017 1:21:02 PM (6 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIstrMath.py
r2862 r2894 2923 2923 2924 2924 def GetFobsSq(Histograms,Phases,parmDict,calcControls): 2925 'Needs a doc string' 2925 'Compute the observed structure factors for Powder histograms' 2926 #starttime = time.time(); print 'start GetFobsSq' 2926 2927 histoList = Histograms.keys() 2927 2928 histoList.sort() … … 3032 3033 Histogram = Histograms[histogram] 3033 3034 Histogram['Residuals']['hId'] = Histograms[histogram]['hId'] 3035 #print 'end GetFobsSq t=',time.time()starttime 3034 3036 3035 3037 def getPowderProfile(parmDict,x,varylist,Histogram,Phases,calcControls,pawleyLookup): 3036 'Needs a doc string' 3038 'Computes the powder pattern for a histogram based on contributions from all used phases' 3039 3040 #starttime = time.time(); print 'start getPowderProfile' 3037 3041 3038 3042 def GetReflSigGamCW(refl,im,wave,G,GB,phfx,calcControls,parmDict): … … 3191 3195 if badPeak: 3192 3196 print 'ouch #4 bad profile coefficients yield negative peak width; some reflections skipped' 3197 #print 'end getPowderProfile t=',time.time()starttime 3193 3198 return yc,yb 3194 3199 3195 3200 def getPowderProfileDerv(parmDict,x,varylist,Histogram,Phases,rigidbodyDict,calcControls,pawleyLookup): 3196 'Needs a doc string' 3201 '''Computes the derivatives of the computed powder pattern with respect to all 3202 refined parameters 3203 ''' 3204 #starttime = time.time(); print 'start getPowderProfileDerv' 3197 3205 3198 3206 def cellVaryDerv(pfx,SGData,dpdA): … … 3228 3236 bakType = calcControls[hfx+'bakType'] 3229 3237 dMdv = np.zeros(shape=(len(varylist),len(x))) 3230 dMdv = ma.array(dMdv,mask=np.outer(np.ones(len(varylist)),ma.getmaskarray(x))) #x is a MaskedArray! 3238 # do not need dMdv to be a masked array at this point. Moved conversion to later in this routine. 3239 #dMdv = ma.array(dMdv,mask=np.outer(np.ones(len(varylist)),ma.getmaskarray(x))) #x is a MaskedArray! 3231 3240 dMdb,dMddb,dMdpk = G2pwd.getBackgroundDerv(hfx,parmDict,bakType,calcControls[hfx+'histType'],x) 3232 3241 if hfx+'Back;0' in varylist: # for now assume that Back;x vars to not appear in constraints … … 3260 3269 else: 3261 3270 wave = parmDict[hfx+'Lam'] 3271 #print '#1 getPowderProfileDerv t=',time.time()starttime 3262 3272 for phase in Histogram['Reflection Lists']: 3263 3273 refDict = Histogram['Reflection Lists'][phase] … … 3289 3299 # print 'sfderv time %.3fs'%(time.time()time0) 3290 3300 ApplyRBModelDervs(dFdvDict,parmDict,rigidbodyDict,Phase) 3301 #print '#2 getPowderProfileDerv t=',time.time()starttime 3302 # determine the parameters that will have derivatives computed only at end 3303 nonatomvarylist = [] 3304 for name in varylist: 3305 if '::RBV;' not in name: 3306 try: 3307 aname = name.split(pfx)[1][:2] 3308 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3309 'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param 3310 except IndexError: 3311 continue 3312 nonatomvarylist.append(name) 3313 nonatomdependentVars = [] 3314 for name in dependentVars: 3315 if '::RBV;' not in name: 3316 try: 3317 aname = name.split(pfx)[1][:2] 3318 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3319 'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param 3320 except IndexError: 3321 continue 3322 nonatomdependentVars.append(name) 3323 #timelist = 10*[0.0] 3324 #timestart = 10*[0.0] 3325 #========================================================================================== 3326 #========================================================================================== 3291 3327 for iref,refl in enumerate(refDict['RefList']): 3328 #timestart[0] = time.time() 3292 3329 if im: 3293 3330 h,k,l,m = refl[:4] … … 3309 3346 break 3310 3347 pos = refl[5+im] 3348 #itim=0;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3311 3349 if 'C' in calcControls[hfx+'histType']: 3312 3350 tanth = tand(pos/2.0) … … 3339 3377 dMdpk[i] += refl[11+im]*refl[9+im]*dMdipk[i] #cw[iBeg:iFin]* 3340 3378 dervDict = {'int':dMdpk[0],'pos':dMdpk[1],'alp':dMdpk[2],'bet':dMdpk[3],'sig':dMdpk[4],'gam':dMdpk[5]} 3379 #itim=1;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3341 3380 if Phase['General'].get('doPawley'): 3342 3381 dMdpw = np.zeros(len(x)) … … 3375 3414 hfx+'sig2':[refl[4+im]**4,'sig'],hfx+'sigq':[1./refl[4+im]**2,'sig'], 3376 3415 hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],} 3416 #itim=2;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3377 3417 for name in names: 3378 3418 item = names[name] … … 3394 3434 if Ka2 and iFin2iBeg2: 3395 3435 depDerivDict[iPO][iBeg2:iFin2] += dIdPO[iPO]*dervDict2['int'] 3436 #itim=3;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3396 3437 for i,name in enumerate(['omega','chi','phi']): 3397 3438 aname = pfx+'SH '+name … … 3433 3474 if Ka2 and iFin2iBeg2: 3434 3475 depDerivDict[name][iBeg2:iFin2] += dDijDict[name]*dervDict2['pos'] 3476 #itim=4;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3435 3477 for i,name in enumerate([pfx+'mV0',pfx+'mV1',pfx+'mV2']): 3436 3478 if name in varylist: … … 3474 3516 if Ka2 and iFin2iBeg2: 3475 3517 depDerivDict[phfx+name][iBeg2:iFin2] += parmDict[phfx+'Scale']*dFdvDict[phfx+name][iref]*dervDict2['int']/refl[9+im] 3518 #itim=5;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3476 3519 if not Phase['General'].get('doPawley') and not parmDict[phfx+'LeBail']: 3477 3520 #do atom derivatives  for RB,F,X & U so far  how do I scale mixed phase constraints? … … 3480 3523 if refl[9+im]: 3481 3524 corr = dervDict['int']/refl[9+im] 3525 #if Ka2 and iFin2iBeg2: 3526 # corr2 = dervDict2['int']/refl[9+im] 3527 #itim=6;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3528 for name in nonatomvarylist: 3529 dMdv[varylist.index(name)][iBeg:iFin] += dFdvDict[name][iref]*corr 3482 3530 if Ka2 and iFin2iBeg2: 3483 corr2 = dervDict2['int']/refl[9+im] 3484 for name in varylist+dependentVars: 3485 if '::RBV;' in name: 3486 pass 3487 else: 3488 try: 3489 aname = name.split(pfx)[1][:2] 3490 if aname not in ['Af','dA','AU','RB','AM','Xs','Xc','Ys','Yc','Zs','Zc', \ 3491 'Tm','Xm','Ym','Zm','U1','U2','U3']: continue # skip anything not an atom or rigid body param 3492 except IndexError: 3493 continue 3494 if name in varylist: 3495 dMdv[varylist.index(name)][iBeg:iFin] += dFdvDict[name][iref]*corr 3496 if Ka2 and iFin2iBeg2: 3497 dMdv[varylist.index(name)][iBeg2:iFin2] += dFdvDict[name][iref]*corr2 3498 elif name in dependentVars: 3499 depDerivDict[name][iBeg:iFin] += dFdvDict[name][iref]*corr 3500 if Ka2 and iFin2iBeg2: 3501 depDerivDict[name][iBeg2:iFin2] += dFdvDict[name][iref]*corr2 3531 dMdv[varylist.index(name)][iBeg2:iFin2] += dFdvDict[name][iref]*corr2 3532 #itim=7;timelist[itim] += time.time()timestart[itim]; timestart[itim+1] = time.time() 3533 for name in nonatomdependentVars: 3534 depDerivDict[name][iBeg:iFin] += dFdvDict[name][iref]*corr 3535 if Ka2 and iFin2iBeg2: 3536 depDerivDict[name][iBeg2:iFin2] += dFdvDict[name][iref]*corr2 3537 #itim=8;timelist[itim] += time.time()timestart[itim] 3502 3538 # print 'profile derv time: %.3fs'%(time.time()time0) 3503 3539 # now process derivatives in constraints 3540 #print '#3 getPowderProfileDerv t=',time.time()starttime 3541 #print timelist,sum(timelist) 3542 dMdv = ma.array(dMdv,mask=np.outer(np.ones(len(varylist)),ma.getmaskarray(x))) #x is a MaskedArray! 3504 3543 G2mv.Dict2Deriv(varylist,depDerivDict,dMdv) 3544 #print 'end getPowderProfileDerv t=',time.time()starttime 3505 3545 return dMdv 3506 3546
Note: See TracChangeset
for help on using the changeset viewer.