source: trunk/imports/G2phase_CIF.py @ 1762

Last change on this file since 1762 was 1762, checked in by vondreele, 9 years ago

fix exports of reflection csv & txt files to work for CW & TOF data as well as
3 & (3+1) symmetries
fix Det-X --> Det-Y
remove a Yield - caused crash
fix c-unique & a-unique monoclinit cell refinement & display
fix cif readers for phase

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Author Revision URL Id
File size: 27.0 KB
Line 
1# -*- coding: utf-8 -*-
2########### SVN repository information ###################
3# $Date: 2015-03-25 20:42:15 +0000 (Wed, 25 Mar 2015) $
4# $Author: vondreele $
5# $Revision: 1762 $
6# $URL: trunk/imports/G2phase_CIF.py $
7# $Id: G2phase_CIF.py 1762 2015-03-25 20:42:15Z vondreele $
8########### SVN repository information ###################
9'''
10*Module G2phase_CIF: Coordinates from CIF*
11------------------------------------------
12
13Parses a CIF using  PyCifRW from James Hester and pulls out the
14structural information.
15
16If a CIF generated by ISODISTORT is encountered, extra information is
17added to the phase entry and constraints are generated.
18
19'''
20# Routines to import Phase information from CIF files
21import sys
22import random as ran
23import numpy as np
24import re
25import GSASIIIO as G2IO
26import GSASIIobj as G2obj
27import GSASIIspc as G2spc
28import GSASIIElem as G2elem
29import GSASIIlattice as G2lat
30import GSASIIpy3 as G2p3
31import GSASIIpath
32GSASIIpath.SetVersionNumber("$Revision: 1762 $")
33import CifFile as cif # PyCifRW from James Hester
34
35class CIFPhaseReader(G2IO.ImportPhase):
36    'Implements a phase importer from a possibly multi-block CIF file'
37    def __init__(self):
38        super(self.__class__,self).__init__( # fancy way to say ImportPhase.__init__
39            extensionlist=('.CIF','.cif','.txt'),
40            strictExtension=False,
41            formatName = 'CIF',
42            longFormatName = 'Crystallographic Information File import'
43            )
44       
45    def ContentsValidator(self, filepointer):
46        return self.CIFValidator(filepointer)
47
48    def Reader(self,filename,filepointer, ParentFrame=None, usedRanIdList=[], **unused):
49        self.isodistort_warnings = ''
50        self.Phase = G2IO.SetNewPhase(Name='new phase',SGData=G2IO.P1SGData) # create a new empty phase dict
51        # make sure the ranId is really unique!
52        while self.Phase['ranId'] in usedRanIdList:
53            self.Phase['ranId'] = ran.randint(0,sys.maxint)
54        returnstat = False
55        cellitems = (
56            '_cell_length_a','_cell_length_b','_cell_length_c',
57            '_cell_angle_alpha','_cell_angle_beta','_cell_angle_gamma',)
58        cellwaveitems = (
59            '_cell_wave_vector_seq_id',
60            '_cell_wave_vector_x','_cell_wave_vector_y','_cell_wave_vector_z')
61        reqitems = (
62             '_atom_site_fract_x',
63             '_atom_site_fract_y',
64             '_atom_site_fract_z',
65            )
66        phasenamefields = (
67            '_chemical_name_common',
68            '_pd_phase_name',
69            '_chemical_formula_sum'
70            )
71        try:
72            self.ShowBusy() # this can take a while
73            try:
74                cf = G2IO.ReadCIF(filename)
75            except Exception as detail:
76                self.errors = "Parse or reading of file failed in pyCifRW; check syntax of file in enCIFer or CheckCIF"
77                return False
78            finally:
79                self.DoneBusy()
80            # scan blocks for structural info
81            self.errors = 'Error during scan of blocks for datasets'
82            str_blklist = []
83            for blk in cf.keys():
84                for r in reqitems+cellitems:
85                    if r not in cf[blk].keys():
86                        break
87                else:
88                    str_blklist.append(blk)
89            if not str_blklist:
90                selblk = None # no block to choose
91            elif len(str_blklist) == 1: # only one choice
92                selblk = 0
93            else:                       # choose from options
94                choice = []
95                for blknm in str_blklist:
96                    choice.append('')
97                    # accumumlate some info about this phase
98                    choice[-1] += blknm + ': '
99                    for i in phasenamefields: # get a name for the phase
100                        name = cf[blknm].get(i).strip()
101                        if name is None or name == '?' or name == '.':
102                            continue
103                        else:
104                            choice[-1] += name.strip()[:20] + ', '
105                            break
106                    na = len(cf[blknm].get("_atom_site_fract_x"))
107                    if na == 1:
108                        choice[-1] += '1 atom'
109                    else:
110                        choice[-1] += ('%d' % nd) + ' atoms'
111                    choice[-1] += ', cell: '
112                    fmt = "%.2f,"
113                    for i,key in enumerate(cellitems):
114                        if i == 3: fmt = "%.f,"
115                        if i == 5: fmt = "%.f"
116                        choice[-1] += fmt % cif.get_number_with_esd(
117                            cf[blknm].get(key))[0]
118                    sg = cf[blknm].get("_symmetry_space_group_name_H-M",'')
119                    if not sg: sg = cf[blknm].get("_space_group_name_H-M_alt",'')
120                    if sg: choice[-1] += ', (' + sg.strip() + ')'
121                selblk = self.PhaseSelector(
122                    choice,
123                    ParentFrame=ParentFrame,
124                    title= 'Select a phase from one the CIF data_ blocks below',
125                    size=(600,100)
126                    )
127            self.errors = 'Error during reading of selected block'
128            if selblk is None:
129                returnstat = False # no block selected or available
130            else:
131                blknm = str_blklist[selblk]
132                blk = cf[str_blklist[selblk]]
133                E = True
134                Super = False
135                SpGrp = blk.get("_symmetry_space_group_name_H-M",'')
136                if not SpGrp:
137                    SpGrp = blk.get("_space_group_name_H-M_alt",'')
138                if not SpGrp:
139                    sspgrp = blk.get("_space_group_ssg_name",'').split('(')
140                    SpGrp = sspgrp[0]
141                    SuperSg = '('+sspgrp[1].replace('\\','')
142                    Super = True
143                    SuperVec = [[0,0,.1],False,4]
144                # try normalizing the space group, to see if we can pick the space group out of a table
145                SpGrpNorm = G2spc.StandardizeSpcName(SpGrp)
146                if SpGrpNorm:
147                    E,SGData = G2spc.SpcGroup(SpGrpNorm)
148                # nope, try the space group "out of the Box"
149                if E and SpGrp:
150                    E,SGData = G2spc.SpcGroup(SpGrp)
151                if E:
152                    if not SpGrp:
153                        self.warnings += 'No space group name was found in the CIF.'
154                        self.warnings += '\nThe space group has been set to "P 1". '
155                        self.warnings += "Change this in phase's General tab."
156                    else:
157                        self.warnings += 'ERROR in space group symbol '+SpGrp
158                        self.warnings += '\nThe space group has been set to "P 1". '
159                        self.warnings += "Change this in phase's General tab."
160                        self.warnings += '\nAre there spaces separating axial fields?\n\nError msg: '
161                        self.warnings += G2spc.SGErrors(E)
162                    SGData = G2IO.SGData # P 1
163                self.Phase['General']['SGData'] = SGData
164                # cell parameters
165                cell = []
166                for lbl in cellitems:
167                    cell.append(cif.get_number_with_esd(blk[lbl])[0])
168                Volume = G2lat.calc_V(G2lat.cell2A(cell))
169                self.Phase['General']['Cell'] = [False,]+cell+[Volume,]
170                # read in atoms
171                self.errors = 'Error during reading of atoms'
172                atomlbllist = [] # table to look up atom IDs
173                atomloop = blk.GetLoop('_atom_site_label')
174                atomkeys = [i.lower() for i in atomloop.keys()]
175                if not blk.get('_atom_site_type_symbol'):
176                    self.isodistort_warnings += '\nlack of atom types prevents ISODISTORT processing'
177                if blk.get('_atom_site_aniso_label'):
178                    anisoloop = blk.GetLoop('_atom_site_aniso_label')
179                    anisokeys = [i.lower() for i in anisoloop.keys()]
180                else:
181                    anisoloop = None
182                    anisokeys = []
183                self.Phase['Atoms'] = []
184                G2AtomDict = {  '_atom_site_type_symbol' : 1,
185                                '_atom_site_label' : 0,
186                                '_atom_site_fract_x' : 3,
187                                '_atom_site_fract_y' : 4,
188                                '_atom_site_fract_z' : 5,
189                                '_atom_site_occupancy' : 6,
190                                '_atom_site_aniso_u_11' : 11,
191                                '_atom_site_aniso_u_22' : 12,
192                                '_atom_site_aniso_u_33' : 13,
193                                '_atom_site_aniso_u_12' : 14,
194                                '_atom_site_aniso_u_13' : 15,
195                                '_atom_site_aniso_u_23' : 16, }
196                ranIdlookup = {}
197                for aitem in atomloop:
198                    atomlist = ['','','',0,0,0,1.0,'',0,'I',0.01,0,0,0,0,0,0,0]
199                    atomlist[-1] = ran.randint(0,sys.maxint) # add a random Id
200                    while atomlist[-1] in ranIdlookup:
201                        atomlist[-1] = ran.randint(0,sys.maxint) # make it unique
202                    for val,key in zip(aitem,atomkeys):
203                        col = G2AtomDict.get(key)
204                        if col >= 3:
205                            atomlist[col] = cif.get_number_with_esd(val)[0]
206                        elif col is not None:
207                            atomlist[col] = val
208                        elif key in ('_atom_site_thermal_displace_type',
209                                   '_atom_site_adp_type'):   #Iso or Aniso?
210                            if val.lower() == 'uani':
211                                atomlist[9] = 'A'
212                        elif key == '_atom_site_u_iso_or_equiv':
213                            atomlist[10] =cif.get_number_with_esd(val)[0]
214                    if not atomlist[1] and atomlist[0]:
215                        for i in range(2,0,-1):
216                            typ = atomlist[0].strip()[:i]
217                            if G2elem.CheckElement(typ):
218                                atomlist[1] = typ
219                            if not atomlist[1]: atomlist[1] = 'Xe'
220                    ulbl = '_atom_site_aniso_label'
221                    if  atomlist[9] == 'A' and atomlist[0] in blk.get(ulbl):
222                        for val,key in zip(anisoloop.GetKeyedPacket(ulbl,atomlist[0]),
223                                           anisokeys):
224                            col = G2AtomDict.get(key)
225                            if col:
226                                atomlist[col] = cif.get_number_with_esd(val)[0]
227                    atomlist[7],atomlist[8] = G2spc.SytSym(atomlist[3:6],SGData)
228                    atomlist[1] = G2elem.FixValence(atomlist[1])
229                    self.Phase['Atoms'].append(atomlist)
230                    ranIdlookup[atomlist[0]] = atomlist[-1]
231                    if atomlist[0] in atomlbllist:
232                        self.warnings += ' ERROR: repeated atom label: '+atomlist[0]
233                    else:
234                        atomlbllist.append(atomlist[0])
235                if len(atomlbllist) != len(self.Phase['Atoms']):
236                    self.isodistort_warnings += '\nRepeated atom labels prevents ISODISTORT decode'
237                for lbl in phasenamefields: # get a name for the phase
238                    name = blk.get(lbl)
239                    if name is None:
240                        continue
241                    name = name.strip()
242                    if name == '?' or name == '.':
243                        continue
244                    else:
245                        break
246                else: # no name found, use block name for lack of a better choice
247                    name = blknm
248                self.Phase['General']['Name'] = name.strip()[:20]
249                self.Phase['General']['Super'] = Super
250                if Super:
251                    self.Phase['General']['Type'] = 'modulated'
252                    self.Phase['General']['SuperVec'] = SuperVec
253                    self.Phase['General']['SuperSg'] = SuperSg
254                    self.Phase['General']['SSGData'] = G2spc.SSpcGroup(SGData,SuperSg)[1]
255                if not self.isodistort_warnings:
256                    if blk.get('_iso_displacivemode_label') or blk.get('_iso_occupancymode_label'):
257                        self.errors = "Error while processing ISODISTORT constraints"
258                        self.ISODISTORT_proc(blk,atomlbllist,ranIdlookup)
259                else:
260                    self.warnings += self.isodistort_warnings
261                returnstat = True
262        except Exception as detail:
263            self.errors += '\n  '+str(detail)
264            print 'CIF error:',detail # for testing
265            print sys.exc_info()[0] # for testing
266            import traceback
267            print traceback.format_exc()
268            returnstat = False
269        return returnstat
270
271    def ISODISTORT_proc(self,blk,atomlbllist,ranIdlookup):
272        'Process ISODISTORT items to create constraints etc.'
273        varLookup = {'dx':'dAx','dy':'dAy','dz':'dAz','do':'Afrac'}
274        'Maps ISODISTORT parm names to GSAS-II names'
275        #----------------------------------------------------------------------
276        # read in the ISODISTORT displacement modes
277        #----------------------------------------------------------------------
278        self.Constraints = []
279        explaination = {}
280        if blk.get('_iso_displacivemode_label'):
281            modelist = []
282            shortmodelist = []
283            for lbl in blk.get('_iso_displacivemode_label'):
284                modelist.append(lbl)
285                # assume lbl is of form SSSSS[x,y,z]AAAA(a,b,...)BBBBB
286                # where SSSSS is the parent spacegroup, [x,y,z] is a location
287                regexp = re.match(r'.*?\[.*?\](.*?)\(.*?\)(.*)',lbl)
288                # this extracts the AAAAA and BBBBB parts of the string
289                if regexp:
290                    lbl = regexp.expand(r'\1\2') # parse succeeded, make a short version
291                G2obj.MakeUniqueLabel(lbl,shortmodelist) # make unique and add to list
292            # read in the coordinate offset variables names and map them to G2 names/objects
293            coordVarLbl = []
294            G2varLbl = []
295            G2varObj = []
296            error = False
297            for lbl in blk.get('_iso_deltacoordinate_label'):
298                coordVarLbl.append(lbl)
299                if '_' in lbl:
300                    albl = lbl[:lbl.rfind('_')]
301                    vlbl = lbl[lbl.rfind('_')+1:]
302                else:
303                    self.warnings += ' ERROR: _iso_deltacoordinate_label not parsed: '+lbl
304                    error = True
305                    continue
306                if albl not in atomlbllist:
307                    self.warnings += ' ERROR: _iso_deltacoordinate_label atom not found: '+lbl
308                    error = True
309                    continue
310                else:
311                    anum = atomlbllist.index(albl)
312                var = varLookup.get(vlbl)
313                if not var:
314                    self.warnings += ' ERROR: _iso_deltacoordinate_label variable not found: '+lbl
315                    error = True
316                    continue
317                G2varLbl.append('::'+var+':'+str(anum)) # variable name, less phase ID
318                G2varObj.append(G2obj.G2VarObj(
319                    (self.Phase['ranId'],None,var,ranIdlookup[albl])
320                    ))
321            if error:
322                raise Exception,"Error decoding variable labels"
323
324            if len(G2varObj) != len(modelist):
325                print "non-square input"
326                raise Exception,"Rank of _iso_displacivemode != _iso_deltacoordinate"
327
328            error = False
329            ParentCoordinates = {}
330            for lbl,exp in zip(
331                blk.get('_iso_coordinate_label'),
332                blk.get('_iso_coordinate_formula'),
333                ):
334                if '_' in lbl:
335                    albl = lbl[:lbl.rfind('_')]
336                    vlbl = lbl[lbl.rfind('_')+1:]
337                else:
338                    self.warnings += ' ERROR: _iso_coordinate_label not parsed: '+lbl
339                    error = True
340                    continue
341                if vlbl not in 'xyz' or len(vlbl) != 1:
342                    self.warnings += ' ERROR: _iso_coordinate_label coordinate not parsed: '+lbl
343                    error = True
344                    continue
345                i = 'xyz'.index(vlbl)
346                if not ParentCoordinates.get(albl):
347                    ParentCoordinates[albl] = [None,None,None]
348                if '+' in exp:
349                    val = exp.split('+')[0].strip()
350                    val = G2p3.FormulaEval(val)
351                    if val is None:
352                        self.warnings += ' ERROR: _iso_coordinate_formula coordinate not interpreted: '+lbl
353                        error = True
354                        continue
355                    ParentCoordinates[albl][i] = val
356                else:
357                    ParentCoordinates[albl][i] = G2p3.FormulaEval(exp)
358            if error:
359                print self.warnings
360                raise Exception,"Error decoding variable labels"
361            # get mapping of modes to atomic coordinate displacements
362            displacivemodematrix = np.zeros((len(G2varObj),len(G2varObj)))
363            for row,col,val in zip(
364                blk.get('_iso_displacivemodematrix_row'),
365                blk.get('_iso_displacivemodematrix_col'),
366                blk.get('_iso_displacivemodematrix_value'),):
367                displacivemodematrix[int(row)-1,int(col)-1] = float(val)
368            # Invert to get mapping of atom displacements to modes
369            displacivemodeInvmatrix = np.linalg.inv(displacivemodematrix)
370            # create the constraints
371            for i,row in enumerate(displacivemodeInvmatrix):
372                constraint = []
373                for j,(lbl,k) in enumerate(zip(coordVarLbl,row)):
374                    if k == 0: continue
375                    constraint.append([k,G2varObj[j]])
376                constraint += [shortmodelist[i],False,'f']
377                self.Constraints.append(constraint)
378            #----------------------------------------------------------------------
379            # save the ISODISTORT info for "mode analysis"
380            if 'ISODISTORT' not in self.Phase: self.Phase['ISODISTORT'] = {}
381            self.Phase['ISODISTORT'].update({
382                'IsoModeList' : modelist,
383                'G2ModeList' : shortmodelist,
384                'IsoVarList' : coordVarLbl,
385                'G2VarList' : G2varObj,
386                'ParentStructure' : ParentCoordinates,
387                'Var2ModeMatrix' : displacivemodeInvmatrix,
388                'Mode2VarMatrix' : displacivemodematrix,
389                })
390            # make explaination dictionary
391            for mode,shortmode in zip(modelist,shortmodelist):
392                explaination[shortmode] = "ISODISTORT full name "+str(mode)
393        #----------------------------------------------------------------------
394        # now read in the ISODISTORT occupancy modes
395        #----------------------------------------------------------------------
396        if blk.get('_iso_occupancymode_label'):
397            modelist = []
398            shortmodelist = []
399            for lbl in blk.get('_iso_occupancymode_label'):
400                modelist.append(lbl)
401                # assume lbl is of form SSSSS[x,y,z]AAAA(a,b,...)BBBBB
402                # where SSSSS is the parent spacegroup, [x,y,z] is a location
403                regexp = re.match(r'.*?\[.*?\](.*?)\(.*?\)(.*)',lbl)
404                # this extracts the AAAAA and BBBBB parts of the string
405                if regexp:
406                    lbl = regexp.expand(r'\1\2') # parse succeeded, make a short version
407                lbl = lbl.replace('order','o')
408                G2obj.MakeUniqueLabel(lbl,shortmodelist) # make unique and add to list
409            # read in the coordinate offset variables names and map them to G2 names/objects
410            occVarLbl = []
411            G2varLbl = []
412            G2varObj = []
413            error = False
414            for lbl in blk.get('_iso_deltaoccupancy_label'):
415                occVarLbl.append(lbl)
416                if '_' in lbl:
417                    albl = lbl[:lbl.rfind('_')]
418                    vlbl = lbl[lbl.rfind('_')+1:]
419                else:
420                    self.warnings += ' ERROR: _iso_deltaoccupancy_label not parsed: '+lbl
421                    error = True
422                    continue
423                if albl not in atomlbllist:
424                    self.warnings += ' ERROR: _iso_deltaoccupancy_label atom not found: '+lbl
425                    error = True
426                    continue
427                else:
428                    anum = atomlbllist.index(albl)
429                var = varLookup.get(vlbl)
430                if not var:
431                    self.warnings += ' ERROR: _iso_deltaoccupancy_label variable not found: '+lbl
432                    error = True
433                    continue
434                G2varLbl.append('::'+var+':'+str(anum)) # variable name, less phase ID
435                G2varObj.append(G2obj.G2VarObj(
436                    (self.Phase['ranId'],None,var,ranIdlookup[albl])
437                    ))
438            if error:
439                raise Exception,"Error decoding variable labels"
440
441            if len(G2varObj) != len(modelist):
442                print "non-square input"
443                raise Exception,"Rank of _iso_occupancymode != _iso_deltaoccupancy"
444
445            error = False
446            ParentCoordinates = {}
447            for lbl,exp in zip(
448                blk.get('_iso_occupancy_label'),
449                blk.get('_iso_occupancy_formula'),
450                ):
451                if '_' in lbl:
452                    albl = lbl[:lbl.rfind('_')]
453                    vlbl = lbl[lbl.rfind('_')+1:]
454                else:
455                    self.warnings += ' ERROR: _iso_occupancy_label not parsed: '+lbl
456                    error = True
457                    continue
458                if vlbl != 'occ':
459                    self.warnings += ' ERROR: _iso_occupancy_label coordinate not parsed: '+lbl
460                    error = True
461                    continue
462                if '+' in exp:
463                    val = exp.split('+')[0].strip()
464                    val = G2p3.FormulaEval(val)
465                    if val is None:
466                        self.warnings += ' ERROR: _iso_occupancy_formula coordinate not interpreted: '+lbl
467                        error = True
468                        continue
469                    ParentCoordinates[albl] = val
470            if error:
471                raise Exception,"Error decoding occupancy labels"
472            # get mapping of modes to atomic coordinate displacements
473            occupancymodematrix = np.zeros((len(G2varObj),len(G2varObj)))
474            for row,col,val in zip(
475                blk.get('_iso_occupancymodematrix_row'),
476                blk.get('_iso_occupancymodematrix_col'),
477                blk.get('_iso_occupancymodematrix_value'),):
478                occupancymodematrix[int(row)-1,int(col)-1] = float(val)
479            # Invert to get mapping of atom displacements to modes
480            occupancymodeInvmatrix = np.linalg.inv(occupancymodematrix)
481            # create the constraints
482            for i,row in enumerate(occupancymodeInvmatrix):
483                constraint = []
484                for j,(lbl,k) in enumerate(zip(occVarLbl,row)):
485                    if k == 0: continue
486                    constraint.append([k,G2varObj[j]])
487                constraint += [shortmodelist[i],False,'f']
488                self.Constraints.append(constraint)
489            #----------------------------------------------------------------------
490            # save the ISODISTORT info for "mode analysis"
491            if 'ISODISTORT' not in self.Phase: self.Phase['ISODISTORT'] = {}
492            self.Phase['ISODISTORT'].update({
493                'OccModeList' : modelist,
494                'G2OccModeList' : shortmodelist,
495                'OccVarList' : occVarLbl,
496                'G2OccVarList' : G2varObj,
497                'BaseOcc' : ParentCoordinates,
498                'Var2OccMatrix' : occupancymodeInvmatrix,
499                'Occ2VarMatrix' : occupancymodematrix,
500                })
501            # make explaination dictionary
502            for mode,shortmode in zip(modelist,shortmodelist):
503                explaination[shortmode] = "ISODISTORT full name "+str(mode)
504        #----------------------------------------------------------------------
505        # done with read
506        #----------------------------------------------------------------------
507        if explaination: self.Constraints.append(explaination)
508
509        # # debug: show the mode var to mode relations
510        # for i,row in enumerate(displacivemodeInvmatrix):
511        #     l = ''
512        #     for j,(lbl,k) in enumerate(zip(coordVarLbl,row)):
513        #         if k == 0: continue
514        #         if l: l += ' + '
515        #         #l += lbl+' * '+str(k)
516        #         l += G2varLbl[j]+' * '+str(k)
517        #     print str(i) + ': '+shortmodelist[i]+' = '+l
518        # print 70*'='
519
520        # # debug: Get the ISODISTORT offset values
521        # coordVarDelta = {}
522        # for lbl,val in zip(
523        #     blk.get('_iso_deltacoordinate_label'),
524        #     blk.get('_iso_deltacoordinate_value'),):
525        #     coordVarDelta[lbl] = float(val)
526        # modeVarDelta = {}
527        # for lbl,val in zip(
528        #     blk.get('_iso_displacivemode_label'),
529        #     blk.get('_iso_displacivemode_value'),):
530        #     modeVarDelta[lbl] = cif.get_number_with_esd(val)[0]
531
532        # print 70*'='
533        # # compute the mode values from the reported coordinate deltas
534        # for i,row in enumerate(displacivemodeInvmatrix):
535        #     l = ''
536        #     sl = ''
537        #     s = 0.
538        #     for lbl,k in zip(coordVarLbl,row):
539        #         if k == 0: continue
540        #         if l: l += ' + '
541        #         l += lbl+' * '+str(k)
542        #         if sl: sl += ' + '
543        #         sl += str(coordVarDelta[lbl])+' * '+str(k)
544        #         s += coordVarDelta[lbl] * k
545        #     print 'a'+str(i)+' = '+l
546        #     print '\t= '+sl
547        #     print  modelist[i],shortmodelist[i],modeVarDelta[modelist[i]],s
548        #     print
549
550        # print 70*'='
551        # # compute the coordinate displacements from the reported mode values
552        # for i,lbl,row in zip(range(len(coordVarLbl)),coordVarLbl,displacivemodematrix):
553        #     l = ''
554        #     sl = ''
555        #     s = 0.0
556        #     for j,k in enumerate(row):
557        #         if k == 0: continue
558        #         if l: l += ' + '
559        #         l += 'a'+str(j+1)+' * '+str(k)
560        #         if sl: sl += ' + '
561        #         sl += str(shortmodelist[j]) +' = '+ str(modeVarDelta[modelist[j]]) + ' * '+str(k)
562        #         s += modeVarDelta[modelist[j]] * k
563        #     print lbl+' = '+l
564        #     print '\t= '+sl
565        #     print lbl,G2varLbl[i],coordVarDelta[lbl],s
566        #     print
567
568        # determine the coordinate delta values from deviations from the parent structure
569        # for atmline in self.Phase['Atoms']:
570        #     lbl = atmline[0]
571        #     x,y,z = atmline[3:6]
572        #     if lbl not in ParentCoordinates:
573        #         print lbl,x,y,z
574        #         continue
575        #     px,py,pz = ParentCoordinates[lbl]
576        #     print lbl,x,y,z,x-px,y-py,z-pz
Note: See TracBrowser for help on using the repository browser.