# Introduction to atomman: Basic support and analysis tools

Lucas M. Hale, lucas.hale@nist.gov, Materials Science and Engineering Division, NIST.

Disclaimers

## 1. Introduction

This Notebook outlines some of the other tools in atomman that provide basic support features and simple analysis of the atomistic systems.

Library Imports

:

# Standard Python libraries
import os
from io import open
from copy import deepcopy
import datetime

# http://www.numpy.org/
import numpy as np

# https://pandas.pydata.org/
import pandas as pd

# https://github.com/usnistgov/atomman
import atomman as am
import atomman.unitconvert as uc

# Show atomman version
print('atomman version =', am.__version__)

# Show date of Notebook execution
print('Notebook executed on', datetime.date.today())

atomman version = 1.4.4
Notebook executed on 2022-03-17


Construct a demonstration 2x2x2 diamond cubic silicon system

:

a = uc.set_in_units(5.431, 'angstrom')
ucell = am.load('prototype', 'A4--C--dc', a=a, symbols='Si')

system = ucell.supersize(2,2,2)

print(system.natoms)

64


## 2. Elastic constants

The full elastic constants tensor for a given crystal can be represented with the atomman.ElasticConstants class. The values in an ElasticConstants object can be set and retrieved in a variety of formats and transformed to other Cartesian coordinate systems.

See the 3.1. ElasticConstants class Jupyter Notebook for more details and a full description of all of the class methods.

:

# Define an ElasticConstants object for diamond cubic silicon
# values taken from http://www.ioffe.ru/SVA/NSM/Semicond/Si/mechanic.html
C11 = uc.set_in_units(16.60 * 10**11, 'dyn/cm^2')
C12 = uc.set_in_units( 6.40 * 10**11, 'dyn/cm^2')
C44 = uc.set_in_units( 7.96 * 10**11, 'dyn/cm^2')

C = am.ElasticConstants(C11=C11, C12=C12, C44=C44)

:

# Get 6x6 Cij Voigt representation of elastic constants in GPa
print('Cij (GPa) =')
print(uc.get_in_units(C.Cij, 'GPa'))

Cij (GPa) =
[[166.   64.   64.    0.    0.    0. ]
[ 64.  166.   64.    0.    0.    0. ]
[ 64.   64.  166.    0.    0.    0. ]
[  0.    0.    0.   79.6   0.    0. ]
[  0.    0.    0.    0.   79.6   0. ]
[  0.    0.    0.    0.    0.   79.6]]


## 3. Relative distances between atoms

There are a few built-in tools for investigating the relative positions between atoms of the same and different systems.

### 3.1. System.dvect()

The System.dvect() method computes the shortest vector(s) between two points or list of points within the System taking into account the System’s periodic dimensions.

Parameters

• pos_0 (numpy.ndarray or index) Absolute Cartesian vector position(s) to use as reference point(s). If the value can be used as an index, then self.atoms.pos[pos_0] is taken.

• pos_1 (numpy.ndarray or index) Absolute Cartesian vector position(s) to find relative to pos_0. If the value can be used as an index, then self.atoms.pos[pos_1] is taken.

:

# Calculate shortest vector between atoms 1 and 60
print(system.dvect(1, 60))

[ 4.07325  4.07325 -4.07325]


### 3.2. System.dmag()

The System dmag() method computes the magnitude of the shortest vector(s) between two points or list of points within the System taking into account the System’s periodic dimensions. This is identical to computing dvect above, then finding the magnitude of those vectors, but should be faster.

:

# Calculate shortest distance between position [5., 5., 5.] and all atoms in system
dmags = system.dmag([5.0, 5.0, 5.0], range(system.natoms))
print(dmags)

