Skip to content

Tutorial YY

Lee Burton edited this page Aug 5, 2025 · 1 revision

๐Ÿงช Local Atomate2 + Jobflow + Jupyter Setup (MacBook, Micromamba)

This guide walks you through creating a working Jupyter notebook environment for generating and visualizing VASP workflows using Atomate2 and Jobflow.


1. โœ… Create the Conda Environment

micromamba create -n atomate2_local -c conda-forge python=3.11
micromamba activate atomate2_local

2. ๐Ÿ“ฆ Install Required Packages

pip install 'git+ssh://git@github.com/materialsproject/atomate2.git#egg=atomate2[jobs]'
pip install pymatgen monty custodian jobflow ase notebook ipywidgets nglview tqdm

3. ๐Ÿ—‚๏ธ Organize POTCAR Files

Restructure your POTCARs to this format:

VASP_PSP_DIR/
โ””โ”€โ”€ POT_GGA_PAW_PBE_54/
    โ”œโ”€โ”€ Si/POTCAR
    โ”œโ”€โ”€ O/POTCAR
    โ””โ”€โ”€ ...

You can do this with:

import os, shutil

src_dir = "/path/to/flat_potcars"
for f in os.listdir(src_dir):
    if f.startswith("POTCAR_"):
        el = f.replace("POTCAR_", "")
        os.makedirs(os.path.join(src_dir, el), exist_ok=True)
        shutil.copy(os.path.join(src_dir, f), os.path.join(src_dir, el, "POTCAR"))

Then rename the folder to match expected functional:

mv POT_GGA_PAW_PBE POT_GGA_PAW_PBE_54

4. ๐Ÿงช Build and Run a Workflow in a Notebook

a. Set environment variables

import os
from pymatgen.core import SETTINGS

potcar_path = "/Users/yourname/path/to/VASP_PSP_DIR"
os.environ["PMG_VASP_PSP_DIR"] = potcar_path
os.environ["VASP_PSP_DIR"] = potcar_path
SETTINGS["PMG_VASP_PSP_DIR"] = potcar_path

b. Generate inputs

from pymatgen.core import Structure, Lattice
from atomate2.vasp.jobs.core import RelaxMaker
from atomate2.vasp.sets.base import VaspInputGenerator
from jobflow import run_locally

structure = Structure.from_spacegroup("Fd-3m", Lattice.cubic(5.4307), ["Si"], [[0, 0, 0]])

input_set_generator = VaspInputGenerator(
    user_incar_settings={"ISIF": 3, "IBRION": 2, "NSW": 99, "ENCUT": 520}
)

job = RelaxMaker(input_set_generator=input_set_generator).make(structure)
responses = run_locally([job], create_folders=True, ensure_success=False)

๐Ÿ’ก This creates input files in job-0/, but does not run VASP (since itโ€™s not installed).


5. ๐ŸŽฅ Visualize Structures in Jupyter

a. Install ase if not already:

pip install ase

b. Display the structure

import nglview as nv
nv.show_pymatgen(structure)

โœ… Done!

You now have:

  • Atomate2 + Jobflow working locally
  • VASP input generation
  • Structure visualization
  • Reproducible environment for students

Clone this wiki locally