Ignore:
Timestamp:
Jun 29, 2021 12:23:09 PM (21 months ago)
Author:
toby
Message:

fix initialization problem when EQUIV are changed to constraints; improve warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImapvars.py

    r4852 r4983  
    682682            constrDict,varyList)
    683683        #print('debug: using MoveConfEquiv to address =',errmsg)
    684         if problemVars: parmsChanged = MoveConfEquiv(constrDict,fixedList)
     684        if problemVars: parmsChanged,mvMsg = MoveConfEquiv(constrDict,fixedList)
    685685#    GSASIIpath.IPyBreak()
    686686
     
    824824    shortmsg = ''
    825825    changed = False
    826    
     826
    827827    # Process the equivalences
    828828    #    If there are conflicting parameters, move them into constraints. This
     
    835835            constrDict,varyList,parmDict,SeqHist)
    836836        if problemVars:
    837             parmsChanged = MoveConfEquiv(constrDict,fixedList)
     837            parmsChanged,mvMsg = MoveConfEquiv(constrDict,fixedList)
    838838            changed = True
    839839    if errmsg:
     
    943943            GramSchmidtOrtho(constrArr,len(group))
    944944        except:
    945             msg = 'Singular relationships'
     945            msg = 'Singular relationships found while processing constraints group:'
     946            for rel in group:
     947                msg += '\n  ' + _FormatConstraint(constrDict[rel],fixedList[rel])
    946948            break
    947949        mapvar = []
     
    10061008        print(60*'=')
    10071009        print('Constraints were reclassified to avoid conflicts, as below:')
     1010        print(mvMsg)
     1011        print('New constraints are:')
    10081012        print (VarRemapShow(varyList,True))
    10091013        print(60*'=')
     
    12611265    global problemVars
    12621266    parmsChanged = 0
     1267    msg = ''
     1268    if problemVars:
     1269        msg = 'Conflict: variable(s) used in both equivalences and constraints: '
     1270        for i1,v1 in enumerate(problemVars):
     1271            if i1 > 0: msg += ', '
     1272            msg += v1
    12631273    for i,(varlist,mapvars) in enumerate(zip(dependentParmList,indParmList)):
    12641274        conf = False
     
    12741284            parmsChanged += 1
    12751285            indvar = indParmList[i][0]
     1286            msg += '\n  Removing equivalence:\n    ' + _showEquiv(
     1287                dependentParmList[i],indParmList[i],invarrayList[i])
     1288            msg += '\n  Creating new constraint(s):'
    12761289            for dep,mult in zip(dependentParmList[i],invarrayList[i]):
    1277                 #print('debug replacing equiv with constraint equation 0=',{indvar:-1.,dep:mult[0]})
    12781290                constrDict += [{indvar:-1.,dep:mult[0]}]
    12791291                fixedList += ['0.0']
     1292                msg += '\n    ' + _FormatConstraint(constrDict[-1],fixedList[-1])
    12801293            dependentParmList[i] = None
    12811294    if parmsChanged:
     
    12831296            if dependentParmList[i] is None:
    12841297                del dependentParmList[i],indParmList[i],arrayList[i],invarrayList[i]
    1285     return parmsChanged
     1298    return parmsChanged,msg
    12861299
    12871300def StoreEquivalence(independentVar,dependentList,symGen=True):
     
    15031516    return s1
    15041517
     1518def _showEquiv(varlist,mapvars,invmultarr):
     1519    '''Format an equivalence relationship
     1520    note that
     1521    varlist,           mapvars,     invmultarr
     1522    are elements of
     1523    dependentParmList, indParmList, invarrayList
     1524    '''
     1525    for i,mv in enumerate(mapvars):
     1526        if len(varlist) == 1:
     1527            s1 = str(mv) + ' is equivalent to '
     1528        else:
     1529            s1 = str(mv) + ' is equivalent to parameters: '
     1530        j = 0
     1531        for v,m in zip(varlist,invmultarr):
     1532            if debug: print ('v,m[0]: ',v,m[0])
     1533            if len(s1.split('\n')[-1]) > 75: s1 += '\n        '
     1534            if j > 0: s1 += ' & '
     1535            j += 1
     1536            s1 += str(v)
     1537            if m != 1:
     1538                s1 += " / " + str(m[0])
     1539    return s1
     1540
    15051541def VarRemapShow(varyList,inputOnly=False):
    15061542    '''List out the saved relationships. This should be done after the constraints have been
Note: See TracChangeset for help on using the changeset viewer.