Changeset 3192


Ignore:
Timestamp:
Dec 13, 2017 12:09:08 PM (4 years ago)
Author:
vondreele
Message:

the cif reader will now read magnetic cif files as two phases - one nuclear with all atoms & the other magnetic with just the magnetic atoms. NB: spin flips are not yet properly assigned; working on that.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r3191 r3192  
    885885            psub = self.GPXtree.AppendItem(parent=sub,text=PhaseName)
    886886            self.GPXtree.SetItemPyData(psub,rd.Phase)
     887            try:
     888                rd.MPhase['General']['Name'] = G2obj.MakeUniqueLabel(PhaseName+' mag',phaseNameList)
     889                PhaseName = rd.MPhase['General']['Name'][:]
     890                newPhaseList.append(PhaseName)
     891                psub = self.GPXtree.AppendItem(parent=sub,text=PhaseName)
     892                self.GPXtree.SetItemPyData(psub,rd.MPhase)
     893            except TypeError:
     894                pass
    887895            self.GPXtree.Expand(self.root) # make sure phases are seen
    888896            self.GPXtree.Expand(sub)
  • trunk/imports/G2phase_CIF.py

    r3191 r3192  
    3838    def __init__(self):
    3939        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
    40             extensionlist=('.CIF','.cif','.txt','.mcif'),
     40            extensionlist=('.CIF','.cif','.mcif'),
    4141            strictExtension=False,
    4242            formatName = 'CIF',
     
    161161                MSpGrp = blk.get("_space_group.magn_name_BNS",'')
    162162                SpGrp = MSpGrp.replace("'",'')
    163                 if '_' in SpGrp: SpGrp = SpGrp.split('_')[1]
     163                SpGrp = SpGrp[:2]+SpGrp[2:].replace('_','')   #get rid of screw '_'
     164                if '_' in SpGrp[1]: SpGrp = SpGrp.split('_')[1]
    164165                if SpGrp:   #TODO need to decide if read nuclear phase or magnetic phase
    165166                    magnetic = True
     
    241242                magatomloop = blk.GetLoop('_atom_site_moment_label')
    242243                magatomkeys = [i.lower() for i in magatomloop.keys()]
     244                magatomlabels = blk.get('_atom_site_moment_label')
    243245            if blk.get('_atom_site_aniso_label'):
    244246                anisoloop = blk.GetLoop('_atom_site_aniso_label')
     
    297299            ranIdlookup = {}
    298300            for aitem in atomloop:
    299                 mc = 0
    300                 if magnetic:
    301                     atomlist = ['','','',0.,0.,0.,1.0, 0.,0.,0.,'',0.,'I',0.01, 0.,0.,0.,0.,0.,0.,]
    302                     mc = 3
    303                 else:
    304                     atomlist = ['','','',0.,0.,0.,1.0,'',0.,'I',0.01, 0.,0.,0.,0.,0.,0.,]
     301                atomlist = ['','','',0.,0.,0.,1.0,'',0.,'I',0.01, 0.,0.,0.,0.,0.,0.,]
    305302                for val,key in zip(aitem,atomkeys):
    306303                    col = G2AtomDict.get(key,-1)
    307304                    if col >= 3:
    308305                        atomlist[col] = cif.get_number_with_esd(val)[0]
    309                         if col >= 11: atomlist[9+mc] = 'A' # if any Aniso term is defined, set flag
     306                        if col >= 11: atomlist[9] = 'A' # if any Aniso term is defined, set flag
    310307                    elif col is not None and col != -1:
    311308                        atomlist[col] = val
     
    313310                               '_atom_site_adp_type'):   #Iso or Aniso?
    314311                        if val.lower() == 'uani':
    315                             atomlist[9+mc] = 'A'
     312                            atomlist[9] = 'A'
    316313                    elif key == '_atom_site_u_iso_or_equiv':
    317314                        uisoval = cif.get_number_with_esd(val)[0]
    318315                        if uisoval is not None:
    319                             atomlist[10+mc] = uisoval
     316                            atomlist[10] = uisoval
    320317                if not atomlist[1] and atomlist[0]:
    321318                    typ = atomlist[0].rstrip('0123456789-+')
     
    326323                        self.warnings += ' Atom type '+typ+' not recognized; Xe assumed\n'
    327324                if atomlist[0] in anisolabels: # does this atom have aniso values in separate loop?
    328                     atomlist[9+mc] = 'A'
     325                    atomlist[9] = 'A'
    329326                    for val,key in zip(anisoloop.GetKeyedPacket('_atom_site_aniso_label',atomlist[0]),anisokeys):
    330327                        col = G2AtomDict.get(key)
    331328                        if col:
    332                             atomlist[col+mc] = cif.get_number_with_esd(val)[0]
    333                 if magnetic:
    334                     for mitem in magatomloop:
    335                         matom = mitem[G2MagDict.get('_atom_site_moment_label',-1)]
    336                         if atomlist[0] == matom:
    337                             for mval,mkey in zip(mitem,magatomkeys):
    338                                 mcol = G2MagDict.get(mkey,-1)
    339                                 if mcol:
    340                                     atomlist[mcol] = cif.get_number_with_esd(mval)[0]
    341                             break                           
    342                 atomlist[7+mc],atomlist[8+mc] = G2spc.SytSym(atomlist[3:6],SGData)[:2]
     329                            atomlist[col] = cif.get_number_with_esd(val)[0]
     330                atomlist[7],atomlist[8] = G2spc.SytSym(atomlist[3:6],SGData)[:2]
    343331                atomlist[1] = G2elem.FixValence(atomlist[1])
    344332                atomlist.append(ran.randint(0,sys.maxsize)) # add a random Id
     
    349337                else:
    350338                    atomlbllist.append(atomlist[0])
     339
     340                if magnetic and atomlist[0] in magatomlabels:
     341                    matomlist = atomlist[:7]+[0.,0.,0.,]+atomlist[7:]
     342                    for mval,mkey in zip(magatomloop.GetKeyedPacket('_atom_site_moment_label',atomlist[0]),magatomkeys):
     343                        mcol = G2MagDict.get(mkey,-1)
     344                        if mcol:
     345                            matomlist[mcol] = cif.get_number_with_esd(mval)[0]
     346                    self.MPhase['Atoms'].append(matomlist)
    351347                if Super:
    352348                    Sfrac = []
     
    407403            self.Phase['General']['Super'] = Super
    408404            if magnetic:
    409                 self.Phase['General']['Type'] = 'magnetic'               
     405                self.MPhase['General']['Type'] = 'magnetic'               
     406                self.MPhase['General']['Name'] = name.strip()[:20]+' mag'
     407                self.MPhase['General']['Super'] = Super
     408            else:
     409                self.MPhase = None
    410410            if Super:
    411411                self.Phase['General']['Type'] = 'modulated'
Note: See TracChangeset for help on using the changeset viewer.