Changeset 3191 for trunk/imports/G2phase_CIF.py
- Timestamp:
- Dec 13, 2017 8:26:51 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/imports/G2phase_CIF.py
r3186 r3191 55 55 while self.Phase['ranId'] in usedRanIdList: 56 56 self.Phase['ranId'] = ran.randint(0,sys.maxsize) 57 self.MPhase = G2obj.SetNewPhase(Name='new phase') # create a new empty phase dict 58 # make sure the ranId is really unique! 59 while self.MPhase['ranId'] in usedRanIdList: 60 self.MPhase['ranId'] = ran.randint(0,sys.maxsize) 57 61 returnstat = False 58 62 cellitems = ( … … 74 78 try: 75 79 cf = G2obj.ReadCIF(filename) 76 except :77 msg = 'Unreadable cif file'80 except cif.StarError as msg: 81 msg = 'Unreadable cif file\n'+str(msg) 78 82 self.errors = msg 79 83 self.warnings += msg … … 109 113 choice[-1] += '1 atom' 110 114 else: 111 choice[-1] += ('%d' % n d) + ' atoms'115 choice[-1] += ('%d' % na) + ' atoms' 112 116 choice[-1] += ', cell: ' 113 117 fmt = "%.2f," … … 131 135 E = True 132 136 Super = False 133 if blk.get("_space_group_ssg_name",''): 137 moddim = int(blk.get("_cell_modulation_dimension",'0')) 138 if moddim: 134 139 Super = True 140 if moddim > 1: 141 msg = 'more than 3+1 super symmetry is not allowed in GSAS-II' 142 self.errors = msg 143 self.warnings += msg 144 return False 145 if blk.get('_cell_subsystems_number'): 146 msg = 'Composite super structures not allowed in GSAS-II' 147 self.errors = msg 148 self.warnings += msg 149 return False 150 sspgrp = blk.get("_space_group_ssg_name",'') 151 if 'X' in sspgrp: 152 self.warnings += '\nAd hoc incommensurate space group '+sspgrp+' is not allowed in GSAS-II' 153 self.errors = 'Ad hoc incommensurate space groups not allowed in GSAS-II' 154 return False 135 155 magnetic = False 136 156 self.Phase['General']['Type'] = 'nuclear' … … 139 159 SpGrp = blk.get("_space_group_name_H-M_alt",'') 140 160 if not SpGrp: 141 SpGrp = blk.get("_parent_space_group.name_H-M",'') 161 MSpGrp = blk.get("_space_group.magn_name_BNS",'') 162 SpGrp = MSpGrp.replace("'",'') 163 if '_' in SpGrp: SpGrp = SpGrp.split('_')[1] 142 164 if SpGrp: #TODO need to decide if read nuclear phase or magnetic phase 143 165 magnetic = True 144 self. Phase['General']['Type'] = 'magnetic'145 self. Phase['General']['AtomPtrs'] = [3,1,10,12]166 self.MPhase['General']['Type'] = 'magnetic' 167 self.MPhase['General']['AtomPtrs'] = [3,1,10,12] 146 168 if Super: 147 sspgrp = blk.get("_space_group_ssg_name",'').split('(') 169 sspgrp = blk.get("_space_group_ssg_name",'') 170 sspgrp = sspgrp.split('(') 148 171 SpGrp = sspgrp[0] 149 172 SuperSg = '('+sspgrp[1].replace('\\','') … … 152 175 SpGrp = SpGrp.replace('_','') 153 176 # try normalizing the space group, to see if we can pick the space group out of a table 177 if Super: 178 SpGrp = G2spc.StandardizeSpcName(SpGrp) 179 if not SpGrp: 180 msg = 'GSAS-II failed to find space group symbol; not a valid cif file' 181 self.errors = msg 182 self.warnings += msg 183 return False 184 if not SpGrp: 185 msg = 'GSAS-II failed to find space group symbol; not a valid cif file' 186 self.errors = msg 187 self.warnings += msg 188 return False 154 189 E,SGData = G2spc.SpcGroup(SpGrp) 155 190 if E and SpGrp: … … 165 200 else: 166 201 self.warnings += 'ERROR in space group symbol '+SpGrp 167 if 'X' in SpGrp:168 self.warnings += '\nAd hoc incommensurate space groups not allowed in GSAS-II'169 202 self.warnings += '\nThe space group has been set to "P 1". ' 170 203 self.warnings += "Change this in phase's General tab." … … 173 206 SGData = G2obj.P1SGData # P 1 174 207 self.Phase['General']['SGData'] = SGData 208 if magnetic: 209 self.MPhase['General']['SGData'] = SGData 175 210 if Super: 176 211 E,SSGData = G2spc.SSpcGroup(SGData,SuperSg) … … 188 223 Volume = G2lat.calc_V(G2lat.cell2A(cell)) 189 224 self.Phase['General']['Cell'] = [False,]+cell+[Volume,] 225 if magnetic: 226 self.MPhase['General']['Cell'] = [False,]+cell+[Volume,] 190 227 if Super: 191 if int(blk.get('_cell_modulation_dimension','')) > 1:192 msg = 'more than 3+1 super symmetry is not allowed in GSAS-II'193 self.errors = msg194 self.warnings += msg195 return False196 228 waveloop = blk.GetLoop('_cell_wave_vector_seq_id') 197 229 waveDict = dict(waveloop.items()) … … 224 256 displSloop = None 225 257 displFloop = None 226 disp Sdict = {}227 disp Fdict = {}258 displSdict = {} 259 displFdict = {} 228 260 UijFloop = None 229 261 UijFdict = {} … … 244 276 UijFdict = dict(UijFloop.items()) 245 277 self.Phase['Atoms'] = [] 278 if magnetic: 279 self.MPhase['Atoms'] = [] 246 280 G2AtomDict = { '_atom_site_type_symbol' : 1, 247 281 '_atom_site_label' : 0, … … 320 354 Spos = np.zeros((4,6)) 321 355 nim = -1 322 for i,item in enumerate(displFdict['_atom_site_displace_fourier_atom_site_label']): 323 if item == atomlist[0]: 324 waveType = 'Fourier' 325 ix = ['x','y','z'].index(displFdict['_atom_site_displace_fourier_axis'][i]) 326 im = int(displFdict['_atom_site_displace_fourier_wave_vector_seq_id'][i]) 327 if im != nim: 328 nim = im 329 val = displFdict['_atom_site_displace_fourier_param_sin'][i] 330 Spos[im-1][ix] = cif.get_number_with_esd(val)[0] 331 val = displFdict['_atom_site_displace_fourier_param_cos'][i] 332 Spos[im-1][ix+3] = cif.get_number_with_esd(val)[0] 356 waveType = 'Fourier' 357 if displFdict: 358 for i,item in enumerate(displFdict['_atom_site_displace_fourier_atom_site_label']): 359 if item == atomlist[0]: 360 waveType = 'Fourier' 361 ix = ['x','y','z'].index(displFdict['_atom_site_displace_fourier_axis'][i]) 362 im = int(displFdict['_atom_site_displace_fourier_wave_vector_seq_id'][i]) 363 if im != nim: 364 nim = im 365 val = displFdict['_atom_site_displace_fourier_param_sin'][i] 366 Spos[im-1][ix] = cif.get_number_with_esd(val)[0] 367 val = displFdict['_atom_site_displace_fourier_param_cos'][i] 368 Spos[im-1][ix+3] = cif.get_number_with_esd(val)[0] 333 369 if nim >= 0: 334 370 Spos = [[spos,False] for spos in Spos[:nim]]
Note: See TracChangeset
for help on using the changeset viewer.