Changeset 4983 for trunk/GSASIImapvars.py
- Timestamp:
- Jun 29, 2021 12:23:09 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIImapvars.py
r4852 r4983 682 682 constrDict,varyList) 683 683 #print('debug: using MoveConfEquiv to address =',errmsg) 684 if problemVars: parmsChanged = MoveConfEquiv(constrDict,fixedList)684 if problemVars: parmsChanged,mvMsg = MoveConfEquiv(constrDict,fixedList) 685 685 # GSASIIpath.IPyBreak() 686 686 … … 824 824 shortmsg = '' 825 825 changed = False 826 826 827 827 # Process the equivalences 828 828 # If there are conflicting parameters, move them into constraints. This … … 835 835 constrDict,varyList,parmDict,SeqHist) 836 836 if problemVars: 837 parmsChanged = MoveConfEquiv(constrDict,fixedList)837 parmsChanged,mvMsg = MoveConfEquiv(constrDict,fixedList) 838 838 changed = True 839 839 if errmsg: … … 943 943 GramSchmidtOrtho(constrArr,len(group)) 944 944 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]) 946 948 break 947 949 mapvar = [] … … 1006 1008 print(60*'=') 1007 1009 print('Constraints were reclassified to avoid conflicts, as below:') 1010 print(mvMsg) 1011 print('New constraints are:') 1008 1012 print (VarRemapShow(varyList,True)) 1009 1013 print(60*'=') … … 1261 1265 global problemVars 1262 1266 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 1263 1273 for i,(varlist,mapvars) in enumerate(zip(dependentParmList,indParmList)): 1264 1274 conf = False … … 1274 1284 parmsChanged += 1 1275 1285 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):' 1276 1289 for dep,mult in zip(dependentParmList[i],invarrayList[i]): 1277 #print('debug replacing equiv with constraint equation 0=',{indvar:-1.,dep:mult[0]})1278 1290 constrDict += [{indvar:-1.,dep:mult[0]}] 1279 1291 fixedList += ['0.0'] 1292 msg += '\n ' + _FormatConstraint(constrDict[-1],fixedList[-1]) 1280 1293 dependentParmList[i] = None 1281 1294 if parmsChanged: … … 1283 1296 if dependentParmList[i] is None: 1284 1297 del dependentParmList[i],indParmList[i],arrayList[i],invarrayList[i] 1285 return parmsChanged 1298 return parmsChanged,msg 1286 1299 1287 1300 def StoreEquivalence(independentVar,dependentList,symGen=True): … … 1503 1516 return s1 1504 1517 1518 def _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 1505 1541 def VarRemapShow(varyList,inputOnly=False): 1506 1542 '''List out the saved relationships. This should be done after the constraints have been
Note: See TracChangeset
for help on using the changeset viewer.