Structure Module#

The structure module provides support for atomic structure I/O, generation, and manipulation.

List of module contents#

Read cif file functions:

Operations on logical conditions:

Create a Monkhorst-Pack k-point mesh function

Tile matrix malipulation functions

Rotate plane function

Trivial filter function

Base class for Structure class:

Base class for DefectStructure, Crystal, and Jellium classes:

SeeK-path functions

Interpolate structures functions

Animate structures functions

Concrete Structure classes:

Structure generation functions:

Read structure functions

Module contents#

nexus.structure.read_cif_celldata(filepath, block=None, grammar='1.1')[source]#
nexus.structure.read_cif_cell(filepath, block=None, grammar='1.1', cell='prim')[source]#
nexus.structure.read_cif(filepath, block=None, grammar='1.1', cell='prim', args_only=False)[source]#
nexus.structure.equate(expr)[source]#
nexus.structure.negate(expr)[source]#
nexus.structure.kmesh(kaxes, dim, shift=None)[source]#

Create a Monkhorst-Pack k-point mesh

nexus.structure.reduce_tilematrix(tiling)[source]#
nexus.structure.rotate_plane(plane, angle, points, units='degrees')[source]#
nexus.structure.recenter_points(pos, center, axes)[source]#

Center a given set of points in a cell around a provided center.

Parameters:
posNDArray

Array of N positions with shape (N,3)

centerNDArray

Position of the center

axesNDArray

Array of the cell vectors with shape (3,3)

Returns:
posNDArray

Array of positions centered around the given center

Notes

This function also ensures that points close (within 1e-12) to the minimum edge (-0.5) of the cell are placed exactly on that edge. The intent here is to make sure that atoms close to or on the leading edge (+0.5) are wrapped around to retain periodicity.

nexus.structure.trivial_filter(T)[source]#
class nexus.structure.MaskFilter(*vars, **kwargs)[source]#

Bases: DevBase

Methods

__call__(T)

Call self as a function.

append(value)

class_error(message[, header, exit, trace, ...])

Report an error relating to a class.

error(message[, header, exit, trace])

Report an error inside a class.

first()

keys()

list(*keys)

open_log(filepath)

save([fpath])

sorted_keys()

warn(msg[, indent])

Warning from inside a Nexus class.

add

add_optional

check_required

check_types

check_types_optional

class_get

class_has

class_items

class_keys

class_log

class_set

class_set_optional

class_set_single

class_warn

clear

close_log

copy

copy_from

copy_to

data_repr

delete

delete_optional

delete_required

dict

extract

extract_optional

get

get_optional

get_path

get_required

inverse

items

last

list_optional

load

log

move_from

move_from_optional

move_to

move_to_optional

not_implemented

obj

path_exists

random_key

select_random

serial

set

set_optional

set_path

shallow_copy

to_dict

to_obj

transfer_from

transfer_to

tree

tuple

values

write

set(mask, dim=3)[source]#
nexus.structure.optimal_tilematrix(axes, volfac, dn=1, tol=0.001, filter=<function trivial_filter>, mask=None, nc=5, Tref=None)[source]#
class nexus.structure.Sobj(*vars, **kwargs)[source]#

Bases: DevBase

Methods

append(value)

class_error(message[, header, exit, trace, ...])

Report an error relating to a class.

error(message[, header, exit, trace])

Report an error inside a class.

first()

keys()

list(*keys)

open_log(filepath)

save([fpath])

sorted_keys()

warn(msg[, indent])

Warning from inside a Nexus class.

add

add_optional

check_required

check_types

check_types_optional

class_get

class_has

class_items

class_keys

class_log

class_set

class_set_optional

class_set_single

class_warn

clear

close_log

copy

copy_from

copy_to

data_repr

delete

delete_optional

delete_required

dict

extract

extract_optional

get

get_optional

get_path

get_required

inverse

items

last

list_optional

load

log

move_from

move_from_optional

move_to

move_to_optional

not_implemented

obj

path_exists

random_key

select_random

serial

set

set_optional

set_path

shallow_copy

to_dict

to_obj

transfer_from

transfer_to

tree

tuple

values

write

class nexus.structure.Structure(axes=None, scale=1.0, elem=None, pos=None, elem_pos=None, mag=None, center=None, kpoints=None, kweights=None, kgrid=None, kshift=None, permute=None, units=None, tiling=None, rescale=True, dim=3, operations=None, background_charge=0, frozen=None, bconds=None, posu=None, use_prim=None, add_kpath=False, symm_kgrid=False)[source]#

Bases: Sobj

General class for all physical structures

Parameters:
axesArrayLike, optional

Lattice vectors of the cell

scaleint or float, default=1.

Scaling for all other physical values. See rescale for more information.

elemArrayLike, optional

Array of atomic symbols.

posArrayLike, optional

Positions of the atoms.

elem_posstr, optional

Multiline string with each line containing an atom where an atom is an element and its position. Overrides elem and pos.

magArrayLike, optional

Magnetic moments of each atom.

centerArrayLike, optional

Defined center of the cell, defaults to the [0.5, 0.5, 0.5] point of the cell.

kpointsArrayLike, optional

Array containing the positions of k-points.

kweightsArrayLike, optional

Weight of individual k-points, must be as long as the number of k-points.

kgridint, optional

Number of subdivisions to create a Monkhorst-Pack k-point mesh. See kmesh for a more in-depth explanation. Overrides kpoints if specified.

kshiftArrayLike, optional

Vector to translate k-points if k-grid is specified.

permuteArrayLike, optional

Vector to permute the structure. See permute for more information.

unitsstr, optional

Units of the positions. See unit_converter.py for a full list of supported units.

tilingArrayLike of int, optional

A vector of ints for tiling the cell in each dimension. See tile for more information.

rescalebool, default=True

True will rescale the supplied structural information with the scaling factor provided (see scale), False sets the scale without altering the provided structural information.

dimint, default=3

Dimensionality of the Structure. See Notes for more information.

operationsiterable of str, optional

Operations to perform on the structure. See set_operations for more information.

background_chargeint, default=0

The total background charge of the system. Positive for cations, negative for anions, and zero for neutral systems.

frozenArrayLike of bool, optional

Mask array of booleans with the same length as the number of atoms and width of dim. See set_frozen for more information.

bcondsstr or tuple of str, optional

Boundary conditions either in all directions or specified for each dimension. Defaults to periodic in all directions.

posuArrayLike, optional

The positions of the atoms in units of the lattice parameter. Overrides pos.

use_primbool, optional

Option to convert the unit cell to a primitive cell. Requires that the seekpath package is installed [0].

add_kpathbool, default=False

Optionally add k-points to the primitive cell. Only used if use_prim is True.

symm_kgridbool, default=False

Option for generating a Monkhorst-Pack k-point grid with only symmetric k-points. Requires the spglib package [1]. See add_symmetrized_mesh for more information.

Attributes:
axesNDArray

Lattice vectors of the cell as a square matrix of dimension dim x dim.

scaleint or float

Scaling for all other physical values.

elemNDArray of str

Array of atomic symbols.

posNDArray of float

Positions of the atoms.

centerNDArray of float

Defined center of the cell.

kpointsNDArray of float

Array containing the positions of k-points.

kweightsNDArray of float

Weight of individual k-points.

unitsstr

Units of the atom positions.

dimint, default=3

Dimensionality of the Structure.

operationsMapping of str to function

Operations to perform on the structure. See set_operations for more information.

background_chargeint, default=0

The total background charge of the system. Positive for cations, negative for anions, and zero for neutral systems.

bcondsNDArray of str

Boundary conditions either in all directions or specified for each dimension

magNDArray of float or None

Magnetic moments of each atom, or None if system is not magnetized.

tmatrixNDArray of int or None

A vector of ints for tiling the cell in each dimension. See tile for more information.

frozenNDArray of bool or None, default=None

Mask array of booleans with the same length as the number of atoms and width of dim, where True indicates the atoms are locked in place and False indicates they are free to move.

