Package diffpy :: Package Structure :: Package expansion :: Module shapeUtils
[hide private]
[frames] | no frames]

Source Code for Module diffpy.Structure.expansion.shapeUtils

 1  #!/usr/bin/env python 
 2  ############################################################################## 
 3  # 
 4  # PDFgui            by DANSE Diffraction group 
 5  #                   Simon J. L. Billinge 
 6  #                   (c) 2008 trustees of the Michigan State University. 
 7  #                   All rights reserved. 
 8  # 
 9  # File coded by:    Chris Farrow 
10  # 
11  # See AUTHORS.txt for a list of people who contributed. 
12  # See LICENSE.txt for license information. 
13  # 
14  ############################################################################## 
15   
16  """Utilities for making shapes.""" 
17   
18  __id__ = "$Id: shapeUtils.py 2980 2009-04-02 00:14:33Z juhas $" 
19   
20 -def findCenter(S):
21 """Find the approximate center atom of a structure. 22 23 The center of the structure is the atom closest to (0.5, 0.5, 0.5) 24 25 Returns the index of the atom. 26 """ 27 best = -1 28 bestd = len(S) 29 center = [0.5, 0.5, 0.5] # the cannonical center 30 31 for i in range(len(S)): 32 d = S.lattice.dist(S[i].xyz, center) 33 if d < bestd: 34 bestd = d 35 best = i 36 37 return best
38 39 if __name__ == "__main__": 40 41 import os.path 42 datadir = "../../tests/testdata" 43 S = Structure() 44 S.read(os.path.join(datadir, "CdSe_bulk.stru"), "pdffit") 45 newS = makeEllipsoid(S, 20) 46 newS.write("CdSe_d20.stru", "pdffit") 47 newS = makeEllipsoid(S, 20, 10, 10) 48 newS.write("CdSe_a20_b10_c10.stru", "pdffit") 49 newS = makeEllipsoid(S, 20, 15, 10) 50 newS.write("CdSe_a20_b15_c10.stru", "pdffit") 51 S = Structure() 52 S.read(os.path.join(datadir, "Ni.stru"), "pdffit") 53 newS = makeEllipsoid(S, 20) 54 newS.write("Ni_d20.stru", "pdffit") 55 newS = makeEllipsoid(S, 20, 4) 56 newS.write("Ni_a20_b4_c20.stru", "pdffit") 57 newS = makeEllipsoid(S, 20, 15, 10) 58 newS.write("Ni_a20_b15_c10.stru", "pdffit") 59