Changeset 2838 for trunk/GSASIIstrMath.py
- Timestamp:
- May 24, 2017 2:32:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIstrMath.py
r2837 r2838 306 306 negWt = {} 307 307 pWsum = {} 308 pWnum = {} 308 309 for phase in Phases: 309 310 pId = Phases[phase]['pId'] … … 325 326 for name,rest in names: 326 327 pWsum[name] = 0. 328 pWnum[name] = 0 327 329 itemRest = phaseRest[name] 328 330 if itemRest[rest] and itemRest['Use']: … … 344 346 pWt.append(wt/esd**2) 345 347 pWsum[name] += wt*((obs-calc)/esd)**2 348 pWnum[name] += 1 346 349 elif name in ['Torsion','Rama']: 347 350 coeffDict = itemRest['Coeff'] … … 359 362 pWt.append(wt/esd**2) 360 363 pWsum[name] += wt*(restr/esd)**2 364 pWnum[name] += 1 361 365 elif name == 'ChemComp': 362 366 for i,[indx,factors,obs,esd] in enumerate(itemRest[rest]): … … 368 372 pWt.append(wt/esd**2) 369 373 pWsum[name] += wt*((obs-calc)/esd)**2 374 pWnum[name] += 1 370 375 elif name == 'Texture': 371 376 SHkeys = textureData['SH Coeff'][1].keys() … … 385 390 pWt.append(wt/esd1**2) 386 391 pWsum[name] += wt*(-Z1[ind[0]][ind[1]]/esd1)**2 392 pWnum[name] += 1 387 393 if ifesd2: 388 394 Z2 = 1.-Z … … 392 398 pWt.append(wt/esd2**2) 393 399 pWsum[name] += wt*(Z2/esd2)**2 400 pWnum[name] += 1 394 401 395 402 for phase in Phases: … … 400 407 cell = General['Cell'][1:7] 401 408 pWsum[name] = 0.0 409 pWnum[name] = 0 402 410 for hist in Phases[phase]['Histograms']: 403 411 if not Phases[phase]['Histograms'][hist]['Use']: … … 427 435 pWt.append(wt) 428 436 pWsum[name] += wt*(Y[ind])**2 437 pWnum[name] += 1 429 438 pWsum['PWLref'] = 0. 439 pWnum[name] = 0 430 440 for item in varyList: 431 441 if 'PWLref' in item and parmDict[item] < 0.: … … 436 446 pWt.append(negWt[pId]) 437 447 pWsum['PWLref'] += negWt[pId]*(parmDict[item])**2 448 pWnum[name] += 1 438 449 pVals = np.array(pVals) 439 450 pWt = np.array(pWt) #should this be np.sqrt? 440 return pNames,pVals,pWt,pWsum 451 return pNames,pVals,pWt,pWsum,pWnum 441 452 442 453 def penaltyDeriv(pNames,pVal,HistoPhases,calcControls,parmDict,varyList): … … 710 721 #reflection processing begins here - big arrays! 711 722 iBeg = 0 723 time0 = time.time() 712 724 while iBeg < nRef: 713 725 iFin = min(iBeg+blkSize,nRef) … … 795 807 refl.T[7] = np.copy(refl.T[9]) 796 808 refl.T[10] = atan2d(fbs[0],fas[0]) #ignore f' & f" 797 # GSASIIpath.IPyBreak()798 809 # refl.T[10] = atan2d(np.sum(fbs,axis=0),np.sum(fas,axis=0)) #include f' & f" 799 810 iBeg += blkSize 800 # print ' %d sf time %.4f\r'%(nRef,time.time()-time0)811 # print 'sf time %.4f, nref %d, blkSize %d'%(time.time()-time0,nRef,blkSize) 801 812 802 813 def StructureFactorDerv2(refDict,G,hfx,pfx,SGData,calcControls,parmDict): … … 849 860 if not SGData['SGInv'] and 'S' in calcControls[hfx+'histType'] and phfx+'Flack' in parmDict: 850 861 Flack = 1.-2.*parmDict[phfx+'Flack'] 851 #time0 = time.time()862 time0 = time.time() 852 863 #reflection processing begins here - big arrays! 853 864 iBeg = 0 … … 940 951 # GSASIIpath.IPyBreak() 941 952 iBeg += blkSize 942 # print ' %d derivative time %.4f\r'%(nRef,time.time()-time0)953 # print 'derv time %.4f, nref %d, blkSize %d'%(time.time()-time0,nRef,blkSize) 943 954 #loop over atoms - each dict entry is list of derivatives for all the reflections 944 955 for i in range(len(Mdata)): … … 3099 3110 else: 3100 3111 StructureFactor2(refDict,G,hfx,pfx,SGData,calcControls,parmDict) 3101 # print 'sf calc time: %.3fs'%(time.time()-time0)3102 3112 badPeak = False 3103 3113 for iref,refl in enumerate(refDict['RefList']): … … 3572 3582 for item in ['BabA','BabU']: 3573 3583 if phfx+item in varylist: 3574 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[p fx+item][iref]*parmDict[phfx+'Scale']*ref[11+im]3584 dMdvh[varylist.index(phfx+item)][iref] = w*dFdvDict[phfx+item][iref]*parmDict[phfx+'Scale']*ref[11+im] 3575 3585 elif phfx+item in dependentVars: 3576 depDerivDict[phfx+item][iref] = w*dFdvDict[p fx+item][iref]*parmDict[phfx+'Scale']*ref[11+im]3586 depDerivDict[phfx+item][iref] = w*dFdvDict[phfx+item][iref]*parmDict[phfx+'Scale']*ref[11+im] 3577 3587 else: #F refinement 3578 3588 for iref,ref in enumerate(refDict['RefList']): … … 3653 3663 3654 3664 GetFobsSq(Histograms,Phases,parmDict,calcControls) 3655 pNames,pVals,pWt,pWsum = penaltyFxn(HistoPhases,calcControls,parmDict,varylist)3665 pNames,pVals,pWt,pWsum,pWnum = penaltyFxn(HistoPhases,calcControls,parmDict,varylist) 3656 3666 if np.any(pVals): 3657 3667 dpdv = penaltyDeriv(pNames,pVals,HistoPhases,calcControls,parmDict,varylist) … … 3730 3740 continue #skip non-histogram entries 3731 3741 GetFobsSq(Histograms,Phases,parmDict,calcControls) 3732 pNames,pVals,pWt,pWsum = penaltyFxn(HistoPhases,calcControls,parmDict,varylist)3742 pNames,pVals,pWt,pWsum,pWnum = penaltyFxn(HistoPhases,calcControls,parmDict,varylist) 3733 3743 if np.any(pVals): 3734 3744 dpdv = penaltyDeriv(pNames,pVals,HistoPhases,calcControls,parmDict,varylist) … … 3958 3968 dlg.Destroy() 3959 3969 raise G2obj.G2Exception('User abort') #Abort!! 3960 pDict,pVals,pWt,pWsum = penaltyFxn(HistoPhases,calcControls,parmDict,varylist)3970 pDict,pVals,pWt,pWsum,pWnum = penaltyFxn(HistoPhases,calcControls,parmDict,varylist) 3961 3971 if len(pVals): 3962 3972 pSum = np.sum(pWt*pVals**2) 3963 3973 for name in pWsum: 3964 3974 if pWsum[name]: 3965 print ' Penalty function for % 8s = %12.5g'%(name,pWsum[name])3975 print ' Penalty function for %5d %8ss = %12.5g'%(pWnum[name],name,pWsum[name]) 3966 3976 print 'Total penalty function: %12.5g on %d terms'%(pSum,len(pVals)) 3967 3977 Nobs += len(pVals)
Note: See TracChangeset
for help on using the changeset viewer.