Changeset 963 for trunk


Ignore:
Timestamp:
Jun 20, 2013 5:07:33 PM (12 years ago)
Author:
toby
Message:

more CIF work, more docs

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIobj.py

    r956 r963  
    143143==========  ===============  ====================================================
    144144General         \            Overall information for the phase (dict)
    145   \         AtomPtrs         ? (list)
     145  \         AtomPtrs         list of four locations to use to pull info
     146                             from the atom records (list)
    146147  \         F000X            x-ray F(000) intensity (float)
    147148  \         F000N            neutron F(000) intensity (float)
     
    183184pId             \            Phase Id number for current project (int).
    184185Atoms           \            Atoms in phase as a list of lists. The outer list
    185                              is for each atom, the inner list contains 18
    186                              items:
    187                              0) atom label, 1) the atom type,
    188                              2) the refinement flags, 3-6) x, y, z, frac
    189                              7) site symmetry, 8) site multiplicity,
    190                              9) 'I' or 'A' for iso/anisotropic,
    191                              10) Uiso, 10-16) Uij, 16) unique Id #.
     186                             is for each atom, the inner list contains varying
     187                             items depending on the type of phase, see
     188                             the :ref:`Atom Records <Atoms_table>` description.
    192189                             (list of lists)
    193190Drawing         \            Display parameters (dict)
     
    285282            '111' is used (P 1, and ?).
    286283==========  ====================================================
     284
     285Atom Records
     286------------
     287
     288.. _Atoms_table:
     289
     290.. index::
     291   single: Atoms record description
     292   single: Data object descriptions; Atoms record
     293
     294
     295If ``phasedict`` points to the phase information in the data tree, then
     296atoms are contained in a list of atom records (list) in
     297``phasedict['Atoms']``. Also needed to read atom information
     298are four pointers, ``cx,ct,cs,cia = phasedict['General']['AtomPtrs']``,
     299which define locations in the atom record, as shown below.
     300
     301.. tabularcolumns:: |l|p{4.5in}|
     302
     303==============   ====================================================
     304location         explanation
     305==============   ====================================================
     306cx,cx+1,cx+2      the x,y and z coordinates
     307cx+3              fractional occupancy (also cs-1)
     308ct-1              atom label
     309ct                atom type
     310ct+1              refinement flags
     311cs                site symmetry string
     312cs+1              site multiplicity
     313cia               ADP flag: Isotropic ('I') or Anisotropic ('A')
     314cia+1             Uiso
     315cia+2...cia+6     U11, U22, U33, U12, U13, U23
     316==============   ====================================================
     317
     318
     319*Classes and routines*
     320----------------------
    287321
    288322'''
  • TabularUnified trunk/GSASIIspc.py

    r956 r963  
    202202def AllOps(SGData):
    203203    '''
    204     Returns a list of all operators for a space group, including those for centering and a center of symmetry
     204    Returns a list of all operators for a space group, including those for
     205    centering and a center of symmetry
    205206   
    206207    :param SGData: from :func:`SpcGroup`
    207     :returns: list of strings of formatted symmetry operators
    208     '''
    209     SGText = []
     208    :returns: (SGTextList,offsetList,symOpList,G2oprList) where
     209
     210      * SGTextList: a list of strings with formatted and normalized
     211        symmetry operators.
     212      * offsetList: a tuple of (dx,dy,dz) offsets that relate the GSAS-II
     213        symmetry operation to the operator in SGTextList and symOpList.
     214        these dx (etc.) values are added to the GSAS-II generated
     215        positions to provide the positions that are generated
     216        by the normalized symmetry operators.       
     217      * symOpList: a list of tuples with the normalized symmetry
     218        operations as (M,T) values
     219        (see ``SGOps`` in the :ref:`Space Group object<SGData_table>`)
     220      * G2oprList: The GSAS-II operations for each symmetry operation as
     221        a tuple with (center,mult,opnum), where center is (0,0,0), (0.5,0,0),
     222        (0.5,0.5,0.5),...; where mult is 1 or -1 for the center of symmetry
     223        and opnum is the number for the symmetry operation, in ``SGOps``
     224        (starting with 0).
     225    '''
     226    SGTextList = []
     227    offsetList = []
     228    symOpList = []
     229    G2oprList = []
    210230    onebar = (1,)
    211231    if SGData['SGInv']:
     
    213233    for cen in SGData['SGCen']:
    214234        for mult in onebar:
    215             for M,T in SGData['SGOps']:
    216                 OPtxt = MT2text(mult*M,(mult*T)+cen)
    217                 SGText.append(OPtxt.replace(' ',''))
    218     return SGText
    219 
     235            for j,(M,T) in enumerate(SGData['SGOps']):
     236                offset = [0,0,0]
     237                Tprime = (mult*T)+cen
     238                for i in range(3):
     239                    while Tprime[i] < 0:
     240                        Tprime[i] += 1
     241                        offset[i] += 1
     242                    while Tprime[i] >= 1:
     243                        Tprime[i] += -1
     244                        offset[i] += -1
     245                OPtxt = MT2text(mult*M,Tprime)
     246                SGTextList.append(OPtxt.replace(' ',''))
     247                offsetList.append(tuple(offset))
     248                symOpList.append((mult*M,Tprime))
     249                G2oprList.append((cen,mult,j))
     250    return SGTextList,offsetList,symOpList,G2oprList
    220251   
    221252def MT2text(M,T):
  • TabularUnified trunk/exports/G2cif.py

    r960 r963  
    66import os.path
    77import GSASIIIO as G2IO
    8 reload(G2IO)
     8#reload(G2IO)
    99import GSASIIgrid as G2gd
    1010import GSASIIstrIO as G2stIO
     
    1313import GSASIIlattice as G2lat
    1414import GSASIIspc as G2spg
     15reload(G2spg)
    1516
    1617def getCallerDocString(): # for development
     
    6768
    6869        def WriteOverall():
    69             '''TODO: Write out overall refinement information
     70            '''Write out overall refinement information.
     71
     72            More could be done here, but this is a good start.
    7073            '''
    7174            WriteCIFitem('_pd_proc_info_datetime', self.CIFdate)
     
    8588            WriteCIFitem('_refine_ls_goodness_of_fit_all',GOF)
    8689
     90            # get restraint info
     91            # restraintDict = self.OverallParms.get('Restraints',{})
     92            # for i in  self.OverallParms['Constraints']:
     93            #     print i
     94            #     for j in self.OverallParms['Constraints'][i]:
     95            #         print j
    8796            #WriteCIFitem('_refine_ls_number_restraints',TEXT)
    8897           
     
    300309                        cia+1:'AUiso',cia+2:'AU11',cia+3:'AU22',cia+4:'AU33',
    301310                        cia+5:'AU12',cia+6:'AU13',cia+7:'AU23'}
    302             labellist = []
     311            self.labellist = []
    303312           
    304313            pfx = str(phasedict['pId'])+'::'
     
    306315            naniso = 0
    307316            for i,at in enumerate(Atoms):
    308                 s = PutInCol(MakeUniqueLabel(at[ct-1],labellist),6) # label
     317                s = PutInCol(MakeUniqueLabel(at[ct-1],self.labellist),6) # label
    309318                fval = self.parmDict.get(fpfx+str(i),at[cfrac])
    310319                if fval == 0.0: continue # ignore any atoms that have a occupancy set to 0 (exact)
     
    354363                if fval == 0.0: continue # ignore any atoms that have a occupancy set to 0 (exact)
    355364                if at[cia] == 'I': continue
    356                 s = PutInCol(labellist[i],6) # label
     365                s = PutInCol(self.labellist[i],6) # label
    357366                for j in (2,3,4,5,6,7):
    358367                    sigdig = -0.0009
     
    444453                          G2mth.ValEsd(cellmass/Z,-0.09,True))
    445454
     455        def WriteDistances(phasenam,SymOpList,offsetList,symOpList,G2oprList):
     456            '''Report bond distances and angles for the CIF
     457
     458            Note that _geom_*_symmetry_* fields are values of form
     459            n_klm where n is the symmetry operation in SymOpList (counted
     460            starting with 1) and (k-5, l-5, m-5) are translations to add
     461            to (x,y,z). See
     462            http://www.iucr.org/__data/iucr/cifdic_html/1/cif_core.dic/Igeom_angle_site_symmetry_.html
     463
     464            TODO: need a method to select publication flags for distances/angles
     465            '''
     466            phasedict = self.Phases[phasenam] # pointer to current phase info           
     467            Atoms = phasedict['Atoms']
     468            cx,ct,cs,cia = phasedict['General']['AtomPtrs']
     469            fpfx = str(phasedict['pId'])+'::Afrac:'       
     470            cfrac = cx+3
     471            # loop over interatomic distances for this phase
     472            WriteCIFitem('\n# MOLECULAR GEOMETRY')
     473            WriteCIFitem('loop_' +
     474                         '\n\t_geom_bond_atom_site_label_1' +
     475                         '\n\t_geom_bond_atom_site_label_2' +
     476                         '\n\t_geom_bond_distance' +
     477                         '\n\t_geom_bond_site_symmetry_1' +
     478                         '\n\t_geom_bond_site_symmetry_2' +
     479                         '\n\t_geom_bond_publ_flag')
     480
     481            # Note that labels should be read from self.labellist to correspond
     482            # to the values reported in the atoms table and zero occupancy atoms
     483            # should not be included
     484            fpfx = str(phasedict['pId'])+'::Afrac:'       
     485            for i,at in enumerate(Atoms):
     486                if self.parmDict.get(fpfx+str(i),at[cfrac]) == 0.0: continue
     487                lbl = self.labellist[i]
     488
     489
     490            # loop over interatomic angles for this phase
     491            WriteCIFitem('loop_' +
     492                         '\n\t_geom_angle_atom_site_label_1' +
     493                         '\n\t_geom_angle_atom_site_label_2' +
     494                         '\n\t_geom_angle_atom_site_label_3' +
     495                         '\n\t_geom_angle' +
     496                         '\n\t_geom_angle_site_symmetry_1' +
     497                         '\n\t_geom_angle_site_symmetry_2' +
     498                         '\n\t_geom_angle_site_symmetry_3' +
     499                         '\n\t_geom_angle_publ_flag')
     500
     501
    446502        def WritePhaseInfo(phasenam):
    447             # see writepha.for
    448             print 'TODO: phase info for',phasenam,'goes here'
    449             # THINK: how to select publication flags for distances/angles?
     503            WriteCIFitem('\n# phase info for '+str(phasenam) + ' follows')
    450504            phasedict = self.Phases[phasenam] # pointer to current phase info           
    451505            WriteCIFitem('_pd_phase_name', phasenam)
     
    478532
    479533            # generate symmetry operations including centering and center of symmetry
    480             WriteCIFitem('loop_ _symmetry_equiv_pos_site_id _symmetry_equiv_pos_as_xyz')
    481             for i,op in enumerate(G2spg.AllOps(phasedict['General']['SGData']),start=1):
     534            SymOpList,offsetList,symOpList,G2oprList = G2spg.AllOps(
     535                phasedict['General']['SGData'])
     536            WriteCIFitem('loop_ _space_group_symop_id _space_group_symop_operation_xyz')
     537            for i,op in enumerate(SymOpList,start=1):
    482538                WriteCIFitem('   {:3d}  {:}'.format(i,op.lower()))
    483539
     
    512568            # report cell contents
    513569            WriteComposition(phasenam)
    514 #            if not self.quickmode:
    515                 # report distances and angles
    516 #                WriteDistances(phasenam)
     570            if not self.quickmode:      # report distances and angles
     571                WriteDistances(phasenam,SymOpList,offsetList,symOpList,G2oprList)
    517572
    518573            #raise Exception,'Testing'
    519 
    520             #C now loop over interatomic distances for this phase
    521             WriteCIFitem('\n# MOLECULAR GEOMETRY')
    522             WriteCIFitem('loop_' +
    523                          '\n\t_geom_bond_atom_site_label_1' +
    524                          '\n\t_geom_bond_atom_site_label_2' +
    525                          '\n\t_geom_bond_distance' +
    526                          '\n\t_geom_bond_site_symmetry_1' +
    527                          '\n\t_geom_bond_site_symmetry_2' +
    528                          '\n\t_geom_bond_publ_flag')
    529 
    530             #C now loop over interatomic angles for this phase
    531             WriteCIFitem('loop_' +
    532                          '\n\t_geom_angle_atom_site_label_1' +
    533                          '\n\t_geom_angle_atom_site_label_2' +
    534                          '\n\t_geom_angle_atom_site_label_3' +
    535                          '\n\t_geom_angle' +
    536                          '\n\t_geom_angle_site_symmetry_1' +
    537                          '\n\t_geom_angle_site_symmetry_2' +
    538                          '\n\t_geom_angle_site_symmetry_3' +
    539                          '\n\t_geom_angle_publ_flag')
    540574
    541575        def WritePowderData(histlbl):
     
    9681002                    WriteSingleXtalData(key1)
    9691003
    970         # TODO: how to report _pd_proc_ls_peak_cutoff?
    9711004        WriteCIFitem('#--' + 15*'eof--' + '#')
    9721005
Note: See TracChangeset for help on using the changeset viewer.