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

[1]:
# 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.3.2
Notebook executed on 2020-04-15

Construct a demonstration 2x2x2 diamond cubic silicon system

[2]:
a = uc.set_in_units(5.431, 'angstrom')
box = am.Box(a=a, b=a, c=a)
pos = [[0.00, 0.00, 0.00], [0.50, 0.50, 0.00], [0.50, 0.00, 0.50], [0.00, 0.50, 0.50],
       [0.25, 0.25, 0.25], [0.75, 0.75, 0.25], [0.75, 0.25, 0.75], [0.25, 0.75, 0.75]]
atoms = am.Atoms(atype=1, pos=pos)
ucell = am.System(atoms=atoms, box=box, scale=True)
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 03.1. ElasticConstants class Jupyter Notebook for more details and a full description of all of the class methods.

[3]:
# 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)
[4]:
# 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 atomman.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.

[5]:
# Calculate shortest vector between atoms 1 and 60
print(system.dvect(1, 60))
[ 4.07325  4.07325 -4.07325]
[6]:
# Calculate shortest distance between position [5., 5., 5.] and all atoms in system
pos = system.atoms.pos

dvects = system.dvect([5.0, 5.0, 5.0], pos)
print(np.linalg.norm(dvects, axis=1))
[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 5.86626957 5.86626957 2.2175116  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 7.33774633
 4.93424363 4.93424363 7.08419092 3.25939281 6.33398788 6.33398788
 5.45266877 2.2175116  5.86626957 5.86626957 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 4.93424363
 4.93424363 7.33774633 0.7465139  4.4706471  4.4706471  4.4706471
 3.09820588 6.6163557  6.6163557  6.6163557 ]

3.2. 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.

[7]:
# 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))
[[1.45629769 0.03696404 0.05722462]
 [2.00686953 1.94532145 2.77116162]
 [1.91756282 0.94092042 2.26377047]
 [2.9526688  0.07250513 1.12895736]
 [2.19722268 2.65485694 2.23476383]
 [2.63916535 2.29916939 1.79608253]
 [1.68939243 0.03100305 2.37374329]
 [1.13899849 2.51595438 2.64002661]
 [1.18727388 1.94055994 1.29324607]
 [2.63406863 1.66458785 0.42472578]
 [0.1801896  0.19913024 0.47132252]
 [1.43823169 1.60062644 1.9801167 ]
 [1.06678252 1.67307716 2.17109002]
 [2.66102307 0.75125987 1.74577752]
 [0.19523563 0.19894138 0.17892037]
 [1.20842722 2.0379491  0.15797423]
 [2.04350974 0.57966062 0.70072767]
 [0.19184315 2.19370496 0.53833017]
 [2.95244336 1.8956028  2.52859627]
 [1.24800491 2.97190875 2.53275447]
 [0.40229111 2.2664548  2.06719997]
 [1.21177212 2.67299859 1.25635053]
 [1.13794425 2.79344038 0.05812333]
 [0.31003332 2.33413303 2.65571074]
 [0.52931765 0.7374415  0.92127556]
 [1.2294966  1.58689044 0.38830086]
 [2.20931642 1.05278979 0.6757112 ]
 [1.081391   0.45426115 0.7245832 ]
 [2.9991907  2.43856586 1.95745012]
 [0.48875965 1.65811912 1.73096561]
 [2.78195203 2.05669005 1.28455495]
 [2.23318689 2.66736586 1.60787869]
 [0.26820787 1.88439082 0.77598973]
 [2.50380772 2.18308933 0.07301058]
 [2.11869311 1.56972576 1.24481659]
 [1.10447952 0.71265862 1.42613734]
 [2.09743188 2.21629133 2.85844232]
 [1.70476632 2.65408886 1.06203527]
 [1.588303   1.08921303 2.59617603]
 [1.49469369 0.82369836 1.42980791]
 [1.84601267 2.33351055 2.1979709 ]
 [0.47909529 2.85488761 0.37421567]
 [0.13989635 2.83854446 1.47026478]
 [0.93078192 1.38071304 1.09652262]
 [2.30515599 0.99438398 0.89492745]
 [2.57150815 1.11713478 2.4869003 ]
 [0.68953984 2.70052591 1.45014376]
 [0.51076651 2.86574772 2.62898785]
 [2.76220752 1.29497476 1.21676381]
 [0.88179045 1.51229441 1.87699994]
 [0.49422674 0.08164123 0.14685938]
 [0.88700586 0.73196998 0.95348412]
 [2.02648666 1.95222626 0.55270003]
 [2.2247568  2.39158765 2.46514303]
 [2.12110675 2.18959206 2.5282649 ]
 [0.51782298 0.53856191 1.39356825]
 [1.89842006 2.56365459 0.35106965]
 [0.52290939 1.85172408 1.04131508]
 [2.42468263 1.7087464  0.00346999]
 [2.73847009 0.98941826 2.60552494]
 [1.22619477 1.68183985 0.42465541]
 [2.55323091 2.17034444 1.19097902]
 [2.98580159 2.54431181 1.63393472]
 [2.20723374 0.12076041 0.48688061]]