[8.66025404 5.95297241 5.95297241 5.95297241 6.30856205 3.87088054
3.87088054 3.87088054 7.08419092 6.33398788 6.33398788 3.25939281
5.45266877 2.2175116  5.86626957 5.86626957 7.08419092 6.33398788
3.25939281 6.33398788 5.45266877 5.86626957 2.2175116  5.86626957
5.03701519 6.69334927 3.91218142 3.91218142 4.43455051 4.93424363
4.93424363 7.33774633 7.08419092 3.25939281 6.33398788 6.33398788
5.45266877 5.86626957 5.86626957 2.2175116  5.03701519 3.91218142
6.69334927 3.91218142 4.43455051 4.93424363 7.33774633 4.93424363
5.03701519 3.91218142 3.91218142 6.69334927 4.43455051 7.33774633
4.93424363 4.93424363 0.7465139  4.4706471  4.4706471  4.4706471
3.09820588 6.6163557  6.6163557  6.6163557 ]


### 3.3. displacement()

The atomman.displacement() function compares two systems with the same number of atoms and calculates the vector differences between all atoms with the same atomic id’s. The vectors returned are the shortest vectors after taking periodic boundaries in consideration, i.e. it uses dvect().

Parameters

• system_0 (atomman.System) The initial system to calculate displacements from.

• system_1 (atomman.System) The final system to calculate displacements to.

• box_reference (str or None) Specifies which system’s boundary conditions to use.

• ‘initial’ uses system_0’s box and pbc.

• ‘final’ uses system_1’s box and pbc (Default).

• None computes the straight difference between the positions without accounting for periodic boundaries.

:

# Copy system and randomly displace atoms
system2 = deepcopy(system)
system2.atoms.pos += 3 * np.random.rand(system.natoms, 3)
system2.wrap()

# Show displacement between the two systems
print(am.displacement(system, system2))

[[2.30367917 2.3487104  2.85970854]
[2.27531496 1.02050817 1.25967965]
[1.99799574 1.79240305 2.79155531]
[1.46566173 0.87350871 1.29437791]
[2.77683528 2.19979903 1.16142669]
[0.60495831 1.15905085 1.71790408]
[0.46916565 0.01687008 0.69069794]
[0.03807811 0.17934985 1.84228672]
[1.30814234 2.2749664  2.228111  ]
[0.4733944  1.82776664 1.3905906 ]
[0.64635201 2.19211811 1.22608594]
[2.57601426 0.33474941 2.95331058]
[1.09514577 2.47585748 0.49684326]
[0.58881538 0.21115074 0.55100254]
[1.76572129 2.25280815 2.94703426]
[1.29744841 0.33726989 2.09833713]
[1.60520234 0.02979757 1.20061231]
[0.28008485 1.78521247 0.29061105]
[1.21434029 0.23657935 0.7577544 ]
[2.37806405 2.45198497 2.39362906]
[0.14053644 2.15866906 1.10367296]
[1.0536264  2.29378046 0.23994123]
[0.15528608 2.2203562  1.72805651]
[2.90616602 1.00688418 2.61202397]
[0.21585405 2.95324745 1.88622874]
[1.43118836 2.49088101 2.75680438]
[0.05657582 1.17135651 1.28196146]
[2.10464253 0.18507456 2.85016199]
[0.38826712 2.37178757 2.73443301]
[1.61813321 2.38720787 2.63159538]
[1.95775363 0.80757433 1.47483392]
[1.63511724 2.69818564 1.74395684]
[1.16640353 0.77160045 2.66565507]
[0.32272071 2.49814439 2.15183727]
[2.36899807 1.67740462 1.9469423 ]
[0.2422808  2.5393543  2.4089751 ]
[1.25833723 0.37773689 0.70414346]
[0.09379404 2.18908778 1.35098384]
[2.30804979 0.49560984 0.83050823]
[1.73813343 2.02976942 1.12679582]
[2.57592371 0.18490332 2.47941382]
[2.74878022 2.15525565 0.03469917]
[2.10352374 1.10580935 2.52521685]
[1.35452161 1.28921551 2.70993406]
[0.03276028 1.87242305 2.6855388 ]
[1.68675533 0.89297636 1.80403308]
[0.95034231 0.5505729  2.0755478 ]
[0.04056123 0.02081778 1.3307037 ]
[0.65271422 2.20230841 1.8556757 ]
[0.2528307  0.58758373 2.35980699]
[0.93405983 2.84143804 0.64891983]
[1.58624429 1.2460871  0.73859355]
[2.9127833  0.6539877  0.47553949]
[0.83242444 0.67899395 1.31062329]
[2.95105346 0.79403734 0.5554988 ]
[0.39031125 1.58785371 1.2526019 ]
[1.86368324 2.2306242  0.00973364]
[0.1094249  2.11421856 2.58857125]
[2.95233953 1.31099997 0.26150053]
[0.50435727 0.87342455 2.4600054 ]
[0.48684772 0.66580478 0.89776317]
[2.04569564 0.52110356 0.41227405]
[0.46450444 2.27451199 2.72634176]
[0.12208499 1.80657146 2.59124352]]


