Commit c7d3303e authored by rym's avatar rym
Browse files

Added py3Dmol and jupyter dependencies; updated .extend_vdW_layers to...

Added py3Dmol and jupyter dependencies; updated .extend_vdW_layers to correctly map layers back to cell; updated example.ipynb to use view_structure fxn, which uses py3Dmol
parent d26ad8ff
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
# vdW_structures

## Overview
`vdW_structures` is a Python package built on `ase` and `pymatgen` that facilitates the construction of van der Waals (vdW) layered materials.
`vdW_structures` is a Python package built on `ase` and `pymatgen` that facilitates the construction of van der Waals (vdW) layered materials. It requires 'jupyter' and 'py3Dmol' for testing and visualization. 

## Features
- Allows the user to extract and recombine individual layers of vdW materials.
- Improves `pymatgen`'s CoherentInterfaceBuilder() handling of vdW heterostructure construction.
- Supports common vdW structural transformations (e.g., x, y and z-direction shifts of individual layers).

- NOTE: Solving for and setting vdW layers is currently only supported along c-lattice vectors with no x or y components, e.g., [0, 0, z]. 

## Installation
You can install `vdW_structures` using pip:

@@ -15,7 +17,7 @@ You can install `vdW_structures` using pip:
pip install git+https://github.com/yourusername/vdW_structures.git
```

Alternatively, if you're developing the package, clone the repository and install it in editable mode. 
Alternatively, if you'd like to make local changes to the package, clone the repository and install it in editable mode. 

```bash
git clone https://github.com/yourusername/vdW_structures.git
+3 −1
Original line number Diff line number Diff line
@@ -14,7 +14,9 @@ authors = [
dependencies = [
    "numpy",  # Add your dependencies here
    "ase",
    "pymatgen"
    "jupyter",
    "pymatgen",
    "py3Dmol"
]

[tool.setuptools]
+609 −139

File changed.

Preview size limit exceeded, changes collapsed.

+609 −139

File changed.

Preview size limit exceeded, changes collapsed.

+13 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ from copy import deepcopy


class VdWStructure:
    def __init__(self, structure: Structure, minimum_vdW_gap: Union[int, float]):
    def __init__(self, structure: Structure, minimum_vdW_gap: Union[int, float], shift_gap=True):
        """Identify van der Waals layers based on if the spacing between atomic layers exceeds the minimum_vdW_gap."""
        if not isinstance(structure, Structure):
            raise TypeError(f"Expected a pymatgen Structure object, got {type(structure).__name__}")
@@ -29,7 +29,11 @@ class VdWStructure:
            except:
                raise ValueError(f"No van der Waals layers found with a gap of {minimum_vdW_gap} Å.")
        
        if shift_gap:
            self.structure = self.shift_to_vdW_gap(structure, self.vdW_layers, self.layer_images).get_sorted_structure()
        else:
            self.structure = structure 
 
        self.vdW_layers, self.layer_images, self.vdW_spacings = self.get_vdW_layers(self.structure)
        #print(self.vdW_layers, self.layer_images, self.vdW_spacings)
        
@@ -296,4 +300,11 @@ class VdWStructure:
                
        no_spacing_extended_structure = self._add_vdW_sites(new_layer_numbers)
        correct_spacing_structure = self._rescale_vdW_lattice(new_layer_numbers, no_spacing_extended_structure)

        # Might need to adjust this depending on the gap location        
        correct_spacing_vdW = VdWStructure(correct_spacing_structure.get_sorted_structure(), self.minimum_vdW_gap)
        correct_spacing_atoms = correct_spacing_structure.to_ase_atoms()
        correct_spacing_atoms.center(axis=2, vacuum=correct_spacing_vdW.vdW_spacings[0]/2) # Set to bottom gap
        correct_spacing_structure = self.ase_atoms_adaptor.get_structure(correct_spacing_atoms)
        
        return VdWStructure(correct_spacing_structure.get_sorted_structure(), self.minimum_vdW_gap)
Loading