Twist 2D materials#
Getting Started with the Terminal Tool#
You can use the terminal command-line tool to generate twisted 2D heterostructures. The tool provides a straightforward interface with configurable parameters.
Basic Command#
dock design twist-2d stack -h
Usage: dock design twist-2d stack [OPTIONS] PRIM_POSCAR1 SUPER1_A1_A2 PRIM_POSCAR2 SUPER2_A1_A2
Generate twisted 2D heterostructures with custom parameters.
Options:
-d, --next-layer-dis FLOAT Distance between twisted layers (in Angstrom). [default: 2.0]
-z, --start-z FLOAT Starting z-coordinate for the first layer. [default: 0.1]
-h, --help Show this message and exit.
Example Usage#
Generate a twisted bilayer structure with carbon and boron nitride layers:
dock design twist-2d stack "POSCAR-C" "7,8,-8,15" "POSCAR-BN" "8,7,-7,15"
Advanced Usage: Python Class API#
For more flexibility and programmatic control, DeepH-dock provides the Twist2D class that can be integrated into your Python workflows or custom scripts.
Basic Implementation#
from deepx_dock.design.twist_2d.twist import Twist2D
# Create an object for t2d
twist_2d = Twist2D()
# Initialize the different twisted layers
m = 7
n = 8
#--> 1st layer
super_a1_mult = [m, n]
super_a2_mult = [-n, m+n]
twist_2d.add_layer(super_a1_mult, super_a2_mult, next_layer_dis=3.0, prim_poscar="POSCAR-C")
#--> 2nd layer
super_a1_mult = [n, m]
super_a2_mult = [-m, n+m]
twist_2d.add_layer(super_a1_mult, super_a2_mult, prim_poscar="POSCAR-BN")
# Twisting the layers
twist_2d.twist_layers(start_z=0.1)
# Write results to the file
twist_2d.write_res_to_poscar()
# (Optional) Calculate the twisted angles of each layer in degree
print(twist_2d.twisted_angles)
# (Optional) Calculate the strain add (volume changes) in each layer, + for volume increasing compare to the orginal primitive cell, vice versa.
print(twist_2d.layers_strain)
[do] Write the twisted structure to POSCAR-Twisted ...
[np.float64(0.0), np.float64(4.408454669372472)]
[np.float64(0.0), np.float64(-0.03437501870207649)]
DeepH-dock: Flexible Integration for Computational Research#
DeepH-dock is designed with developer convenience in mind, offering multiple integration points:
Dual Interface Design#
Command-Line Interface: Perfect for quick prototyping, batch processing, and integration with shell scripts
Python API: Ideal for complex workflows, custom analysis pipelines, and integration with other computational tools
Seamless Integration#
The library follows Pythonic design principles, making it easy to incorporate into existing projects. Whether you’re building automated workflows with tools like Snakemake or Nextflow, or developing interactive notebooks with Jupyter, DeepH-dock provides a consistent and intuitive interface.
Extensibility#
The modular architecture allows researchers to:
Extend existing functionality with custom transformations
Implement new structure generation algorithms
Integrate with popular computational chemistry packages
Build custom visualization and analysis tools
Quick Reference#
Use Case |
Recommended Approach |
Key Benefits |
|---|---|---|
Quick structure generation |
Terminal command |
Fast, one-line solution |
Batch processing multiple structures |
Shell script + CLI |
Easy automation |
Custom workflow integration |
Python API |
Full program control |
Research & development |
Python API + Jupyter |
Interactive exploration |
Development Philosophy#
DeepH-dock embraces the Unix philosophy of “doing one thing well” while providing multiple access points. This design ensures that both novice users and experienced developers can work efficiently with the tool (See “For Developers” Section).
Start by experimenting with the terminal commands for quick results, then explore the Python API as your needs grow more complex. The consistent parameter naming between interfaces makes transitioning between them intuitive and straightforward.