### 3.4. System.neighborlist()

A list of neighbor atoms within a cutoff can be constructed using the System.neighborlist() method. The list of neighbors is returned as an atomman.NeighborList object.

See the 3.2. NeighborList class Jupyter Notebook for more details on how the list is calculated and can be used.

Parameters

• cutoff (float, optional) Radial cutoff distance for identifying neighbors. Must be given if model is not given.

• model (str or file-like object, optional) Gives the file path or content to load. If given, no other parameters are allowed.

• initialsize (int, optional) The number of neighbor positions to initially assign to each atom. Default value is 20.

• deltasize (int, optional) Specifies the number of extra neighbor positions to allow each atom when the number of neighbors exceeds the underlying array size. Default value is 10.

Returns

• (atomman.NeighborList) The compiled list of neighbors.

:

# Identify neighbors within 3 angstroms
neighbors = system.neighborlist(cutoff=3)


The coordinataion numbers for the atoms can be retrieved with coord.

:

# Show average atomic coordination
print('Average coordination =', neighbors.coord.mean())

Average coordination = 4.0


Index selection on the NeighborList object will return the indices of the neighbor atoms.

:

# List neighbor atoms of atom 6
print('Neighbors of atom 6 =', neighbors)

Neighbors of atom 6 = [ 2 11 33 40]


The neighbor indices can then be used to filter other properties to only focus on an atom’s neighbors.

:

# List the dmag values between atom 9 and its neighbors
print(system.dmag(9, neighbors))

[2.35169198 2.35169198 2.35169198 2.35169198]


## 4. Region selectors

A number of geometric shape definitions are available in the atomman.region submodule to help identify regions in space above/below planes or inside/outside of regions. These are useful for constructing systems by slicing away atoms to create nanostructures, or for performing analysis on only select regions.

See the 3.3. Region selectors Jupyter Notebook for more details and a list of all available shapes.

:

# Define a plane normal to the y axis and positioned halfway across system
plane = am.region.Plane([0,1,0], system.box.bvect / 2)

# Count number of atoms in system, and above/below plane
print(f'{system.natoms} atoms in system')

abovecount = np.sum(plane.above(system.atoms.pos))
print(f'{abovecount} atoms above plane')

belowcount = np.sum(plane.below(system.atoms.pos))
print(f'{belowcount} atoms below plane')

# Define a sphere centered at [0,0,0] with radius = 6
sphere = am.region.Sphere([0,0,0], 6)

# Count atoms inside sphere
insidecount = np.sum(sphere.inside(system.atoms.pos))
print(f'{insidecount} atoms inside sphere')

64 atoms in system
24 atoms above plane
40 atoms below plane
11 atoms inside sphere


## 5. Basic tools

This lists some of the other basic tools and features in atomman.

### 5.1. Atomic information

• atomman.tools.atomic_number() returns the atomic number associated with an element’s atomic symbol.

• atomman.tools.atomic_symbol() returns the elemental symbol associated with an given atomic number.

• atomman.tools.atomic_mass() returns the atomic mass of an element or isotope. The atom can be identified with atomic number or atomic/isotope symbol.

:

