Changeset 5287
- Timestamp:
- May 23, 2022 1:24:25 PM (17 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r5282 r5287 84 84 import GSASIIpwd as G2pwd 85 85 import GSASIIstrMain as G2stMn 86 import GSASIIstrMath as G2stMth 86 87 import defaultIparms as dI 87 88 import GSASIIfpaGUI as G2fpa … … 5564 5565 Controls = self.GPXtree.GetItemPyData(GetGPXtreeItemId(self,self.root, 'Controls')) 5565 5566 savCyc,Controls['max cyc'] = Controls['max cyc'],0 5567 saveDervtype,Controls['deriv type'] = Controls['deriv type'],'analytic Hessian' 5566 5568 Controls['PhasePartials'] = os.path.abspath(os.path.splitext(self.GSASprojectfile)[0]+'.partials') 5567 5569 self.OnFileSave(event) … … 5574 5576 except Exception as msg: 5575 5577 print('Refinement failed with message',msg) 5578 Controls['deriv type'] = saveDervtype 5576 5579 Controls['max cyc'] = savCyc 5577 5580 Controls['PhasePartials'] = None … … 5593 5596 dlg.Destroy() 5594 5597 if result == wx.ID_NO: 5598 Controls['deriv type'] = saveDervtype 5595 5599 Controls['max cyc'] = savCyc 5596 5600 Controls['PhasePartials'] = None … … 5633 5637 print('Error histogram',hId,'not found. This should not happen!') 5634 5638 fp.close() 5639 Controls['deriv type'] = saveDervtype 5635 5640 Controls['max cyc'] = savCyc 5636 5641 Controls['PhasePartials'] = None … … 5663 5668 print('File',phPartialFile,'written') 5664 5669 5670 Controls['deriv type'] = saveDervtype 5665 5671 Controls['max cyc'] = savCyc 5666 5672 Controls['PhasePartials'] = None -
trunk/GSASIImath.py
r5271 r5287 383 383 return [x0,None,info] 384 384 chisqf = np.sum(M**2) # ending chi**2 385 if not maxcyc: #zero cycle calc exit here 386 info = {'num cyc':0,'fvec':M,'nfev':0,'lamMax':0,'SVD0':0, 387 'Converged':True, 'DelChi2':0., 'Xvec':XvecAll, 'chisq0':chisqf} 388 return [x0,None,info] 385 389 psing_prev = [i for i in range(n) if i not in indices] # save dropped vars 386 390 if AmatAll is None: # Save some time and use Hessian from the last refinement cycle -
trunk/GSASIIstrMain.py
r5266 r5287 253 253 break 254 254 IfOK = True 255 if not len(varyList) :255 if not len(varyList) or not result[2]['num cyc']: 256 256 covMatrix = [] 257 257 break … … 403 403 refPlotUpdate=refPlotUpdate) 404 404 if IfOK: 405 sigDict = dict(zip(varyList,sig)) 406 newCellDict = G2stMth.GetNewCellParms(parmDict,varyList) 407 newAtomDict = G2stMth.ApplyXYZshifts(parmDict,varyList) 408 covData = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals, 409 'varyListStart':varyListStart,'Lastshft':Lastshft, 410 'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict, 411 'newCellDict':newCellDict,'freshCOV':True} 412 # add indirectly computed uncertainties into the esd dict 413 sigDict.update(G2mv.ComputeDepESD(covMatrix,varyList)) 414 G2stIO.PrintIndependentVars(parmDict,varyList,sigDict,pFile=printFile) 415 G2stMth.ApplyRBModels(parmDict,Phases,rigidbodyDict,True) 416 G2stIO.SetRigidBodyModels(parmDict,sigDict,rigidbodyDict,printFile) 417 G2stIO.SetPhaseData(parmDict,sigDict,Phases,rbIds,covData,restraintDict,printFile) 418 G2stIO.SetISOmodes(parmDict,sigDict,Phases,printFile) 419 G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,calcControls, 420 pFile=printFile,covMatrix=covMatrix,varyList=varyList) 421 G2stIO.SetHistogramData(parmDict,sigDict,Histograms,calcControls,pFile=printFile) 422 # check for variables outside their allowed range, reset and freeze them 423 frozen = dropOOBvars(varyList,parmDict,sigDict,Controls,parmFrozenList) 424 # covData['depSig'] = G2stIO.PhFrExtPOSig # created in G2stIO.SetHistogramData, no longer used? 425 covData['depSigDict'] = {i:(parmDict[i],sigDict[i]) for i in parmDict if i in sigDict} 426 if len(frozen): 427 if 'msg' in Rvals: 428 Rvals['msg'] += '\n' 429 else: 430 Rvals['msg'] = '' 431 msg = ('Warning: {} variable(s) refined outside limits and were frozen ({} total frozen)' 432 .format(len(frozen),len(parmFrozenList)) 433 ) 434 G2fil.G2Print(msg) 435 Rvals['msg'] += msg 436 elif len(parmFrozenList): 437 if 'msg' in Rvals: 438 Rvals['msg'] += '\n' 439 else: 440 Rvals['msg'] = '' 441 msg = ('Note: a total of {} variable(s) are frozen due to refining outside limits' 442 .format(len(parmFrozenList)) 443 ) 444 G2fil.G2Print('Note: ',msg) 445 Rvals['msg'] += msg 405 if len(covMatrix): #empty for zero cycle refinement 406 sigDict = dict(zip(varyList,sig)) 407 newCellDict = G2stMth.GetNewCellParms(parmDict,varyList) 408 newAtomDict = G2stMth.ApplyXYZshifts(parmDict,varyList) 409 covData = {'variables':result[0],'varyList':varyList,'sig':sig,'Rvals':Rvals, 410 'varyListStart':varyListStart,'Lastshft':Lastshft, 411 'covMatrix':covMatrix,'title':GPXfile,'newAtomDict':newAtomDict, 412 'newCellDict':newCellDict,'freshCOV':True} 413 # add indirectly computed uncertainties into the esd dict 414 sigDict.update(G2mv.ComputeDepESD(covMatrix,varyList)) 415 G2stIO.PrintIndependentVars(parmDict,varyList,sigDict,pFile=printFile) 416 G2stMth.ApplyRBModels(parmDict,Phases,rigidbodyDict,True) 417 G2stIO.SetRigidBodyModels(parmDict,sigDict,rigidbodyDict,printFile) 418 G2stIO.SetPhaseData(parmDict,sigDict,Phases,rbIds,covData,restraintDict,printFile) 419 G2stIO.SetISOmodes(parmDict,sigDict,Phases,printFile) 420 G2stIO.SetHistogramPhaseData(parmDict,sigDict,Phases,Histograms,calcControls, 421 pFile=printFile,covMatrix=covMatrix,varyList=varyList) 422 G2stIO.SetHistogramData(parmDict,sigDict,Histograms,calcControls,pFile=printFile) 423 # check for variables outside their allowed range, reset and freeze them 424 frozen = dropOOBvars(varyList,parmDict,sigDict,Controls,parmFrozenList) 425 # covData['depSig'] = G2stIO.PhFrExtPOSig # created in G2stIO.SetHistogramData, no longer used? 426 covData['depSigDict'] = {i:(parmDict[i],sigDict[i]) for i in parmDict if i in sigDict} 427 if len(frozen): 428 if 'msg' in Rvals: 429 Rvals['msg'] += '\n' 430 else: 431 Rvals['msg'] = '' 432 msg = ('Warning: {} variable(s) refined outside limits and were frozen ({} total frozen)' 433 .format(len(frozen),len(parmFrozenList)) 434 ) 435 G2fil.G2Print(msg) 436 Rvals['msg'] += msg 437 elif len(parmFrozenList): 438 if 'msg' in Rvals: 439 Rvals['msg'] += '\n' 440 else: 441 Rvals['msg'] = '' 442 msg = ('Note: a total of {} variable(s) are frozen due to refining outside limits' 443 .format(len(parmFrozenList)) 444 ) 445 G2fil.G2Print('Note: ',msg) 446 Rvals['msg'] += msg 446 447 G2stIO.SetUsedHistogramsAndPhases(GPXfile,Histograms,Phases,rigidbodyDict,covData,parmFrozenList,makeBack) 447 448 printFile.close() -
trunk/GSASIIstrMath.py
r5284 r5287 3305 3305 phPartialFP.close() 3306 3306 3307 3308 3307 if 'C' in calcControls[hfx+'histType']: 3309 3308 shl = max(parmDict[hfx+'SH/L'],0.002)
Note: See TracChangeset
for help on using the changeset viewer.