In [1]:
import ase.io as io
from ase.build import cut
from ase.spacegroup import crystal

a = 9.04
skutterudite = crystal(('Co', 'Sb'),
                       basis=[(0.25, 0.25, 0.25), (0.0, 0.335, 0.158)],
                       spacegroup=204,
                       cellpar=[a, a, a, 90, 90, 90])

# Create a new atoms instance with Co at origo including all atoms on the
# surface of the unit cell
cosb3 = cut(skutterudite, origo=(0.25, 0.25, 0.25), extend=1.01)

# Define the atomic bonds to show
bondatoms = []
symbols = cosb3.get_chemical_symbols()
for i in range(len(cosb3)):
    for j in range(i):
        if (symbols[i] == symbols[j] == 'Co' and
            cosb3.get_distance(i, j) < 4.53):
            bondatoms.append((i, j))
        elif (symbols[i] == symbols[j] == 'Sb' and
              cosb3.get_distance(i, j) < 2.99):
            bondatoms.append((i, j))

# Create nice-looking image using povray
io.write('spacegroup-cosb3.pov', cosb3,
         transparent=True,
         display=False,
         run_povray=True,
         camera_type='perspective',
         background=(0, 0, 0, 1.),
         canvas_width=1200,
         radii=0.4,
         rotation='90y',
         bondlinewidth=0.07,
         bondatoms=bondatoms)


---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-1-5d27b0cf746b> in <module>
     36          rotation='90y',
     37          bondlinewidth=0.07,
---> 38          bondatoms=bondatoms)

~\Miniconda3\envs\arpes\lib\site-packages\ase\io\formats.py in write(filename, images, format, parallel, append, **kwargs)
    403 
    404     _write(filename, fd, format, io, images, parallel=parallel, append=append,
--> 405            **kwargs)
    406 
    407 

~\Miniconda3\envs\arpes\lib\site-packages\ase\io\formats.py in _write(filename, fd, format, io, images, parallel, append, **kwargs)
    450                              .format(format))
    451         else:
--> 452             io.write(filename, images, **kwargs)
    453 
    454 

~\Miniconda3\envs\arpes\lib\site-packages\ase\io\pov.py in write_pov(filename, atoms, run_povray, povray_path, stderr, extras, **parameters)
    483         if errcode != 0:
    484             raise OSError('Povray command ' + cmd +
--> 485                           ' failed with error code %d' % errcode)

OSError: Povray command povray spacegroup-cosb3.ini 2> /dev/null failed with error code 1

POVRay Settings

To get transparency modify pov ray .pov file to include

background {srgbt <0.00, 0.00, 0.00, 1.00>}

and the .ini file to contain

Output_Alpha=True

You can also adjust the .pov file to change the distance to the spotlight source, and adjust the diffuse lighting conditions on ase3.


In [186]:
2400 / 1.5664649389


Out[186]:
1532.112172063885

In [80]:
from arpes.utilities.bz import hex_cell

a = 5.761
c = 12.178
alloy = crystal(
    symbols=['S', 'Nb', 'Fe', 'Nb'], 
    basis=[(1./3, 0, 3./8,), (1./3, 2./3, 0), (1./3, 2./3, 1./4), (0, 0, 0)], 
    cell=hex_cell(a=a, c=c), 
    spacegroup=182,
)

fenbs2 = cut(alloy, origo=(0, 0, 0.28), extend=(3.01, 3.01, 6.91), clength=2.1, tolerance=1)

# Define the atomic bonds to show
bondatoms = []
symbols = fenbs2.get_chemical_symbols()
for i in range(len(fenbs2)):
    for j in range(i):
        if (symbols[i] in {'Nb', 'S'} and symbols[j] in {'S', 'Nb'} and symbols[i] != symbols[j] and
            fenbs2.get_distance(i, j) < 4):
            bondatoms.append((i, j))

# Create nice-looking image using povray
io.write('spacegroup-fenbs2.pov', fenbs2,
         transparent=False,
         display=False,
         run_povray=True,
         camera_type='perspective',
         canvas_width=1200,
         radii=0.4,
         rotation='5y,-80x',
         bondlinewidth=0.07,
         bondatoms=bondatoms)

#view(alloy, viewer='x3d')

In [70]:
from ase.build import graphene_nanoribbon
graphene =

In [85]:
a = 5.761
c = 12.178
graphene = graphene_nanoribbon(3, 3, sheet=True)
overlayer = graphene.copy()


# Define the atomic bonds to show
bondatoms = []
symbols = graphene.get_chemical_symbols()

for i in range(len(graphene)):
    for j in range(i):
        if graphene.get_distance(i, j) < 1.5:
            bondatoms.append((i, j))

# Create nice-looking image using povray
io.write('spacegroup-graphene.pov', graphene,
         transparent=False,
         display=False,
         run_povray=True,
         camera_type='perspective',
         canvas_width=1200,
         radii=0.4,
         rotation='0y,-90x',
         bondlinewidth=0.07,
         bondatoms=bondatoms)