# Get atomic number for an atomic symbol
num = am.tools.atomic_number('Fe')
print(num)

# Get atomic symbol for an atomic number
symbol = am.tools.atomic_symbol(num)
print(symbol)

# Get atomic mass for an atomic symbol
mass = am.tools.atomic_mass(symbol)
print(mass)

# Get atomic mass for an atomic number
mass = am.tools.atomic_mass(num)
print(mass)

26
Fe
55.845
55.845

:

# Get atomic mass for an isotope
mass = am.tools.atomic_mass('Al-26')
print(mass)

25.986891904


### 5.2. axes_check()

The axes_check() function is useful when working in Cartesian systems. Given a (3,3) array representing three 3D Cartesian vectors:

• The three vectors are checked that they are orthogonal and right-handed.

• The corresponding array of unit vectors are returned. This can then be used for crystal transformations.

:

axes = [[-1, 0, 1],
[ 1, 0, 1],
[ 0, 1, 0]]
print(am.tools.axes_check(axes))

[[-0.70710678  0.          0.70710678]
[ 0.70710678  0.          0.70710678]
[ 0.          1.          0.        ]]


### 5.3. filltemplate()

The filltemplate() function takes a template and fills in values for delimited template variables.

:

madlibs = "My friend <name> really likes to use templates to <verb>, says that they are <adjective>!"
s_delimiter = '<'
e_delimiter = '>'

terms = {}
terms['name'] = 'Charlie'
terms['verb'] = 'program'

print(am.tools.filltemplate(madlibs, terms, s_delimiter, e_delimiter))

My friend Charlie really likes to use templates to program, says that they are delicious!


### 5.4. indexstr()

Iterates through all indicies of an array with a given shape, returning both the numeric index and a string representation.

:

for index, istr in am.tools.indexstr((3,2)):
print('index ->', repr(index), ', istr ->', repr(istr))

index -> (0, 0) , istr -> ''
index -> (0, 1) , istr -> ''
index -> (1, 0) , istr -> ''
index -> (1, 1) , istr -> ''
index -> (2, 0) , istr -> ''
index -> (2, 1) , istr -> ''


### 5.5. uber_open_rmode

uber_open_rmode is a context manager that allows for similar reading of content from a file or from a string variable. It equivalently handles:

• str path name to a file

• str content

• open file-like object

:

# Define str and save to file
text = 'Here I am, read me!'
fname = 'text.txt'
with open(fname, 'w') as f:
f.write(text)

# Use uber_open_rmode on text
with am.tools.uber_open_rmode(text) as f:

# Use uber_open_rmode on file path
with am.tools.uber_open_rmode(fname) as f:

# Use uber_open_rmode on file-like object
with open(fname, 'rb') as fobject:
with am.tools.uber_open_rmode(fobject) as f:

b'Here I am, read me!'
b'Here I am, read me!'
b'Here I am, read me!'


### 5.6. vect_angle()

The vect_angle() function returns the angle between two vectors.

:

vect1 = 2*np.random.rand(3)-1
vect2 = 2*np.random.rand(3)-1

print('Angle between', vect1, 'and', vect2, '=')
print(am.tools.vect_angle(vect1, vect2), 'degrees')

Angle between [ 0.82190188 -0.16527953 -0.94974471] and [-0.03216575 -0.5275421  -0.55407587] =
52.763036400965284 degrees


### 5.7. duplicates_allclose()

Determine duplicates in dataframe based on tolerances. The implementation first uses pandas.DataFrame.duplicated on the dcols argument with keep=False to keep all duplicates. The duplicate sub-dataframe is then sorted on both dcols and fcols. A diff between each row is then done on the sorted duplicates dataframe. The float values are then checked for their tolerances.

Note: False duplicates may be identified if tolerance ranges overlap. Consider dataframe with rows 1,2,3. If row 2 matches row 1 within the tolerances, and row 3 matches row 2 within the tolerances, both rows 2 and 3 will be labeled as tolerances even if row 3 does not match row 1 within the tolerances.

Parameters - dataframe (pandas.DataFrame) The dataframe to search for duplicates - dcols (list) The column names that are tested for exact duplicates. - fcols (dict) The column names (keys) that are tested using absolute tolerances (values).

Returns - (list of bool of length nrows) False for first occurrence of checked values, True for subsequent duplicates.

:

# Generate test DataFrame
df = pd.DataFrame({'A':[1.00001, 1.00002, 3.0000, 1.000000], 'B':['Same', 'Diff', 'Same', 'Same']})
df

:

A B
0 1.00001 Same
1 1.00002 Diff
2 3.00000 Same
3 1.00000 Same
:

# Show unique values
df[~am.tools.duplicates_allclose(df, dcols=['B'], fcols={'A':1e-4})]

:

A B
1 1.00002 Diff
2 3.00000 Same
3 1.00000 Same

### 5.8. Miller index conversions

• atomman.tools.miller.vector3to4(indices) converts vectors from three-term Miller indices to four-term Miller-Bravais indices for hexagonal systems. Updated version 1.2.6: now returns vectors with magnitudes consistent withe given vectors rather than rescaling to the smallest integer representations.

• atomman.tools.miller.vector4to3(indices) converts vectors from four-term Miller-Bravais indices to three-term Miller indices. Updated version 1.2.6: now returns vectors with magnitudes consistent withe given vectors rather than rescaling to the smallest integer representations.

• atomman.tools.miller.plane3to4(indices) converts planes from three-term Miller indices to four-term Miller-Bravais indices for hexagonal systems. Added version 1.2.8

• atomman.tools.miller.plane4to3(indices) converts planes from four-term Miller-Bravais indices to three-term Miller indices. Added version 1.2.8

• atomman.tools.miller.vector_crystal_to_cartesian(indices, box) converts Miller and Miller-Bravais indices to Cartesian vectors based on a supplied box. Updated version 1.2.6 renamed from vectortocartesian for consistency.

• atomman.tools.miller.plane_crystal_to_cartesian(indices, box) converts Miller and Miller-Bravais plane indices to Cartesian normal vectors based on a supplied box. The method uses the definition of the crystal planes to identify two in-plane crystal vectors, converts them to Cartesian, and obtains the plane normal as the cross product of the two vectors. Added version 1.3.2

• atomman.tools.miller.vector_primitive_to_conventional(indices, setting) converts vectors relative to a primitive unit cell to a conventional unit cell in the given setting (p, a, b, c, i or f). Added version 1.2.6

• atomman.tools.miller.vector_conventional_to_primitive(indices, setting) converts vectors relative to a conventional unit cell in the given setting (p, a, b, c, i or f) to a primitive unit cell. Added version 1.2.6

:

# Test single vector conversions
print(am.tools.miller.vector3to4(np.array([3,3,3])))
print(am.tools.miller.vector4to3(np.array([1,1,-2,0])))

[ 1.  1. -2.  3.]
[3. 3. 0.]

:

# Generate random uvw crystal indices
indices = np.random.randint(-5,6, (3,3))
print(indices)
print()

# Convert to hexagonal uvtw's
indices = am.tools.miller.vector3to4(indices)
print(indices)
print()

# Convert back to uvw's and see that values are recovered
indices = am.tools.miller.vector4to3(indices)
print(indices)

[[ 4 -1  0]
[-2 -5  3]
[-2  3 -4]]

[[ 3.         -2.         -1.          0.        ]
[ 0.33333333 -2.66666667  2.33333333  3.        ]
[-2.33333333  2.66666667 -0.33333333 -4.        ]]

[[ 4. -1.  0.]
[-2. -5.  3.]
[-2.  3. -4.]]

:

# Test single plane conversions
print(am.tools.miller.plane3to4(np.array([3,3,3])))
print(am.tools.miller.plane4to3(np.array([1,1,-2,0])))

[ 3.  3. -6.  3.]
[1. 1. 0.]

:

# Generate random hkl crystal indices
indices = np.random.randint(-5,6, (3,3))
print(indices)
print()

