cellify

A user-friendly CLI tool for DFT researchers to generate supercells and prepare inputs.

View the Project on GitHub ToAmano/cellify

cellify

PyPI version Python versions License: MIT Test Suite Coverage

A user-friendly command-line interface (CLI) tool designed for DFT researchers to quickly generate supercells and prepare calculation-ready inputs (VASP, Quantum ESPRESSO, etc.) from unit cells.


Features


Installation

1. Install via PyPI

To install the latest stable release of cellify directly using pip:

pip install cellify

2. Local Installation (Development)

To install from the source code for development or customization:

git clone https://github.com/ToAmano/cellify.git
cd cellify
pip install -e .

# Or install with test dependencies
pip install -e ".[test]"

CLI Usage

cellify -i <input_file> -o <output_file> [options]

Arguments List

[!NOTE] 3D Visualization (Tkinter / _tkinter error) If you run with -w/--view and see ModuleNotFoundError: No module named '_tkinter', your Python environment is missing Tcl/Tk support:

  • macOS (Homebrew Python): Run brew install python-tk (or python-tk@3.9 matching your python version).
  • macOS (Conda Python): Run conda install -c conda-forge tk python inside your active environment.
  • Linux (Ubuntu/Debian): Run sudo apt-get install python3-tk.

If Tkinter is not available, cellify automatically falls back to rendering a 2D projection window using matplotlib.


Examples

1. Create a simple $2 \times 2 \times 3$ supercell (VASP POSCAR)

cellify -i POSCAR -o POSCAR_223 --dim 2 2 3

Primitive Unit Cell 2x2x3 Supercell

2. Convert primitive cell to conventional and scale to 2x2x2

cellify -i Si_primitive.POSCAR -o Si_conventional_222.POSCAR --conventional --dim 2 2 2

Primitive Unit Cell Conventional 2x2x2 Supercell

3. Orthogonalize a hexagonal cell (Quantum ESPRESSO input)

# Preserves &CONTROL and &SYSTEM settings, and updates nat, CELL_PARAMETERS, and ATOMIC_POSITIONS
cellify -i qe.in -o qe_ortho.in --matrix "1 -1 0 / 1 1 0 / 0 0 1"

Primitive QE Cell Orthogonalized QE Cell

4. Generate the smallest supercell keeping defect distance $\ge 15\ \text{Å}$

cellify -i POSCAR -o POSCAR_defect_bulk --min-dist 15.0

Primitive Unit Cell 4x4x4 scaled Supercell

5. Create a silicon supercell and replace 1 atom with Phosphorus (n-type doped model)

cellify -i Si_unit.cif -o Si_doped.POSCAR --dim 3 3 3 --substitute "Si:P:0"

Conventional Unit Cell 3x3x3 Doped Supercell

6. Introduce vacancies in a supercell (e.g., delete a specific Silicon atom, or randomly remove 2 Oxygen atoms)

# Deletes the Silicon atom at absolute index 0
cellify -i Si_supercell.POSCAR -o Si_vacancy.POSCAR --vacancy-index "Si:0"

# Randomly removes 2 Oxygen atoms from the structure
cellify -i STO_supercell.POSCAR -o STO_vacancies.POSCAR --vacancy-count "O:2"

Si 2x2x2 Supercell Si Supercell with Vacancy

7. Generate a $\text{SrTiO}_3$ (100) surface slab model with $15\ \text{Å}$ vacuum

cellify -i STO_bulk.cif -o STO_100_slab.POSCAR --slab 1 0 0 --thick 12.0 --vacuum 15.0

Bulk STO Unit Cell STO (100) Surface Slab

8. Extract relaxed structure from a Quantum ESPRESSO output log and generate an SCF input

# Reads the final relaxed structure from vc-relax.out,
# merges it with the computational settings in template.in,
# and writes scf.in with calculation = 'scf' and updated atom/type counts.
cellify -i vc-relax.out --template template.in -o scf.in --calc scf
graph TD
    subgraph Inputs ["Input Files"]
        A["vc-relax.out (QE Output Log)<br/>➔ Contains relaxed atomic coordinates"]
        B["template.in (Input Template)<br/>➔ Contains K-points, parameters, etc."]
    end

    C["cellify -i vc-relax.out --template template.in -o scf.in --calc scf"]

    subgraph Output ["Output File"]
        D["scf.in (Merged SCF Input)<br/>✓ Merged parameters & coordinates<br/>✓ Updated 'nat', 'ntyp' & calculation='scf'"]
    end

    A --> C
    B --> C
    C --> D

    style C fill:#238636,color:#fff,stroke:#2ea44f,stroke-width:2px;
    style D fill:#1f6feb,color:#fff,stroke:#58a6ff,stroke-width:2px;

For more hands-on examples, check out the examples/ directory.


Directory Structure

cellify/
├── pyproject.toml
├── README.md
├── examples/         # Runnable use cases for VASP and Quantum ESPRESSO
└── src/
    └── cellify/
        ├── __init__.py
        ├── cli.py            # CLI parser & execution flow
        ├── core.py           # Core structure modeling logic
        ├── viewer.py         # WebGL 3D structure viewer
        └── adapters/         # Formats and parameter preservation
            ├── __init__.py
            ├── base.py       # Base adapter interface
            ├── espresso.py   # Quantum ESPRESSO adapter
            └── standard.py   # Standard pymatgen/ASE adapter