Changeset 1092


Ignore:
Timestamp:
Oct 9, 2013 10:27:52 AM (8 years ago)
Author:
vondreele
Message:

remove GSASIIsolve - never will be used
put back matrix rescaling for v-cov matrix
add detail for penalty fxn output - still something wrong with this

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1087 r1092  
    7373import GSASIIstrIO as G2stIO
    7474import GSASIImapvars as G2mv
    75 import GSASIIsolve as G2sol
    7675
    7776#wx inspector - use as needed
  • trunk/GSASIImath.py

    r1091 r1092  
    148148    nfev += 1
    149149    Yvec,Amat = Hess(x0,*args)
    150     Amatlam = Amat          #*(One+Lam)/Anorm
     150    Amatlam = Amat*(One+Lam)/Anorm              #scale Amat to Marquardt array
    151151    try:
    152         Bmat = nl.inv(Amatlam)          #*(One+Lam)/Anorm
     152        Bmat = nl.inv(Amatlam)*(One+Lam)/Anorm      #rescale Bmat to Marquardt array
    153153        return [x0,Bmat,{'num cyc':icycle,'fvec':M,'nfev':nfev,'lamMax':lamMax,'psing':[]}]
    154154    except nl.LinAlgError:
  • trunk/GSASIIstrMath.py

    r1088 r1092  
    307307    pWt = []
    308308    negWt = {}
     309    pWsum = {}
    309310    for phase in Phases:
    310311        pId = Phases[phase]['pId']
     
    323324            ['ChemComp','Sites'],['Texture','HKLs']]
    324325        for name,rest in names:
     326            pWsum[name] = 0.
    325327            itemRest = phaseRest[name]
    326328            if itemRest[rest] and itemRest['Use']:
     
    341343                        pVals.append(obs-calc)
    342344                        pWt.append(wt/esd**2)
     345                        pWsum[name] += wt*((obs-calc)/esd)**2
    343346                elif name in ['Torsion','Rama']:
    344347                    coeffDict = itemRest['Coeff']
     
    355358                        pVals.append(obs-calc)
    356359                        pWt.append(wt/esd**2)
     360                        pWsum[name] += wt*((obs-calc)/esd)**2
    357361                elif name == 'ChemComp':
    358362                    for i,[indx,factors,obs,esd] in enumerate(itemRest[rest]):
     
    363367                        pVals.append(obs-calc)
    364368                        pWt.append(wt/esd**2)                   
     369                        pWsum[name] += wt*((obs-calc)/esd)**2
    365370                elif name == 'Texture':
    366371                    SHkeys = textureData['SH Coeff'][1].keys()
     
    379384                            pVals.append(Z1[ind[0]][ind[1]])
    380385                            pWt.append(wt/esd1**2)
     386                            pWsum[name] += wt*((obs-calc)/esd)**2
    381387                        if ifesd2:
    382388                            Z2 = 1.-Z
     
    385391                                pVals.append(Z1[ind[0]][ind[1]])
    386392                                pWt.append(wt/esd2**2)
     393                                pWsum[name] += wt*((obs-calc)/esd)**2
    387394         
    388395    for item in varyList:
     
    393400                pVals.append(-parmDict[item])
    394401                pWt.append(negWt[pId])
     402                pWsum[name] += negWt[pId]*(-parmDict[item])**2
    395403    pVals = np.array(pVals)
    396404    pWt = np.array(pWt)         #should this be np.sqrt?
    397     return pNames,pVals,pWt
     405    return pNames,pVals,pWt,pWsum
    398406   
    399407def penaltyDeriv(pNames,pVal,HistoPhases,parmDict,varyList):
     
    17041712            dMdv = np.sqrt(wtFactor)*dMdvh
    17051713           
    1706     pNames,pVals,pWt = penaltyFxn(HistoPhases,parmDict,varylist)
     1714    pNames,pVals,pWt,pWsum = penaltyFxn(HistoPhases,parmDict,varylist)
    17071715    if np.any(pVals):
    17081716        dpdv = penaltyDeriv(pNames,pVals,HistoPhases,parmDict,varylist)
     
    17221730    :returns: Vec,Hess where Vec is the least-squares vector and Hess is the Hessian
    17231731    '''
    1724     'Needs a doc string'
    17251732    parmDict.update(zip(varylist,values))
    17261733    G2mv.Dict2Map(parmDict,varylist)
     
    18501857        else:
    18511858            continue        #skip non-histogram entries
    1852     pNames,pVals,pWt = penaltyFxn(HistoPhases,parmDict,varylist)
     1859    pNames,pVals,pWt,pWsum = penaltyFxn(HistoPhases,parmDict,varylist)
    18531860    if np.any(pVals):
    18541861        dpdv = penaltyDeriv(pNames,pVals,HistoPhases,parmDict,varylist)
     
    19921999            dlg.Destroy()
    19932000            raise Exception         #Abort!!
    1994     pDict,pVals,pWt = penaltyFxn(HistoPhases,parmDict,varylist)
     2001    pDict,pVals,pWt,pWsum = penaltyFxn(HistoPhases,parmDict,varylist)
    19952002    if np.any(pVals):
    19962003        pSum = np.sum(pWt*pVals**2)
    1997         print 'Penalty function: %.3f on %d terms'%(pSum,len(pVals))
     2004        for name in pWsum:
     2005            print '  Penalty function for %s = %.3f'%(name,pWsum[name])
     2006        print 'Total penalty function: %.3f on %d terms'%(pSum,len(pVals))
    19982007        Nobs += len(pVals)
    19992008        M = np.concatenate((M,np.sqrt(pWt)*pVals))
Note: See TracChangeset for help on using the changeset viewer.