Changeset 4020
 Timestamp:
 Jun 8, 2019 5:19:32 AM (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/GSASIIconstrGUI.py
r3948 r4020 1452 1452 #print('old A',G2lat.cell2A(oldPhase['General']['Cell'][1:7])) 1453 1453 #print('new A',G2lat.cell2A(newPhase['General']['Cell'][1:7])) 1454 for iAnew,Asi in enumerate(['A0','A1','A2','A3','A4','A5']): # loop through A[i] for new cell 1455 Nparm = str(npId) + '::' + Asi 1456 if Nparm != SetUniqAj(npId,iAnew,nSGData): 1457 continue # skip: Ai constrained from Aj or must be zero 1458 multDict = {} 1459 for iAorg in range(6): 1460 cA = conMat[iAnew][iAorg] # coeff for A[i] in constraint matrix 1461 if abs(cA) < 1.e8: continue 1462 parm = SetUniqAj(opId,iAorg,oSGData) # translate to unique A[i] in original cell 1463 if not parm: continue # must be zero 1464 # sum coeff 1465 if parm in multDict: 1466 multDict[parm] += cA 1467 else: 1468 multDict[parm] = cA 1469 # any nonzero multipliers? 1470 maxMult = 0 1471 for i in multDict: 1472 maxMult = max(maxMult,abs(multDict[i])) 1473 if maxMult <= 0: # Nparm computes as zero; Fix this parameter 1474 constraints['Phase'] += [[ 1475 [0.0,G2obj.G2VarObj(Nparm)], 1476 None,None,'h']] 1477 elif len(multDict) == 1: # create equivalence 1478 key = list(multDict.keys())[0] 1479 constraints['Phase'] += [[ 1480 [1.0,G2obj.G2VarObj(key)], 1481 [multDict[key],G2obj.G2VarObj(Nparm)], 1482 None,None,'e']] 1483 else: # create constraint 1484 constr = [[1.0,G2obj.G2VarObj(Nparm)]] 1485 for key in multDict: 1486 constr += [[multDict[key],G2obj.G2VarObj(key)]] 1487 constr += [0.0,None,'c'] 1488 constraints['Phase'] += [constr] 1454 1455 #this is still incorrect for hex/trig/ortho/tetragonal > monoclinic 1456 1457 # for iAnew,Asi in enumerate(['A0','A1','A2','A3','A4','A5']): # loop through A[i] for new cell 1458 # Nparm = str(npId) + '::' + Asi 1459 # if Nparm != SetUniqAj(npId,iAnew,nSGData): 1460 # continue # skip: Ai constrained from Aj or must be zero 1461 # multDict = {} 1462 # for iAorg in range(6): 1463 # cA = conMat[iAnew][iAorg] # coeff for A[i] in constraint matrix 1464 # if abs(cA) < 1.e8: continue 1465 # parm = SetUniqAj(opId,iAorg,oSGData) # translate to unique A[i] in original cell 1466 # if not parm: continue # must be zero 1467 # # sum coeff 1468 # if parm in multDict: 1469 # multDict[parm] += cA 1470 # else: 1471 # multDict[parm] = cA 1472 # # any nonzero multipliers? 1473 # maxMult = 0 1474 # for i in multDict: 1475 # maxMult = max(maxMult,abs(multDict[i])) 1476 # if maxMult <= 0: # Nparm computes as zero; Fix this parameter 1477 # constraints['Phase'] += [[ 1478 # [0.0,G2obj.G2VarObj(Nparm)], 1479 # None,None,'h']] 1480 # elif len(multDict) == 1: # create equivalence 1481 # key = list(multDict.keys())[0] 1482 # constraints['Phase'] += [[ 1483 # [1.0,G2obj.G2VarObj(key)], 1484 # [multDict[key],G2obj.G2VarObj(Nparm)], 1485 # None,None,'e']] 1486 # else: # create constraint 1487 # constr = [[1.0,G2obj.G2VarObj(Nparm)]] 1488 # for key in multDict: 1489 # constr += [[multDict[key],G2obj.G2VarObj(key)]] 1490 # constr += [0.0,None,'c'] 1491 # constraints['Phase'] += [constr] 1489 1492 1490 1493 # constraints on HAP Scale, etc.
Note: See TracChangeset
for help on using the changeset viewer.