Changeset 3413


Ignore:
Timestamp:
May 29, 2018 3:10:32 PM (6 years ago)
Author:
vondreele
Message:

modify RefineCore? & Refine/SeqRefine? to use ifSeq parameter instead of ifPrint; give message on singular matrix.
quit ifSeq or press on with fewer variables if not.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r3411 r3413  
    743743            FrstVarb = varList[sel]
    744744            VarObj = G2obj.G2VarObj(FrstVarb)
    745             moreVarb = G2obj.SortVariables(
    746                 FindEquivVarb(FrstVarb,[i for i in varList if i not in omitVars]))
     745            moreVarb = G2obj.SortVariables(FindEquivVarb(FrstVarb,[i for i in varList if i not in omitVars]))
    747746            newcons = SelectVarbs(page,VarObj,moreVarb,title2+FrstVarb,constType)
    748747            if len(newcons) > 0:
  • trunk/GSASIIstrMain.py

    r3378 r3413  
    4848
    4949def RefineCore(Controls,Histograms,Phases,restraintDict,rigidbodyDict,parmDict,varyList,
    50     calcControls,pawleyLookup,ifPrint,printFile,dlg):
     50    calcControls,pawleyLookup,ifSeq,printFile,dlg):
    5151    '''Core optimization routines, shared between SeqRefine and Refine
    5252
     
    5656#    for item in parmDict: print item,parmDict[item] ######### show dict just before refinement
    5757    G2mv.Map2Dict(parmDict,varyList)
     58    ifPrint = True
     59    if ifSeq:
     60        ifPrint = False
    5861    Rvals = {}
    5962    while True:
     
    113116        printFile.write(' wR = %7.2f%%, chi**2 = %12.6g, GOF = %6.2f\n'%(Rvals['Rwp'],Rvals['chisq'],Rvals['GOF']))
    114117        sig = len(varyList)*[None,]
    115         if 'None' in str(type(result[1])):
     118        if 'None' in str(type(result[1])) and ifSeq:    #this bails out of a sequential refinement on singular matrix
    116119            IfOK = False
    117120            covMatrix = []
     121            print ('**** Refinement failed - singular matrix ****')
     122            if 'Hessian' in Controls['deriv type']:
     123                num = len(varyList)-1
     124                for i,val in enumerate(np.flipud(result[2]['psing'])):
     125                    if val:
     126                        print ('Bad parameter: '+varyList[num-i])
     127            else:
     128                Ipvt = result[2]['ipvt']
     129                for i,ipvt in enumerate(Ipvt):
     130                    if not np.sum(result[2]['fjac'],axis=1)[i]:
     131                        print ('Bad parameter: '+varyList[ipvt-1])
    118132            break
    119133        IfOK = True
     
    216230#    print G2mv.VarRemapShow(varyList)
    217231
    218     ifPrint = True
     232    ifSeq = False
    219233    printFile.write('\n Refinement results:\n')
    220234    printFile.write(135*'-'+'\n')
     
    223237        covData = {}
    224238        IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histograms,Phases,restraintDict,
    225             rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifPrint,printFile,dlg)
     239            rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg)
    226240        if IfOK:
    227241            sigDict = dict(zip(varyList,sig))
     
    441455            firstVaryList = newVaryList
    442456
    443         ifPrint = False
     457        ifSeq = True
    444458        printFile.write('\n Refinement results for histogram: %s\n'%histogram)
    445459        printFile.write(135*'-'+'\n')
     
    447461#        try:
    448462            IfOK,Rvals,result,covMatrix,sig = RefineCore(Controls,Histo,Phases,restraintDict,
    449                 rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifPrint,printFile,dlg)
     463                rigidbodyDict,parmDict,varyList,calcControls,pawleyLookup,ifSeq,printFile,dlg)
    450464            if PlotFunction:
    451465                PlotFunction(G2frame,Histo[histogram]['Data'],histogram)
Note: See TracChangeset for help on using the changeset viewer.