Methods

add_atoms(elem, pos)

adjust_axes(axes)

append(value)

at_Gpoint()

at_Lpoint()

at_real_kpoint()

bond_compression(reference, neighbors)

bonds(neighbors[, vectors])

boundary([dims, dtol])

carve(identifiers)

cell_image(p[, center])

center_distances(points[, center])

center_molecule([rmin_edge])

Center a molecule in a unit cell, ensuring equal padding on all sides.

center_solid()

change_units(units[, folded])

chemical_coordination([indices, nmax, rmax, ...])

class_error(message[, header, exit, trace, ...])

Report an error relating to a class.

clear_kpoints()

cleave(axis, loc[, sep, remove, tol])

clone_from(other)

corners()

Calculate vectors corresponding to the 8 corners of the unit cell.

cube_deviation()

displacement(reference[, map])

distances([pos1, pos2])

distortion(reference, neighbors)

error(message[, header, exit, trace])

Report an error inside a class.

face_distances()

face_vectors([axes, distances])

first()

fold(small, *requests)

fold_pos(large[, tol])

get_cell()

group_atoms([folded])

Group the atoms by their element type, sorting in alphabetical order.

incorporate(other)

inside(pos[, axes, center, tol, separate])

inversion_symmetrize_kpoints([tol, folded])

keys()

kfold(tiling, kpoints, kweights)

layer_composition(layers)

layers([axis, dtol, dbin, plot, composition])

list(*keys)

locate(identifiers[, radii, exterior])

locate_simple(pos)

madelung([axes, tol])

matrix_transform(A)

Arbitrary transformation matrix (column-major).

miller_direction(h, k, l[, normalize])

miller_normal(h, k, l[, normalize])

min_image_centroid([points, indices])

min_image_centroids([points, indices])

min_image_norms(points, norms)

nearest_neighbors([indices, rmax, nmax, ...])

open_log(filepath)

order_by_species([folded])

ordered_species([symbol])

permute(permutation)

point_defect([identifiers, elem, dr])

pos_to_str([units, with_elem])

Write the positions of a structure to a string, optionally with atomic symbols.

project_plane(a1, a2[, points])

rcore_max([units])

read_fhi_aims(filepath)

recenter([center])

Center atoms around a new provided center of the unit cell, or if a new center is not provided then use the (0.5 0.5 0.5) point of the unit cell.

recenter_k([kpoints, kaxes, kcenter, ...])

Center k-points around the provided center of k-space.

recorner([center])

Center atoms around the origin of the cell.

remove(identifiers)

rename([folded])

Rename element names in a structure.

reorder(order)

replace(identifiers[, elem, pos, radii, ...])

replace_nearest(elem[, pos])

rescale(scale)

reset_axes([axes])

Reset the structure's axes, k-space axes, and center.

reshape_axes(reshaping)

ring_graphs(order, **kwargs)

rinscribe_cube(*args, **kwargs)

rotate(r[, rp, passive, units, check])

Arbitrary rotation of the structure.

rotate_plane(plane, angle[, units])

rwigner_cube(*args, **kwargs)

save([fpath])

scalar_displacement(reference)

select_twist([selector, tol])

shell(cell, neighbors[, direction])

shells(identifiers[, radii, exterior, ...])

skew(skew)

Arbitrary transformation matrix (row-major).

slide(v[, recenter])

sorted_keys()

space_group_operations([tol, unit])

species([symbol])

spglib_cell()

stretch(s1, s2, s3)

translate(v)

unique_kpoints([tol, folded])

unique_points(points, axes[, weights, tol])

unique_points_fast(points, axes[, weights, tol])

unique_positions([tol, folded])

unsheared_axes([axes, distances])

upcast(DerivedStructure)

voronoi_neighbors([indices, restrict, ...])

warn(msg[, indent])

Warning from inside a Nexus class.

write_axes()

Write the unit cell axes as a string.

write_fhi_aims([filepath])

write_xyz([filepath])

Write a Structure object to an XYZ file

zero_corner()

add

add_kmesh

add_kpoints

add_optional

add_symmetrized_kmesh

all_periodic

any_periodic

become_primitive

bounding_box

bravais_lattice_name

check_consistent

check_point_group_operations

check_required

check_tiling

check_types

check_types_optional

class_get

class_has

class_items

class_keys

class_log

class_set

class_set_optional

class_set_single

class_warn

clear

close_log

connected_graphs

copy

copy_from

copy_to

count_kshells

data_repr

delete

delete_optional

delete_required

dict

distance_table

embed

equivalent_atoms

extract

extract_optional

freeze

get

get_atomic_numbers

get_magnetic_moments

get_number_of_atoms

get_optional

get_path

get_required

get_scaled_positions

get_smallest

get_symmetry

get_symmetry_dataset

has_axes

has_folded

has_folded_structure

has_tmatrix

interpolate

inverse

is_frozen

is_magnetic

is_open

is_periodic

is_tiled

items

kgrid_from_kspacing

kmap

kpoints_qmcpack

kpoints_reduced

kpoints_unit

last

list_optional

load

log

makov_payne

min_image_distances

min_image_vectors

move_from

move_from_optional

move_to

move_to_optional

neighbor_table

not_implemented

obj

operate

opt_tilematrix

path_exists

plot2d

plot2d_ax

plot2d_kax

plot2d_kp

plot2d_points

plot2d_pos

point_group_operations

pos_to_cartesian

pos_unit

primitive

random_key

rcell

read

read_cif

read_poscar

read_xsf

read_xyz

remove_folded

remove_folded_structure

rinscribe

rmg_lattice

rmg_transform

rmin

rwigner

select_random

serial

set

set_axes

set_bconds

set_elem

set_folded

set_folded_structure

set_frozen

set_mag

set_operations

set_optional

set_path

set_pos

shallow_copy

show

size

symmetry_data

tile

tile_opt

tile_points

tile_points_brute

tile_points_simple

tilematrix

to_dict

to_obj

transfer_from

transfer_to

tree

tuple

values

vector_table

volume

voronoi_distances

voronoi_radii

voronoi_species_radii

voronoi_vectors

write

write_poscar

write_xsf

Notes

Currently the Structure class only partially supports 2-dimensional structures.

References

operations = recenter              function               remove_folded_structure  function             #
classmethod set_operations()[source]#
check_consistent(tol=1e-08, exit=True, message=False)[source]#
set_axes(axes)[source]#
set_bconds(bconds)[source]#
set_elem(elem)[source]#
set_pos(pos)[source]#
set_mag(mag=None)[source]#
set_frozen(frozen=None)[source]#
size()[source]#
has_axes()[source]#
operate(operations)[source]#
has_tmatrix()[source]#
is_tiled()[source]#
set_folded(folded)[source]#
remove_folded()[source]#
has_folded()[source]#
set_folded_structure(folded)[source]#
remove_folded_structure()[source]#
has_folded_structure()[source]#
group_atoms(folded=True) None[source]#

Group the atoms by their element type, sorting in alphabetical order.

Parameters:
foldedbool, default=True

Optionally sort the folded structure, if it exists.

Examples

>>> structure = Structure(
...     elem = ["Be", "N", "C", "Be", "C", "O"],
...     pos = np.array([
...         [0, 0, 0],
...         [0, 0, 0],
...         [0, 0, 0],
...         [0, 0, 0],
...         [0, 0, 0],
...         [0, 0, 0],
...     ], dtype=np.float64),
... )
>>> print(structure.elem)
['Be' 'N' 'C' 'Be' 'C' 'O']
>>> structure.group_atoms()
>>> print(structure.elem)
['Be' 'Be' 'C' 'C' 'N' 'O']
rename(folded=True, **name_pairs) None[source]#

Rename element names in a structure.

Parameters:
foldedbool, default=True

Rename elements in folded structure as well as tiled structure (if there is no folded structure then this does nothing)

**name_pairsdict[str]

A dictionary containing key:value pairs where the key is the old element name and the value is the new element name.