# Convert to hexagonal hkil's
indices = am.tools.miller.plane3to4(indices)
print(indices)
print()

# Convert back to hkl's and see that values are recovered
indices = am.tools.miller.plane4to3(indices)
print(indices)

[[ 0  0 -5]
[-3  5  3]
[ 1 -3  5]]

[[ 0.  0. -0. -5.]
[-3.  5. -2.  3.]
[ 1. -3.  2.  5.]]

[[ 0.  0. -5.]
[-3.  5.  3.]
[ 1. -3.  5.]]

:

# Define a hexagonal box
a = uc.set_in_units(2.51, 'angstrom')
c = uc.set_in_units(4.07, 'angstrom')
box = am.Box(a=a, b=a, c=c, gamma=120)

# Pass Miller indices
indices = [[1,0,0],
[0,1,0],
[0,0,1]]
print(am.tools.miller.vector_crystal_to_cartesian(indices, box))
print()

# Pass equivalent Miller-Bravais indices
indices = [[ 2/3,-1/3,-1/3, 0],
[-1/3, 2/3,-1/3, 0],
[   0,   0,   0, 1]]
print(am.tools.miller.vector_crystal_to_cartesian(indices, box))

[[ 2.51        0.          0.        ]
[-1.255       2.17372376  0.        ]
[ 0.          0.          4.07      ]]

[[ 2.51        0.          0.        ]
[-1.255       2.17372376  0.        ]
[ 0.          0.          4.07      ]]

:

# Define a hexagonal box
a = uc.set_in_units(2.51, 'angstrom')
c = uc.set_in_units(4.07, 'angstrom')
box = am.Box(a=a, b=a, c=c, gamma=120)

# Pass Miller plane indices
indices = [ 0, 0, 1]
print(am.tools.miller.plane_crystal_to_cartesian(indices, box))
indices = [ 1, 0, 0]
print(am.tools.miller.plane_crystal_to_cartesian(indices, box))
print()

# Pass equivalent Miller-Bravais indices
indices = [ 0, 0, 0, 1]
print(am.tools.miller.plane_crystal_to_cartesian(indices, box))
indices = [ 1, 0,-1, 0]
print(am.tools.miller.plane_crystal_to_cartesian(indices, box))

[ 0. -0.  1.]
[ 0.8660254  0.5       -0.       ]

[ 0. -0.  1.]
[ 0.8660254  0.5       -0.       ]

:

# Define a primitive bcc unit cell box
a = uc.set_in_units(2.86, 'angstrom')
p_box = am.Box.trigonal(a * 3**0.5 / 2, alpha=109.466666667)
p_ucell = am.System(box=p_box)
print(p_ucell)

avect =  [ 2.477,  0.000,  0.000]
bvect =  [-0.825,  2.335,  0.000]
cvect =  [-0.825, -1.167,  2.023]
origin = [ 0.000,  0.000,  0.000]
natoms = 1
natypes = 1
symbols = (None,)
pbc = [ True  True  True]
per-atom properties = ['atype', 'pos']
id   atype  pos  pos  pos
0       1   0.000   0.000   0.000

:

# Convert conventional box vectors to primitive vectors
a_uvw = am.tools.miller.vector_conventional_to_primitive([1, 0, 0], setting='i')
b_uvw = am.tools.miller.vector_conventional_to_primitive([0, 1, 0], setting='i')
c_uvw = am.tools.miller.vector_conventional_to_primitive([0, 0, 1], setting='i')
p_uvws = np.array([a_uvw, b_uvw, c_uvw])
print('primitive uvws:')
print(p_uvws)

# Convert back to conventional just for consistency
print('conventional uvws:')
print(am.tools.miller.vector_primitive_to_conventional(p_uvws, setting='i'))

primitive uvws:
[[ 0. -1. -1.]
[ 1.  1.  0.]
[ 1.  0.  1.]]
conventional uvws:
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]

:

# rotate system using p_uvws to get conventional unit cell
c_ucell = p_ucell.rotate(p_uvws)
print(c_ucell)

