Open
Description
When running the following code:
from mp_api.client import MPRester
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from atomate2.vasp.flows.mp import MPGGADoubleRelaxMaker
from atomate2.vasp.powerups import (
update_user_incar_settings,
update_user_potcar_functional,
)
from jobflow import run_locally
# Set POTCAR functional
user_potcar_functional = "PBE_64"
# Get structure from MP
material_id = "mp-126"
with MPRester() as mpr:
# First get the task id from the materials doc
materials = mpr.materials.search(material_ids=[material_id], fields=["task_ids"])
task_id = materials[0].task_ids[0]
# Now get the calculation that includes MAGMOM settings
tasks = mpr.materials.tasks.search(task_ids=[task_id],
fields=["input.incar", "calcs_reversed"])
# Get the INCAR settings from the calculation
incar_settings = tasks[0].calcs_reversed[0].input.incar
# Get the structure and convert to conventional cell
structure = mpr.materials.get_structure_by_material_id(material_id)
structure = SpacegroupAnalyzer(structure).get_conventional_standard_structure()
# Convert MAGMOM list to dictionary format
if "MAGMOM" in incar_settings:
print("Original MAGMOM settings:", incar_settings["MAGMOM"])
print("Number of sites in structure:", len(structure))
# Get unique species list
species_list = [site.species_string for site in structure]
unique_species = sorted(set(species_list))
print("Unique species in structure:", unique_species)
# Set all species to the first MAGMOM value from the original calculation
magmom_dict = {specie: incar_settings["MAGMOM"][0] for specie in unique_species}
incar_settings["MAGMOM"] = magmom_dict
print("MAGMOM dictionary:", magmom_dict)
# Create a simple flow with just the relax
flow = MPGGADoubleRelaxMaker().make(structure)
# Update POTCAR settings
flow = update_user_potcar_functional(flow, user_potcar_functional)
# Update INCAR settings
flow = update_user_incar_settings(flow, incar_settings)
# Run the flow
#responses = run_locally(flow, create_folders=True, ensure_success=True)
The following info will be shown:
In [29]: flow = update_user_potcar_functional(flow, user_potcar_functional)
/home/werner/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/pymatgen/io/vasp/sets.py:288: BadInputSetWarning: Overriding the POTCAR functional is generally not recommended as it significantly affects the results of calculations and compatibility with other calculations done with the same input set. Note that some POTCAR symbols specified in the configuration file may not be available in the selected functional.
warnings.warn(
In [30]: flow = update_user_incar_settings(flow, incar_settings)
/home/werner/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/pymatgen/io/vasp/sets.py:288: BadInputSetWarning: Overriding the POTCAR functional is generally not recommended as it significantly affects the results of calculations and compatibility with other calculations done with the same input set. Note that some POTCAR symbols specified in the configuration file may not be available in the selected functional.
warnings.warn(
It seems that this warning should be triggered by update_user_potcar_functional instead of update_user_incar_settings.
See materialsproject/pymatgen#4179 for the related discussion.
Regards,
Zhao
Metadata
Metadata
Assignees
Labels
No labels