Examples

>>> structure = Structure(
...     elem = ["N", "C", "O", "H"],
...     pos = np.array([
...         [0, 0, 0],
...         [0, 0, 0],
...         [0, 0, 0],
...         [0, 0, 0],
...     ], dtype=np.float64),
... )
>>> print(structure.elem)
['N' 'C' 'O' 'H']
>>> structure.rename(N="Dy", C="Er")
>>> print(structure.elem)
['Dy' 'Er' 'O' 'H']
reset_axes(axes: ArrayLike | None = None) None[source]#

Reset the structure’s axes, k-space axes, and center.

Notes

If axes is given, this function will remove the previous folded structure (as new axes could invalidate the tiling) and then set self.axes to the new axes, update the k-space axes, and set the center of the cell to be the (0.5, 0.5, 0.5) point.

If axes are not given (e.g. axes=None, the default), then this function will reuse the same axes as the current structure, reset the k-space axes, and set the cell center at the (0.5, 0.5, 0.5) point.

Examples

Providing axes will also make sure kaxes and center are consistent.

>>> structure = Structure(
...     axes = np.array([
...         [6.0, 0.0, 0.0],
...         [0.0, 6.0, 0.0],
...         [0.0, 0.0, 6.0],
...     ]),
... )
>>> print(structure.axes)
[[6. 0. 0.]
[0. 6. 0.]
[0. 0. 6.]]
>>> print(structure.kaxes)
[[1.04719755 0.         0.        ]
[0.         1.04719755 0.        ]
[0.         0.         1.04719755]]
>>> print(structure.center)
[3. 3. 3.]
>>> structure.reset_axes(np.array([
...     [12.0,  0.0,  0.0],
...     [ 0.0, 12.0,  0.0],
...     [ 0.0,  0.0, 12.0],
... ]))
>>> print(structure.axes)
[[12.  0.  0.]
[ 0. 12.  0.]
[ 0.  0. 12.]]
>>> print(structure.kaxes)
[[0.52359878 0.         0.        ]
[0.         0.52359878 0.        ]
[0.         0.         0.52359878]]
>>> print(structure.center)
[6. 6. 6.]

Alternatively, if you don’t provide axes you can ensure that the kaxes and center of the structure are correct. Here we set center to be at the origin, then use reset_axes to correct it.

>>> structure = Structure(
...     axes = np.array([
...         [6.0, 0.0, 0.0],
...         [0.0, 6.0, 0.0],
...         [0.0, 0.0, 6.0],
...     ]),
...     center = np.array([0.0, 0.0, 0.0]),
... )
>>> print(structure.center)
[0. 0. 0.]
>>> structure.reset_axes()
>>> print(structure.center)
[3. 3. 3.]
adjust_axes(axes)[source]#
reshape_axes(reshaping)[source]#
write_axes() str[source]#

Write the unit cell axes as a string.

Only implemented for self.dim=3.

corners() NDArray[float64][source]#

Calculate vectors corresponding to the 8 corners of the unit cell.

Only implemented for self.dim=3.

miller_direction(h, k, l, normalize=False)[source]#
miller_normal(h, k, l, normalize=False)[source]#
project_plane(a1, a2, points=None)[source]#
bounding_box(scale=1.0, minsize=None, mindist=0, box='tight', recenter=False)[source]#
center_molecule(rmin_edge=1e-08)[source]#

Center a molecule in a unit cell, ensuring equal padding on all sides.

Parameters:
rmin_edgefloat-like or array_like, default=1e-8

Minimum acceptable distance from the cell edges to any atom in the molecule, potentially specified per-axis.

Notes

The default rmin_edge of 1e-8 is designed to just barely contain the molecule. It is important to ensure that for larger, non-periodic molecular systems or atoms that the unit cell size is sufficiently large to contain the charge density otherwise the molecular system will interact with the neighboring periodic replica, resulting in unphysical electrostatic interactions

For reference, 5 Bohr contains >99.3% of the charge density around a Hydrogen atom.

center_solid()[source]#
permute(permutation)[source]#
rotate_plane(plane, angle, units='degrees')[source]#
upcast(DerivedStructure)[source]#
incorporate(other)[source]#
clone_from(other)[source]#
add_atoms(elem, pos)[source]#
is_open()[source]#
is_periodic()[source]#
any_periodic()[source]#
all_periodic()[source]#
distances(pos1=None, pos2=None)[source]#
count_kshells(kcut, tilevec=[12, 12, 12], nkdig=10)[source]#
volume()[source]#
rwigner(nc=5)[source]#
rinscribe()[source]#
rwigner_cube(*args, **kwargs)[source]#
rinscribe_cube(*args, **kwargs)[source]#
rmin()[source]#
rcell()[source]#
cube_deviation()[source]#
unsheared_axes(axes=None, distances=False)[source]#
face_vectors(axes=None, distances=False)[source]#
face_distances()[source]#
rescale(scale)[source]#
stretch(s1, s2, s3)[source]#
rotate(r, rp=None, passive=False, units='radians', check=True)[source]#

Arbitrary rotation of the structure.

Parameters:
rarray_like of float with shape (3,3) or array_like of float shape (3,) or str

If a 3x3 matrix, then code executes rotation consistent with this matrix – it is assumed that the matrix acts on a column-major vector (eg, v’=Rv). If a three-dimensional array, then the operation of the function depends on the input type of rp in the following ways:

  1. If rp is a scalar, then rp is assumed to be an angle and a rotation of rp is made about the axis defined by r.

  2. If rp is a vector, then rp is assumed to be an axis and a rotation is made such that r aligns with rp.

  3. If rp is a str, then the rotation is such that r aligns with the axis given by the str ('x', 'y', 'z', 'a0', 'a1', or 'a2').

If a str then the axis, r, is defined by the input label (e.g. ‘x’, ‘y’, ‘z’, ‘a1’, ‘a2’, or ‘a3’) and the operation of the function depends on the input type of rp in the same ways as above.

rparray_like of float with shape (3) or str, optional

If a 3-dimensional vector is given, then rp is assumed to be an axis and a rotation is made such that the axis r is aligned with rp. If a str, then rp is assumed to be an angle and a rotation about the axis defined by r is made by an angle rp. If a str is given, then rp is assumed to be an axis defined by the given label (e.g. ‘x’, ‘y’, ‘z’, ‘a1’, ‘a2’, or ‘a3’) and a rotation is made such that the axis r is aligned with rp.

passivebool, default=False

If True, perform a passive rotation. If False, perform an active rotation.

units{“radians”, “rad”, “degrees”, “deg”}, default=”radians”

Units of rp, if rp is given as an angle (scalar).

checkbool, default=True

Perform a check to verify rotation matrix is orthogonal.

matrix_transform(A)[source]#

Arbitrary transformation matrix (column-major).

Parameters:
Aarray_like, float, shape (3,3)

Transform the structure using the matrix A. It is assumed that A is in column-major form, i.e., it transforms a vector v as v’ = Av

skew(skew)[source]#

Arbitrary transformation matrix (row-major).

Parameters:
skewarray_like, float, shape (3,3)

Transform the structure using the matrix skew. It is assumed that skew is in row-major form, i.e., it transforms a vector v as v’ = vT

