Ignore:
Timestamp:
Sep 8, 2017 2:17:29 PM (4 years ago)
Author:
toby
Message:

expand error reporting with constraints (no fixes yet to prevent them)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImapvars.py

    r3046 r3056  
    202202     to parameter equations.  The dict key is an ascii string, but the
    203203     dict value is a float.  Unlikely to be used externally.
     204
     205symGenList:
     206     a list of boolean values that will be True to indicate that a constraint
     207     (only equivalences) is generated by symmetry (or Pawley overlap)
     208     
     209problemVars:
     210     a list containing variables that show up in constraints producing errors
    204211
    205212*Routines*
     
    227234fixedVarList = [] # List of variables that should not be refined
    228235symGenList = [] # Flag if constraint is generated by symmetry
     236problemVars = [] # variables causing errors
    229237
    230238# prefix for parameter names
     
    329337    errmsg = ''
    330338    warnmsg = ''
     339    global problemVars
     340    problemVars = []
    331341    fixVlist = []
    332342    # process fixed variables (holds)
     
    358368                    if v in indepVarList:
    359369                        errmsg += '\nVariable '+v+' is used to set values in a constraint before its value is set in another constraint\n'
     370                        if v not in problemVars: problemVars.append(v)
    360371                    if m == 0: zeromult = True
    361372                    if v in varyList:
     
    389400        s = ''
    390401        for var in sorted(set(multdepVarList)):
     402            if v not in problemVars: problemVars.append(v)
    391403            if s != "": s+= ", "
    392404            s += str(var)           
     
    399411        s = ''
    400412        for var in sorted(inboth):
     413            if var not in problemVars: problemVars.append(var)
    401414            if s != "": s+= ", "
    402415            s += str(var)
     
    422435                if var in fixVlist:
    423436                    errmsg += '\nParameter '+var+" is Fixed and used in a constraint:\n\t"
     437                    if var not in problemVars: problemVars.append(var)
    424438                    errmsg += _FormatConstraint(constrDict[rel],fixedList[rel])+"\n"
    425439            if varied > 0 and varied != len(VarKeys(constrDict[rel])):
     
    921935        for v in fixedVarList:
    922936            s += '    ' + v + '\n'
    923     s += 'Variable mapping relations:\n'
     937    s += 'User-supplied variable mapping relations:\n'
    924938    symout = ''
    925939    global dependentParmList,arrayList,invarrayList,indParmList,fixedDict,symGenList
     
    929943        for i,mv in enumerate(mapvars):
    930944            if multarr is None:
    931                 s1 = '  ' + str(mv) + ' is equivalent to parameter(s): '
     945#                s1 = '  ' + str(mv) + ' is equivalent to parameter(s): '
     946                if len(varlist) == 1:
     947                    s1 = '   ' + str(mv) + ' is equivalent to '
     948                else:
     949                    s1 = '   ' + str(mv) + ' is equivalent to parameters: '
    932950                j = 0
    933951                for v,m in zip(varlist,invmultarr):
     
    968986            s += '\n'
    969987    return s
     988
     989def GetSymEquiv():
     990    '''Return the automatically generated (equivalence) relationships.
     991
     992    :returns: a list of strings containing the details of the contraint relationships
     993    '''
     994    symout = []
     995    global dependentParmList,arrayList,invarrayList,indParmList,fixedDict,symGenList
     996
     997    for varlist,mapvars,multarr,invmultarr,symFlag in zip(
     998        dependentParmList,indParmList,arrayList,invarrayList,symGenList):
     999        for i,mv in enumerate(mapvars):
     1000            if not symFlag: continue
     1001            if multarr is None:
     1002                s1 = str(mv) + ' = '
     1003                j = 0
     1004                for v,m in zip(varlist,invmultarr):
     1005                    if debug: print 'v,m[0]: ',v,m[0]
     1006                    if len(s1.split('\n')[-1]) > 75: s1 += '\n        '
     1007                    if j > 0: s1 += ' =  '
     1008                    j += 1
     1009                    s1 += str(v)
     1010                    if m != 1:
     1011                        s1 += " / " + str(m[0])
     1012                    symout.append(s1)
     1013                continue
     1014            else:
     1015                s = '  %s = ' % mv
     1016                j = 0
     1017                for m,v in zip(multarr[i,:],varlist):
     1018                    if m == 0: continue
     1019                    if j > 0: s += ' + '
     1020                    j += 1
     1021                    s += '(%s * %s)' % (m,v)
     1022                print 'unexpected sym op=',s
     1023    return symout
    9701024
    9711025def Dict2Deriv(varyList,derivDict,dMdv):
Note: See TracChangeset for help on using the changeset viewer.