Changeset 3197
- Timestamp:
- Dec 19, 2017 2:24:36 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r3195 r3197 2217 2217 ''' 2218 2218 def __init__(self,parent,title,prompt,value='',size=(200,-1),help=''): 2219 wx.Dialog.__init__(self,parent,wx.ID_ANY,title, 2220 pos=wx.DefaultPosition, 2221 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 2219 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, 2220 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) 2222 2221 self.value = value 2223 2222 self.prompt = prompt … … 2225 2224 self.panel = wx.Panel(self) 2226 2225 mainSizer = wx.BoxSizer(wx.VERTICAL) 2226 mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER) 2227 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 2228 self.valItem = wx.TextCtrl(self.panel,-1,value=self.value,size=size) 2229 sizer1.Add(self.valItem,0,wx.ALIGN_CENTER) 2227 2230 if help: 2228 sizer1 = wx.BoxSizer(wx.HORIZONTAL)2229 sizer1.Add((-1,-1),1, wx.EXPAND, 0)2230 2231 sizer1.Add(HelpButton(self.panel,help),0,wx.ALIGN_RIGHT|wx.ALL) 2231 mainSizer.Add(sizer1,0,wx.ALIGN_RIGHT|wx.EXPAND) 2232 mainSizer.Add(wx.StaticText(self.panel,-1,self.prompt),0,wx.ALIGN_CENTER) 2233 self.valItem = wx.TextCtrl(self.panel,-1,value=self.value,size=size) 2234 mainSizer.Add(self.valItem,0,wx.ALIGN_CENTER) 2232 mainSizer.Add(sizer1,0,wx.ALIGN_CENTER) 2235 2233 btnsizer = wx.StdDialogButtonSizer() 2236 2234 OKbtn = wx.Button(self.panel, wx.ID_OK) -
trunk/GSASIIphsGUI.py
r3194 r3197 74 74 ''' Special version of MessageBox that displays magnetic spin text 75 75 ''' 76 def __init__(self,parent,title,text,table, names,spins,):76 def __init__(self,parent,title,text,table,Cents,names,spins,): 77 77 wx.Dialog.__init__(self,parent,wx.ID_ANY,title,pos=wx.DefaultPosition, 78 78 style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,size=wx.Size(420,350)) … … 86 86 first = text[0].split(':')[-1].strip() 87 87 cents = [0,] 88 if 'P' != first[0]:88 if len(Cents): 89 89 cents = text[-1].split(';') 90 90 for line in text: … … 159 159 mainSizer.Add(self.inv,0,WACV) 160 160 if SGData['SGLatt'] != 'P': 161 LattOp = G2spc.Latt2text(SGData['SG Latt']).split(';')161 LattOp = G2spc.Latt2text(SGData['SGCen']).split(';') 162 162 self.latt = wx.RadioBox(panel,-1,'Choose cell centering?',choices=LattOp) 163 163 self.latt.Bind(wx.EVT_RADIOBOX, self.OnOpSelect) … … 408 408 SGTxt.SetValue(self.newSpGrp) 409 409 msg = 'Space Group Error' 410 Style = wx.ICON_EXCLAMATION411 410 Text = '\n'.join(text) 412 wx.MessageBox(Text,caption=msg,style= Style)411 wx.MessageBox(Text,caption=msg,style=wx.ICON_EXCLAMATION) 413 412 else: 414 413 text,table = G2spc.SGPrint(SGData) … … 1354 1353 1355 1354 def OnSpaceGroup(event): 1355 if generalData['SGData']['SGFixed']: 1356 msg = 'Fixed cif generated magnetic space group' 1357 text = 'space group can not be changed' 1358 wx.MessageBox(text,caption=msg,style=wx.ICON_EXCLAMATION) 1359 text,table = G2spc.SGPrint(generalData['SGData']) 1360 SGTxt.SetLabel(generalData['SGData']['SpGrp']) 1361 msg = 'cif based Space Group Information' 1362 G2G.SGMessageBox(General,msg,text,table).Show() 1363 return 1356 1364 helptext = '''\t\t\tGSAS-II space group information 1357 1365 … … 1394 1402 else: 1395 1403 msg = 'Space Group Error' 1396 Style = wx.ICON_EXCLAMATION 1397 wx.MessageBox('Invalid space group number',caption=msg,style=Style) 1404 wx.MessageBox('Invalid space group number',caption=msg,style=wx.ICON_EXCLAMATION) 1398 1405 return 1399 1406 except: … … 1414 1421 SGTxt.SetLabel(generalData['SGData']['SpGrp']) 1415 1422 msg = 'Space Group Error' 1416 Style = wx.ICON_EXCLAMATION1417 1423 Text = '\n'.join(text) 1418 wx.MessageBox(Text,caption=msg,style= Style)1424 wx.MessageBox(Text,caption=msg,style=wx.ICON_EXCLAMATION) 1419 1425 else: 1420 1426 text,table = G2spc.SGPrint(SGData) … … 1727 1733 1728 1734 def OnSpinOp(event): 1735 if SGData['SGFixed']: 1736 msg = 'Fixed cif generated spins' 1737 text = 'Spin configuration can not be changed; it will be reset' 1738 wx.MessageBox(text,caption=msg,style=wx.ICON_EXCLAMATION) 1739 wx.CallAfter(UpdateGeneral) 1740 return 1729 1741 Obj = event.GetEventObject() 1730 1742 isym = Indx[Obj.GetId()] … … 1737 1749 showSpins.SetValue(False) 1738 1750 msg = 'Magnetic spin operators for '+SGData['MagSpGrp'] 1739 text,table = G2spc.SGPrint(SGData,AddInv= True)1751 text,table = G2spc.SGPrint(SGData,AddInv=not SGData['SGFixed']) 1740 1752 text[0] = ' Magnetic Space Group: '+SGData['MagSpGrp'] 1741 1753 text[3] = ' The magnetic lattice point group is '+SGData['MagPtGp'] 1742 SGMagSpinBox(General,msg,text,table, OprNames,SpnFlp).Show()1754 SGMagSpinBox(General,msg,text,table,SGData['SGCen'],OprNames,SpnFlp).Show() 1743 1755 1744 1756 SGData = generalData['SGData'] 1745 1757 Indx = {} 1746 MagSym = generalData['SGData'][' SpGrp'].split()1758 MagSym = generalData['SGData']['MagSpGrp'] 1747 1759 magSizer = wx.BoxSizer(wx.VERTICAL) 1748 1760 magSizer.Add(wx.StaticText(General,label=' Magnetic spin operator selection:'),0,WACV) 1749 if not len(GenSym):1750 magSizer.Add(wx.StaticText(General,label=' No spin inversion allowed'),0,WACV)1751 return magSizer1752 1761 spinSizer = wx.BoxSizer(wx.HORIZONTAL) 1753 spinColor = ['black','red'] 1754 spCode = {-1:'red',1:'black'} 1755 for isym,sym in enumerate(GenSym): 1756 spinSizer.Add(wx.StaticText(General,label=' %s: '%(sym.strip())),0,WACV) 1757 spinOp = wx.ComboBox(General,value=spCode[SGData['SGSpin'][isym]],choices=spinColor, 1758 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1759 Indx[spinOp.GetId()] = isym 1760 spinOp.Bind(wx.EVT_COMBOBOX,OnSpinOp) 1761 spinSizer.Add(spinOp,0,WACV) 1762 MagSym = G2spc.MagSGSym(SGData) 1763 SGData['MagSpGrp'] = MagSym 1764 OprNames,SpnFlp = G2spc.GenMagOps(SGData) 1762 if SGData['SGFixed']: 1763 SpnFlp = SGData['SpnFlp'] 1764 OprNames = G2spc.GenMagOps(SGData)[0] 1765 else: 1766 if not len(GenSym): 1767 magSizer.Add(wx.StaticText(General,label=' No spin inversion allowed'),0,WACV) 1768 else: 1769 spinColor = ['black','red'] 1770 spCode = {-1:'red',1:'black'} 1771 for isym,sym in enumerate(GenSym): 1772 spinSizer.Add(wx.StaticText(General,label=' %s: '%(sym.strip())),0,WACV) 1773 spinOp = wx.ComboBox(General,value=spCode[SGData['SGSpin'][isym]],choices=spinColor, 1774 style=wx.CB_READONLY|wx.CB_DROPDOWN) 1775 Indx[spinOp.GetId()] = isym 1776 spinOp.Bind(wx.EVT_COMBOBOX,OnSpinOp) 1777 spinSizer.Add(spinOp,0,WACV) 1778 MagSym = G2spc.MagSGSym(SGData) 1779 SGData['MagSpGrp'] = MagSym 1780 OprNames,SpnFlp = G2spc.GenMagOps(SGData) 1781 SGData['SpnFlp'] = SpnFlp 1765 1782 SGData['OprNames'] = OprNames 1766 SGData['SpnFlp'] = SpnFlp1767 1783 spinSizer.Add(wx.StaticText(General,label=' Magnetic space group: %s '%(MagSym)),0,WACV) 1768 1784 showSpins = wx.CheckBox(General,label=' Show spins?') … … 2157 2173 G2G.HorizontalLine(mainSizer,General) 2158 2174 2175 if 'SGFixed' not in generalData['SGData']: 2176 generalData['SGData']['SGFixed'] = False 2177 2159 2178 if generalData['Type'] == 'magnetic': 2160 GenSym,GenFlg = G2spc.GetGenSym(generalData['SGData']) 2161 generalData['SGData']['GenSym'] = GenSym 2162 generalData['SGData']['GenFlg'] = GenFlg 2179 if not generalData['SGData']['SGFixed']: 2180 GenSym,GenFlg = G2spc.GetGenSym(generalData['SGData']) 2181 generalData['SGData']['GenSym'] = GenSym 2182 generalData['SGData']['GenFlg'] = GenFlg 2183 generalData['SGData']['MagSpGrp'] = G2spc.MagSGSym(generalData['SGData']) 2163 2184 mainSizer.Add(MagSizer()) 2164 2185 G2G.HorizontalLine(mainSizer,General) … … 2614 2635 SytSym,Mul,Nop,dupDir = G2spc.SytSym(atomData[row][colX:colX+3],SGData) 2615 2636 CSI = G2spc.GetCSpqinel(SytSym,SpnFlp,dupDir) 2616 print (SytSym,Nop,SpnFlp[Nop],CSI,dupDir)2637 # print (SytSym,Nop,SpnFlp[Nop],CSI,dupDir) 2617 2638 for i in range(3): 2618 2639 ci = i+colM … … 4747 4768 elif generalData['Type'] == 'magnetic': 4748 4769 cx,ct,cs,ci = [2,1,9,20] #x, type, style & index 4770 drawingData['vdwScale'] = 0.20 4749 4771 drawingData['atomPtrs'] = [cx,ct,cs,ci] 4750 4772 if not drawingData.get('Atoms'): -
trunk/GSASIIspc.py
r3194 r3197 15 15 # $Id$ 16 16 ########### SVN repository information ################### 17 from __future__ import division, print_function 17 18 import numpy as np 18 19 import numpy.linalg as nl … … 44 45 45 46 * 'SpGrp': space group symbol, slightly cleaned up 47 * 'SGFixed': True if space group data can not be changed, e.g. from magnetic cif; otherwise False 46 48 * 'SGLaue': one of '-1', '2/m', 'mmm', '4/m', '4/mmm', '3R', 47 49 '3mR', '3', '3m1', '31m', '6/m', '6/mmm', 'm3', 'm3m' … … 76 78 SGData['SGLatt'] = LattSym[SGInfo[2]-1] 77 79 SGData['SGUniq'] = UniqSym[SGInfo[3]+1] 80 SGData['SGFixed'] = False 78 81 if SGData['SGLatt'] == 'P': 79 82 SGData['SGCen'] = np.array(([0,0,0],)) … … 369 372 SGTable - list of strings for each of the operations 370 373 ''' 371 Mult = len(SGData['SGCen'])*len(SGData['SGOps'])*(int(SGData['SGInv'])+1) 374 if SGData['SGFixed']: #inverses included in ops for cif fixed 375 Mult = len(SGData['SGCen'])*len(SGData['SGOps']) 376 else: 377 Mult = len(SGData['SGCen'])*len(SGData['SGOps'])*(int(SGData['SGInv'])+1) 372 378 SGText = [] 373 379 SGText.append(' Space Group: '+SGData['SpGrp']) … … 390 396 SGText.append(' The location of the origin is arbitrary in '+SGData['SGPolax']) 391 397 SGText.append(' ') 392 if SGData['SGLatt'] == 'P':398 if len(SGData['SGCen']) == 1: 393 399 SGText.append(' The equivalent positions are:\n') 394 400 else: 395 401 SGText.append(' The equivalent positions are:') 396 SGText.append(' ('+Latt2text(SGData['SG Latt'])+')+\n')402 SGText.append(' ('+Latt2text(SGData['SGCen'])+')+\n') 397 403 SGTable = [] 398 404 for i,Opr in enumerate(SGData['SGOps']): … … 476 482 return Fld 477 483 478 def Latt2text(Latt): 479 "From lattice type ('P',A', etc.) returns ';' delimited cell centering vectors" 480 lattTxt = {'A':'0,0,0; 0,1/2,1/2','B':'0,0,0; 1/2,0,1/2', 481 'C':'0,0,0; 1/2,1/2,0','I':'0,0,0; 1/2,1/2,1/2', 482 'F':'0,0,0; 0,1/2,1/2; 1/2,0,1/2; 1/2,1/2,0', 483 'R':'0,0,0; 1/3,2/3,2/3; 2/3,1/3,1/3','P':'0,0,0'} 484 return lattTxt[Latt] 485 484 def Latt2text(Cen): 485 "From lattice centering vectors returns ';' delimited cell centering vectors" 486 lattTxt = '' 487 fracList = ['1/2','1/3','2/3','1/4','3/4','1/5','2/5','3/5','4/5','1/6','5/6', 488 '1/7','2/7','3/7','4/7','5/7','6/7','1/8','3/8','5/8','7/8','1/9','2/9','4/9','5/9','7/9','8/9'] 489 mulList = [2,3,3,4,4,5,5,5,5,6,6,7,7,7,7,7,7,8,8,8,8,9,9,9,9,9,9] 490 prodList = [1.,1.,2.,1.,3.,1.,2.,3.,4.,1.,5.,1.,2.,3.,4.,5.,6.,1.,3.,5.,7.,1.,2.,4.,5.,7.,8.] 491 for i,cen in enumerate(Cen): 492 txt = '' 493 for icen in cen: 494 if not icen: 495 txt += '0,' 496 continue 497 for mul,prod,frac in zip(mulList,prodList,fracList): 498 if abs(icen*mul-prod) < 1.e-5: 499 txt += frac+',' 500 break 501 lattTxt += txt[:-1]+'; ' 502 if i and not i%8: 503 lattTxt += '\n ' 504 return lattTxt[:-2] 505 486 506 def SpaceGroup(SGSymbol): 487 507 ''' … … 704 724 SGPtGrp = SGData['SGPtGrp'] 705 725 if not len(SpnFlp): 706 SG Laue['MagPtGp'] = SGPtGrp726 SGData['MagPtGp'] = SGPtGrp 707 727 return SGData['SpGrp'] 708 728 magSym = SGData['SpGrp'].split() … … 931 951 return ' '.join(magSym) 932 952 933 def MagSGSpin(MagSym,SGData): 934 print(MagSym) 935 SGLaue = SGData['SGLaue'] 936 SpnFlp = SGData['SGSpin'] 937 GenSym = SGData['GenSym'] 938 SGPtGrp = SGData['SGPtGrp'] 939 magSym = MagSym.split() 940 if SGLaue in ['-1',]: 941 SGData['MagPtGp'] = SGPtGrp 942 if "'" in magSym[1]: 943 SpnFlp[0] = -1 944 SGData['MagPtGp'] += "'" 945 if magSym[0] in ['A','B','C','I'] and SGData['SpGrp'] != 'I 41/a': 946 if SpnFlp[1] < 0: 947 magSym[0] += '(P)' 948 elif SGPtGrp in ['mmm','mm2','m2m','2mm','222']: 949 SGData['MagPtGp'] = '' 950 for i in [0,1,2]: 951 SGData['MagPtGp'] += SGPtGrp[i] 952 if "'" in magSym[i+1]: 953 SpnFlp[i] = -1 954 SGData['MagPtGp'] += "'" 955 if len(GenSym) > 3: 956 if 'F' in magSym[0]: 957 if 'A' in magSym[0]: 958 SpnFlp[3] = 1 959 elif 'B' in magSym[0]: 960 SpnFlp[4] = 1 961 elif 'C' in magSym[0]: 962 SpnFlp[5] = 1 963 elif 'P' in magSym[0]: 964 SpnFlp[3] = -1 965 elif SGLaue == '6/mmm': #ok 966 SGData['MagPtGp'] = '' 967 if len(GenSym) == 2: 968 for i in [0,1]: 969 SGData['MagPtGp'] += SGPtGrp[i] 970 if "'" in magSym[i+2]: 971 SpnFlp[i] = -1 972 SGData['MagPtGp'] += "'" 953 def MagText2MTS(mcifOpr): 954 "From magnetic space group cif text returns matrix/translation + spin flip" 955 XYZ = {'x':[1,0,0],'-x':[-1,0,0],'y':[0,1,0],'-y':[0,-1,0],'z':[0,0,1],'-z':[0,0,-1], 956 'x-y':[1,-1,0],'-x+y':[-1,1,0],} 957 # TRA = {'+1/2':0.5,'+1/4':.25,'+3/4':.75,'+1/3':1./3.,'+2/3':2./3.,'+1/6':1./6.,'+5/6':5./6., 958 # '+1/9'} 959 ops = mcifOpr.split(",") 960 M = [] 961 T = [] 962 for op in ops[:3]: 963 ip = len(op) 964 if '/' in op: 965 ip = op.index('/')-2 966 T.append(eval(op[ip:])) 967 # T.append(TRA[op[ip:]]) 973 968 else: 974 for i in [0,1,2]: 975 SGData['MagPtGp'] += SGPtGrp[i] 976 if "'" in magSym[i+1]: 977 SpnFlp[i] = -1 978 SGData['MagPtGp'] += "'" 979 elif SGLaue == '4/mmm': 980 if len(GenSym) == 2: 981 for i in [0,1]: 982 SGData['MagPtGp'] += SGPtGrp[i] 983 if "'" in magSym[i+2]: 984 SpnFlp[i] = -1 985 SGData['MagPtGp'] += "'" 986 # else: 987 # if '/' in magSym[1]: #P 4/m m m, etc. 988 # sym = magSym[1].split('/') 989 # Ptsym = ['4','m'] 990 # magPtGp = ['','m','m'] 991 # for i in [0,1,2]: 992 # if SpnFlp[i] < 0: 993 # if i: 994 # magSym[i+1] += "'" 995 # magPtGp[i] += "'" 996 # else: 997 # sym[1] += "'" 998 # Ptsym[1] += "'" 999 # if SpnFlp[1]*SpnFlp[2] < 0: 1000 # sym[0] += "'" 1001 # Ptsym[0] += "'" 1002 # magSym[1] = '/'.join(sym) 1003 # magPtGp[0] = '/'.join(Ptsym) 1004 # if SpnFlp[3] < 0: 1005 # magSym[0] += '(P)' 1006 # else: 1007 # for i in [0,1]: 1008 # if SpnFlp[i] < 0: 1009 # magSym[i+2] += "'" 1010 # if SpnFlp[0]*SpnFlp[1] < 0: 1011 # magSym[1] += "'" 1012 # if SpnFlp[2] < 0: 1013 # magSym[0] += '(P)' 1014 # SGData['MagPtGp'] = ''.join(magPtGp) 1015 elif SGLaue in ['2/m','4/m','6/m']: #all ok 1016 Uniq = {'a':1,'b':2,'c':3,'':1} 1017 SGData['MagPtGp'] = '' 1018 Ptsym = SGLaue.split('/') 1019 if len(GenSym) == 3: 1020 MPtSym = magSym[1].split('/') 1021 for i in [0,1,2]: 1022 if i == 2 and 'P' in magSym[0]: 1023 SpnFlp[i] = -1 1024 elif i < 2: 1025 SGData['MagPtGp'] += Ptsym[i] 1026 if "'" in MPtSym[i]: 1027 SpnFlp[i] = -1 1028 SGData['MagPtGp'] += "'" 1029 else: 1030 for i in range(len(GenSym)): 1031 if i and magSym[0] in ['A','B','C','I'] and SGData['SpGrp'] != 'I 41/a': 1032 if 'P' in magSym[0]: 1033 SpnFlp[i] = -1 1034 else: 1035 SGData['MagPtGp'] += Ptsym[i] 1036 if "'" in magSym[i+1]: 1037 SpnFlp[i] = -1 1038 SGData['MagPtGp'] += "'" 1039 # elif SGLaue in ['3','3m1','31m']: #ok 1040 ## GSASIIpath.IPyBreak() 1041 # Ptsym = list(SGLaue) 1042 # if len(GenSym) == 1: #all ok 1043 # id = 2 1044 # if (len(magSym) == 4) and (magSym[2] == '1'): 1045 # id = 3 1046 # if '3' in GenSym[0]: 1047 # id = 1 1048 # magSym[id].strip("'") 1049 # if SpnFlp[0] < 0: 1050 # magSym[id] += "'" 1051 # Ptsym[id-1] += "'" 1052 # elif len(GenSym) == 2: 1053 # if 'R' in GenSym[1]: 1054 # magSym[-1].strip("'") 1055 # if SpnFlp[0] < 0: 1056 # magSym[-1] += "'" 1057 # Ptsym[-1] += "'" 1058 # else: 1059 # i,j = [1,2] 1060 # if magSym[2] == '1': 1061 # i,j = [1,3] 1062 # magSym[i].strip("'") 1063 # Ptsym[i-1].strip("'") 1064 # magSym[j].strip("'") 1065 # Ptsym[j-1].strip("'") 1066 # if SpnFlp[:2] == [1,-1]: 1067 # magSym[i] += "'" 1068 # Ptsym[i-1] += "'" 1069 # elif SpnFlp[:2] == [-1,-1]: 1070 # magSym[j] += "'" 1071 # Ptsym[j-1] += "'" 1072 # elif SpnFlp[:2] == [-1,1]: 1073 # magSym[i] += "'" 1074 # Ptsym[i-1] += "'" 1075 # magSym[j] += "'" 1076 # Ptsym[j-1] += "'" 1077 # else: 1078 # if 'c' not in magSym[2]: 1079 # i,j = [1,2] 1080 # magSym[i].strip("'") 1081 # Ptsym[i-1].strip("'") 1082 # magSym[j].strip("'") 1083 # Ptsym[j-1].strip("'") 1084 # if SpnFlp[:2] == [1,-1]: 1085 # magSym[i] += "'" 1086 # Ptsym[i-1] += "'" 1087 # elif SpnFlp[:2] == [-1,-1]: 1088 # magSym[j] += "'" 1089 # Ptsym[j-1] += "'" 1090 # elif SpnFlp[:2] == [-1,1]: 1091 # magSym[i] += "'" 1092 # Ptsym[i-1] += "'" 1093 # magSym[j] += "'" 1094 # Ptsym[j-1] += "'" 1095 # SGData['MagPtGp'] = ''.join(Ptsym) 1096 # elif SGData['SGPtGrp'] == '23' and len(magSym): 1097 # SGData['MagPtGp'] = '23' 1098 # if SpnFlp[0] < 0: 1099 # magSym[0] += '(P)' 1100 # elif SGData['SGPtGrp'] == 'm3': 1101 # SGData['MagPtGp'] = "m3" 1102 # if SpnFlp[0] < 0: 1103 # magSym[1] += "'" 1104 # magSym[2] += "'" 1105 # SGData['MagPtGp'] = "m'3'" 1106 # if SpnFlp[1] < 0: 1107 # magSym[0] += '(P)' 1108 # if not 'm' in magSym[1]: #only Ia3 1109 # magSym[1].strip("'") 1110 # SGData['MagPtGp'] = "m3'" 1111 # elif SGData['SGPtGrp'] in ['432','-43m']: 1112 # Ptsym = SGData['SGPtGrp'].split('3') 1113 # if SpnFlp[0] < 0: 1114 # magSym[1] += "'" 1115 # Ptsym[0] += "'" 1116 # magSym[3] += "'" 1117 # Ptsym[1] += "'" 1118 # if SpnFlp[1] < 0: 1119 # magSym[0] += '(P)' 1120 # SGData['MagPtGp'] = '3'.join(Ptsym) 1121 # elif SGData['SGPtGrp'] == 'm-3m': 1122 # Ptsym = ['m','3','m'] 1123 # if SpnFlp[:2] == [-1,1]: 1124 # magSym[1] += "'" 1125 # Ptsym[0] += "'" 1126 # magSym[2] += "'" 1127 # Ptsym[1] += "'" 1128 # elif SpnFlp[:2] == [1,-1]: 1129 # magSym[3] += "'" 1130 # Ptsym[2] += "'" 1131 # elif SpnFlp[:2] == [-1,-1]: 1132 # magSym[1] += "'" 1133 # Ptsym[0] += "'" 1134 # magSym[2] += "'" 1135 # Ptsym[1] += "'" 1136 # magSym[3] += "'" 1137 # Ptsym[2] += "'" 1138 # if SpnFlp[2] < 0: 1139 # magSym[0] += '(P)' 1140 # SGData['MagPtGp'] = ''.join(Ptsym) 1141 print( SpnFlp) 1142 return SpnFlp 1143 969 T.append(0.) 970 M.append(XYZ[op[:ip]]) 971 spnflp = 1 972 if '-1' in ops[3]: 973 spnflp = -1 974 return np.array(M),np.array(T),spnflp 975 1144 976 def GenMagOps(SGData): 1145 977 FlpSpn = SGData['SGSpin'] 1146 978 Nsym = len(SGData['SGOps']) 1147 Nfl = len(SGData['GenFlg'])1148 979 Ncv = len(SGData['SGCen']) 1149 980 sgOp = [M for M,T in SGData['SGOps']] 1150 981 OprName = [GetOprPtrName(str(irtx))[1] for irtx in PackRot(SGData['SGOps'])] 1151 if SGData['SGInv'] :982 if SGData['SGInv'] and not SGData.get('SGFixed',False): 1152 983 Nsym *= 2 1153 984 sgOp += [-M for M,T in SGData['SGOps']] … … 1161 992 OprNames += OprName 1162 993 SpnFlp = np.ones(Nsym,dtype=np.int) 1163 for ieqv in range(Nsym): 1164 for iunq in range(Nfl): 1165 if SGData['SGGen'][ieqv] & SGData['GenFlg'][iunq]: 1166 SpnFlp[ieqv] *= FlpSpn[iunq] 1167 # print '\nMagSpGrp:',SGData['MagSpGrp'],Ncv 1168 # print 'GenFlg:',SGData['GenFlg'] 1169 # print 'GenSym:',SGData['GenSym'] 1170 # print 'FlpSpn:',Nfl,FlpSpn 1171 detM = [nl.det(M) for M in sgOp] 1172 for incv in range(Ncv): 1173 if incv: 1174 SpnFlp = np.concatenate((SpnFlp,SpnFlp[:Nsym]*FlpSpn[Nfl+incv-1])) 1175 if ' 1bar ' in SGData['GenSym'][0] and FlpSpn[0] < 0: 1176 detM[1] = 1. 1177 MagMom = SpnFlp*np.array(Ncv*detM) 1178 SGData['MagMom'] = MagMom 994 Nfl = len(SGData.get('GenFlg',[])) 995 if Nfl: 996 for ieqv in range(Nsym): 997 for iunq in range(Nfl): 998 if SGData['SGGen'][ieqv] & SGData['GenFlg'][iunq]: 999 SpnFlp[ieqv] *= FlpSpn[iunq] 1000 # print '\nMagSpGrp:',SGData['MagSpGrp'],Ncv 1001 # print 'GenFlg:',SGData['GenFlg'] 1002 # print 'GenSym:',SGData['GenSym'] 1003 # print 'FlpSpn:',Nfl,FlpSpn 1004 detM = [nl.det(M) for M in sgOp] 1005 for incv in range(Ncv): 1006 if incv: 1007 SpnFlp = np.concatenate((SpnFlp,SpnFlp[:Nsym]*FlpSpn[Nfl+incv-1])) 1008 if ' 1bar ' in SGData['GenSym'][0] and FlpSpn[0] < 0: 1009 detM[1] = 1. 1010 MagMom = SpnFlp*np.array(Ncv*detM) 1011 SGData['MagMom'] = MagMom 1179 1012 # print 'SgOps:',OprNames 1180 1013 # print 'SGGen:',SGData['SGGen'] … … 1189 1022 if Opr < 0: 1190 1023 opNum += Nops 1191 if SGData['SGInv'] :1024 if SGData['SGInv'] and not SGData['SGFixed']: 1192 1025 Nops *= 2 1193 1026 opNum += cent*Nops … … 2114 1947 '1074003968':' m(120) ','1074790400':' m(210) ','1073741952':' m(+-0) ','1073741826':' 2(001) ', 2115 1948 '1073741856':' 2(100) ','1073741832':' 2(010) ','1073742848':' 2(110) ','1073872896':' 2(120) ', 2116 '1074266112':' 2(210) ','1073742080':' 2(+-0) ','1073741825':' -1 ' 1949 '1074266112':' 2(210) ','1073742080':' 2(+-0) ','1073741825':' -1 ', 2117 1950 } 2118 1951 … … 2235 2068 def GetKNsym(key): 2236 2069 'Needs a doc string' 2237 return KNsym[key] 2070 try: 2071 return KNsym[key] 2072 except KeyError: 2073 return 'sp' 2238 2074 2239 2075 def GetNXUPQsym(siteSym): -
trunk/imports/G2phase_CIF.py
r3194 r3197 160 160 if not SpGrp: 161 161 MSpGrp = blk.get("_space_group.magn_name_BNS",'') 162 if not MSpGrp: 163 MSpGrp = blk.get("_space_group_magn.name_BNS",'') 164 if not MSpGrp: 165 self.warnings += 'No magnetic BNS space group name was found in the CIF.' 166 self.errors = msg 167 self.warnings += msg 168 return False 162 169 SpGrp = MSpGrp.replace("'",'') 163 170 SpGrp = SpGrp[:2]+SpGrp[2:].replace('_','') #get rid of screw '_' 164 if '_' in SpGrp[1]: SpGrp = SpGrp.split('_')[ 1]165 if SpGrp: #TODO need to decide if read nuclear phase or magnetic phase166 167 168 171 if '_' in SpGrp[1]: SpGrp = SpGrp.split('_')[0]+SpGrp[3:] 172 SpGrp = G2spc.StandardizeSpcName(SpGrp) 173 magnetic = True 174 self.MPhase['General']['Type'] = 'magnetic' 175 self.MPhase['General']['AtomPtrs'] = [3,1,10,12] 169 176 if Super: 170 177 sspgrp = blk.get("_space_group_ssg_name",'') … … 208 215 self.Phase['General']['SGData'] = SGData 209 216 if magnetic: 217 SGData['SGFixed'] = True 218 try: 219 sgoploop = blk.GetLoop('_space_group_symop_magn.id') 220 sgcenloop = blk.GetLoop('_space_group_symop_magn_centering.id') 221 opid = sgoploop.GetItemPosition('_space_group_symop_magn_operation.xyz')[1] 222 centid = sgcenloop.GetItemPosition('_space_group_symop_magn_centering.xyz')[1] 223 224 except KeyError: #old mag cif names 225 sgoploop = blk.GetLoop('_space_group_symop.magn_id') 226 sgcenloop = blk.GetLoop('_space_group_symop.magn_centering_id') 227 opid = sgoploop.GetItemPosition('_space_group_symop.magn_operation_xyz')[1] 228 centid = sgcenloop.GetItemPosition('_space_group_symop.magn_centering_xyz')[1] 229 SGData['SGOps'] = [] 230 SGData['SGCen'] = [] 231 spnflp = [] 232 for op in sgoploop: 233 M,T,S = G2spc.MagText2MTS(op[opid]) 234 SGData['SGOps'].append([np.array(M,dtype=float),T]) 235 spnflp.append(S) 236 censpn = [] 237 for cent in sgcenloop: 238 M,C,S = G2spc.MagText2MTS(cent[centid]) 239 SGData['SGCen'].append(C) 240 censpn += list(np.array(spnflp)*S) 210 241 self.MPhase['General']['SGData'] = SGData 211 GenSym,GenFlg = G2spc.GetGenSym(SGData) 212 self.MPhase['General']['SGData']['GenSym'] = GenSym 213 self.MPhase['General']['SGData']['GenFlg'] = GenFlg 214 self.MPhase['General']['SGData']['SGSpin'] = G2spc.MagSGSpin(MSpGrp,SGData) 242 self.MPhase['General']['SGData']['SpnFlp'] = censpn 243 self.MPhase['General']['SGData']['MagSpGrp'] = MSpGrp 244 self.MPhase['General']['SGData']['MagPtGp'] = blk.get('_space_group.magn_point_group') 245 # GenSym,GenFlg = G2spc.GetGenSym(SGData) 246 # self.MPhase['General']['SGData']['GenSym'] = GenSym 247 # self.MPhase['General']['SGData']['GenFlg'] = GenFlg 215 248 if Super: 216 249 E,SSGData = G2spc.SSpcGroup(SGData,SuperSg) … … 244 277 self.isodistort_warnings += '\natom types are missing. \n Check & revise atom types as needed' 245 278 if magnetic: 246 magatomloop = blk.GetLoop('_atom_site_moment_label') 247 magatomkeys = [i.lower() for i in magatomloop.keys()] 248 magatomlabels = blk.get('_atom_site_moment_label') 279 try: 280 magmoment = '_atom_site_moment.label' 281 magatomloop = blk.GetLoop(magmoment) 282 magatomkeys = [i.lower() for i in magatomloop.keys()] 283 magatomlabels = blk.get(magmoment) 284 G2MagDict = {'_atom_site_moment.label': 0, 285 '_atom_site_moment.crystalaxis_x':7, 286 '_atom_site_moment.crystalaxis_y':8, 287 '_atom_site_moment.crystalaxis_z':9} 288 except KeyError: 289 magmoment = '_atom_site_moment_label' 290 magatomloop = blk.GetLoop(magmoment) 291 magatomkeys = [i.lower() for i in magatomloop.keys()] 292 magatomlabels = blk.get(magmoment) 293 G2MagDict = {'_atom_site_moment_label': 0, 294 '_atom_site_moment_crystalaxis_x':7, 295 '_atom_site_moment_crystalaxis_y':8, 296 '_atom_site_moment_crystalaxis_z':9} 297 249 298 if blk.get('_atom_site_aniso_label'): 250 299 anisoloop = blk.GetLoop('_atom_site_aniso_label') … … 296 345 '_atom_site_aniso_u_13' : 15, 297 346 '_atom_site_aniso_u_23' : 16, } 298 G2MagDict = {'_atom_site_moment_label': 0,299 '_atom_site_moment_crystalaxis_x':7,300 '_atom_site_moment_crystalaxis_y':8,301 '_atom_site_moment_crystalaxis_z':9}302 347 303 348 ranIdlookup = {} … … 344 389 if magnetic and atomlist[0] in magatomlabels: 345 390 matomlist = atomlist[:7]+[0.,0.,0.,]+atomlist[7:] 346 for mval,mkey in zip(magatomloop.GetKeyedPacket( '_atom_site_moment_label',atomlist[0]),magatomkeys):391 for mval,mkey in zip(magatomloop.GetKeyedPacket(magmoment,atomlist[0]),magatomkeys): 347 392 mcol = G2MagDict.get(mkey,-1) 348 393 if mcol:
Note: See TracChangeset
for help on using the changeset viewer.