Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error in LargeSigmaHandler parsing OUTCAR with electric field #360

Open
1 of 3 tasks
yanghan234 opened this issue Dec 24, 2024 · 0 comments
Open
1 of 3 tasks
Labels

Comments

@yanghan234
Copy link

Code snippet

import os
import argparse

from atomate2.vasp.flows.phonons import PhononMaker
from atomate2.vasp.jobs.core import DielectricMaker, StaticMaker, TightRelaxMaker, RelaxMaker
from atomate2.vasp.jobs.mp import MPGGARelaxMaker, MPGGAStaticMaker
from atomate2.vasp.powerups import update_user_kpoints_settings, update_user_incar_settings
from atomate2.vasp.sets.mp import MPGGAStaticSetGenerator
from atomate2.common.jobs.phonons import get_supercell_size
from jobflow import run_locally, JobStore, Flow
from maggma.stores.mongolike import MemoryStore
from monty.serialization import dumpfn
from pymatgen.core import Structure
from pymatgen.io.vasp.sets import MPStaticSet
from mp_api.client import MPRester


def run_polarization_finite_field(structure, store):
    os.environ["OMP_NUM_THREADS"] = "1"

    job = StaticMaker(
        input_set_generator=MPStaticSet(auto_ispin=True,),
    ).make(structure,)
    job = update_user_incar_settings(
        job,
        {
            "LCALCEPS": True, 
            "LCALCPOL": True, 
            "EFIELD_PEAD": [ 0.01, 0.01, 0.01],
            "LPEAD": True,
            "ISMEAR": 0,
            "EDIFF": 1e-6,
        }
    )

    workflow = Flow([job])

    run_locally(workflow, store=store, create_folders=True)
    outputs = list(store.query(load=True))
    save_folder = os.path.abspath("./")
    dumpfn(outputs, os.path.join(save_folder, "outputs.json"))


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Run calculation with finite field")
    parser.add_argument("--mp_id", type=str, help="Materials Project ID")
    args = parser.parse_args()

 
    mpr = MPRester(os.environ["MP_API_KEY"])
    structure = mpr.get_structure_by_material_id(args.mp_id)

    store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()})
    run_polarization_finite_field(structure, store)

What happened?

This script above runs static calculations under electrical field. However, I got the error message below.

It turns out that the LargeSigmaHandler handler did not properly deal with the calculations under finite field. In such senario, the calculations will be done for electrical field along 3 directions, and the ionic step index will always start from 1 for each direction. However, LargeSigmaHandler will treat the OUTCAR as if these is only one ionic step.

Version

2024.10.16

Which OS?

  • MacOS
  • Windows
  • Linux

Log output

Retrieving MaterialsDoc documents: 100%|█████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 18236.10it/s]
2024-12-24 03:39:00,329 INFO Started executing jobs locally
2024-12-24 03:39:00,333 INFO Starting job - static (ccbc7678-b61b-4302-b8b4-d0a339b80ada)
  with zopen(filename, mode="rt", errors="replace") as file:
2024-12-24 03:44:04,035 INFO static failed with exception:
Traceback (most recent call last):
  File "/opt/miniforge/lib/python3.10/site-packages/jobflow/managers/local.py", line 114, in _run_job
    response = job.run(store=store)
  File "/opt/miniforge/lib/python3.10/site-packages/jobflow/core/job.py", line 600, in run
    response = function(*self.function_args, **self.function_kwargs)
  File "/opt/miniforge/lib/python3.10/site-packages/atomate2/vasp/jobs/base.py", line 228, in make
    run_vasp(**self.run_vasp_kwargs)
  File "/opt/miniforge/lib/python3.10/site-packages/atomate2/vasp/run.py", line 161, in run_vasp
    custodian_manager.run()
  File "/opt/miniforge/lib/python3.10/site-packages/custodian/custodian.py", line 385, in run
    self._run_job(job_n, job)
  File "/opt/miniforge/lib/python3.10/site-packages/custodian/custodian.py", line 488, in _run_job
    has_error = self._do_check(self.monitors, terminate)
  File "/opt/miniforge/lib/python3.10/site-packages/custodian/custodian.py", line 653, in _do_check
    if handler.check(directory=self.directory):
  File "/opt/miniforge/lib/python3.10/site-packages/custodian/vasp/handlers.py", line 1408, in check
    entropies_per_atom[ie_step - 1] = smearing_entropy[ie_step_idx]
IndexError: list index out of range

2024-12-24 03:44:04,035 INFO Finished executing jobs locally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant