src.easycrystallography.Components
Lattice
Lattice
Bases: BaseObj
a: float
property
writable
Get the a lattice parameter.
:return: a lattice parameter :rtype: float
alpha: float
property
writable
Get the alpha lattice parameter.
:return: alpha lattice parameter :rtype: float
angles: Tuple[float, float, float]
property
Get the angles of the unit cell in degrees.
:return: Tuple of unit cell angles (alpha, beta, gamma) :rtype: tuple
b: float
property
writable
Get the b lattice parameter.
:return: b lattice parameter :rtype: float
beta: float
property
writable
Get the beta lattice parameter.
:return: beta lattice parameter :rtype: float
c: float
property
writable
Get the c lattice parameter.
:return: c lattice parameter :rtype: float
gamma: float
property
writable
Get the gamma lattice parameter.
:return: gamma lattice parameter :rtype: float
inv_matrix: np.ndarray
property
Inverse of lattice matrix.
:return: Inverse of lattice matrix :rtype: np.ndarray
lengths: Tuple[float, float, float]
property
Get the lengths of the unit cell.
:return: Tuple of unit cell lengths (a, b, c) :rtype: tuple
matrix: np.ndarray
property
Get the lattice matrix.
:return: Lattice matrix in the form of a 9x9 matrix :rtype: np.ndarray
metric_tensor: np.ndarray
property
The metric tensor of the lattice.
:return metric tensor of the lattice :rtype: np.ndarray
reciprocal_lattice: L
property
Return the reciprocal lattice. Note that this is the standard reciprocal lattice used for solid state physics with a factor of 2 * pi. If you are looking for the crystallographic reciprocal lattice, use the reciprocal_lattice_crystallographic property.
:return: New cell in the reciprocal lattice :rtype: Lattice
reciprocal_lattice_crystallographic: L
property
Returns the crystallographic reciprocal lattice, i.e., no factor of 2 * pi.
:return: New cell in the crystallographic reciprocal lattice :rtype: Lattice
volume: float
property
Volume of the unit cell.
:return: Volume of the unit cell :rtype: ureg.Quantity
__copy__()
Returns a deep copy of the Lattice
:return: Deep copy of self :rtype:
__format__(fmt_spec='')
Support format printing. Supported formats are:
- "l" for a list format that can be easily copied and pasted, e.g., ".3fl" prints something like "[[10.000, 0.000, 0.000], [0.000, 10.000, 0.000], [0.000, 0.000, 10.000]]"
- "p" for lattice parameters ".1fp" prints something like "{10.0, 10.0, 10.0, 90.0, 90.0, 90.0}"
- Default will simply print a 3x3 matrix form. E.g., 10.000 0.000 0.000 0.000 10.000 0.000 0.000 0.000 10.000
__matrix(a, b, c, alpha, beta, gamma)
staticmethod
Calculating the crystallographic matrix is time consuming and we use it often, so we have memoized it. :param a: a lattice parameter :type a: float :param b: b lattice parameter :type b: float :param c: c lattice parameter :type c: float :param alpha: alpha lattice parameter :type alpha: float :param beta: beta lattice parameter :type beta: float :param gamma: gamma lattice parameter :type gamma: float :return: crystallographic matrix :rtype: np.ndarray
cubic(a, interface=None)
classmethod
Convenience constructor for a cubic lattice.
:param a: The a lattice parameter of the cubic cell. :type a: float :return: Crystallographic unit cell container :rtype: Lattice
d_hkl(miller_index)
Returns the distance between the hkl plane and the origin
:param miller_index: (h. k. l) Miller index of plane :type miller_index: Vector3Like :return: Distance between the hkl plane and the origin :rtype: float
from_matrix(matrix, interface=None)
classmethod
Construct a crystallographic unit cell from the lattice matrix
:param matrix: Matrix describing the crystallographic unit cell in the form of a numpy array, 1x9 list or 3x3 list. :type matrix: np.ndarray, List[float], List[List[float]] :return: Crystallographic unit cell container :rtype: Lattice
get_cartesian_coords(fractional_coords)
Returns the cartesian coordinates given fractional coordinates.
:param fractional_coords: fractional_coords (3x1 array): Fractional coords. :type fractional_coords: np.ndarray , list :return: Cartesian coordinates :rtype: np.ndarray
get_fractional_coords(cart_coords)
Returns the fractional coordinates given cartesian coordinates.
:param cart_coords: cart_coords (3x1 array): Fractional coords. :type cart_coords: np.ndarray , list :return: Fractional coordinates. :rtype: np.ndarray
get_points_in_sphere(frac_points, center, r, zip_results=True)
Find all points within a sphere from the point taking into account periodic boundary conditions. This includes sites in other periodic images. Algorithm: 1. place sphere of radius r in crystal and determine minimum supercell (parallelpiped) which would contain a sphere of radius r. for this we need the projection of a_1 on a unit vector perpendicular to a_2 & a_3 (i.e. the unit vector in the direction b_1) to determine how many a_1"s it will take to contain the sphere. Nxmax = r * length_of_b_1 / (2 Pi) 2. keep points falling within r. Args: frac_points: All points in the lattice in fractional coordinates. center: Cartesian coordinates of center of sphere. r: radius of sphere. zip_results (bool): Whether to zip the results together to group by point, or return the raw fcoord, dist, index arrays Returns: if zip_results: [(fcoord, dist, index, supercell_image) ...] since most of the time, subsequent processing requires the distance, index number of the atom, or index of the image else: fcoords, dists, inds, image
get_vector_along_lattice_directions(cart_coords)
Returns the coordinates along lattice directions given cartesian coordinates. Note, this is different than a projection of the cartesian vector along the lattice parameters. It is simply the fractional coordinates multiplied by the lattice vector magnitudes.
:param cart_coords: cart_coords (3x1 array): Fractional coords. :type cart_coords: np.ndarray , list :return: Lattice coordinates. :rtype: np.ndarray
hexagonal(a, c, interface=None)
classmethod
Convenience constructor for a hexagonal lattice of dimensions a x a x c
:param a: a lattice parameter of the hexagonal cell. :type a: float :param c: c lattice parameter of the hexagonal cell. :type c: float :return: Crystallographic unit cell container :rtype: Lattice
is_hexagonal(hex_angle_tol=5, hex_length_tol=0.01)
Returns true if the Lattice is hexagonal.
:param hex_angle_tol: Angle tolerance :param hex_length_tol: Length tolerance :return: Whether lattice corresponds to hexagonal lattice. :rtype: bool
is_orthogonal()
Returns true if the cell is orthogonal (all angles 90 degrees)
:return: Whether all angles are 90 degrees. :rtype: bool
monoclinic(a, b, c, beta, interface=None)
classmethod
Convenience constructor for a monoclinic lattice of dimensions a x b x c with non right-angle beta between lattice vectors a and c.
:param a: a lattice parameter of the monoclinc cell. :type a: float :param b: b lattice parameter of the monoclinc cell. :type b: float :param c: c lattice parameter of the monoclinc cell. :type c: float :param beta: beta angle between lattice vectors b and c in degrees. :type beta: float :return: Crystallographic unit cell container :rtype: Lattice
orthorhombic(a, b, c, interface=None)
classmethod
Convenience constructor for an orthorhombic lattice.
:param a: a lattice parameter of the orthorhombic cell. :type a: float :param b: b lattice parameter of the orthorhombic cell. :type b: float :param c: c lattice parameter of the orthorhombic cell. :type c: float :return: Crystallographic unit cell container :rtype: Lattice
rhombohedral(a, alpha, interface=None)
classmethod
Convenience constructor for a rhombohedral lattice of dimensions a x a x a.
:param a: a lattice parameter of the monoclinc cell. :type a: float :param alpha: Angle for the rhombohedral lattice in degrees. :type alpha: float :return: Crystallographic unit cell container :rtype: Lattice
scale(new_volume)
Return a new Cell with volume new_volume by performing a scaling of the lattice vectors so that length proportions and angles are preserved.
:param new_volume: New volume to scale to. :type new_volume: float :return: New cell scaled to volume :rtype: Lattice
scale_lengths(length_scales)
Return a new Cell where the cell lengths have been scaled by the scaling factors. Angles are preserved.
:param length_scales: Scaling for each length or universal scaling factor :type length_scales: Union[float, Vector3Like] :return: New Cell scaled by user supplied scale factors :rtype: Lattice
tetragonal(a, c, interface=None)
classmethod
Convenience constructor for a tetragonal lattice.
:param a: a lattice parameter of the tetragonal cell. :type a: float :param c: c lattice parameter of the tetragonal cell. :type c: float :return: Crystallographic unit cell container :rtype: Lattice
PeriodicLattice
Bases: Lattice
__copy__()
Returns a deep copy of the Periodic-Lattice. Note that the spacegroup parameter is also a copy!!
:return: Deep copy of self :rtype: PeriodicLattice
enforce_sym()
Enforce symmetry constraints on to a Lattice
from_matrix(matrix, interface=None)
classmethod
Construct a crystallographic unit cell from the lattice matrix
:param matrix: Matrix describing the crystallographic unit cell in the form of a numpy array, 1x9 list or 3x3 list. :type matrix: np.ndarray, List[float], List[List[float]] :return: Crystallographic unit cell container :rtype: Lattice
to_cell()
Convert the PeriodicLattice to a standard Lattice. i.e. drop spacegroup. The return is a copy
:return: Lattice with spacegroup information dropped. :rtype: Lattice
find_neighbors(label, nx, ny, nz)
Given a cube index, find the neighbor cube indices Args: label: (array) (n,) or (n x 3) indice array nx: (int) number of cells in y direction ny: (int) number of cells in y direction nz: (int) number of cells in z direction Returns: neighbor cell indices
get_integer_index(miller_index, round_dp=4, verbose=True)
Attempt to convert a vector of floats to whole numbers. Args: miller_index (list of float): A list miller indexes. round_dp (int, optional): The number of decimal places to round the miller index to. verbose (bool, optional): Whether to print warnings. Returns: (tuple): The Miller index.
get_points_in_spheres(all_coords, center_coords, r, pbc=True, numerical_tol=1e-08, lattice=None, return_fcoords=False)
For each point in center_coords
, get all the neighboring points in all_coords
that are within the
cutoff radius r
.
Args:
all_coords: (list of cartesian coordinates) all available points
center_coords: (list of cartesian coordinates) all centering points
r: (float) cutoff radius
pbc: (bool or a list of bool) whether to set periodic boundaries
numerical_tol: (float) numerical tolerance
lattice: (Lattice) lattice to consider when PBC is enabled
return_fcoords: (bool) whether to return fractional coords when pbc is set.
Returns:
List[List[Tuple[coords, distance, index, image]]]
Site
Atoms
Bases: BaseCollection
append(*args, **kwargs)
Add an atom to the crystal
PeriodicSite
Bases: Site
cart_coords: np.ndarray
property
Get the atomic position in Cartesian form. :return: :rtype:
get_orbit()
Generate all orbits for a given fractional position.
Site
Bases: BaseObj
fract_coords: np.ndarray
property
Get the current sites fractional co-ordinates as an array
:return: Array containing fractional co-ordinates :rtype: np.ndarray
fract_distance(other_site)
Get the distance between two sites
:param other_site: Second site :param other_site: Second site :type other_site: Site :return: Distance between 2 sites :rtype: float
SpaceGroup
SpaceGroup
Bases: BaseObj
crystal_system: str
property
Which crystal system the space group belongs to
:return: Crystal system of the space group
hall_symbol: str
property
Hall symbol of the space group
:return: Hall symbol of the space group
hermann_mauguin: str
property
Space group name as defined by a Hermann-Mauguin symbol
:return: Space group name as a string
int_number: int
property
writable
International number of the space group
:return: International number of the space group
is_reference_setting: bool
property
Is the space group setting the reference setting?
:return: Is the space group setting the reference setting?
it_coordinate_system_code: Optional[Descriptor]
property
writable
Space group setting. If the space group does not have a setting, this will be None. Equivalent to setting, defined to satisfy CIF Template
:return: Space group setting
it_number: int
property
writable
International number of the space group Equivalent to int_number, defined to satisfy CIF Template
:return: International number of the space group
name_hall: str
property
Hall symbol of the space group Equivalent to hall_symbol, defined to satisfy CIF Template
:return: Hall symbol of the space group
name_hm_alt: Descriptor
property
writable
Space group name as defined by a Hermann-Mauguin symbol Equivalent to space_group_HM_name, defined to satisfy CIF Template
:return: Space group name as easyCore Descriptor
setting: Optional[Descriptor]
property
writable
Space group setting. If the space group does not have a setting, this will be None.
:return: Space group setting
setting_str: str
property
Space group setting as a string. If the space group does not have a setting, this will be an empty string.
:return: Space group setting as a string
space_group_HM_name: Descriptor
property
writable
Space group name as defined by a Hermann-Mauguin symbol
:return: Space group name as easyCore Descriptor
symmetry_ops: List[SymmOp]
property
writable
List of symmetry operations of the space group
:return: List of symmetry operations of the space group
symmetry_xyz: str
property
Symmetry operations of the space group as a string
:return: String of symmetry operations of the space group
__init__(space_group_HM_name=None, setting=None, symmetry_ops=None, interface=None)
Generate a spacegroup object from it's Hermann-Mauguin symbol and setting. The setting can be a part of the Hermann-Mauguin symbol.
:param space_group_HM_name: Hermann-Mauguin symbol :param setting: Optional setting for the space group :param interface: Interface to the calculator
__on_change(new_spacegroup, new_setting=None, operations_set=None, set_internal=True)
Internal function to update the space group. This function is called when the space group is changed. It checks the form of the imputs, generates reference data, and updates the internal data (if requested).
:param new_spacegroup: New space group number or name :param new_setting: New space group setting :param set_internal: Should internal objects be updated
find_settings_by_number(number)
staticmethod
Find the IT_coordinate_system_code by group's number. gemmi doesn't do it natively.
from_gemmi_operations(operations, interface=None)
classmethod
Generate a space group from a list of gemmi operations or a gemmi group of operations.
:param operations: Operations which define a space group :param interface: Interface to the calculator
from_generators(rotations, translations, interface=None)
classmethod
Create a space group from a lists of rotations and translations. Each translation is applied to each rotation.
:param rotations: Array of rotation matrices [n[3x3]] :param translations: Array of translations [m[1x3]] :param interface: Interface to the calculator
from_int_number(int_number, hexagonal=True, interface=None)
classmethod
Generate a spacegroup object from it's spacegroup number (1-231). :param int_number: spacegroup number :param hexagonal: Should a hexagonal setting be used? :param interface: Interface to the calculator
from_symMatrices(rotations, translations, interface=None)
classmethod
Create a space group from a lists of rotations and translations. The number of rotations and translations must be the same.
:param rotations: Array of rotation matrices [n[3x3]] :param translations: Array of translations [n[1x3]] :param interface: Interface to the calculator
from_symOps(sym_ops, interface=None)
classmethod
Create a space group from a list of easycrystallography symmetry operations.
:param sym_ops: List of easycrystallography symmetry operations :param interface: Interface to the calculator
from_xyz_string(xyz_string, interface=None)
classmethod
Create a space group from a string or list of strings of the form 'x,y,z'.
:param xyz_string: String defining space group operators :param interface: Interface to the calculator
get_orbit(point, tol=1e-05)
Returns the orbit for a point.
:param point: Point to get the orbit for :param tol: Tolerance for the orbit :return: Orbits of the point
get_site_multiplicity(site, tol=1e-05)
Get the multiplicity of a given site
:param site: Site to get the multiplicity of :param tol: Tolerance for the orbit :return: Multiplicity of the site
symmetry_matrices()
Get the rotational and translational matrices of the space group
:return: Rotation and translation matrices
in_array_list(array_list, a, tol=1e-05)
Extremely efficient nd-array comparison using numpy's broadcasting. This function checks if a particular array a, is present in a list of arrays. It works for arrays of any size, e.g., even matrix searches.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array_list
|
[array]
|
A list of arrays to compare to. |
required |
a
|
array
|
The test array for comparison. |
required |
tol
|
float
|
The tolerance. Defaults to 1e-5. If 0, an exact match is done. |
1e-05
|
Returns:
Type | Description |
---|---|
bool
|
(bool) |