change_units(units, folded=True)[source]#
cleave(axis, loc, sep=None, remove=False, tol=1e-06)[source]#
translate(v)[source]#
slide(v, recenter=True)[source]#
zero_corner()[source]#
locate_simple(pos)[source]#
locate(identifiers, radii=None, exterior=False)[source]#
freeze(identifiers=None, radii=None, exterior=False, negate=False, directions='xyz')[source]#
is_frozen()[source]#
is_magnetic(tol=1e-08)[source]#
carve(identifiers)[source]#
remove(identifiers)[source]#
replace(identifiers, elem=None, pos=None, radii=None, exterior=False)[source]#
replace_nearest(elem, pos=None)[source]#
point_defect(identifiers=None, elem=None, dr=None)[source]#
species(symbol=False)[source]#
ordered_species(symbol=False)[source]#
order_by_species(folded=False)[source]#
reorder(order)[source]#
layers(axis=0, dtol=0.03, dbin=0.01, plot=False, composition=False)[source]#
layer_composition(layers)[source]#
shells(identifiers, radii=None, exterior=False, cumshells=False, distances=False, dtol=1e-06)[source]#
connected_graphs(order, indices=None, rmax=None, nmax=None, voronoi=False, degree=False, site_maps=False, **spec_max)[source]#
ring_graphs(order, **kwargs)[source]#
min_image_centroid(points=None, indices=None)[source]#
min_image_centroids(points=None, indices=None)[source]#
min_image_vectors(points=None, points2=None, axes=None, pairs=True)[source]#
min_image_distances(points=None, points2=None, axes=None, vectors=False, pairs=True)[source]#
distance_table(points=None, points2=None, axes=None, vectors=False)[source]#
vector_table(points=None, points2=None, axes=None)[source]#
neighbor_table(points=None, points2=None, axes=None, distances=False, vectors=False)[source]#
min_image_norms(points, norms)[source]#
voronoi_neighbors(indices=None, restrict=False, distance_ordered=True)[source]#
voronoi_vectors(indices=None, restrict=None)[source]#
voronoi_distances(indices=None, restrict=False)[source]#
voronoi_radii(indices=None, restrict=None)[source]#
voronoi_species_radii()[source]#
nearest_neighbors(indices=None, rmax=None, nmax=None, restrict=False, voronoi=False, distances=False, **spec_max)[source]#
chemical_coordination(indices=None, nmax=None, rmax=None, restrict=False, voronoi=False, neighbors=False, distances=False, **spec_max)[source]#
rcore_max(units=None)[source]#
cell_image(p, center=None)[source]#
center_distances(points, center=None)[source]#
recenter(center=None)[source]#

Center atoms around a new provided center of the unit cell, or if a new center is not provided then use the (0.5 0.5 0.5) point of the unit cell.

recenter_k(kpoints=None, kaxes=None, kcenter=None, remove_duplicates=False)[source]#

Center k-points around the provided center of k-space.

Parameters:
kpointsNDArray | None, default = None

Array of N k-points to center with shape (N,3)

kaxesNDArray | None, default = None

Array of axes describing the k-space cell with shape (3,3)

kcenterNDArray | None, default = None

Array containing a custom center of k-space with shape (3,3)

remove_duplicatesbool, default = False

Remove k-points that have a distance less than 1e-8

recorner(center=None)[source]#

Center atoms around the origin of the cell.

Parameters:
centerNDArray, default = self.center

Position of the center of the cell.

Notes

If the user supplies center, then this will modify self.center to reflect that change.

inside(pos, axes=None, center=None, tol=1e-08, separate=False)[source]#
tile(*td, **kwargs)[source]#
tile_points(points, axes, tilemat, tilevec=None)[source]#
tile_points_simple(points, axes, tilevec)[source]#
tile_points_brute(points, axes, tilemat)[source]#
opt_tilematrix(*args, **kwargs)[source]#
tile_opt(*args, **kwargs)[source]#
check_tiling(tol=1e-06, exit=True)[source]#
kfold(tiling, kpoints, kweights)[source]#
get_smallest()[source]#
fold(small, *requests)[source]#
tilematrix(small=None, tol=1e-06, status=False)[source]#
primitive(source=None, tmatrix=False, add_kpath=False, **kwargs)[source]#
become_primitive(source=None, add_kpath=False, **kwargs)[source]#
add_kpoints(kpoints, kweights=None, unique=False, recenter=True, cell_unit=False)[source]#
clear_kpoints()[source]#
kgrid_from_kspacing(kspacing)[source]#
add_kmesh(kgrid=None, kshift=None, unique=False, kspacing=None)[source]#
add_symmetrized_kmesh(kgrid=None, kshift=(0, 0, 0), kspacing=None)[source]#
kpoints_unit(kpoints=None)[source]#
kpoints_reduced(kpoints=None)[source]#
kpoints_qmcpack(kpoints=None)[source]#
inversion_symmetrize_kpoints(tol=1e-10, folded=False)[source]#
unique_points(points, axes, weights=None, tol=1e-10)[source]#
unique_points_fast(points, axes, weights=None, tol=1e-10)[source]#
unique_positions(tol=1e-10, folded=False)[source]#
unique_kpoints(tol=1e-10, folded=False)[source]#
kmap()[source]#
select_twist(selector='smallest', tol=1e-06)[source]#
fold_pos(large, tol=0.001)[source]#
pos_unit(pos=None)[source]#
pos_to_cartesian()[source]#
at_Gpoint()[source]#
at_Lpoint()[source]#
at_real_kpoint()[source]#
bonds(neighbors, vectors=False)[source]#
displacement(reference, map=False)[source]#
scalar_displacement(reference)[source]#
distortion(reference, neighbors)[source]#
bond_compression(reference, neighbors)[source]#
boundary(dims=(0, 1, 2), dtol=1e-06)[source]#
embed(small, dims=(0, 1, 2), dtol=1e-06, utol=1e-06)[source]#
shell(cell, neighbors, direction='in')[source]#
interpolate(other, images, min_image=True, recenter=True, match_com=False, chained=False)[source]#
madelung(axes=None, tol=1e-10)[source]#
makov_payne(q=1, eps=1.0, units='Ha', order=1)[source]#
read(filepath, format=None, elem=None, block=None, grammar='1.1', cell='prim', contents=False)[source]#
read_xyz(filepath)[source]#
read_xsf(filepath)[source]#
read_poscar(filepath, elem=None)[source]#
read_cif(filepath, block=None, grammar='1.1', cell='prim')[source]#
read_fhi_aims(filepath)[source]#
write(filepath=None, format=None)[source]#
pos_to_str(units: str = 'A', with_elem: bool = False)[source]#

Write the positions of a structure to a string, optionally with atomic symbols.

Parameters:
unitsstr, default=”A”

Units for the positions.

with_elembool, default=False

Optionally write the atomic symbols with the positions.

Notes

This function will write the positions in the format (in this case using with_elem=True) .. code-block:: python

“{element:2} {dim1:12.8f} {dim2:12.8f} … {dimN:12.8f}n”

write_xyz(filepath=None)[source]#

Write a Structure object to an XYZ file

Parameters:
filepathPathLike or None, default=None

Path to where the XYZ file should be written. If this is None, then this function just returns what would have been written to the XYZ file.

Returns:
xyzstr

The text that was or would have been written to the XYZ file.

Notes

To get a string of only the atomic positions, use pos_to_str() instead.

