βοΈ Professional Heterojunction Modeling Platform
A comprehensive toolkit for building, analyzing, and optimizing heterostructure interfaces for DFT calculations
Features β’ Installation β’ Quick Start β’ Documentation β’ Web Interface
InterfaceML provides a complete suite of tools for heterojunction modeling with a focus on:
- Build perovskite/fullerene interfaces for solar cell applications
- Automatic surface termination selection (PbI, FAI, MAI, AI)
- Multi-layer stacking (e.g., Perovskite/C70/C60)
- Intelligent supercell generation with minimal adsorbate interactions
- Support for symmetric slabs with consistent terminations
- Coherent interface matching with automatic strain optimization
- ZSL algorithm for finding commensurate supercells
- Bidirectional or unidirectional strain application
- Customizable Miller indices for both materials
- Comprehensive strain analysis and reporting
- Selective Dynamics: Fix bottom N layers for relaxation calculations
- Layer Splitting: Separate multi-layer stacks into individual files
- Automatic layer detection for interface structures
- Intelligent whole-molecule inclusion (prevents splitting organic cations)
- Support for multi-interface structures
- Preserves original lattice parameters when splitting
- Compatible with VASP and CP2K
- Compute charge density differences: ΞΟ = Ο(interface) - Ο(A) - Ο(B)
- Streaming cube file processing (memory-efficient)
- Direct VESTA visualization support
- Python 3.8 or higher
- pip or conda package manager
git clone https://github.com/yourusername/InterfaceML.git
cd InterfaceML
pip install -e .pip install -r requirements.txtnumpy >= 1.20.0pymatgen >= 2022.0.0flask >= 2.0.0(for web interface)flask-cors >= 3.0.0(for web interface)
# Basic usage: Perovskite + C60
python build_heterojunctions/interface_builder.py \
--adsorbate_mode \
--base structures/perovskites/H5PbCI3N2.cif \
--adsorbate structures/etl/C60-Ih.cif \
--termination PbI \
--distance 2.5 \
--supercell auto \
--output my_interface.vasp
# Multi-layer stack: Perovskite + C70 + C60
python build_heterojunctions/interface_builder.py \
--adsorbate_mode \
--base structures/perovskites/fapbi3-1.cif \
--adsorbate structures/etl/C70-D5h.cif structures/etl/C60-Ih.cif \
--termination FAI \
--layer_gaps 2.0 2.0 \
--supercell auto \
--output perovskite_c70_c60.vasp# Fix bottom 3 layers
python build_heterojunctions/fix_interface_layers.py \
--by_z_layers \
--input my_interface.vasp \
--n_fix_layers 3 \
--output my_interface_fixed.vasp
# Multi-interface structure: split into layers
python build_heterojunctions/fix_interface_layers.py \
--by_layers \
--input perovskite_c70_c60.vasp \
--n_interfaces 2 \
--fixed_layers 1 \
--output perovskite_c70_c60_fixed.vasp# Split a 3-layer stack (2 interfaces) into separate files
# Each layer keeps the original lattice parameters
python build_heterojunctions/fix_interface_layers.py \
--by_layers \
--input trilayer.vasp \
--n_interfaces 2 \
--print_only
# Or use Python API
python -c "
from interfaceml.core import io, splitting
structure = io.load_structure('trilayer.vasp')
layers = splitting.split_structure_into_layers(structure, n_interfaces=2)
for i, layer in enumerate(layers, 1):
io.write_poscar(layer, f'layer{i}.vasp')
print(f'Layer {i}: {len(layer)} atoms')
"python build_heterojunctions/delta_density_cube.py \
--interface interface_density.cube \
--layer1 perovskite_density.cube \
--layer2 c60_density.cube \
--output delta_density.cubefrom interfaceml.core import io, layering
# Load structure
structure = io.load_structure("my_structure.vasp")
# Detect layers
layers, tolerance = layering.split_layers_by_z(structure, gap_cut=True)
# Fix bottom 3 layers
fixed_indices = []
for layer in layers[:3]:
fixed_indices.extend(layer)
# Include whole molecules
fixed_indices = layering.include_whole_molecules(structure, fixed_indices)
# Generate selective dynamics
selective_dynamics = [(False, False, False) if i in fixed_indices else (True, True, True)
for i in range(len(structure))]
# Write POSCAR
io.write_poscar(structure, "output_fixed.vasp", selective_dynamics=selective_dynamics)InterfaceML includes a beautiful, modern web interface for interactive modeling:
# Start the web server
python -m interfaceml.web.app
# Or use the CLI command
interfaceml-webThen open your browser to http://localhost:5000
- π Drag-and-drop file upload for structure files (.cif, .vasp, .xyz)
- π¨ Interactive parameter configuration with real-time validation
- π Visual feedback with structure information display
- β¬οΈ Direct download of generated structure files
- π Multi-tab interface for different modeling workflows
- βοΈ Layer splitting - Separate multi-layer structures (preserves lattice)
- π§ Selective dynamics - Fix layers for relaxation
InterfaceML/
βββ interfaceml/ # Main Python package
β βββ core/ # Core functionality modules
β β βββ io.py # Structure I/O (VASP, CIF, XYZ)
β β βββ layering.py # Layer detection and manipulation
β β βββ splitting.py # Smart layer splitting
β βββ cli/ # Command-line interface tools
β β βββ build_interface.py
β β βββ fix_layers.py
β β βββ delta_density.py
β βββ web/ # Flask web application
β β βββ app.py # Main Flask app
β β βββ templates/ # HTML templates
β β βββ static/ # CSS and JavaScript
β βββ utils/ # Utility functions
β βββ geometry.py # Geometric calculations
βββ build_heterojunctions/ # Original scripts (maintained for compatibility)
β βββ interface_builder.py
β βββ fix_interface_layers.py
β βββ delta_density_cube.py
β βββ README.md # Detailed technical documentation
βββ structures/ # Example structure files
β βββ perovskites/
β βββ etl/
β βββ heterojunctions/
βββ examples/ # Tutorial notebooks and scripts
βββ docs/ # Additional documentation
βββ setup.py # Package installation script
βββ requirements.txt # Python dependencies
βββ README.md # This file
- build_heterojunctions/README.md - Comprehensive CLI usage guide
- docs/GETTING_STARTED.md - Tutorial and workflows
- docs/LAYER_SPLITTING.md - Layer splitting guide
- docs/SMART_SPLITTING_ALGORITHM.md - Smart splitting algorithm details
- Tutorials - Example workflows
- Perovskite/ETL (C60, TiO2) interfaces
- Charge transfer analysis
- Interface optimization
- 2D material interfaces
- Metal-semiconductor junctions
- Coherent interface engineering
- Pre-processing for VASP, CP2K, Quantum ESPRESSO
- Automatic structure preparation
- Post-processing charge density analysis
# Use a pre-relaxed slab directly
python build_heterojunctions/interface_builder.py \
--adsorbate_mode \
--slab_input my_relaxed_slab.vasp \
--adsorbate structures/etl/C60-Ih.cif \
--distance 2.5 \
--output relaxed_with_c60.vasp# Specify exact supercell dimensions
python build_heterojunctions/interface_builder.py \
--adsorbate_mode \
--base structures/perovskites/H5PbCI3N2.cif \
--adsorbate structures/etl/C60-Ih.cif \
--termination PbI \
--supercell_xy 2 2 \
--output interface_2x2.vasp# Adjust tolerance for layer clustering
python build_heterojunctions/fix_interface_layers.py \
--by_z_layers \
--input structure.xyz \
--n_fix_layers 3 \
--tol 0.5 \
--debug_layers \
--print_only# Step 1: Build interface
python build_heterojunctions/interface_builder.py \
--adsorbate_mode \
--base structures/perovskites/fapbi3-1.cif \
--adsorbate structures/etl/C60-Ih.cif \
--termination FAI \
--distance 2.5 \
--supercell auto \
--output fapbi3_c60.vasp
# Step 2: Add selective dynamics (fix bottom 3 layers)
python build_heterojunctions/fix_interface_layers.py \
--by_z_layers \
--input fapbi3_c60.vasp \
--n_fix_layers 3 \
--output fapbi3_c60_fixed.vasp
# Step 3: Run DFT calculation (your favorite code)
# ...
# Step 4: Analyze charge transfer
python build_heterojunctions/delta_density_cube.py \
--interface fapbi3_c60_density.cube \
--layer1 fapbi3_density.cube \
--layer2 c60_density.cube \
--output delta_charge.cubeContributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
# Clone repository
git clone https://github.com/yourusername/InterfaceML.git
cd InterfaceML
# Install in development mode with dev dependencies
pip install -e ".[dev]"
# Quick import check
python -c "from interfaceml.core import io, layering, splitting; print('OK')"This project is licensed under the MIT License - see the LICENSE file for details.
For questions, bug reports, or feature requests:
- Open an issue on GitHub
- Email: interface@example.com
- Built with Pymatgen - Materials analysis library
- Interface matching based on ZSL algorithm
- Inspired by real-world DFT workflow challenges in heterojunction research
If you use InterfaceML in your research, please cite:
@software{interfaceml2024,
title = {InterfaceML: A Professional Toolkit for Heterojunction Modeling},
author = {Interface Modeling Lab},
year = {2024},
url = {https://github.com/yourusername/InterfaceML}
}Made with β€οΈ for the computational materials science community
β Star us on GitHub if InterfaceML helps your research!