def LatticeViewer(lattice, atoms, isCartesian=True): if not isCartesian: atoms = atoms2cart(lattice, atoms) lx, ly, lz = lattice if doTranslate: cx, cy, cz = 0.5 * (lx + ly + lz) else: cx, cy, cz = 0, 0, 0 o = array([-cx, -cy, -cz]) gray = (0.5, 0.5, 0.5) red = (1, 0, 0) lines = [ (tuple(o), tuple(o + lx), gray), (tuple(o + lx), tuple(o + lx + ly), gray), (tuple(o + lx + ly), tuple(o + ly), gray), (tuple(o + ly), tuple(o), gray), (tuple(o + lz), tuple(o + lx + lz), gray), (tuple(o + lx + lz), tuple(o + lx + ly + lz), gray), (tuple(o + lx + ly + lz), tuple(o + ly + lz), gray), (tuple(o + ly + lz), tuple(o + lz), gray), (tuple(o), tuple(o + lz), gray), (tuple(o + lx), tuple(o + lx + lz), gray), (tuple(o + lx + ly), tuple(o + lx + ly + lz), gray), (tuple(o + ly), tuple(o + ly + lz), gray), ] spheres = [] for sym, pos in atoms: x, y, z = pos x, y, z = x - cx, y - cy, z - cz spheres.append(((x, y, z), 0.3, red, 20, 20)) cyls = [] bs = BSWindow(spheres, cyls, lines) bs.run() return
from Pistol.Util import distance from Pistol.XYZ import read for filename in sys.argv[1:]: geos = read(filename,do_center=1) geo = geos[-1] spheres = [] for atno,(x,y,z) in geo: r,g,b = color[atno] rad = radius[atno] rad *= 0.25 r /= 255. g /= 255. b /= 255. spheres.append(((x,y,z),rad,(r,g,b),20,20)) cyls = [] nat = len(geo) for i in range(nat): atno1,(x1,y1,z1) = geo[i] for j in range(i): atno2,(x2,y2,z2) = geo[j] r12 = distance((x1,y1,z1),(x2,y2,z2)) r12o = 0.6*(radius[atno1]+radius[atno2]) if 0.3 < r12 < r12o: cyls.append(((x1,y1,z1),(x2,y2,z2),0.15,20,(0.5,0.5,0.5))) bs = BSWindow(spheres,cyls) bs.run()