write_xsf(filepath=None)[source]#
write_poscar(filepath=None)[source]#
write_fhi_aims(filepath=None)[source]#
plot2d_ax(ix=0, iy=1, *args, **kwargs)[source]#
plot2d_pos(ix=0, iy=1, *args, **kwargs)[source]#
plot2d_points(points, ix=0, iy=1, *args, **kwargs)[source]#
plot2d(pos_style='b.', ax_style='k-')[source]#
plot2d_kax(ix, iy, *args, **kwargs)[source]#
plot2d_kp(ix, iy, *args, **kwargs)[source]#
show(viewer='vmd', filepath='/tmp/tmp.xyz')[source]#
get_cell()[source]#
get_scaled_positions()[source]#
get_number_of_atoms()[source]#
get_atomic_numbers()[source]#
get_magnetic_moments()[source]#
spglib_cell()[source]#
get_symmetry(symprec=1e-05)[source]#
get_symmetry_dataset(symprec=1e-05, angle_tolerance=-1.0, hall_number=0)[source]#
symmetry_data(*args, **kwargs)[source]#
bravais_lattice_name(symm_data=None)[source]#
space_group_operations(tol=1e-05, unit=False)[source]#
point_group_operations(tol=1e-05, unit=False)[source]#
check_point_group_operations(rotations=None, tol=1e-05, unit=False, dtol=1e-05, ncheck=1, exit=False)[source]#
equivalent_atoms()[source]#
rmg_lattices = cubic_F               str                    cubic_I               str                    cubic_P               str                    hexagonal_P           str                    orthorhombic_P        str                    tetragonal_P          str                  #
rmg_lattice(allow_tile=False, all_results=False, ret_bravais=False, exit=False, warn=False)[source]#
rmg_transform(allow_tile=False, allow_general=False, all_results=False)[source]#
nexus.structure.get_conventional_cell(structure=None, symprec=1e-05, angle_tolerance=1.0, seekpathout=None)[source]#
nexus.structure.get_primitive_cell(structure=None, symprec=1e-05, angle_tolerance=1.0, seekpathout=None)[source]#
nexus.structure.get_kpath(structure=None, check_standard=True, with_time_reversal=False, recipe='hpkot', reference_distance=0.025, threshold=1e-07, symprec=1e-05, angle_tolerance=1.0, seekpathout=None)[source]#
nexus.structure.get_symmetry(structure=None, symprec=1e-05, angle_tolerance=1.0, seekpathout=None)[source]#
nexus.structure.get_structure_with_bands(cell=0, structure=None, with_time_reversal=False, reference_distance=0.025, threshold=1e-07, symprec=1e-05, angle_tolerance=1.0)[source]#
nexus.structure.get_band_tiling(structure=None, check_standard=True, use_ktol=True, kpoints_label=None, kpoints_rel=None, max_volfac=20, min_volfac=0, target_volfac=None)[source]#
nexus.structure.get_seekpath_full(structure=None, seekpathout=None, conventional=False, primitive=False, **kwargs)[source]#
nexus.structure.interpolate_structures(struct1, struct2=None, images=None, min_image=True, recenter=True, match_com=False, repackage=False, chained=False)[source]#
nexus.structure.structure_animation(filepath, structures, tiling=None)[source]#
class nexus.structure.DefectStructure(*args, **kwargs)[source]#

Bases: Structure

Methods

add_atoms(elem, pos)

adjust_axes(axes)

append(value)

at_Gpoint()

at_Lpoint()

at_real_kpoint()

bond_compression(reference, neighbors)

bonds(neighbors[, vectors])

boundary([dims, dtol])

carve(identifiers)

cell_image(p[, center])

center_distances(points[, center])

center_molecule([rmin_edge])

Center a molecule in a unit cell, ensuring equal padding on all sides.

center_solid()

change_units(units[, folded])

chemical_coordination([indices, nmax, rmax, ...])

class_error(message[, header, exit, trace, ...])

Report an error relating to a class.

clear_kpoints()

cleave(axis, loc[, sep, remove, tol])

clone_from(other)

corners()

Calculate vectors corresponding to the 8 corners of the unit cell.

cube_deviation()

displacement(reference[, map])

distances([pos1, pos2])

distortion(reference, neighbors)

error(message[, header, exit, trace])

Report an error inside a class.

face_distances()

face_vectors([axes, distances])

first()

fold(small, *requests)

fold_pos(large[, tol])

get_cell()

group_atoms([folded])

Group the atoms by their element type, sorting in alphabetical order.

incorporate(other)

inside(pos[, axes, center, tol, separate])

inversion_symmetrize_kpoints([tol, folded])

keys()

kfold(tiling, kpoints, kweights)

layer_composition(layers)

layers([axis, dtol, dbin, plot, composition])

list(*keys)

locate(identifiers[, radii, exterior])

locate_simple(pos)

madelung([axes, tol])

matrix_transform(A)

Arbitrary transformation matrix (column-major).

miller_direction(h, k, l[, normalize])

miller_normal(h, k, l[, normalize])

min_image_centroid([points, indices])

min_image_centroids([points, indices])

min_image_norms(points, norms)

nearest_neighbors([indices, rmax, nmax, ...])

open_log(filepath)

order_by_species([folded])

ordered_species([symbol])

permute(permutation)

point_defect([identifiers, elem, dr])

pos_to_str([units, with_elem])

Write the positions of a structure to a string, optionally with atomic symbols.

project_plane(a1, a2[, points])

rcore_max([units])

read_fhi_aims(filepath)

recenter([center])

Center atoms around a new provided center of the unit cell, or if a new center is not provided then use the (0.5 0.5 0.5) point of the unit cell.

recenter_k([kpoints, kaxes, kcenter, ...])

Center k-points around the provided center of k-space.

recorner([center])

Center atoms around the origin of the cell.

remove(identifiers)

rename([folded])

Rename element names in a structure.

reorder(order)

replace(identifiers[, elem, pos, radii, ...])

replace_nearest(elem[, pos])

rescale(scale)

reset_axes([axes])

Reset the structure's axes, k-space axes, and center.

reshape_axes(reshaping)

ring_graphs(order, **kwargs)

rinscribe_cube(*args, **kwargs)

rotate(r[, rp, passive, units, check])

Arbitrary rotation of the structure.

rotate_plane(plane, angle[, units])

rwigner_cube(*args, **kwargs)

save([fpath])

scalar_displacement(reference)

select_twist([selector, tol])

shell(cell, neighbors[, direction])

shells(identifiers[, radii, exterior, ...])

skew(skew)

Arbitrary transformation matrix (row-major).

slide(v[, recenter])

sorted_keys()

space_group_operations([tol, unit])

species([symbol])

spglib_cell()

stretch(s1, s2, s3)

translate(v)

unique_kpoints([tol, folded])

unique_points(points, axes[, weights, tol])

unique_points_fast(points, axes[, weights, tol])

unique_positions([tol, folded])

unsheared_axes([axes, distances])

upcast(DerivedStructure)

voronoi_neighbors([indices, restrict, ...])

warn(msg[, indent])

Warning from inside a Nexus class.

write_axes()

Write the unit cell axes as a string.

write_fhi_aims([filepath])

write_xyz([filepath])

Write a Structure object to an XYZ file

zero_corner()

add

add_kmesh

add_kpoints

add_optional

add_symmetrized_kmesh

all_periodic

any_periodic

become_primitive

bounding_box

bravais_lattice_name

check_consistent

check_point_group_operations

check_required

check_tiling

check_types

check_types_optional

class_get

class_has

class_items

class_keys

class_log

class_set

class_set_optional

class_set_single

class_warn

clear

close_log

compare

connected_graphs

copy

copy_from

copy_to

count_kshells

data_repr

defect_from_bond_compression

defect_from_displacement

delete

delete_optional

delete_required

dict

distance_table

embed

equivalent_atoms

extract

extract_optional

freeze

get

get_atomic_numbers

get_magnetic_moments

get_number_of_atoms

get_optional

get_path

get_required

get_scaled_positions

get_smallest

get_symmetry

get_symmetry_dataset

has_axes

has_folded

has_folded_structure

has_tmatrix

interpolate

inverse

is_frozen

is_magnetic

is_open

is_periodic

is_tiled

items

kgrid_from_kspacing

kmap

kpoints_qmcpack

kpoints_reduced

kpoints_unit

last

list_optional

load

log

makov_payne

min_image_distances

min_image_vectors

move_from

move_from_optional

move_to

move_to_optional

neighbor_table

not_implemented

obj

operate

opt_tilematrix

path_exists

plot2d

plot2d_ax

plot2d_kax

plot2d_kp

plot2d_points

plot2d_pos

point_group_operations

pos_to_cartesian

pos_unit

primitive

random_key

rcell

read

read_cif

read_poscar

read_xsf

read_xyz

remove_folded

remove_folded_structure

rinscribe

rmg_lattice

rmg_transform

rmin

rwigner

select_random

serial

set

set_axes

set_bconds

set_elem

set_folded

set_folded_structure

set_frozen

set_mag

set_operations

set_optional

set_path

set_pos

shallow_copy

show

size

symmetry_data

tile

tile_opt

tile_points

tile_points_brute

tile_points_simple

tilematrix

to_dict

to_obj

