structure

class javelin.structure.Structure(symbols=None, numbers=None, unitcell=1, ncells=None, positions=None, rotations=False, translations=False, magnetic_moments=False)[source]

The structure class is made up of a unitcell and a list of atoms

Structure can be initialize using either another javelin.structure.Structure, ase.Atoms or diffpy.Structure.structure.Structure. It is recommended you use javelin.structure.Structure.reindex() after initializing from a foreign type in order to get the correct unitcell structure type.

Parameters:
  • symbols (list) – atoms symbols to initialize structure
  • numbers (list) – atomic numbers to initialize structure
  • unitcell (javelin.unitcell.UnitCell) – unitcell of structure, can be javelin.unitcell.UnitCell or values used to initialize the UnitCell
  • ncells (list) – ncells has four components, (i, j, k, n) where i, j, k are the number of unitcell in each direction and n is the number of site positions in each unitcell. The product of ncells must equal the total number of atoms in the structure.
  • positions (3 x n array-like) – array of atom coordinates
add_atom(i=0, j=0, k=0, site=0, Z=None, symbol=None, position=None)[source]

Adds a single atom to the structure. It the atom exist as provided i, j, k and site it will be replaced.

Parameters:
  • i (int) – unitcell index
  • j (int) – unitcell index
  • k (int) – unitcell index
  • site (int) – site index
  • Z (int) – atomic number
  • symbol (int) – chemical symbol
  • position (vector) – position within the unitcell
>>> stru=Structure(numbers=[12],positions=[[0.,0.,0.]],unitcell=5.64)
>>> stru.atoms # doctest: +NORMALIZE_WHITESPACE
             Z symbol    x    y    z
i j k site
0 0 0 0     12     Mg  0  0  0
>>> stru.add_atom(Z=13, position=[0.,0.5,0.])
>>> stru.atoms # doctest: +NORMALIZE_WHITESPACE
             Z symbol    x    y    z
i j k site
0 0 0 0     13     Al  0...  0.5  0...
>>> stru.add_atom(Z=13, position=[0.5,0.,0.], i=1)
>>> stru.atoms # doctest: +NORMALIZE_WHITESPACE
             Z symbol    x    y    z
i j k site
0 0 0 0     13     Al  0.0  0.5  0...
1 0 0 0     13     Al  0.5  0.0  0...
atoms = None

Attribute storing list of atom type and positions as a pandas.DataFrame

Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> stru.atoms
             Z symbol    x    y    z
i j k site
0 0 0 0     11     Na  0.0  0.0  0.0
      1     17     Cl  0.5  0.5  0.5
      2     11     Na  0.0  1.0  0.0
element

Array of all elements in the structure

Returns:array of element symbols
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> stru.element
array(['Na', 'Cl', 'Na'], dtype=object)
get_atom_Zs()[source]

Get a list of unique atomic number in structure

Returns:array of Zs
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> print(stru.get_atom_Zs())
[11 17]
get_atom_count()[source]

Returns a count of each different type of atom in the structure

Returns:series of atom count
Return type:pandas.Series
Example:
>>> stru = Structure(symbols=['Na','Na'],positions=[[0,0,0],[0.5,0.5,0.5]])
>>> stru.get_atom_count()
Na    2
Name: symbol, dtype: int64
get_atom_symbols()[source]

Get a list of unique atom symbols in structure

Returns:array of atom symbols
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> stru.get_atom_symbols()
array(['Na', 'Cl'], dtype=object)
get_atomic_numbers()[source]

Array of all atomic numbers in the structure

Returns:array of atomic numbers
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> print(stru.get_atomic_numbers())
[11 17 11]
get_average_site(site=0, separate_site=True)[source]
get_average_structure(separate_sites=True)[source]
get_cell()[source]
get_celldisp()[source]
get_chemical_formula()[source]

Returns the chemical formula of the structure

Returns:chemical formula
Return type:str
Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> stru.get_chemical_formula()
'Cl1Na2'
get_chemical_symbols()[source]

Same as javelin.structure.Structure.element

get_displacement_correlation(vectors, direction=(1, 1, 1), direction2=None)[source]
Parameters:vectors (javelin.neighborlist.NeighborList or n x 5 array of neighbor vectors) – neighbor vectors
Returns:displacement correlation
Return type:float
get_magnetic_moments()[source]
get_neighbors(site=0, target_site=None, minD=0.01, maxD=1.1)[source]

Return a javelin.neighborlist.NeighborList for the given sites and distances

get_occupational_correlation(vectors, atom)[source]
Parameters:
Returns:

occupational correlation

Return type:

float

get_positions()[source]

Same as javelin.structure.Structure.xyz_cartn

get_scaled_positions()[source]

Array of all xyz positions in fractional lattice units of the atoms in the structure

Returns:3 x n array of atom positions
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.get_scaled_positions()
array([[ 0. ,  0. ,  0. ],
       [ 0.5,  0.5,  0.5]])
info

Dictionary of key-value pairs with additional information about the system.

Not implemented, only for ASE compatibility.

number_of_atoms

The total number of atoms in the structure

Returns:number of atoms in structure
Return type:int
Example:
>>> stru = Structure(symbols=['Na','Cl','Na'],positions=[[0,0,0],[0.5,0.5,0.5],[0,1,0]])
>>> stru.number_of_atoms
3
rattle(scale=0.001, seed=None)[source]

Randomly move all atoms by a normal distbution with a standard deviation given by scale.

