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)
In [186]:
2400 / 1.5664649389
Out[186]:
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?
In [154]:
from scipy.spatial.distance import pdist, squareform
In [155]:
squareform(pdist(ps))
Out[155]:
In [152]:
ps.shape
Out[152]:
In [134]:
np.matmul
Out[134]:
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])