transfer_from

transfer_to

tree

tuple

values

vector_table

volume

voronoi_distances

voronoi_radii

voronoi_species_radii

voronoi_vectors

write

write_poscar

write_xsf

defect_from_bond_compression(compression_cutoff, bond_eq, neighbors)[source]#
defect_from_displacement(displacement_cutoff, reference)[source]#
compare(dist_cutoff, d1, d2=None)[source]#
class nexus.structure.Crystal(lattice=None, cell=None, centering=None, constants=None, atoms=None, basis=None, basis_vectors=None, tiling=None, cscale=None, axes=None, units=None, angular_units='degrees', kpoints=None, kgrid=None, mag=None, frozen=None, kshift=(0, 0, 0), permute=None, operations=None, elem=None, pos=None, use_prim=None, add_kpath=False, symm_kgrid=False)[source]#

Bases: Structure

Generate a crystal structure.

Parameters:
latticestr, optional
cellstr, optional
centering{“P”, “A”, “B”, “C”, “F”, “I”, “R”}, optional
constantsfloat or tuple of float, optional

Lattice constants required for the specified lattice. The order for these is (a, b, c, α, β, γ). If the specified lattice does not require some constant, you can omit it, but retain the overall order of the constants.

atomsstr or tuple of str, optional

The atomic symbol(s) of the atoms in the lattice.

basislist of lists of floats, optional

A list of vectors that define the atom positions with respect to the basis_vectors. If there are multiple atoms, this should have the sample length as atoms.

basis_vectorsArrayLike of float or {“prim”, “conv”}, optional

A set of 3 vectors that define the basis used to transform basis.

cscalelist of float, optional

Scaling values for the provided constants. Must have the same length as constants.

Attributes:
lattice_constants
lattices
centering_types
lattice_centerings
centerings
cell_types
cell_aliases
cell_classes
constantsNDArray of float

The lattice constants (a, b, c) for the crystal.

anglesNDArray of float

The angles (α, β, γ) for the crystal.

generation_infoobj of str: str

The supplied inputs to the class constructor.

Methods

add_atoms(elem, pos)

adjust_axes(axes)

append(value)

at_Gpoint()

at_Lpoint()

at_real_kpoint()

bond_compression(reference, neighbors)

bonds(neighbors[, vectors])

boundary([dims, dtol])

carve(identifiers)

cell_image(p[, center])

center_distances(points[, center])

center_molecule([rmin_edge])

Center a molecule in a unit cell, ensuring equal padding on all sides.

center_solid()

change_units(units[, folded])

chemical_coordination([indices, nmax, rmax, ...])

class_error(message[, header, exit, trace, ...])

Report an error relating to a class.

clear_kpoints()

cleave(axis, loc[, sep, remove, tol])

clone_from(other)

corners()

Calculate vectors corresponding to the 8 corners of the unit cell.

cube_deviation()

displacement(reference[, map])

distances([pos1, pos2])

distortion(reference, neighbors)

error(message[, header, exit, trace])

Report an error inside a class.

face_distances()

face_vectors([axes, distances])

first()

fold(small, *requests)

fold_pos(large[, tol])

get_cell()

group_atoms([folded])

Group the atoms by their element type, sorting in alphabetical order.

incorporate(other)

inside(pos[, axes, center, tol, separate])

inversion_symmetrize_kpoints([tol, folded])

keys()

kfold(tiling, kpoints, kweights)

layer_composition(layers)

layers([axis, dtol, dbin, plot, composition])

list(*keys)

locate(identifiers[, radii, exterior])

locate_simple(pos)

madelung([axes, tol])

matrix_transform(A)

Arbitrary transformation matrix (column-major).

miller_direction(h, k, l[, normalize])

miller_normal(h, k, l[, normalize])

min_image_centroid([points, indices])

min_image_centroids([points, indices])

min_image_norms(points, norms)

nearest_neighbors([indices, rmax, nmax, ...])

open_log(filepath)

order_by_species([folded])

ordered_species([symbol])

permute(permutation)

point_defect([identifiers, elem, dr])

pos_to_str([units, with_elem])

Write the positions of a structure to a string, optionally with atomic symbols.

project_plane(a1, a2[, points])

rcore_max([units])

read_fhi_aims(filepath)

recenter([center])

Center atoms around a new provided center of the unit cell, or if a new center is not provided then use the (0.5 0.5 0.5) point of the unit cell.

recenter_k([kpoints, kaxes, kcenter, ...])

Center k-points around the provided center of k-space.

recorner([center])

Center atoms around the origin of the cell.

remove(identifiers)

rename([folded])

Rename element names in a structure.

reorder(order)

replace(identifiers[, elem, pos, radii, ...])

replace_nearest(elem[, pos])

rescale(scale)

reset_axes([axes])

Reset the structure's axes, k-space axes, and center.

reshape_axes(reshaping)

ring_graphs(order, **kwargs)

rinscribe_cube(*args, **kwargs)

rotate(r[, rp, passive, units, check])

Arbitrary rotation of the structure.

rotate_plane(plane, angle[, units])

rwigner_cube(*args, **kwargs)

save([fpath])

scalar_displacement(reference)

select_twist([selector, tol])

shell(cell, neighbors[, direction])

shells(identifiers[, radii, exterior, ...])

skew(skew)

Arbitrary transformation matrix (row-major).

slide(v[, recenter])

sorted_keys()

space_group_operations([tol, unit])

species([symbol])

spglib_cell()

stretch(s1, s2, s3)

translate(v)

unique_kpoints([tol, folded])

unique_points(points, axes[, weights, tol])

unique_points_fast(points, axes[, weights, tol])

unique_positions([tol, folded])

unsheared_axes([axes, distances])

upcast(DerivedStructure)

voronoi_neighbors([indices, restrict, ...])

warn(msg[, indent])

Warning from inside a Nexus class.

write_axes()

Write the unit cell axes as a string.

write_fhi_aims([filepath])

write_xyz([filepath])

Write a Structure object to an XYZ file

zero_corner()

add

add_kmesh

add_kpoints

add_optional

add_symmetrized_kmesh

all_periodic

any_periodic

become_primitive

bounding_box

bravais_lattice_name

check_consistent

check_point_group_operations

check_required

check_tiling

check_types

check_types_optional

class_get

class_has

class_items

class_keys

class_log

class_set

class_set_optional

class_set_single

class_warn

clear

close_log

connected_graphs

copy

copy_from

copy_to

count_kshells

data_repr

delete

delete_optional

delete_required

dict

distance_table

embed

equivalent_atoms

extract

extract_optional

freeze

get

get_atomic_numbers

get_magnetic_moments

get_number_of_atoms

get_optional

get_path

get_required

get_scaled_positions

get_smallest

get_symmetry

get_symmetry_dataset

has_axes

has_folded

has_folded_structure

has_tmatrix

interpolate

inverse

is_frozen

is_magnetic

is_open

is_periodic

is_tiled

items

kgrid_from_kspacing

kmap

kpoints_qmcpack

kpoints_reduced

kpoints_unit

last

list_optional

load

log

makov_payne

min_image_distances

min_image_vectors

move_from

move_from_optional

move_to

move_to_optional

neighbor_table

not_implemented

obj

operate

opt_tilematrix

path_exists

plot2d

plot2d_ax

plot2d_kax

plot2d_kp

plot2d_points

plot2d_pos

point_group_operations

pos_to_cartesian

pos_unit

primitive

random_key

rcell

read

read_cif

read_poscar

read_xsf

read_xyz

remove_folded

remove_folded_structure

rinscribe

rmg_lattice

rmg_transform

rmin

rwigner

select_random

serial

set

set_axes

set_bconds

set_elem

set_folded

set_folded_structure

set_frozen

set_mag

set_operations

set_optional

set_path

set_pos

shallow_copy

show

size

symmetry_data

tile

tile_opt

tile_points

tile_points_brute

tile_points_simple

tilematrix

to_dict

to_obj

transfer_from