avect =  [ 2.860,  0.000,  0.000]
bvect =  [-0.000,  2.860,  0.000]
cvect =  [-0.000,  0.000,  2.860]
origin = [ 0.000,  0.000,  0.000]
natoms = 2
natypes = 1
symbols = (None,)
pbc = [ True  True  True]
per-atom properties = ['atype', 'pos']
id   atype  pos  pos  pos
0       1   0.000   0.000   0.000
1       1   1.430   1.430   1.430


### 5.9. Crystal lattice identification

Note version 1.4.4 These have been added as methods of the Box class. These stand-alone functions are likely to be depreciated in the next major atomman version.

There are also a few tests for identifying if a supplied box is consistent with a standard representation of a crystal family unit cell.

• atomman.tools.identifyfamily(box) returns str crystal family if box corresponds to a standard crystal representation. Otherwise, returns None.

• atomman.tools.iscubic(box)) returns bool indicating if box is a standard cubic box.

• atomman.tools.ishexagonal(box)) returns bool indicating if box is a standard hexagonal box.

• atomman.tools.istetragonal(box)) returns bool indicating if box is a standard tetragonal box.

• atomman.tools.isrhombohedral(box)) returns bool indicating if box is a standard rhombohedral box.

• atomman.tools.isorthorhombic(box)) returns bool indicating if box is a standard orthorhombic box.

• atomman.tools.ismonoclinic(box)) returns bool indicating if box is a standard monoclinic box.

• atomman.tools.istriclinic(box)) returns bool indicating if box is a standard triclinic box.

All of these functions use the following standard representation criteria:

• cubic:

• $$a = b = c$$

• $$\alpha = \beta = \gamma = 90$$

• hexagonal:

• $$a = b \ne c$$

• $$\alpha = \beta = 90$$

• $$\gamma = 120$$

• tetragonal:

• $$a = b \ne c$$

• $$\alpha = \beta = \gamma = 90$$

• rhombohedral:

• $$a = b = c$$

• $$\alpha = \beta = \gamma \ne 90$$

• orthorhombic:

• $$a \ne b \ne c$$

• $$\alpha = \beta = \gamma = 90$$

• monoclinic:

• $$a \ne b \ne c$$

• $$\alpha = \gamma = 90$$

• $$\beta \ne 90$$

• triclinic:

• $$a \ne b \ne c$$

• $$\alpha \ne \beta \ne \gamma$$

:

# Define an orthogonal box
a = uc.set_in_units(2.51, 'angstrom')
b = uc.set_in_units(3.13, 'angstrom')
c = uc.set_in_units(4.07, 'angstrom')
box = am.Box(a=a, b=b, c=c)

print('identifyfamily =', am.tools.identifyfamily(box))
print('iscubic =       ', am.tools.iscubic(box))
print('ishexagonal =   ', am.tools.ishexagonal(box))
print('istetragonal =  ', am.tools.istetragonal(box))
print('isrhombohedral =', am.tools.isrhombohedral(box))
print('isorthorhombic =', am.tools.isorthorhombic(box))
print('ismonoclinic =  ', am.tools.ismonoclinic(box))
print('istriclinic =   ', am.tools.istriclinic(box))

identifyfamily = orthorhombic
iscubic =        False
ishexagonal =    False
istetragonal =   False
isrhombohedral = False
isorthorhombic = True
ismonoclinic =   False
istriclinic =    False

:

# Define a non-standard tetragonal box with a=c!=b
box = am.Box(a=a, b=b, c=a)
print('identifyfamily =', am.tools.identifyfamily(box))

identifyfamily = None


### 5.10. compositionstr()

Takes a list of symbols and the counts for each and returns a reduced composition string. Used by System.composition.

:

symbols = ['Si', 'Al', 'Si']
counts = [500, 1000, 2000]
print('Composition =', am.tools.compositionstr(symbols, counts))

Composition = Al2Si5


File Cleanup

:

os.remove('text.txt')