EPWpy.structure.lattice#
Functions
|
Builds supercell of a certain size |
|
Builds supercell of a certain size for the polarization vector |
Classes
|
A class representing a crystal lattice and its associated data. |
- class EPWpy.structure.lattice.Lattice(data)[source]#
Bases:
objectA class representing a crystal lattice and its associated data.
This class provides a basic interface for storing and managing lattice-related information. It can serve as the foundational class for structural manipulation, symmetry analysis, or visualization routines in materials simulations.
- Parameters:
data (dict or object) -- Input data structure containing lattice information. Typically includes lattice vectors, atomic positions, and element types, but may be any user-defined format compatible with downstream methods.
- data#
The input lattice data, stored for use by other methods.
- Type:
dict or object
- home#
The working directory path at the time of object initialization.
- Type:
str
Examples
>>> lattice_data = { ... 'lattice_vectors': [[1.0, 0.0, 0.0], ... [0.0, 1.0, 0.0], ... [0.0, 0.0, 1.0]], ... 'atomic_positions': [[0.0, 0.0, 0.0]], ... 'elements': ['Si'] ... } >>> lat = Lattice(lattice_data) >>> lat.home '/home/user/project'
- display_lattice(supercell=None, view=None, bond_length=3.5, type_view='mayavi')[source]#
Visualize the atomic lattice of the system.
This method displays the atomic structure of the simulated material using either Mayavi (for interactive 3D visualization) or Matplotlib (for static plotting). It supports supercell expansion and customizable view parameters.
- Parameters:
supercell (list or None, optional) -- Supercell expansion factors along each lattice direction, e.g.,
[2, 2, 1]for a 2×2×1 supercell. IfNone, uses the primitive cell.view (dict or None, optional) -- Dictionary specifying visualization options such as rotation, zoom, or color scheme. Example:
{'azimuth': 45, 'elevation': 30, 'wrap': False}IfNone, defaults are used.bond_length (float, optional) -- Maximum interatomic distance (in Å) for drawing bonds (default:
3.5).type_view (str, optional) -- Visualization backend: -
'mayavi'→ interactive 3D visualization (default) -'matplotlib'→ static 3D plotting for environments without Mayavi
- Returns:
Visualization object returned by the selected backend: -
Mayaviscene if available and selected. -Matplotlibfigure otherwise.- Return type:
object
Notes
Requires Mayavi to be installed for full 3D interactive visualization.
If Mayavi is not available, falls back automatically to Matplotlib rendering.
The visualization includes lattice vectors and atomic species.
Example
>>> epw = EPWProperties(file='epw2.out', system='MoS2') >>> epw.display_lattice(supercell=[2,2,1], type_view='matplotlib')
- display_phonons(pl_vec, supercell=None, view=None, bond_length=3.5, type_view='mayavi')[source]#
Display the phonon displacement modes of the crystal structure.
This method visualizes phonon modes (atomic vibrations) using the provided phonon displacement vectors (pl_vec). The visualization can be generated using either Mayavi or Matplotlib, depending on availability and the type_view argument.
- Parameters:
pl_vec (array-like) -- Phonon displacement vectors for each atom in the structure. Typically obtained from a phonon calculation or interpolation step. Must have shape (N_atoms, 3).
supercell (list[int], optional) -- Supercell expansion factors in each lattice direction [nx, ny, nz]. If not provided, the primitive cell is used.
view (dict, optional) -- Visualization parameters, such as camera orientation or zoom level. Default is an empty dictionary.
bond_length (float, optional) -- Maximum bond distance (in Ångströms) used to determine which atoms are connected by bonds in the visualization. Default is 3.5 Å.
type_view (str, optional) --
- Visualization backend to use. Options are:
'mayavi': use Mayavi for 3D interactive rendering (default)
'matplotlib': use Matplotlib for static rendering
- Returns:
A visualization object or figure handle created by the selected visualization backend.
- Return type:
object
Notes
This method constructs the full crystal structure (including optional supercell expansion) and overlays atomic displacement vectors representing phonon modes. The resulting data is passed to an external visualization routine (display_crystal_phonon).
Examples
>>> pl_vec = np.random.randn(4, 3) # Example displacement vectors >>> model.display_phonons(pl_vec, supercell=[2, 2, 1], type_view='matplotlib')
- get_Data(pl_vec, supercell=None, view=None, bond_length=3.5, type_view='mayavi')[source]#
Display phonon modes
- property structure_params#
Returns structure parameters as a dictionary Units are Angstrom for variables in Cartesian
- property structure_params_summary#
Print structure as a formatted string