Changeset 5360
- Timestamp:
- Oct 29, 2022 5:45:12 PM (11 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r5356 r5360 573 573 else: 574 574 kw['style'] = wx.TE_PROCESS_ENTER 575 if 'size' not in kw: # wx 4.2.0 needs a size 576 kw['size'] = (105,-1) 575 577 if typeHint is not None: 576 578 self.type = typeHint -
trunk/GSASIIpwdGUI.py
r5354 r5360 3946 3946 def OnIndexPeaks(event): 3947 3947 PatternId = G2frame.PatternId 3948 print ('Peak Indexing')3948 #print ('Peak Indexing') 3949 3949 keepcells = [] 3950 3950 try: -
trunk/ISODISTORT.py
r5130 r5360 17 17 import os 18 18 import os.path 19 import requests 19 try: 20 import requests 21 except: 22 print('Module requests not installed, access to ISODISTORT not possible') 20 23 import copy 21 24 import GSASIIscriptable as G2sc -
trunk/docs/source/packages.rst
r5317 r5360 73 73 (`conda create -n <env> package-list...`), it will not be added 74 74 unless you request it specifically. 75 75 * requests: this package simplifies http access 76 (https://requests.readthedocs.io/). It is used for access to 77 webpages such as ISODISTORT and for some internal software downloads. 78 76 79 *Conda command*: 77 80 Here is a typical conda command used to install a GSAS-II compatible 78 81 Python interpreter:: 79 82 80 conda install python=3.9 wxpython numpy scipy matplotlib pyopengl pillow h5py imageio subversion -c conda-forge83 conda install python=3.9 wxpython numpy scipy matplotlib pyopengl pillow h5py imageio subversion requests -c conda-forge 81 84 82 85 or to put a Python configured for GSAS-II into a separate conda … … 84 87 command:: 85 88 86 conda create -n g2python python=3.9 wxpython numpy scipy matplotlib pyopengl pillow h5py imageio conda subversion -c conda-forge89 conda create -n g2python python=3.9 wxpython numpy scipy matplotlib pyopengl pillow h5py imageio conda subversion requests -c conda-forge 87 90 88 91 Note that at present the subversion is only available for Linux, so -
trunk/fsource/NISTlatsubs/OUTPT1.f
r5355 r5360 194 194 2700 FORMAT(//36X,'***** Supercell ',I3,' *****'/) 195 195 2800 FORMAT(//37X,'***** Subcell ',I3,' *****'/) 196 2900 FORMAT(1X,'T 1=',4X,3F7.2,'/',3F7.2,'/',3F7.2) 197 3000 FORMAT(1X,'T 2=',4X,3F7.2,'/',3F7.2,'/',3F7.2) 198 3100 FORMAT(1X,'T 2 INV=',3F7.2,'/',3F7.2,'/',3F7.2) 196 C Minor formatting change by Brian Toby 10/29/2022: increase sig. digits 197 C for cell reduction matrix display 198 C 2900 FORMAT(1X,'T 1=',4X,3F7.2,'/',3F7.2,'/',3F7.2) 199 C 3000 FORMAT(1X,'T 2=',4X,3F7.2,'/',3F7.2,'/',3F7.2) 200 C 3100 FORMAT(1X,'T 2 INV=',3F7.2,'/',3F7.2,'/',3F7.2) 201 2900 FORMAT(1X,'T 1=',4X,3F14.7,'/',3F14.7,'/',3F14.7) 202 3000 FORMAT(1X,'T 2=',4X,3F14.7,'/',3F14.7,'/',3F14.7) 203 3100 FORMAT(1X,'T 2 INV=',3F14.7,'/',3F14.7,'/',3F14.7) 199 204 3200 FORMAT(1H+,108X,'** Cell Matrix **'/) 200 205 3300 FORMAT(1X,'CELL 1=',3F10.4,1X,3F10.3,14X,'V1=',F10.2,5X,3F10.3) -
trunk/fsource/SConstruct
r5356 r5360 382 382 installcmd = "copy $TARGET " + InstallLoc 383 383 else: 384 installcmd = " cp -p$TARGET " + InstallLoc384 installcmd = "mv $TARGET " + InstallLoc 385 385 return [cmd, installcmd] 386 386 env.Append(BUILDERS = {'nist' : Builder(generator = generate_nist)},) -
trunk/nistlat.py
r5357 r5360 14 14 This implements an interface to the NIST*LATTICE code using 15 15 the Spring 1991 program version. NIST*LATTICE, "A Program to Analyze 16 Lattice Relationships" was created by Vicky Lynn Karen and Alan D. Mighell, 17 National Institute of Standards and Technology, Materials Science and 18 Engineering Laboratory, Gaithersburg, Maryland 20899. 19 20 [cite: V. L. Karen and A. D. Mighell, NIST Technical Note 1290 21 (1991), https://nvlpubs.nist.gov/nistpubs/Legacy/TN/nbstechnicalnote1290.pdf; 22 V. L. Karen & A. D. Mighell, U.S. Patent 5,235,523, 16 Lattice Relationships" was created by Vicky Lynn Karen and Alan D. Mighell 17 (National Institute of Standards and Technology, Materials Science and 18 Engineering Laboratory, Gaithersburg, Maryland 20899.) 19 Minor code modifications made to provide more significant digits for 20 cell reduction matrix terms. 21 22 [if used cite: V. L. Karen and A. D. Mighell, NIST Technical Note 1290 (1991), 23 https://nvlpubs.nist.gov/nistpubs/Legacy/TN/nbstechnicalnote1290.pdf; 24 and V. L. Karen & A. D. Mighell, U.S. Patent 5,235,523, 23 25 https://patents.google.com/patent/US5235523A/en?oq=5235523] 24 26 25 27 This is still under development; not yet in use. 26 28 27 Easy part done: cell reduction and reversion of that. Work to come, 28 "Search for higher symmetry unit cells" & "Relate two unit cells" 29 Work to come: "Relate two unit cells" 29 30 ''' 30 31 … … 40 41 41 42 def showCell(cell,center,setting): 42 'format cell input or output' 43 '''show unit cell input or output nicely formatted. 44 :param list cell: six lattice constants as float values. 45 :param str center: cell centering code; one of P/A/B/C/F/I/R 46 Note that 'R' is used for rhombohedral lattices in either 47 rhombohedral (primitive) or hexagonal cells. 48 :param str setting: is ' ' except for rhombohedral symmetry where 49 it will be R or H for the cell type. 50 :returns: a formatted string 51 ''' 43 52 s = "{:.4f} {:.4f} {:.4f} {:.3f} {:.3f} {:.3f}".format(*cell) 44 53 s += ' ' + centerLbl.get(center,'?') … … 47 56 48 57 def uniqCells(cellList): 49 'remove duplicated cells from an output list' 58 '''remove duplicated cells from a cell output list 59 :param list cellList: A list of reduced cells where each entry represents a 60 reduced cell as (_,cell,_,_,center,...) where cell has six lattice 61 constants and center is the cell centering code (P/A/B/C/F/I/R). 62 :returns: a list as above, but where each unique cell is listed only once 63 ''' 50 64 uList = [] 51 65 shown = [] … … 56 70 uList.append(i) 57 71 return uList 72 73 def emulateLP(line,fp): 74 '''Emulate an antique 132 column line printer, where the first column 75 that is printed is used for printer control. '1' starts a new page 76 and '0' double-spaces. Not implemented is '+' which overprints. 77 If the file pointer is not None, the line is copied to the 78 file, removing the first column but adding a bit of extra formatting 79 to separate pages or add a blank line where needed. 80 81 :param str line: string to be printed 82 :param file fp: file pointer object 83 ''' 84 if not fp: return 85 if line[0] == '1': 86 fp.write('\n'+130*'='+'\n'+line[1:]) 87 elif line[0] == '0': 88 fp.write('\n'+line[1:]) 89 elif len(line) == 1: 90 fp.write('\n') 91 else: 92 fp.write(line[1:]) 58 93 59 def ReduceCell(center, cellin,mode=0,deltaV=0):94 def ReduceCell(center, cellin, mode=0, deltaV=0, output=None): 60 95 '''Compute reduced cell(s) with NIST*LATTICE 61 96 62 :param str center: cell centering code ,one of P/A/B/C/F/I/R97 :param str center: cell centering code; one of P/A/B/C/F/I/R 63 98 Note that 'R' is used for rhombohedral lattices in either 64 99 hexagonal or rhombohedral (primitive) cells … … 71 106 :param int deltaV: volume ratios for sub/supercells if mode != 0 as 72 107 ratio of original cell to smallest subcell or largest supercell. Ignored 73 if mode=0. 108 if mode=0. 109 :param str output: name of file to write the NIST*LATTICE output 74 110 :returns: a dict with item 'input' with input cell as (cell,center,setting) 75 111 and 'output' which is a list of reduced cells of form … … 89 125 (a,b,c,alpha,beta,gamma) = cellin 90 126 celldict = {} 91 if center == "R": 127 if center == "R" and alpha == 90 and beta == 90 and gamma == 120: 128 setting = "H" 129 elif center == "R" : 92 130 setting = "R" 93 elif alpha == 90 and beta == 90 and gamma == 120:94 setting = "H"95 131 # prepare input and start program 96 132 cellline = '{:10.4f}{:10.4f}{:10.4f}{:10.3f}{:10.3f}{:10.3f}'.format(*cellin) … … 110 146 line = '?' 111 147 linenum = 0 148 fp = None 149 if output: fp = open(output,'w') 112 150 try: 113 151 for b in p.stdout.readlines(): 114 152 linenum += 1 115 153 line = b.decode() 154 emulateLP(line,fp) 116 155 pat = r"T 2= (.*)/ (.*)/ (.*)" # transform matrix 117 156 s = re.split(pat,line) … … 137 176 finally: 138 177 p.terminate() 139 if len(celldict['output'] or len(err) > 0) ==0:178 if len(celldict['output']) == 0 or len(err) > 0: 140 179 print('Error:' ,err.decode()) 141 180 return celldict … … 190 229 191 230 231 def CompareCell(cell1, center1, cell2, center2, tolerance=3*[0.2]+3*[1], 232 mode='I', vrange=8, output=None): 233 '''Search for matrices that relate two unit cells 234 235 :param list cell1: six lattice constants as float values for 1st cell 236 :param str center1: cell centering code for 1st cell; one of P/A/B/C/F/I/R 237 Note that 'R' is used for rhombohedral lattices in either 238 hexagonal or rhombohedral (primitive) cells 239 :param list cell2: six lattice constants as float values for 2nd cell 240 :param str center2: cell centering code for 2nd cell (see center1) 241 :param list tolerance: comparison tolerances for a, b, c, alpha, beta 242 & gamma (defaults to [0.2,0.2,0.2,1.,1.,1.] 243 :param str mode: search mode, which should be either 'I' or 'F' 244 'I' provides searching with integral matrices or 245 'F' provides searching with integral and fractional matrices 246 :param int vrange: maximum matrix term range. 247 Must be 1 <= vrange <= 10 for mode='F' or 248 Must be 1 <= vrange <= 40 for mode='I' 249 :param str output: name of file to write the NIST*LATTICE output 250 251 :returns: a list of matrices that match cell1 to cell2 where 252 each entry contains (det, im, m, tol, one2two, two2one) where 253 0: det is the determinant, giving the volume ratio between cells 254 1: im relates the reduced cell for cell1 to the reduced cell for cell2 255 2: m relates the reduced cell for cell2 to the reduced cell for cell1 256 3: tol quality of agreement as six differences between the 257 two reduced cells 258 4: one2two numpy matrix that transforms cell1 to cell2 259 5: two2one numpy matrix that transforms cell2 to cell1 260 ''' 261 # reduce input cells. Save cell, volume and matrix 262 rcVmat = [[],[]] 263 rcVmat[0] = ReduceCell(center1,cell1)['output'][0][1:4] 264 rcVmat[1] = ReduceCell(center2,cell2)['output'][0][1:4] 265 reverseCells = False 266 if rcVmat[0][1] < rcVmat[1][1]: # largest volume goes first 267 reverseCells = True 268 rcVmat = list(reversed(rcVmat)) 269 # prepare input and start program 270 inp = "REL 1\n" 271 inp += "{:.1s} {:2d} {:10.5f}{:10.5f}{:10.5f}{:10.5f}{:10.5f}{:10.5f}\n".format( 272 mode,vrange,*tolerance) 273 for i in range(2): 274 inp += " {:10.5f}{:10.5f}{:10.5f}{:10.4f}{:10.4f}{:10.4f}\n".format( 275 *rcVmat[i][0]) 276 p = subprocess.Popen([nistlattice], 277 stdin=subprocess.PIPE, 278 stdout=subprocess.PIPE, 279 stderr=subprocess.PIPE) 280 p.stdin.write(bytearray(inp,'utf8')) 281 p.stdin.close() 282 err = p.stderr.read() 283 line = '?' 284 fp = None 285 if output: fp = open(output,'w') 286 # read output and parse 287 lines = [b.decode() for b in p.stdout.readlines()] 288 p.terminate() 289 if fp: 290 for line in lines: emulateLP(line,fp) 291 fp.close() 292 lnum = 0 293 while lnum < len(lines): 294 if ' H Matrix ' in lines[lnum] and ' Determinant' in lines[lnum]: 295 lnum += 2 296 break 297 lnum += 1 298 else: 299 print('no header found') 300 return [] 301 302 xforms = [] 303 while lnum < len(lines): 304 try: 305 sl = lines[lnum].split() 306 if len(sl) == 10: 307 sl = [float(i) for i in sl] 308 m = 3*[3*[0]] # forward matrix 309 im = 3*[3*[0]] # inverse matrix 310 tol = 6*[0] 311 m[0] = sl[0:3] 312 im[0] = sl[3:6] 313 tol[0:3] = sl[6:9] 314 det = sl[9] 315 316 lnum += 1 317 sl = [float(i) for i in lines[lnum].split()] 318 m[1] = sl[0:3] 319 im[1] = sl[3:6] 320 tol[3:] = sl[6:9] 321 322 lnum += 1 323 sl = [float(i) for i in lines[lnum].split()] 324 m[2] = sl[0:3] 325 im[2] = sl[3:6] 326 327 xmatI = np.dot(np.dot(np.linalg.inv(rcVmat[0][2]),m),rcVmat[1][2]) 328 xmat = np.dot(np.dot(np.linalg.inv(rcVmat[1][2]),im),rcVmat[0][2]) 329 if reverseCells: 330 one2two, two2one = xmatI, xmat 331 xforms.append((det, m, im, tol, one2two, two2one)) 332 else: 333 one2two, two2one = xmat, xmatI 334 xforms.append((det, im, m, tol, one2two, two2one)) 335 except Exception as msg: 336 print('error with line',lnum,msg) 337 print(lines[lnum]) 338 339 lnum += 1 340 if len(err) > 0: 341 print('Execution error:' ,err.decode()) 342 return xforms 343 192 344 if __name__ == '__main__': # test code 345 193 346 import GSASIIlattice as G2lat 347 cell1 = (5.03461,5.03461,13.74753,90,90,120) 348 center1 = 'R' 349 cell2 = (7.40242,5.03461,5.42665,90,84.14,90) 350 center2 = 'P' 351 #print(ReduceCell(center1,cell1,output='/tmp/reduce.txt')) 352 tolerance = 3*[0.1]+3*[.5] 353 print('\ncomparing ',showCell(cell1,center1,' '),showCell(cell2,center2,' ')) 354 out = CompareCell(cell1, center1, cell2, center2, tolerance, output='/tmp/CompCell.txt') 355 for i in out: 356 print(70*'=') 357 print(i[0],i[3],'\n',i[5]) 358 print('testing with 1st entry') 359 print('cell1 ',showCell(cell1,center1,' ')) 360 print('cell2-->cell1',G2lat.TransformCell(cell2,out[0][5])) 361 print('cell2 ',showCell(cell2,center2,' ')) 362 print('cell1-->cell2',G2lat.TransformCell(cell1,out[0][4])) 363 364 out = CompareCell(cell2, center2, cell1, center1, tolerance) 365 print('reversed input, testing with 1st entry') 366 print('cell1 ',showCell(cell2,center2,' ')) 367 print('cell2-->cell1',G2lat.TransformCell(cell1,out[0][5])) 368 print('cell2 ',showCell(cell1,center1,' ')) 369 print('cell1-->cell2',G2lat.TransformCell(cell2,out[0][4])) 370 371 372 center2 = 'I' 373 print('\n\ncomparing ',showCell(cell1,center1,' '),showCell(cell2,center2,' ')) 374 out = CompareCell(cell1, center1, cell2, center2, tolerance) 375 for i in out: 376 print(70*'=') 377 print(i[0],i[3],'\n',i[5]) 378 print('testing with 1st entry') 379 print('cell1 ',showCell(cell1,center1,' ')) 380 print('cell2-->cell1',G2lat.TransformCell(cell2,out[0][5])) 381 print('cell2 ',showCell(cell2,center2,' ')) 382 print('cell1-->cell2',G2lat.TransformCell(cell1,out[0][4])) 383 384 import sys; sys.exit() 385 386 194 387 cellin = [5.,5.,5.,85.,85.,85.,] 195 388 cellList = ConvCell(cellin)
Note: See TracChangeset
for help on using the changeset viewer.