materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.52k stars 867 forks source link

CP2K input set creation (error with basis set/potential finding for given structure) #4186

Open msiron-entalpic opened 2 hours ago

msiron-entalpic commented 2 hours ago

Python version

3.12

Pymatgen version

v2024.9.17.1

Operating system version

MacOSX

Current behavior

Git clone cp2k v2022 for the data directory Performed pmg config --cp2k /path/to/cp2k/data /path/to/pmg/cp2kdata

Doing any compounds mixed with In, O as species gives this error (also with other composition) while doing the elements alone do not give rise to any errors.

I attached the process basis set/potentials file from the pmg config --cp2k for In, O as example.

Expected Behavior

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[28], line 1
----> 1 RelaxSet(structure=Structure([[4,0,0],[0,4,0],[0,0,4]],['In','O',],[[0,0,0,],[0,0,2],], coords_are_cartesian=True))

File [~/dev/pymatgen/src/pymatgen/io/cp2k/sets.py:1423](http://localhost:8889/lab/workspaces/auto-U/tree/dev/scratch/~/dev/pymatgen/src/pymatgen/io/cp2k/sets.py#line=1422), in RelaxSet.__init__(self, **kwargs)
   1422 def __init__(self, **kwargs) -> None:
-> 1423     super().__init__(run_type="GEO_OPT", **kwargs)
   1424     self.activate_motion()

File [~/dev/pymatgen/src/pymatgen/io/cp2k/sets.py:296](http://localhost:8889/lab/workspaces/auto-U/tree/dev/scratch/~/dev/pymatgen/src/pymatgen/io/cp2k/sets.py#line=295), in DftSet.__init__(self, structure, project_name, basis_and_potential, element_defaults, xc_functionals, multiplicity, ot, energy_gap, qs_method, eps_default, eps_scf, max_scf, minimizer, preconditioner, algorithm, linesearch, rotation, occupation_preconditioner, cutoff, rel_cutoff, ngrids, progression_factor, override_default_params, wfn_restart_file_name, kpoints, smearing, cell, **kwargs)
    293     scf["MAX_DIIS"] = Keyword("MAX_DIIS", 15)
    295 # Get basis, potential, and XC info
--> 296 self.basis_and_potential = DftSet.get_basis_and_potential(self.structure, self.basis_and_potential)
    297 self.basis_set_file_names = self.basis_and_potential.get("basis_filenames", ())
    298 self.potential_file_name = self.basis_and_potential.get("potential_filename")

File [~/dev/pymatgen/src/pymatgen/io/cp2k/sets.py:574](http://localhost:8889/lab/workspaces/auto-U/tree/dev/scratch/~/dev/pymatgen/src/pymatgen/io/cp2k/sets.py#line=573), in DftSet.get_basis_and_potential(structure, basis_and_potential, cp2k_data_dir)
    572 pfn2 = getattr(potential, "filename", None)
    573 if pfn1 and pfn2 and pfn1 != pfn2:
--> 574     raise ValueError(
    575         "Provided potentials have more than one corresponding file."
    576         "CP2K does not support multiple potential filenames"
    577     )
    578 data["potential_filename"] = pfn2
    580 data[el] = {"basis": basis, "aux_basis": aux_basis, "potential": potential}

ValueError: Provided potentials have more than one corresponding file.CP2K does not support multiple potential filenames

Minimal example

from pymatgen.core import Structure
from pymatgen.io.cp2k.sets import RelaxSet

RelaxSet(structure=Structure([[4,0,0],[0,4,0],[0,0,4]],['In',],[[0,0,0,]],], coords_are_cartesian=True)) # works well

RelaxSet(structure=Structure([[4,0,0],[0,4,0],[0,0,4]],['In','O',],[[0,0,0,],[0,0,2],], coords_are_cartesian=True)) # does not work

Relevant files to reproduce this bug

Archive.zip

msiron-entalpic commented 2 hours ago

I should add that I am using an older Pymatgen and older CP2K but this is the exact same error with newest Pymatgen and newest CP2K data directory.