transfer_to

tree

tuple

values

vector_table

volume

voronoi_distances

voronoi_radii

voronoi_species_radii

voronoi_vectors

write

write_poscar

write_xsf

See also

Structure

All remaining parameters are passed to this class’s constructor. See its docstring for more details.

lattice_constants = cubic                 list                   hexagonal             list                   monoclinic            list                   orthorhombic          list                   rhombohedral          list                   tetragonal            list                   triclinic             list                 #

Mapping from a lattice type to the required values to create the cell.

lattices = ['triclinic', 'monoclinic', 'orthorhombic', 'tetragonal', 'hexagonal', 'cubic', 'rhombohedral']#

List of lattice systems.

centering_types = base_centered         tuple                  body_centered         str                    face_centered         str                    primitive             str                    rhombohedral_centered  str                  #

Mapping from centering types to their Pearson symbol.

lattice_centerings = cubic                 list                   hexagonal             list                   monoclinic            list                   orthorhombic          list                   rhombohedral          list                   tetragonal            list                   triclinic             list                 #

Mapping of lattice systems to allowed centering types.

centerings = A                     list                   B                     list                   C                     list                   F                     list                   I                     list                   P                     list                   R                     list                 #
cell_types = {'conventional', 'primitive'}#

Types of cells, currently only primitive and conventional.

cell_aliases = conv                  str                    prim                  str                  #

Mapping from shortened aliases prim and conv to their cell type.

cell_classes = bcc                   str                    cubic                 str                    fcc                   str                    hex                   str                    hexagonal             str                    monoclinic            str                    orthorhombic          str                    rhombohedral          str                    sc                    str                    tetragonal            str                    triclinic             str                  #

Mapping from common lattice names to their lattices.

