Changeset 3435


Ignore:
Timestamp:
Jun 14, 2018 3:31:10 PM (3 years ago)
Author:
vondreele
Message:

make new routine GetSpGrpfromUser? & use it inGeneral & Transform fo space group input
modify getHKLpeak to check for magnetic space group extinctions - passes hkl that is allowed by either.
modify G2pwdGUI to retain SGData in Unit Cell data (in ssopts dict)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r3429 r3435  
    326326        def OnSpaceGroup(event):
    327327            event.Skip()
    328             Flds = SGTxt.GetValue().split()
    329             Flds[0] = Flds[0].upper()
    330             #get rid of extra spaces between fields first
    331             for fld in Flds: fld = fld.strip()
    332             SpcGp = ' '.join(Flds)
     328            SpcGp = GetSpGrpfromUser(self.panel,self.newSpGrp)
    333329            if SpcGp == self.newSpGrp: #didn't change it!
    334330                return
     
    432428        sgSizer = wx.BoxSizer(wx.HORIZONTAL)
    433429        sgSizer.Add(wx.StaticText(self.panel,label='  Space group: '),0,WACV)
    434         SGTxt = wx.TextCtrl(self.panel,value=self.newSpGrp,style=wx.TE_PROCESS_ENTER)
    435         SGTxt.Bind(wx.EVT_TEXT_ENTER,OnSpaceGroup)
    436         SGTxt.Bind(wx.EVT_KILL_FOCUS,OnSpaceGroup)
     430        SGTxt = wx.Button(self.panel,wx.ID_ANY,self.newSpGrp,size=(100,-1))
     431        SGTxt.Bind(wx.EVT_BUTTON,OnSpaceGroup)
    437432        sgSizer.Add(SGTxt,0,WACV)
    438433        mainSizer.Add(sgSizer,0,WACV)
     
    943938################################################################################
    944939################################################################################
     940def GetSpGrpfromUser(parent,SpGrp):
     941    helptext = '''\t\t\tGSAS-II space group information
     942               
     943Space groups are entered here as given in Volume I or Volume A of the
     944International Tables using the short Hermann-Mauguin symbol,except that spaces
     945are placed between axial fields (e.g. "P 4/m m m", "F D 3 M" or "p -3 1 m").
     946NB: the cubic "bar" in "F d -3 m" is unnecessary, and upper/lower case is not required.
     947
     948Where a centrosymmetric tetragonal or cubic space group has alternate origin settings,
     949Origin choice 2 (with the center of symmetry at the origin, which gives an -x,-y,-z
     950symmetry operator) is always used. Refer to the relevant pages in IT I or A to find
     951the offset in atom positions between the two choices.
     952
     953For rhombohedral space groups, (R xxx) the hexagonal setting is assumed. Append a
     954final R to the name (R xxx R) to indicate that a rhombohedral cell should be
     955used (not recommended when alpha >> 120 or << 60, due to correlation.)
     956
     957For standard settings of space groups, space group numbers (1-230) can alternately
     958be entered.
     959
     960GSAS-II will accept non-standard settings of space groups. For example, space
     961group "P -1" can be set to include face centering, using symbol "F -1" and "P 1 1 21/a"
     962as a nonstandard version of "P 21/c".
     963
     964Review the symmetry operators generated by GSAS-II to confirm that you have
     965entered the right symbol for your structure.
     966'''
     967    dlg = G2G.SingleStringDialog(parent,'Get Space Group',
     968        '  Input the space group with spaces between axial fields  \n  (e.g. p 21/c, P 63/m m c, P 4/m m m) or enter a space\n  group number between 1 and 230.',
     969        value=SpGrp,help=helptext)
     970    if not dlg.Show():
     971        dlg.Destroy()
     972        return
     973    else:
     974        try:
     975            # has a space group number been input?
     976            spcnum = int(dlg.GetValue())
     977            if 1 <= spcnum <= 230:
     978                SpcGp = G2spc.spgbyNum[spcnum]
     979            else:
     980                msg = 'Space Group Error'
     981                wx.MessageBox('Invalid space group number',caption=msg,style=wx.ICON_EXCLAMATION)
     982                return
     983        except:
     984            #get rid of extra spaces between fields first
     985            Flds = dlg.GetValue().split()
     986            for fld in Flds: fld = fld.strip()
     987            SpcGp = ' '.join(Flds)
     988        finally:
     989            dlg.Destroy()
     990    return SpcGp
    945991   
    946992   
     
    13351381                    G2G.SGMessageBox(General,msg,text,table).Show()
    13361382                    return
    1337                 helptext = '''\t\t\tGSAS-II space group information
    1338                
    1339 Space groups are entered here as given in Volume I or Volume A of the
    1340 International Tables using the short Hermann-Mauguin symbol,except that spaces
    1341 are placed between axial fields (e.g. "P 4/m m m", "F D 3 M" or "p -3 1 m").
    1342 NB: the cubic "bar" in "F d -3 m" is unnecessary, and upper/lower case is not required.
    1343 
    1344 Where a centrosymmetric tetragonal or cubic space group has alternate origin settings,
    1345 Origin choice 2 (with the center of symmetry at the origin, which gives an -x,-y,-z
    1346 symmetry operator) is always used. Refer to the relevant pages in IT I or A to find
    1347 the offset in atom positions between the two choices.
    1348 
    1349 For rhombohedral space groups, (R xxx) the hexagonal setting is assumed. Append a
    1350 final R to the name (R xxx R) to indicate that a rhombohedral cell should be
    1351 used (not recommended when alpha >> 120 or << 60, due to correlation.)
    1352 
    1353 For standard settings of space groups, space group numbers (1-230) can alternately
    1354 be entered.
    1355 
    1356 GSAS-II will accept non-standard settings of space groups. For example, space
    1357 group "P -1" can be set to include face centering, using symbol "F -1" and "P 1 1 21/a"
    1358 as a nonstandard version of "P 21/c".
    1359 
    1360 Review the symmetry operators generated by GSAS-II to confirm that you have
    1361 entered the right symbol for your structure.
    1362 '''
    1363                 dlg = G2G.SingleStringDialog(General,'Get Space Group',
    1364                     '  Input the space group with spaces between axial fields  \n  (e.g. p 21/c, P 63/m m c, P 4/m m m) or enter a space\n  group number between 1 and 230.',
    1365                     value=SpGrp,help=helptext)
    1366                 if not dlg.Show():
    1367                     dlg.Destroy()
    1368                     return
    1369                 else:
    1370                     try:
    1371                         # has a space group number been input?
    1372                         spcnum = int(dlg.GetValue())
    1373                         if 1 <= spcnum <= 230:
    1374                             SpcGp = G2spc.spgbyNum[spcnum]
    1375                         else:
    1376                             msg = 'Space Group Error'
    1377                             wx.MessageBox('Invalid space group number',caption=msg,style=wx.ICON_EXCLAMATION)
    1378                             return
    1379                     except:
    1380                         #get rid of extra spaces between fields first
    1381                         Flds = dlg.GetValue().split()
    1382                         for fld in Flds: fld = fld.strip()
    1383                         SpcGp = ' '.join(Flds)
    1384                     finally:
    1385                         dlg.Destroy()
    13861383                # try a lookup on the user-supplied name
     1384                SpcGp = GetSpGrpfromUser(General,SpGrp)
    13871385                SpGrpNorm = G2spc.StandardizeSpcName(SpcGp)
    13881386                if SpGrpNorm:
  • trunk/GSASIIpwd.py

    r3231 r3435  
    10231023
    10241024def getHKLpeak(dmin,SGData,A,Inst=None):
    1025     'needs a doc string'
     1025    '''
     1026    Generates allowed by symmetry reflections with d >= dmin
     1027    NB: GenHKLf & checkMagextc return True for extinct reflections
     1028
     1029    :param dmin:  minimum d-spacing
     1030    :param SGData: space group data obtained from SpcGroup
     1031    :param A: lattice parameter terms A1-A6
     1032    :param Inst: instrument parameter info
     1033    :returns: HKLs: list hkl, etc for allowed reflections
     1034
     1035    '''
    10261036    HKL = G2lat.GenHLaue(dmin,SGData,A)       
    10271037    HKLs = []
    10281038    for h,k,l,d in HKL:
    10291039        ext = G2spc.GenHKLf([h,k,l],SGData)[0]
     1040        if ext and 'MagSpGrp' in SGData:
     1041            ext = G2spc.checkMagextc([h,k,l],SGData)
    10301042        if not ext:
    10311043            if Inst == None:
  • trunk/GSASIIpwdGUI.py

    r3420 r3435  
    28802880    def OnSpcSel(event):
    28812881        controls[13] = spcSel.GetString(spcSel.GetSelection())
     2882        ssopt['SGData'] = G2spc.SpcGroup(controls[13])[1]
    28822883        G2frame.dataWindow.RefineCell.Enable(True)
    28832884        OnHklShow(event)
     
    29652966        A = G2lat.cell2A(cell)
    29662967        spc = controls[13]
    2967         SGData = G2spc.SpcGroup(spc)[1]
     2968        SGData = ssopt.get('SGData',G2spc.SpcGroup(spc)[1])
    29682969        Symb = SGData['SpGrp']
    29692970        if ssopt.get('Use',False):
     
    32653266            dlg.Destroy()
    32663267           
     3268    def OnMagSel(event):
     3269        Obj = event.GetEventObject()
     3270        if Obj.GetValue():
     3271            SGData['SGSpin'] = [1,]*len(SGData['SGSpin'])
     3272            GenSym,GenFlg,BNSsym = G2spc.GetGenSym(SGData)
     3273            SGData['GenSym'] = GenSym
     3274            SGData['GenFlg'] = GenFlg
     3275            OprNames,SpnFlp = G2spc.GenMagOps(SGData)
     3276            SGData['SpnFlp'] = SpnFlp
     3277            SGData['MagSpGrp'] = G2spc.MagSGSym(SGData)
     3278        else:
     3279            del SGData['MagSpGrp']
     3280        OnHklShow(None)
     3281        ssopt['SGData'] = SGData
     3282        wx.CallAfter(UpdateUnitCellsGrid,G2frame,data)
     3283           
    32673284    def OnSpinOp(event):
    32683285        Obj = event.GetEventObject()
     
    33203337    if len(controls) < 14:              #add space group used in indexing
    33213338        controls.append(spaceGroups[bravaisSymb.index(controls[5])])
    3322     SGData = G2spc.SpcGroup(controls[13])[1]
     3339    SGData = ssopt.get('SGData',G2spc.SpcGroup(controls[13])[1])
    33233340    G2frame.GPXtree.SetItemPyData(UnitCellsId,data)            #update with volume
    33243341    bravaisNames = ['Cubic-F','Cubic-I','Cubic-P','Trigonal-R','Trigonal/Hexagonal-P',
     
    34153432        hklShow.Bind(wx.EVT_BUTTON,OnHklShow)
    34163433        littleSizer.Add(hklShow,0,WACV)
     3434    elif 'N' in Inst['Type'][0]:
     3435        MagSel = wx.CheckBox(G2frame.dataWindow,label="Magnetic?")
     3436        MagSel.SetValue('MagSpGrp' in SGData)
     3437        MagSel.Bind(wx.EVT_CHECKBOX,OnMagSel)
     3438        littleSizer.Add(MagSel,0,WACV)
    34173439    mainSizer.Add(littleSizer,0)
    34183440    mainSizer.Add((5,5),0)
    34193441    if 'N' in Inst['Type'][0]:
    3420         Indx = {}
    3421         GenSym,GenFlg,BNSsym = G2spc.GetGenSym(SGData)
    3422         SGData['GenSym'] = GenSym
    3423         SGData['SGGray'] = False
    34243442        neutSizer = wx.BoxSizer(wx.HORIZONTAL)
    3425         neutSizer.Add(wx.StaticText(G2frame.dataWindow,label=' BNS lattice: '),0,WACV)
    3426         BNS = wx.ComboBox(G2frame.dataWindow,value=SGData['BNSlattsym'][0],
    3427             choices=[SGData['SGLatt'],]+list(BNSsym.keys()),style=wx.CB_READONLY|wx.CB_DROPDOWN)
    3428         BNS.Bind(wx.EVT_COMBOBOX,OnBNSlatt)
    3429         neutSizer.Add(BNS,0,WACV)
    3430         spinColor = ['black','red']
    3431         spCode = {-1:'red',1:'black'}
    3432         for isym,sym in enumerate(GenSym[1:]):
    3433             neutSizer.Add(wx.StaticText(G2frame.dataWindow,label=' %s: '%(sym.strip())),0,WACV)               
    3434             spinOp = wx.ComboBox(G2frame.dataWindow,value=spCode[SGData['SGSpin'][isym+1]],choices=spinColor,
    3435                 style=wx.CB_READONLY|wx.CB_DROPDOWN)               
    3436             Indx[spinOp.GetId()] = isym
    3437             spinOp.Bind(wx.EVT_COMBOBOX,OnSpinOp)
    3438             neutSizer.Add(spinOp,0,WACV)
    3439         OprNames,SpnFlp = G2spc.GenMagOps(SGData)
    3440         SGData['SpnFlp'] = SpnFlp
    3441         showSpins = wx.Button(G2frame.dataWindow,label=' Show spins?')
    3442         showSpins.Bind(wx.EVT_BUTTON,OnShowSpins)
    3443         neutSizer.Add(showSpins,0,WACV)
     3443        if 'MagSpGrp' in SGData:
     3444            Indx = {}
     3445            GenSym,GenFlg,BNSsym = G2spc.GetGenSym(SGData)
     3446            SGData['GenSym'] = GenSym
     3447            SGData['SGGray'] = False
     3448            neutSizer.Add(wx.StaticText(G2frame.dataWindow,label=' BNS lattice: '),0,WACV)
     3449            BNS = wx.ComboBox(G2frame.dataWindow,value=SGData['BNSlattsym'][0],
     3450                choices=[SGData['SGLatt'],]+list(BNSsym.keys()),style=wx.CB_READONLY|wx.CB_DROPDOWN)
     3451            BNS.Bind(wx.EVT_COMBOBOX,OnBNSlatt)
     3452            neutSizer.Add(BNS,0,WACV)
     3453            spinColor = ['black','red']
     3454            spCode = {-1:'red',1:'black'}
     3455            for isym,sym in enumerate(GenSym[1:]):
     3456                neutSizer.Add(wx.StaticText(G2frame.dataWindow,label=' %s: '%(sym.strip())),0,WACV)               
     3457                spinOp = wx.ComboBox(G2frame.dataWindow,value=spCode[SGData['SGSpin'][isym+1]],choices=spinColor,
     3458                    style=wx.CB_READONLY|wx.CB_DROPDOWN)               
     3459                Indx[spinOp.GetId()] = isym
     3460                spinOp.Bind(wx.EVT_COMBOBOX,OnSpinOp)
     3461                neutSizer.Add(spinOp,0,WACV)
     3462            OprNames,SpnFlp = G2spc.GenMagOps(SGData)
     3463            SGData['SpnFlp'] = SpnFlp
     3464            showSpins = wx.Button(G2frame.dataWindow,label=' Show spins?')
     3465            showSpins.Bind(wx.EVT_BUTTON,OnShowSpins)
     3466            neutSizer.Add(showSpins,0,WACV)
    34443467        hklShow = wx.Button(G2frame.dataWindow,label="Show hkl positions")
    34453468        hklShow.Bind(wx.EVT_BUTTON,OnHklShow)
  • trunk/GSASIIspc.py

    r3434 r3435  
    19601960def checkHKLextc(HKL,SGData):
    19611961    '''
    1962     Checks if reflection extinct
     1962    Checks if reflection extinct - does not check centering
    19631963
    19641964    :param HKL:  [h,k,l]
    19651965    :param SGData: space group data obtained from SpcGroup
    1966     :returns: False if  extinct; True if allowed
     1966    :returns: True if extinct; False if allowed
    19671967
    19681968    '''
     
    19781978        else:
    19791979            if phkl%1.:
    1980                 return False
    1981     return True
     1980                return True
     1981    return False
    19821982
    19831983def checkMagextc(HKL,SGData):
    19841984    '''
    1985     Checks if reflection magnetically extinct;
     1985    Checks if reflection magnetically extinct; does fullcheck (centering, too)
    19861986    uses algorthm from Gallego, et al., J. Appl. Cryst. 45, 1236-1247 (2012)
    19871987
    19881988    :param HKL:  [h,k,l]
    19891989    :param SGData: space group data obtained from SpcGroup; must have magnetic symmetry SpnFlp data
    1990     :returns: False if magnetically extinct; True if allowed
     1990    :returns: True if magnetically extinct; False if allowed (to match GenHKLf)
    19911991
    19921992    '''
     
    19951995    OpM = np.array([op[0] for op in Ops])
    19961996    OpT = np.array([op[1] for op in Ops])
    1997     if SGData['SGInv']:
     1997    if SGData['SGInv'] and not SGData['SGFixed']:
    19981998        OpM = np.vstack((OpM,-OpM))
    19991999        OpT = np.vstack((OpT,-OpT))%1.
     
    20172017            Psum += pterm
    20182018    if nsum/nA > 1.:        #only need to look at nA=1 frok eq(8)
     2019        return False
     2020    if np.allclose(Psum,np.zeros(3)):
    20192021        return True
    2020     if np.allclose(Psum,np.zeros(3)):
    2021         return False
    20222022    else:
    20232023        if np.inner(HKL,Psum):
    2024             return False
    2025         return True
     2024            return True
     2025        return False
    20262026   
    20272027def checkSSextc(HKL,SSGData):
Note: See TracChangeset for help on using the changeset viewer.