MPStaticSet ends up with `self.structure = None`

Has something significant changed with pymatgen recently? I’m trying to set up MP-compatible VASP input files, and I have scripts that do things along the lines of (starting from an ase.atoms.Atoms object atoms)

    s = IStructure(atoms.cell, atoms.numbers, atoms.positions, coords_are_cartesian=True)
    static = MPRelaxSet(structure=s, user_incar_settings={'LWAVE': False,
                                                          'LCHARG': False,
                                                          'LAECHG': False,
                                                          'LVHAR': False,
                                                          'POTCAR_FUNCTIONAL': 'PBE_54',
                                                          'POTCAR': {'Yb': 'Yb_3', 'W': 'W_sv'},
                                                          'ALGO': 'normal'})
    static.write_input(f"run_mp_{atoms_ind}")

and they used to run fine, but now I get

Traceback (most recent call last):
  File "/home/cluster/bernstei/src/work/MACE/foundations/OMOL_gpu_benchmark/./setup_tests", line 27, in <module>
    static.write_input(f"run_mp_{atoms_ind}")
  File "/home/cluster/bernstei/pymatgen/lib/python3.11/site-packages/pymatgen/io/vasp/sets.py", line 366, in write_input
    vasp_input = self.get_input_set(potcar_spec=potcar_spec)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cluster/bernstei/pymatgen/lib/python3.11/site-packages/pymatgen/io/vasp/sets.py", line 475, in get_input_set
    raise ValueError("Either structure or prev_dir must be set")
ValueError: Either structure or prev_dir must be set

This is with pymatgen installed from pypi, version 2025.6.14,

Any idea what might be going on?

Pymatgen expects a Structure object rather than the immutable version, IStructure, when making a VASP input set. Also, there’s no need to manually instance the Structure class, there’s an in-built conversion from pymatgen:

from ase.atoms import Atoms
from pymatgen.io.ase import AseAtomsAdaptor
from pymatgen.io.vasp.sets import MPStaticSet
from tempfile import TemporaryDirectory
from pathlib import Path

atoms = Atoms(symbols=np.array(["Cs","Cl"]),scaled_positions = np.array([[0.]*3,[0.5]*3]), cell =3.6*np.array([[0.5 if i == j else 0.001 for j in range(3)] for i in range(3)]),pbc=True)
structure = AseAtomsAdaptor().get_structure(atoms)
vis = MPStaticSet(
    structure=structure,
    user_incar_settings={
        'LWAVE': False,
        'LCHARG': False,
        'LAECHG': False,
        'LVHAR': False,
        'POTCAR_FUNCTIONAL': 'PBE_54',
        'POTCAR': {'Yb': 'Yb_3', 'W': 'W_sv'},
        'ALGO': 'normal'
    }
)

with TemporaryDirectory() as temp_dir:
    vis.write_input(temp_dir,potcar_spec=True)
    print([x.name for x in Path(temp_dir).glob("*")])
>>> ['INCAR', 'POTCAR.spec', 'POSCAR', 'KPOINTS']

Thanks. It’s working now, with AseAtomsAdaptor.