Changeset 3618
- Timestamp:
- Sep 24, 2018 3:11:34 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIconstrGUI.py
r3617 r3618 1227 1227 sub = G2gd.GetGPXtreeItemId(G2frame,G2frame.root,'Constraints') 1228 1228 Constraints = G2frame.GPXtree.GetItemPyData(sub) 1229 fracConstr = False1230 1229 for c in Constraints.get('HAP',[]): 1231 1230 if c[-1] != 'c': continue … … 1237 1236 # got a constraint, this is OK 1238 1237 return 1239 dlg = wx.MessageDialog(G2frame, 1240 'You are refining the scale factor and all phase fractions for histogram #'+ 1241 histStr+'. This will produce an unstable refinement. '+ 1242 'Do you want to constrain the sum of phase fractions?', 1243 'Create constraint?', 1244 wx.OK|wx.CANCEL) 1238 dlg = wx.MessageDialog(G2frame,'You are refining the scale factor and all phase fractions for histogram #'+ 1239 histStr+'. This will produce an unstable refinement. '+ 1240 'Do you want to constrain the sum of phase fractions?','Create constraint?',wx.OK|wx.CANCEL) 1245 1241 if dlg.ShowModal() != wx.ID_OK: 1246 1242 dlg.Destroy() … … 1292 1288 cx,ct,cs,cia = newPhase['General']['AtomPtrs'] 1293 1289 nAtoms = newPhase['Atoms'] 1294 oSGData = oldPhase['General']['SGData']1295 1290 nSGData = newPhase['General']['SGData'] 1296 1291 oAcof = G2lat.cell2A(oldPhase['General']['Cell'][1:7]) … … 1303 1298 varyList = [] 1304 1299 xnames = ['dAx','dAy','dAz'] 1305 unames = [['AU11','AU12','AU13'],['AU12','AU22','AU23'],['AU13','AU23','AU33']] 1306 # Us = ['U11','U22','U33','U12','U13','U23'] 1307 Uids = [[0,0,'AU11'],[1,1,'AU22'],[2,2,'AU33'],[0,1,'AU12'],[0,2,'AU13'],[1,2,'AU23']] 1300 # Us = ['AU11','AU22','AU33','AU12','AU13','AU23'] 1301 # Uids = [[0,0,'AU11'],[1,1,'AU22'],[2,2,'AU33'],[0,1,'AU12'],[0,2,'AU13'],[1,2,'AU23']] 1308 1302 for ia,code in enumerate(atCodes): 1309 1303 atom = nAtoms[ia] 1304 if not ia and atom[cia] == 'A': 1305 wx.MessageDialog(G2frame, 1306 'Anisotropic thermal motion constraints are not developed at the present time', 1307 'Anisotropic thermal constraint?',style=wx.ICON_INFORMATION).ShowModal() 1310 1308 siteSym = G2spc.SytSym(atom[cx:cx+3],nSGData)[0] 1311 1309 CSX = G2spc.GetCSxinel(siteSym) 1312 CSU = G2spc.GetCSuinel(siteSym)1310 # CSU = G2spc.GetCSuinel(siteSym) 1313 1311 item = code.split('+')[0] 1314 1312 iat,opr = item.split(':') … … 1339 1337 DepCons = [1.0,G2obj.G2VarObj('%d::%s:%s'%(opId,name,iat))] 1340 1338 constraints['Phase'].append([DepCons,IndpCon,None,None,'e']) 1341 # for iu,Uid in enumerate(Uids): Not right 1339 1340 # DepConsDict = dict(zip(Us,[[],[],[],[],[],[]])) 1341 # for iu,Uid in enumerate(Uids): 1342 # UMT = np.zeros((3,3)) 1343 # UMT[Uid[0],Uid[1]] = 1 1344 # nUMT = G2lat.prodMGMT(UMT,invTrans) 1345 # nUT = G2lat.UijtoU6(nUMT) 1346 # for iu,nU in enumerate(nUT): 1347 # if abs(nU) > 1.e-8: 1348 # parm = '%d::%s;%s'%(opId,Us[iu],iat) 1349 # DepConsDict[Uid[2]].append([abs(nU%1.),G2obj.G2VarObj(parm)]) 1350 # nUcof = atom[iu:iu+6] 1351 # for iU,Usi in enumerate(Us): 1352 # parm = '%d::%s;%d'%(npId,Usi,ia) 1353 # parmDict[parm] = nUcof[iU] 1354 # varyList.append(parm) 1355 # IndpCon = [1.0,G2obj.G2VarObj(parm)] 1356 # if len(DepConsDict[Usi]) == 1: 1357 # if DepConsDict[Usi][0]: 1358 # constraints['Phase'].append([IndpCon,DepConsDict[Usi][0],None,None,'e']) 1359 # elif len(DepConsDict[Usi]) > 1: 1360 # for Dep in DepConsDict[Usi]: 1361 # Dep[0] *= -1 1362 # constraints['Phase'].append([IndpCon]+DepConsDict[Usi]+[0.0,None,'c']) 1363 1364 1365 1366 1367 1342 1368 # for iu in list(set(CSU[0])): 1343 1369 # if not iu: … … 1363 1389 As = ['A0','A1','A2','A3','A4','A5'] 1364 1390 Aids = [[0,0,'A0'],[1,1,'A1'],[2,2,'A2'],[0,1,'A3'],[0,2,'A4'],[1,2,'A5']] 1365 Axes = ['a','b','c']1366 Holds = []1367 1391 DepConsDict = dict(zip(As,[[],[],[],[],[],[]])) 1368 1392 for iA,Aid in enumerate(Aids): … … 1376 1400 parm = SetUniqAj(opId,As[ia],nSGData['SGLaue']) 1377 1401 DepConsDict[Aid[2]].append([nA,G2obj.G2VarObj(parm)]) 1378 for Asi in As:1402 for iA,Asi in enumerate(As): 1379 1403 parm = SetUniqAj(npId,Asi,nSGData['SGLaue']) 1380 1404 parmDict[parm] = nAcof[iA] … … 1388 1412 Dep[0] *= -1 1389 1413 constraints['Phase'].append([IndpCon]+DepConsDict[Asi]+[0.0,None,'c']) 1390 1391 1392 1393 1394 1395 1396 1397 1398 # for iA,Aid in enumerate(Aids): #TODO: this is not generally correct - ok for orthonormal cases1399 # parm = SetUniqAj(npId,Aid[2],nSGData['SGLaue'])1400 # parmDict[parm] = nAcof[iA]1401 # varyList.append(parm)1402 # IndpCon = [1.0,G2obj.G2VarObj(parm)]1403 # DepCons = []1404 # for iat in range(3):1405 # if nSGData['SGLaue'] in ['-1','2/m']: #set holds1406 # if (abs(nAcof[iA]) < 1.e-8) and (abs(invTrans[Aid[0],Aid[1]]) < 1.e-8):1407 # if Axes[iat] != nSGData['SGUniq'] and nSGData['SGLaue'] != oSGData['SGLaue']:1408 # HoldObj = G2obj.G2VarObj('%d::%s'%(npId,Aid[2]))1409 # if not HoldObj in Holds:1410 # constraints['Phase'].append([[0.0,HoldObj],None,None,'h'])1411 # Holds.append(HoldObj)1412 # continue1413 # for ibt in range(3):1414 # if abs(Trans[Aid[0],iat]) > 1.e-4 and abs(invTrans[Aid[1],ibt]) > 1.e-4 and abs(oAcof[iA]) > 1.e-8:1415 # parm = SetUniqAj(opId,As[iat],nSGData['SGLaue'])1416 # parmDict[parm] = oAcof[iat]1417 # if not parm in varyList:1418 # varyList.append(parm)1419 # DepCons.append([invTrans[ibt,iat]*invTrans[iat,ibt],G2obj.G2VarObj(parm)])1420 # if len(DepCons) == 1:1421 # constraints['Phase'].append([IndpCon,DepCons[0],None,None,'e'])1422 # elif len(DepCons) > 1:1423 # for Dep in DepCons:1424 # Dep[0] *= -11425 # constraints['Phase'].append([IndpCon]+DepCons+[0.0,None,'c'])1426 # constDict,fixedList,ignored = G2stIO.ProcessConstraints(constraints['Phase'])1427 # groups,parmlist = G2mv.GroupConstraints(constDict)1428 # G2mv.GenerateConstraints(groups,parmlist,varyList,constDict,fixedList,parmDict)1429 # print 'old',parmDict1430 # G2mv.Dict2Map(parmDict,varyList)1431 # print 'new',parmDict1432 1414 for hId,hist in enumerate(UseList): #HAP - seems OK 1433 1415 ohapkey = '%d:%d:'%(opId,hId) -
trunk/GSASIIpwdGUI.py
r3617 r3618 3394 3394 data[5] = magcells 3395 3395 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) 3396 3397 def OnRefreshKeep(event): 3398 controls,bravais,cells,dminx,ssopt,magcells = G2frame.GPXtree.GetItemPyData(UnitCellsId) 3399 c = event.GetCol() 3400 E,SGData = G2spc.SpcGroup(controls[13]) 3401 if c == 2: 3402 for phase in magcells: 3403 Uvec = phase['Uvec'] 3404 Trans = phase['Trans'] 3405 allmom = phase['allmom'] 3406 invTrans = nl.inv(Trans) 3407 magAtms = phase['magAtms'] 3408 TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom) 3409 data = controls,bravais,cells,dminx,ssopt,magcells 3410 G2frame.GPXtree.SetItemPyData(UnitCellsId,data) 3411 wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) 3396 3412 3397 3413 def MakeNewPhase(event): … … 3500 3516 wx.CallAfter(UpdateUnitCellsGrid,G2frame,data) 3501 3517 3518 def TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom): 3519 found = False 3520 if not magAtms: 3521 phase['Keep'] = True 3522 return 3523 for matm in magAtms: 3524 xyzs = G2spc.GenAtom(matm[3:6],SGData,False,Move=True) 3525 for x in xyzs: 3526 xyz = G2lat.TransformXYZ(x[0]-Uvec,invTrans.T,np.zeros(3))%1. 3527 SytSym,Mul,Nop,dupDir = G2spc.SytSym(xyz,phase['SGData']) 3528 CSI = G2spc.GetCSpqinel(phase['SGData']['SpnFlp'],dupDir) 3529 if any(CSI[0]): #found one - can quit looking 3530 phase['Keep'] = True 3531 if allmom: 3532 if not any(CSI[0]): 3533 phase['Keep'] = False 3534 found = True 3535 break 3536 if found: #found one 3537 break 3538 3502 3539 def OnRunSubsMag(event): 3503 3540 import kSUBGROUPSMAG as kMAG … … 3561 3598 phase['Cell'] = G2lat.TransformCell(controls[6:12],Trans) 3562 3599 phase['aType'] = atype 3563 found = False 3564 if not magAtms: 3565 phase['Keep'] = True 3566 for matm in magAtms: 3567 xyzs = G2spc.GenAtom(matm[3:6],SGData,False,Move=True) 3568 for x in xyzs: 3569 xyz = G2lat.TransformXYZ(x[0]-Uvec,invTrans.T,np.zeros(3))%1. 3570 SytSym,Mul,Nop,dupDir = G2spc.SytSym(xyz,phase['SGData']) 3571 CSI = G2spc.GetCSpqinel(phase['SGData']['SpnFlp'],dupDir) 3572 if any(CSI[0]): #found one - can quit looking 3573 phase['Keep'] = True 3574 if allmom: 3575 if not any(CSI[0]): 3576 phase['Keep'] = False 3577 found = True 3578 break 3579 if found: #found one 3580 break 3600 phase['allmom'] = allmom 3601 phase['magAtms'] = magAtms 3602 TestMagAtoms(phase,magAtms,SGData,Uvec,invTrans,allmom) 3581 3603 magcells.append(phase) 3582 3604 magcells[0]['Use'] = True … … 3881 3903 table.append(row) 3882 3904 MagCellsTable = G2G.Table(table,rowLabels=rowLabels,colLabels=colLabels,types=Types) 3905 G2frame.GetStatusBar().SetStatusText('Double click Keep to refresh Keep flags',1) 3883 3906 magDisplay = G2G.GSGrid(G2frame.dataWindow) 3884 3907 magDisplay.SetTable(MagCellsTable, True) 3885 3908 magDisplay.Bind(wg.EVT_GRID_CELL_LEFT_CLICK,RefreshMagCellsGrid) 3909 magDisplay.Bind(wg.EVT_GRID_LABEL_LEFT_DCLICK,OnRefreshKeep) 3886 3910 magDisplay.AutoSizeColumns(False) 3887 3911 for r in range(magDisplay.GetNumberRows()):
Note: See TracChangeset
for help on using the changeset viewer.