known_crystals = {('Ca2CuO3', 'conv'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('Ca2CuO3', 'prim'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('CaO', 'conv'):   atoms                 tuple                  cell                  str                    constants             float                  lattice               str                  , ('CaO', 'prim'):   atoms                 tuple                  cell                  str                    constants             float                  lattice               str                  , ('Cl2Ca2CuO2', 'afm'):   atoms                 list                   axes                  list                   basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('Cl2Ca2CuO2', 'conv'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('Cl2Ca2CuO2', 'prim'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('CuO', 'conv'):   angular_units         str                    atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('CuO', 'prim'):   angular_units         str                    atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('CuO2_plane', 'conv'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('CuO2_plane', 'prim'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('La2CuO4', 'conv'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('La2CuO4', 'prim'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('NaCl', 'conv'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('NaCl', 'prim'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('ZnO', 'conv'):   atoms                 tuple                  cell                  str                    constants             tuple                  lattice               str                    units                 str                  , ('ZnO', 'prim'):   atoms                 tuple                  cell                  str                    constants             tuple                  lattice               str                    units                 str                  , ('calcium', 'conv'):   atoms                 str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('calcium', 'prim'):   atoms                 str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('copper', 'conv'):   atoms                 str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('copper', 'prim'):   atoms                 str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('diamond', 'conv'):   atoms                 str                    basis                 list                   cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('diamond', 'fcc'):   atoms                 str                    basis                 list                   cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('diamond', 'prim'):   atoms                 str                    basis                 list                   cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('diamond', 'sc'):   atoms                 str                    basis                 list                   cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('graphene', 'conv'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('graphene', 'prim'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('graphene', 'rect'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('graphite_aa', 'hex'):   atoms                 tuple                  axes                  list                   basis                 list                   constants             tuple                  units                 str                  , ('graphite_ab', 'hex'):   atoms                 tuple                  axes                  list                   basis                 list                   constants             tuple                  cscale                tuple                  units                 str                  , ('oxygen', 'conv'):   angular_units         str                    atoms                 tuple                  basis                 list                   basis_vectors         ndarray                cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('oxygen', 'prim'):   angular_units         str                    atoms                 tuple                  basis                 list                   basis_vectors         ndarray                cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('rocksalt', 'conv'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('rocksalt', 'prim'):   atoms                 tuple                  basis                 list                   basis_vectors         str                    cell                  str                    centering             str                    constants             float                  lattice               str                    units                 str                  , ('wurtzite', 'conv'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  , ('wurtzite', 'prim'):   atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  }#

Mapping from material names and their cell types to their crystal information.

desc = atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  #
cdesc = atoms                 tuple                  basis                 list                   cell                  str                    centering             str                    constants             tuple                  lattice               str                    units                 str                  #
cell = 'rect'#
lattice = 'rhombohedral'#
name = 'graphene'#
class nexus.structure.Jellium(charge=None, background_charge=None, cell=None, volume=None, density=None, rs=None, dim=3, axes=None, kpoints=None, kweights=None, kgrid=None, kshift=None, units=None, tiling=None)[source]#

Bases: Structure

Methods

add_atoms(elem, pos)

adjust_axes(axes)

append(value)

at_Gpoint()

at_Lpoint()

at_real_kpoint()

bond_compression(reference, neighbors)

bonds(neighbors[, vectors])

boundary([dims, dtol])

carve(identifiers)

cell_image(p[, center])

center_distances(points[, center])

center_molecule([rmin_edge])

Center a molecule in a unit cell, ensuring equal padding on all sides.

center_solid()

change_units(units[, folded])

chemical_coordination([indices, nmax, rmax, ...])

class_error(message[, header, exit, trace, ...])

Report an error relating to a class.

clear_kpoints()

cleave(axis, loc[, sep, remove, tol])

clone_from(other)

corners()

Calculate vectors corresponding to the 8 corners of the unit cell.

cube_deviation()

displacement(reference[, map])

distances([pos1, pos2])

distortion(reference, neighbors)

error(message[, header, exit, trace])

Report an error inside a class.

face_distances()

face_vectors([axes, distances])

first()

fold(small, *requests)

fold_pos(large[, tol])

get_cell()

group_atoms([folded])

Group the atoms by their element type, sorting in alphabetical order.

incorporate(other)

inside(pos[, axes, center, tol, separate])

inversion_symmetrize_kpoints([tol, folded])

keys()

kfold(tiling, kpoints, kweights)

layer_composition(layers)

layers([axis, dtol, dbin, plot, composition])

list(*keys)

locate(identifiers[, radii, exterior])

locate_simple(pos)

madelung([axes, tol])

matrix_transform(A)

Arbitrary transformation matrix (column-major).

miller_direction(h, k, l[, normalize])

miller_normal(h, k, l[, normalize])

min_image_centroid([points, indices])

min_image_centroids([points, indices])

min_image_norms(points, norms)

nearest_neighbors([indices, rmax, nmax, ...])

open_log(filepath)

order_by_species([folded])

ordered_species([symbol])

permute(permutation)

point_defect([identifiers, elem, dr])

pos_to_str([units, with_elem])

Write the positions of a structure to a string, optionally with atomic symbols.

project_plane(a1, a2[, points])

rcore_max([units])

read_fhi_aims(filepath)

recenter([center])

Center atoms around a new provided center of the unit cell, or if a new center is not provided then use the (0.5 0.5 0.5) point of the unit cell.

recenter_k([kpoints, kaxes, kcenter, ...])

Center k-points around the provided center of k-space.

recorner([center])

Center atoms around the origin of the cell.

remove(identifiers)

rename([folded])

Rename element names in a structure.

reorder(order)

replace(identifiers[, elem, pos, radii, ...])

replace_nearest(elem[, pos])

rescale(scale)

reset_axes([axes])

Reset the structure's axes, k-space axes, and center.

reshape_axes(reshaping)

ring_graphs(order, **kwargs)

rinscribe_cube(*args, **kwargs)

rotate(r[, rp, passive, units, check])

Arbitrary rotation of the structure.

rotate_plane(plane, angle[, units])

rwigner_cube(*args, **kwargs)

save([fpath])

scalar_displacement(reference)

select_twist([selector, tol])

shell(cell, neighbors[, direction])

shells(identifiers[, radii, exterior, ...])

skew(skew)

Arbitrary transformation matrix (row-major).

slide(v[, recenter])

sorted_keys()

space_group_operations([tol, unit])

species([symbol])

spglib_cell()

stretch(s1, s2, s3)

translate(v)

unique_kpoints([tol, folded])

unique_points(points, axes[, weights, tol])

unique_points_fast(points, axes[, weights, tol])

unique_positions([tol, folded])

unsheared_axes([axes, distances])

upcast(DerivedStructure)

voronoi_neighbors([indices, restrict, ...])

warn(msg[, indent])

Warning from inside a Nexus class.

write_axes()

Write the unit cell axes as a string.

write_fhi_aims([filepath])

write_xyz([filepath])

Write a Structure object to an XYZ file

zero_corner()

add

add_kmesh

add_kpoints

add_optional

add_symmetrized_kmesh

all_periodic

any_periodic

become_primitive

bounding_box

bravais_lattice_name

check_consistent

check_point_group_operations

check_required

check_tiling

check_types

check_types_optional

class_get

class_has

class_items

class_keys

class_log

class_set

class_set_optional

class_set_single

class_warn

clear

close_log

connected_graphs

copy

copy_from

copy_to

count_kshells

data_repr

delete

delete_optional

delete_required

density

dict

distance_table

embed

equivalent_atoms

extract

extract_optional

freeze

get

get_atomic_numbers

get_magnetic_moments

get_number_of_atoms

get_optional

get_path

get_required

get_scaled_positions

get_smallest

get_symmetry

get_symmetry_dataset

has_axes

has_folded

has_folded_structure

has_tmatrix

interpolate

inverse

is_frozen

is_magnetic

is_open

is_periodic

is_tiled

items

kgrid_from_kspacing

kmap

kpoints_qmcpack

kpoints_reduced

kpoints_unit

last

list_optional

load

log

makov_payne

min_image_distances

min_image_vectors

move_from

move_from_optional

move_to

move_to_optional

neighbor_table

not_implemented

obj

operate

opt_tilematrix

path_exists

plot2d

plot2d_ax

plot2d_kax

plot2d_kp

plot2d_points

plot2d_pos

point_group_operations

pos_to_cartesian

pos_unit

primitive

random_key

rcell

read

read_cif

read_poscar

read_xsf

read_xyz

remove_folded

remove_folded_structure

rinscribe

rmg_lattice

rmg_transform

rmin

rs

rwigner

select_random

serial

set

set_axes

set_bconds

set_elem

set_folded

set_folded_structure

set_frozen

set_mag

set_operations

set_optional

set_path

set_pos

shallow_copy

show

size

symmetry_data

tile

tile_opt

tile_points

tile_points_brute

tile_points_simple

tilematrix

to_dict

to_obj

transfer_from

transfer_to

tree

tuple

values

vector_table

volume

voronoi_distances

voronoi_radii

voronoi_species_radii

voronoi_vectors

write

write_poscar

write_xsf

prefactors = 1                     float                  2                     float                  3                     float                #
density()[source]#
rs()[source]#
tile()[source]#
nexus.structure.generate_cell(shape, tiling=None, scale=1.0, units=None, struct_type=<class 'nexus.structure.Structure'>)[source]#
nexus.structure.generate_structure(type='crystal', *args, **kwargs)[source]#
nexus.structure.generate_atom_structure(atom=None, units='A', Lbox=None, skew=0, axes=None, kgrid=(1, 1, 1), kshift=(0, 0, 0), bconds=('n', 'n', 'n'), struct_type=<class 'nexus.structure.Structure'>)[source]#

Create a structure with a single atom in the center of a unit cell.

Parameters:
atomstr

The atomic symbol of the atom.

unitsstr, default=”A”

The units of the structure, defaults to Angstroms.

Lboxint or float, optional

Length of the simulation box. Overrides axes.

skewint or float less than 1, default=0

axesArrayLike of float, optional

The unit cell axes.

kgridtuple of int, default=(1,1,1)

Number of k-points in each direction. Used to create a Monkhorst-Pack k-point mesh.

kshifttuple of int, default=(0,0,0)

Vector to use to translate the k-points in the mesh.

bcondstuple of str, default=(“n”,”n”,”n”)

Boundary conditions for the resulting structure.

nexus.structure.generate_dimer_structure(dimer=None, units='A', separation=None, Lbox=None, skew=0, axes=None, kgrid=(1, 1, 1), kshift=(0, 0, 0), bconds=('n', 'n', 'n'), struct_type=<class 'nexus.structure.Structure'>, axis='x')[source]#

Create a structure with a dimer in the center of a unit cell.

Parameters:
dimerlist of str

The atomic symbols of the atoms in the dimer.

unitsstr, default=”A”

The units of the structure, defaults to Angstroms.

separationint or float

The separation between the atoms in the dimer.

Lboxint or float, optional

Length of the simulation box. Overrides axes.

skewint or float less than 1, default=0

axesArrayLike of float, optional

The unit cell axes.

kgridtuple of int, default=(1,1,1)

Number of k-points in each direction. Used to create a Monkhorst-Pack k-point mesh.

kshifttuple of int, default=(0,0,0)

Vector to use to translate the k-points in the mesh.

bcondstuple of str, default=(“n”,”n”,”n”)

Boundary conditions for the resulting structure.

axis{“x”, “y”, “z”}, optional

The axis that the dimer is aligned on.

nexus.structure.generate_trimer_structure(trimer=None, units='A', separation=None, angle=None, Lbox=None, skew=0, axes=None, kgrid=(1, 1, 1), kshift=(0, 0, 0), struct_type=<class 'nexus.structure.Structure'>, axis='x', axis2='y', angular_units='degrees', plane_rot=None)[source]#

Create a structure with a dimer in the center of a unit cell.

Parameters:
trimerlist of str

The atomic symbols of the atoms in the trimer.

unitsstr, default=”A”

The units of the structure, defaults to Angstroms.

separationlist of ints or floats

The separation between the atoms in the trimer. The first value is the distance between atom 1 and atom 2, and the second value is the distance between atom 1 and atom 3.

angleint or float

The angle formed by the three atoms in the trimer.

Lboxint or float, optional

Length of the simulation box. Overrides axes.

skewint or float less than 1, default=0

axesArrayLike of float, optional

The unit cell axes.

kgridtuple of int, default=(1,1,1)

Number of k-points in each direction. Used to create a Monkhorst-Pack k-point mesh.

kshifttuple of int, default=(0,0,0)

Vector to use to translate the k-points in the mesh.

axis{“x”, “y”, “z”}, optional

The axis that atom 1 and atom 2 of the trimer is aligned on.

axis2{“x”, “y”, “z”}, optional

The axis that atom 1 and atom 3 of the trimer is aligned on.

angular_units{“degrees”, “rad”, “radians”}, optional

The units of the supplied angle.

nexus.structure.generate_jellium_structure(*args, **kwargs)[source]#
nexus.structure.generate_crystal_structure(lattice=None, cell=None, centering=None, constants=None, atoms=None, basis=None, basis_vectors=None, tiling=None, cscale=None, axes=None, units=None, angular_units='degrees', mag=None, kpoints=None, kweights=None, kgrid=None, kshift=(0, 0, 0), permute=None, operations=None, struct_type=<class 'nexus.structure.Crystal'>, elem=None, pos=None, frozen=None, posu=None, elem_pos=None, folded_elem=None, folded_pos=None, folded_units=None, use_prim=None, add_kpath=False, symm_kgrid=False, structure=None, shape=None, element=None, scale=None)[source]#

Generate a crystal structure.

See Crystal and Structure for a description of the available parameters.

nexus.structure.generate_defect_structure(defect, structure, shape=None, element=None, tiling=None, scale=1.0, kgrid=None, kshift=(0, 0, 0), units=None, struct_type=<class 'nexus.structure.DefectStructure'>)[source]#
nexus.structure.read_structure(filepath, elem=None, format=None)[source]#