#view(alloy, viewer='x3d')

In [183]:
from ase.build import mx2, stack

ws2 = mx2('WS2', size=(30, 30, 1))

# Define the atomic bonds to show
bondatoms = []
symbols = ws2.get_chemical_symbols()

ls = []
for i in ws2:
    ls.append(i.position)
    
ps = np.stack(ls)
vs = squareform(pdist(ps))

for i in range(vs.shape[0]):
    for j in range(i):
        if vs[i,j] < 3:
            bondatoms.append((i, j))

# Create nice-looking image using povray
colors.jmol_colors[74] = (44. / 255, 132. / 255, 30. / 255) # W
colors.jmol_colors[16] = (109. / 255, 193. / 255, 96. / 255)
colors.cpk_colors[74] = (44. / 255, 132. / 255, 30. / 255) # W
colors.cpk_colors[16] = (109. / 255, 193. / 255, 96. / 255)

#colors.jmol_colors[74] = (229. / 255, 139. / 255, 22. / 255) # W
#colors.jmol_colors[34] = (224. / 255, 169. / 255, 98. / 255) # W
#colors.cpk_colors[74] = (229. / 255, 139. / 255, 22. / 255) # W
#colors.cpk_colors[34] = (224. / 255, 169. / 255, 98. / 255) # W


io.write('spacegroup-ws2.pov', ws2,
         transparent=True,
         display=False,
         run_povray=False,
         camera_type='orthographic',
         canvas_width=1200,
         background=(0, 0, 0, 1.,), # weird alpha convention
         radii=0.4,
         rotation='0y,0x',
         bondlinewidth=0.07,
         bondatoms=bondatoms)

#view(alloy, viewer='x3d')

# W 44, 132, 30
# S 109, 193, 96

# W 229, 139, 22
# Se 224, 169, 98

In [174]:
from ase.data import colors
colors.jmol_colors = colors_copy

In [165]:
io.write?


Signature: io.write(filename, images, format=None, parallel=True, append=False, **kwargs)
Docstring:
Write Atoms object(s) to file.

filename: str or file
    Name of the file to write to or a file descriptor.  The name '-'
    means standard output.
images: Atoms object or list of Atoms objects
    A single Atoms object or a list of Atoms objects.
format: str
    Used to specify the file-format.  If not given, the
    file-format will be taken from suffix of the filename.
parallel: bool
    Default is to write on master only.  Use parallel=False to write
    from all slaves.
append: bool
    Default is to open files in 'w' or 'wb' mode, overwriting existing files.
    In some cases opening the file in 'a' or 'ab' mode (appending) is usefull,
    e.g. writing trajectories or saving multiple Atoms objects in one file.
    WARNING: If the file format does not support multiple entries without
    additional keywords/headers, files created using 'append=True'
    might not be readable by any program! They will nevertheless be
    written without error message.

The use of additional keywords is format specific.
File:      ~/anaconda/envs/python_arpes/lib/python3.5/site-packages/ase/io/formats.py
Type:      function

In [154]:
from scipy.spatial.distance import pdist, squareform

In [155]:
squareform(pdist(ps))


Out[155]:
array([[  0.        ,   2.43204132,   2.43204132, ...,  28.62      ,
         30.26600114,  30.26600114],
       [  2.43204132,   0.        ,   3.19      , ...,  27.09257509,
         28.62      ,  28.79723077],
       [  2.43204132,   3.19      ,   0.        , ...,  27.09257509,
         28.79723077,  28.62      ],
       ..., 
       [ 28.62      ,  27.09257509,  27.09257509, ...,   0.        ,
          2.43204132,   2.43204132],
       [ 30.26600114,  28.62      ,  28.79723077, ...,   2.43204132,
          0.        ,   3.19      ],
       [ 30.26600114,  28.79723077,  28.62      , ...,   2.43204132,
          3.19      ,   0.        ]])

In [152]:
ps.shape


Out[152]:
(300, 3)

In [134]:
np.matmul


Out[134]:
<function numpy.core.multiarray.matmul>

In [15]:
fig, ax = plt.subplots(1, 3, figsize=(15, 5,))

arr = xr.DataArray(np.linspace(0, 1, 100), coords={'x': np.linspace(0, 0.1, 100)}, dims=['x'])
arr.plot(ax=ax[0])

copied = arr.copy(deep=True)
copied.coords['x'] = copied.coords['x'] + 0.05
copied.plot(ax=ax[1])

arr.plot(ax=ax[2])
for axi in ax:
    axi.set_xlim([0, 0.15])
    axi.set_ylim([0, 1])



In [ ]:
fig, ax = plt.subplots(1, 3, figsize=(15, 5,))

arr = xr.DataArray(np.linspace(0, 1, 100), coords={'x': np.linspace(0, 0.1, 100)}, dims=['x'])
arr.plot(ax=ax[0])

copied = arr.copy(deep=True)
copied.coords['x'] += 0.05
copied.plot(ax=ax[1])

arr.plot(ax=ax[2])