Changeset 3465 for trunk/exports


Ignore:
Timestamp:
Jul 10, 2018 11:41:00 AM (3 years ago)
Author:
vondreele
Message:

deal with export/import issues for mag cif files
fix bug for new phase - append atom (space group change problem)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/exports/G2export_CIF.py

    r3464 r3465  
    278278        s += PutInCol(at[cs+1],3)
    279279        WriteCIFitem(fp, s)
    280     if naniso == 0: return
    281     # now loop over aniso atoms
    282     WriteCIFitem(fp, '\nloop_' + '\n   _atom_site_aniso_label' +
    283                  '\n   _atom_site_aniso_U_11' + '\n   _atom_site_aniso_U_22' +
    284                  '\n   _atom_site_aniso_U_33' + '\n   _atom_site_aniso_U_12' +
    285                  '\n   _atom_site_aniso_U_13' + '\n   _atom_site_aniso_U_23')
    286     for i,at in enumerate(Atoms):
    287         fval = parmDict.get(fpfx+str(i),at[cfrac])
    288         if fval == 0.0: continue # ignore any atoms that have a occupancy set to 0 (exact)
    289         if at[cia] == 'I': continue
    290         s = PutInCol(labellist[i],6) # label
    291         for j in (2,3,4,5,6,7):
    292             sigdig = -0.0009
    293             var = pfx+varnames[cia+j]+":"+str(i)
    294             val = parmDict.get(var,at[cia+j])
    295             sig = sigDict.get(var,sigdig)
    296             s += PutInCol(G2mth.ValEsd(val,sig),11)
    297         WriteCIFitem(fp, s)
     280    if naniso:
     281        # now loop over aniso atoms
     282        WriteCIFitem(fp, '\nloop_' + '\n   _atom_site_aniso_label' +
     283                     '\n   _atom_site_aniso_U_11' + '\n   _atom_site_aniso_U_22' +
     284                     '\n   _atom_site_aniso_U_33' + '\n   _atom_site_aniso_U_12' +
     285                     '\n   _atom_site_aniso_U_13' + '\n   _atom_site_aniso_U_23')
     286        for i,at in enumerate(Atoms):
     287            fval = parmDict.get(fpfx+str(i),at[cfrac])
     288            if fval == 0.0: continue # ignore any atoms that have a occupancy set to 0 (exact)
     289            if at[cia] == 'I': continue
     290            s = PutInCol(labellist[i],6) # label
     291            for j in (2,3,4,5,6,7):
     292                sigdig = -0.0009
     293                var = pfx+varnames[cia+j]+":"+str(i)
     294                val = parmDict.get(var,at[cia+j])
     295                sig = sigDict.get(var,sigdig)
     296                s += PutInCol(G2mth.ValEsd(val,sig),11)
     297            WriteCIFitem(fp, s)
    298298    # now loop over mag atoms (e.g. all of them)
    299299    WriteCIFitem(fp, '\nloop_' + '\n   _atom_site_moment.label' +
     
    12321232                         phasedict['General']['SGData']['SGSys'])
    12331233
    1234             spacegroup = phasedict['General']['SGData']['SpGrp'].strip()
    1235             # regularize capitalization and remove trailing H/R
    1236             spacegroup = spacegroup[0].upper() + spacegroup[1:].lower().rstrip('rh ')
    1237             WriteCIFitem(self.fp, '_symmetry_space_group_name_H-M',spacegroup)
    1238 
    1239             # generate symmetry operations including centering and center of symmetry
    1240             SymOpList,offsetList,symOpList,G2oprList,G2opcodes = G2spc.AllOps(
    1241                 phasedict['General']['SGData'])
    1242             WriteCIFitem(self.fp, 'loop_\n    _space_group_symop_id\n    _space_group_symop_operation_xyz')
    1243             for i,op in enumerate(SymOpList,start=1):
    1244                 WriteCIFitem(self.fp, '   {:3d}  {:}'.format(i,op.lower()))
     1234            if phasedict['General']['Type'] in ['nuclear','macromolecular']:
     1235                spacegroup = phasedict['General']['SGData']['SpGrp'].strip()
     1236                # regularize capitalization and remove trailing H/R
     1237                spacegroup = spacegroup[0].upper() + spacegroup[1:].lower().rstrip('rh ')
     1238                WriteCIFitem(self.fp, '_symmetry_space_group_name_H-M',spacegroup)
     1239   
     1240                # generate symmetry operations including centering and center of symmetry
     1241                SymOpList,offsetList,symOpList,G2oprList,G2opcodes = G2spc.AllOps(
     1242                    phasedict['General']['SGData'])
     1243                WriteCIFitem(self.fp, 'loop_\n    _space_group_symop_id\n    _space_group_symop_operation_xyz')
     1244                for i,op in enumerate(SymOpList,start=1):
     1245                    WriteCIFitem(self.fp, '   {:3d}  {:}'.format(i,op.lower()))
     1246            elif phasedict['General']['Type'] == 'magnetic':
     1247                parentSpGrp = phasedict['General']['SGData']['SpGrp'].strip()
     1248                parentSpGrp = parentSpGrp[0].upper() + parentSpGrp[1:].lower().rstrip('rh ')
     1249                WriteCIFitem(self.fp, '_parent_space_group.name_H-M_alt',parentSpGrp)
     1250                spacegroup = phasedict['General']['SGData']['MagSpGrp'].strip()
     1251                spacegroup = spacegroup[0].upper() + spacegroup[1:].lower().rstrip('rh ')
     1252                WriteCIFitem(self.fp, '_space_group_magn.name_BNS',spacegroup)
     1253                # generate symmetry operations including centering and center of symmetry
     1254                SymOpList,offsetList,symOpList,G2oprList,G2opcodes = G2spc.AllOps(
     1255                    phasedict['General']['SGData'])
     1256                SpnFlp = phasedict['General']['SGData']['SpnFlp']
     1257                WriteCIFitem(self.fp, 'loop_\n    _space_group_symop_magn_operation.id\n    _space_group_symop_magn_operation.xyz')
     1258                for i,op in enumerate(SymOpList,start=1):
     1259                    if SpnFlp[i-1] >0:
     1260                        opr = op.lower()+',+1'
     1261                    else:
     1262                        opr = op.lower()+',-1'
     1263                    WriteCIFitem(self.fp, '   {:3d}  {:}'.format(i,opr))
    12451264
    12461265            # loop over histogram(s) used in this phase
     
    12801299                WriteAtomsMagnetic(self.fp, self.Phases[phasenam], phasenam,
    12811300                                  self.parmDict, self.sigDict, self.labellist)
    1282                 raise Exception("no export for "+str(phasedict['General']['Type'])+" coordinates implemented")
     1301#                self.CloseFile()
     1302#                raise Exception("no export for "+str(phasedict['General']['Type'])+" coordinates implemented")
    12831303            # report cell contents
    12841304            WriteComposition(self.fp, self.Phases[phasenam], phasenam, self.parmDict)
Note: See TracChangeset for help on using the changeset viewer.