Changeset 3046


Ignore:
Timestamp:
Sep 5, 2017 2:12:23 PM (4 years ago)
Author:
toby
Message:

label user-supplied & code-generated equivalences (constraints); improve error conflicting constraint error message

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3041 r3046  
    42644264        errmsg, warnmsg = G2stIO.ReadCheckConstraints(self.GSASprojectfile)
    42654265        if errmsg:
    4266             self.ErrorDialog('Refinement error',errmsg)
     4266            self.ErrorDialog('Refinement error',errmsg+'\nCheck console output for more information')
    42674267            return
    42684268        if warnmsg:
  • trunk/GSASIImapvars.py

    r2876 r3046  
    135135       StoreEquivalence('x',('y','z'))
    136136
    137   The latter will run more efficiently. Note that mixing independent and dependent variables is
    138   problematic. This is not allowed:
     137  The latter will run more efficiently. Note that mixing independent and dependent variables would
     138  require assignments to be done in a particular order and thus is not is not allowed. This will cause an
     139  error:
    139140
    140141  .. code-block:: python
     
    225226               # key is original ascii string, value is float
    226227fixedVarList = [] # List of variables that should not be refined
     228symGenList = [] # Flag if constraint is generated by symmetry
    227229
    228230# prefix for parameter names
     
    232234def InitVars():
    233235    '''Initializes all constraint information'''
    234     global dependentParmList,arrayList,invarrayList,indParmList,fixedDict,consNum
     236    global dependentParmList,arrayList,invarrayList,indParmList,fixedDict,consNum,symGenList
    235237    dependentParmList = [] # contains a list of parameters in each group
    236238    arrayList = [] # a list of of relationship matrices
     
    238240    indParmList = [] # a list of names for the new parameters
    239241    fixedDict = {} # a dictionary containing the fixed values corresponding to defined parameter equations
     242    symGenList = [] # Flag if constraint is generated by symmetry
    240243    consNum = 0 # number of the next constraint to be created
    241244
     
    736739        invarrayList.append(np.linalg.inv(constrArr))
    737740        indParmList.append(mapvar)
     741        symGenList.append(False)
    738742    if msg:
    739743        print ' *** ERROR in constraint definitions! ***'
     
    766770        print 'Not Varied: ',fixedVarList
    767771
    768 def StoreEquivalence(independentVar,dependentList):
     772def StoreEquivalence(independentVar,dependentList,symGen=True):
    769773    '''Takes a list of dependent parameter(s) and stores their
    770774    relationship to a single independent parameter (independentVar)
     
    776780         independentVar. Each item in the list can be a string with the parameter
    777781         name or a tuple containing a name and multiplier:
    778          ``['parm1',('parm2',.5),]``
     782         ``['::parm1',('::parm2',.5),]``
    779783
    780784    '''
    781785   
    782     global dependentParmList,arrayList,invarrayList,indParmList
     786    global dependentParmList,arrayList,invarrayList,indParmList,symGenList
    783787    mapList = []
    784788    multlist = []
     
    797801    indParmList.append(tuple((independentVar,)))
    798802    dependentParmList.append(mapList)
     803    symGenList.append(symGen)
    799804    return
    800805
     
    806811
    807812    '''
     813    global dependentVars
    808814    return dependentVars
    809815
     
    815821
    816822    '''
     823    global independentVars
    817824    return independentVars
    818825
     
    915922            s += '    ' + v + '\n'
    916923    s += 'Variable mapping relations:\n'
    917     global dependentParmList,arrayList,invarrayList,indParmList,fixedDict
    918     for varlist,mapvars,multarr,invmultarr in zip(
    919         dependentParmList,indParmList,arrayList,invarrayList):
     924    symout = ''
     925    global dependentParmList,arrayList,invarrayList,indParmList,fixedDict,symGenList
     926
     927    for varlist,mapvars,multarr,invmultarr,symFlag in zip(
     928        dependentParmList,indParmList,arrayList,invarrayList,symGenList):
    920929        for i,mv in enumerate(mapvars):
    921930            if multarr is None:
    922                 s += '  ' + str(mv) + ' is equivalent to parameter(s): '
     931                s1 = '  ' + str(mv) + ' is equivalent to parameter(s): '
    923932                j = 0
    924933                for v,m in zip(varlist,invmultarr):
    925934                    if debug: print 'v,m[0]: ',v,m[0]
    926                     if j > 0: s += '  & '
     935                    if len(s1.split('\n')[-1]) > 75: s1 += '\n        '
     936                    if j > 0: s1 += ' & '
    927937                    j += 1
    928                     s += str(v)
     938                    s1 += str(v)
    929939                    if m != 1:
    930                         s += " / " + str(m[0])                       
    931                 s += '\n'
     940                        s1 += " / " + str(m[0])
     941                if symFlag:
     942                    symout += s1 + '\n'
     943                else:
     944                    s += s1 + '\n'
    932945                continue
    933946            s += '  %s = ' % mv
     
    940953            if mv in varyList: s += ' VARY'
    941954            s += '\n'
     955    if symout:
     956        s += 'Symmetry-generated relations:\n' + symout
    942957    if inputOnly: return s
    943958    s += 'Inverse variable mapping relations:\n'
  • trunk/GSASIIstrIO.py

    r3000 r3046  
    164164                    eqlist.append([var,firstmult/term[0]])
    165165            if len(eqlist) > 0:
    166                 G2mv.StoreEquivalence(firstvar,eqlist)
     166                G2mv.StoreEquivalence(firstvar,eqlist,False)
    167167            else:
    168168                ignored += 1
Note: See TracChangeset for help on using the changeset viewer.