3.3. 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 03.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.

[8]:
# Identify neighbors within 3 angstroms
neighbors = system.neighborlist(cutoff=3)
[9]:
# Show average atomic coordination
print('Average coordination =', neighbors.coord.mean())
Average coordination = 4.0
[10]:
# List neighbor atoms of atom 6
print('Neighbors of atom 6 =', neighbors[6])
Neighbors of atom 6 = [ 2 11 33 40]

4. Region selectors

Added version 1.3.0

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 03.3. Region selectors Jupyter Notebook for more details and a list of all available shapes.

[11]:
# 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.

[12]:
# 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
[13]:
# 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.

[14]:
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.

[15]:
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'
terms['adjective'] = 'delicious'

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.

[16]:
for index, istr in am.tools.indexstr((3,2)):
    print('index ->', repr(index), ', istr ->', repr(istr))
index -> (0, 0) , istr -> '[0][0]'
index -> (0, 1) , istr -> '[0][1]'
index -> (1, 0) , istr -> '[1][0]'
index -> (1, 1) , istr -> '[1][1]'
index -> (2, 0) , istr -> '[2][0]'
index -> (2, 1) , istr -> '[2][1]'

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

[17]:
# 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:
    print(f.read())

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

# Use uber_open_rmode on file-like object
with open(fname, 'rb') as fobject:
    with am.tools.uber_open_rmode(fobject) as f:
        print(f.read())
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.

[18]:
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')
print(am.tools.vect_angle(vect1, vect2, 'radian'), 'radians')
Angle between [-0.54473876  0.51764369 -0.57618031] and [-0.97503279 -0.48213065  0.14930763] =
79.15926717548003 degrees
1.3815898456779983 radians

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.

[19]:
# Generate test DataFrame
df = pd.DataFrame({'A':[1.00001, 1.00002, 3.0000, 1.000000], 'B':['Same', 'Diff', 'Same', 'Same']})
df
[19]:
A B
0 1.00001 Same
1 1.00002 Diff
2 3.00000 Same
3 1.00000 Same
[20]:
# Show unique values
df[~am.tools.duplicates_allclose(df, dcols=['B'], fcols={'A':1e-4})]
[20]:
A B
1 1.00002 Diff
2 3.00000 Same
3 1.00000 Same

5.7. Miller index conversions

atomman.tools.miller.vector3to4(indices) converts vectors from three-term Miller indices to four-term Miller-Bravais indices for hexagonal systems.

atomman.tools.miller.vector4to3(indices) converts vectors from four-term Miller-Bravais indices to three-term Miller indices.

Updated version 1.2.6: vector3to4 and vector4to3 now return absolute vectors instead of rescaling to the smallest integer representations. As such, both functions return floats instead of integers.

[21]:
# Test single value case
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.]
[22]:
# 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)
[[-5 -2 -2]
 [-5  4 -2]
 [ 5 -1 -1]]

[[-2.66666667  0.33333333  2.33333333 -2.        ]
 [-4.66666667  4.33333333  0.33333333 -2.        ]
 [ 3.66666667 -2.33333333 -1.33333333 -1.        ]]

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

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

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

Added version 1.2.8

[23]:
# Test single value case
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.]
[24]:
# 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)
[[-4 -2  0]
 [ 0 -2  0]
 [ 5  0 -1]]

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

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

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 vectortocartesian is renamed vector_crystal_to_cartesian for consistency.

[25]:
# 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      ]]

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

[26]:
# 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.       ]

Added version 1.2.6

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).

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.

[27]:
# 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[0]  pos[1]  pos[2]
      0       1   0.000   0.000   0.000
[28]:
# 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.]]
[29]:
# 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[0]  pos[1]  pos[2]
      0       1   0.000   0.000   0.000
      1       1   1.430   1.430   1.430

5.8. Crystal lattice identification

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\)

[30]:
# 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
[31]:
# 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.9 compositionstr()

Added version 1.2.7

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

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

File Cleanup

[33]:
os.remove('text.txt')