Changeset 5164 for trunk/GSASIIpwd.py


Ignore:
Timestamp:
Jan 28, 2022 8:39:44 AM (7 months ago)
Author:
toby
Message:

some PWD cleanups from Laue Fringe work & fullrmc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIpwd.py

    r5161 r5164  
    20622062    return True
    20632063
     2064def getHeaderInfo(FitPgm,dataType):
     2065    '''Provide parameter name, label name and formatting information for the
     2066    contents of the peak table and where used in DoPeakFit
     2067    '''
     2068    names = ['pos','int']
     2069    lnames = ['position','intensity']
     2070    if FitPgm == 'LaueFringe':
     2071        names += ['sig','gam','cells']
     2072        lnames += ['sigma','gamma','cells']
     2073        fmt = ["%10.5f","%10.3f","%10.3f","%10.3f","%10.3f"]
     2074    elif 'C' in dataType:
     2075        names += ['sig','gam']
     2076        lnames += ['sigma','gamma']
     2077        fmt = ["%10.5f","%10.1f","%10.3f","%10.3f"]
     2078    elif 'T' in dataType:
     2079        names += ['alp','bet','sig','gam']
     2080        lnames += ['alpha','beta','sigma','gamma']
     2081        fmt = ["%10.2f","%10.4f","%8.3f","%8.5f","%10.3f","%10.3f"]
     2082    elif 'E' in dataType:
     2083        names += ['sig']
     2084        lnames += ['sigma']
     2085        fmt = ["%10.5f","%10.1f","%8.3f"]
     2086    else: # 'B'
     2087        names += ['alp','bet','sig','gam']
     2088        lnames += ['alpha','beta','sigma','gamma']
     2089        fmt = ["%10.5f","%10.1f","%8.2f","%8.4f","%10.3f","%10.3f"]
     2090    return names, fmt, lnames
     2091
    20642092def DoPeakFit(FitPgm,Peaks,Background,Limits,Inst,Inst2,data,fixback=None,prevVaryList=[],oneCycle=False,controls=None,wtFactor=1.0,dlg=None,noFit=False):
    20652093    '''Called to perform a peak fit, refining the selected items in the peak
     
    22492277        peakVary = []
    22502278        peakVals = []
    2251         if 'C' in dataType:
    2252             names = ['pos','int','sig','gam']
    2253         elif 'E' in dataType:
    2254             names = ['pos','int','sig']
    2255         else:   #'T' and 'B'
    2256             names = ['pos','int','alp','bet','sig','gam']
     2279        names,_,_ = getHeaderInfo(FitPgm,dataType)
    22572280        for i,peak in enumerate(Peaks):
    22582281            for j,name in enumerate(names):
     
    22652288               
    22662289    def GetPeaksParms(Inst,parmDict,Peaks,varyList):
    2267         if 'C' in Inst['Type'][0]:
    2268             names = ['pos','int','sig','gam']
    2269         elif 'E' in Inst['Type'][0]:
    2270             names = ['pos','int','sig']
    2271         else:   #'T' & 'B'
    2272             names = ['pos','int','alp','bet','sig','gam']
     2290        names,_,_ = getHeaderInfo(FitPgm,Inst['Type'][0])
    22732291        for i,peak in enumerate(Peaks):
    22742292            pos = parmDict['pos'+str(i)]
     
    23042322    def PeaksPrint(dataType,parmDict,sigDict,varyList,ptsperFW):
    23052323        print ('Peak coefficients:')
    2306         if 'C' in dataType:
    2307             names = ['pos','int','sig','gam']
    2308         elif 'E' in dataType:
    2309             names = ['pos','int','sig']
    2310         else:   #'T' & 'B'
    2311             names = ['pos','int','alp','bet','sig','gam']           
     2324        names,fmt,_ = getHeaderInfo(FitPgm,dataType)
    23122325        head = 13*' '
    23132326        for name in names:
     
    23182331        head += 'bins'.center(8)
    23192332        print (head)
    2320         if 'C' in dataType:
    2321             ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f",'gam':"%10.3f"}
    2322         elif 'E' in dataType:
    2323             ptfmt = {'pos':"%10.5f",'int':"%10.1f",'sig':"%10.3f"}
    2324         elif 'T' in dataType:
    2325             ptfmt = {'pos':"%10.2f",'int':"%10.4f",'alp':"%8.3f",'bet':"%8.5f",'sig':"%10.3f",'gam':"%10.3f"}
    2326         else: #'B'
    2327             ptfmt = {'pos':"%10.5f",'int':"%10.1f",'alp':"%8.2f",'bet':"%8.4f",'sig':"%10.3f",'gam':"%10.3f"}
     2333        ptfmt = dict(zip(names,fmt))
    23282334        for i,peak in enumerate(Peaks):
    23292335            ptstr =  ':'
     
    34703476
    34713477def calcRmax(ENGINE):
    3472     'from Bachir, works for non-othorhombic'
     3478    'from Bachir, works for non-orthorhombic cells'
    34733479    a,b,c = ENGINE.basisVectors
    34743480    lens = []
     
    35653571        else:
    35663572            print('What is this?')
    3567     rundata += '    ENGINE.add_constraints(DistanceConstraint(defaultLowerDistance={}))\n'.format(RMCPdict['min Contact'])
     3573    minDists = ''
    35683574    if BondList:
    35693575        rundata += '''    B_CONSTRAINT   = BondConstraint()
     
    35763582            if d1 == 0: continue
    35773583            if d2 == 0:
    3578                 print('Ignoring min distance without maximum')
    3579                 #rundata += '            ("element","{}","{}",{}),\n'.format(
    3580                 #                        e1.strip(),e2.strip(),d1)
     3584                minDists += '("element","{}","{}",{}),'.format(e1.strip(),e2.strip(),d1)
    35813585            else:
    35823586                rundata += '            ("element","{}","{}",{},{}),\n'.format(
    35833587                                        e1.strip(),e2.strip(),d1,d2)
    35843588        rundata += '             ])\n'
     3589    rundata += '    D_CONSTRAINT = DistanceConstraint(defaultLowerDistance={})\n'.format(RMCPdict['min Contact'])
     3590    if minDists:
     3591        rundata += "    D_CONSTRAINT.set_pairs_definition( {'inter':[" + minDists + "]})\n"
     3592    rundata += '    ENGINE.add_constraints(D_CONSTRAINT)\n'
     3593   
    35853594    if AngleList:
    35863595        rundata += '''    A_CONSTRAINT   = BondsAngleConstraint()
Note: See TracChangeset for help on using the changeset viewer.