Parameters:
  • scale (float) – standard deviation
  • seed (int) – seed for random number generator
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> print(stru.xyz)
[[ 0.   0.   0. ]
 [ 0.5  0.5  0.5]]
>>> stru.rattle(seed=42)
>>> print(stru.xyz)
[[  4.96714153e-04  -1.38264301e-04   6.47688538e-04]
 [  5.01523030e-01   4.99765847e-01   4.99765863e-01]]
reindex(ncells)[source]

This will reindex the list of atoms into the unitcell framework of this structure

ncells has four components, (i, j, k, n) where i, j, k are the number of unitcell in each direction and n is the number of site positions in each unitcell. The product of ncells must equal the total number of atoms in the structure.

Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.atoms # doctest: +NORMALIZE_WHITESPACE
             Z symbol    x    y    z
i j k site
0 0 0 0     11     Na  0.0  0.0  0.0
      1     17     Cl  0.5  0.5  0.5
>>> stru.reindex([2,1,1,1])
>>> stru.atoms # doctest: +NORMALIZE_WHITESPACE
             Z symbol    x    y    z
i j k site
0 0 0 0     11     Na  0.0  0.0  0.0
1 0 0 0     17     Cl  0.5  0.5  0.5
repeat(rep)[source]

Repeat the cells a number of time along each dimension

rep argument should be either three value like (1,2,3) or a single value r equivalent to (r,r,r).

Parameters:rep (1 or 3 ints) – repeating rate
Examples:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> print(stru.element)
['Na' 'Cl']
>>> print(stru.xyz_cartn)
[[ 0.    0.    0.  ]
 [ 2.82  2.82  2.82]]
>>> stru.repeat((2,1,1))
>>> print(stru.element)  # doctest: +ALLOW_UNICODE
['Na' 'Cl' 'Na' 'Cl']
>>> print(stru.xyz_cartn)
[[  0.00000000e+00   0.00000000e+00   0.00000000e+00]
 [  2.82000000e+00   2.82000000e+00   2.82000000e+00]
 [  5.64000000e+00   9.06981174e-16   9.06981174e-16]
 [  8.46000000e+00   2.82000000e+00   2.82000000e+00]]
>>> stru = Structure(symbols=['Na'], positions=[[0,0,0]], unitcell=5.64)
>>> print(stru.element)
['Na']
>>> print(stru.xyz_cartn)
[[ 0.  0.  0.]]
>>> stru.repeat(2)
>>> print(stru.element)  # doctest: +ALLOW_UNICODE
['Na' 'Na' 'Na' 'Na' 'Na' 'Na' 'Na' 'Na']
>>> print(stru.xyz_cartn)
[[  0.00000000e+00   0.00000000e+00   0.00000000e+00]
 [  0.00000000e+00   0.00000000e+00   5.64000000e+00]
 [  0.00000000e+00   5.64000000e+00   3.45350397e-16]
 [  0.00000000e+00   5.64000000e+00   5.64000000e+00]
 [  5.64000000e+00   9.06981174e-16   9.06981174e-16]
 [  5.64000000e+00   9.06981174e-16   5.64000000e+00]
 [  5.64000000e+00   5.64000000e+00   1.25233157e-15]
 [  5.64000000e+00   5.64000000e+00   5.64000000e+00]]
replace_atom(to_replace: int, value: int) → None[source]

Replace all atoms in the structure that has Z=`to_replace` with Z=`value`. This uses pandas.DataFrame.replace() to replace the atom Z values

Parameters:
  • to_replace (int) – Z value to replace
  • value (int) – what it is going to be replaced with
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> print(stru.get_atom_count())
Cl    1
Na    1
Name: symbol, dtype: int64
>>> stru.replace_atom(11, 111)
>>> print(stru.get_atom_count())
Cl    1
Rg    1
Name: symbol, dtype: int64
to_ase()[source]
unitcell = None

Attribute containing the unitcell of the structure. Must be of type javelin.unitcell.UnitCell

update_atom_symbols()[source]

This will update the atom symbol list from the Z numbers, this should be run if the Z numbers are modified directly

x

Array of all x positions of in fractional lattice units of the atoms within the unitcell of the structure

Returns:array of atom x positions
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.x
array([ 0. ,  0.5])
xyz

Array of all xyz positions in fractional lattice units of the atoms within the unitcell of the structure

Returns:3 x n array of atom positions
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.xyz
array([[ 0. ,  0. ,  0. ],
       [ 0.5,  0.5,  0.5]])
xyz_cartn

Array of all xyz positions in cartesian coordinates of the atoms in the structure

Returns:3 x n array of atom positions
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.xyz_cartn
array([[ 0.  ,  0.  ,  0.  ],
       [ 2.82,  2.82,  2.82]])
y

Array of all y positions of in fractional lattice units of the atoms within the unitcell of the structure

Returns:array of atom y positions
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.y
array([ 0. ,  0.5])
z

Array of all z positions of in fractional lattice units of the atoms within the unitcell of the structure

Returns:array of atom z positions
Return type:numpy.ndarray
Example:
>>> stru = Structure(symbols=['Na', 'Cl'], positions=[[0,0,0],[0.5,0.5,0.5]], unitcell=5.64)
>>> stru.z
array([ 0. ,  0.5])
javelin.structure.axisAngle2Versor(x, y, z, angle, unit='degrees')[source]
javelin.structure.get_miindex(length=0, ncells=None)[source]
javelin.structure.get_rotation_matrix(l, m, n, theta, unit='degrees')[source]
javelin.structure.get_rotation_matrix_from_versor(w, x, y, z)[source]