Wf_dielectric_constant fails with KeyError: 'piezo_ionic_tensor' after relaxation

Some of my dielectric calculations complete their structure optimization but then are failing before even starting the DFPT calc with

Traceback (most recent call last):
  File "/home/jr769/.venv/py38/lib/python3.8/site-packages/fireworks/core/rocket.py", line 262, in run
    m_action = t.run_task(my_spec)
  File "/home/jr769/.venv/py38/lib/python3.8/site-packages/atomate/vasp/firetasks/parse_outputs.py", line 128, in run_task
    task_doc = drone.assimilate(calc_dir)
  File "/home/jr769/.venv/py38/lib/python3.8/site-packages/atomate/vasp/drones.py", line 218, in assimilate
    d = self.generate_doc(path, vasprun_files, outcar_files)
  File "/home/jr769/.venv/py38/lib/python3.8/site-packages/atomate/vasp/drones.py", line 417, in generate_doc
    d["output"][k] = d_calc_final["output"]["outcar"][k]
KeyError: 'piezo_ionic_tensor'

The relaxation OUTCAR being read was a two-stage, half-k-points in first run. I checked the file and it contains the piezo-electric tensor:


 PIEZOELECTRIC TENSOR (including local field effects)  for field in x, y, z        (e  Angst)
          XX          YY          ZZ          XY          YZ          ZX
  --------------------------------------------------------------------------------
  x     0.00000     0.00000     0.00000     0.00000     0.00000     0.00000
  y     0.00000     0.00000     0.00000     0.00000     0.00000     0.00000
  z     0.00000     0.00000     0.00000     0.00000     0.00000     0.00000

 PIEZOELECTRIC TENSOR (including local field effects)  for field in x, y, z        (C/m^2)
          XX          YY          ZZ          XY          YZ          ZX
  --------------------------------------------------------------------------------
  x     0.00000     0.00000     0.00000     0.00000     0.00000     0.00000
  y     0.00000     0.00000     0.00000     0.00000     0.00000     0.00000
  z     0.00000     0.00000     0.00000     0.00000     0.00000     0.00000

but indeed no piezo-ionic tensor. Can someone explain why this error occurs and how to work around it?

I think I may have accidentally applied the custodian powerup that applies the double_relaxation_run to both the relaxation and the DFPT calc:

custodian = {
    "half_kpts_first_relax": True,
    "job_type": "double_relaxation_run",
}
wf = use_custodian(
    wf, custodian_params=custodian
)

What should have been

wf = use_custodian(
    wf, custodian_params=custodian, fw_name_constraint="structure optimization"
)

Could that be the issue?

I have a hunch that this might be related to the DFPT step being run on a material VASP thinks is metallic (possibly in error), and this eventuality not being caught by the current parsing logic.

Turns out this was all my own fault. The error occurred on some calculations that had been timing out before where I tried to set IBRION = 0 (i.e. regular MD for the ions) to see if a non-perturbative calc would finish in time and at least give a result for the static dielectric constant.

We’re using a band gap model to search for the materials we run the dielectric workflow on. Some of them turn out to be metals despite our model predictions. Do you know if someone has already written a Custodian handler that could be used to abort the calculation in such cases? Or would our best bet be to adapt one of the similar handlers like IncorrectSmearingHandler or ScanMetalHandler?

Are you sure they’re metals? If you’re running VASP 6.1, a change resulted in how the Fermi level was calculated which can result in semiconductors mistakenly appearing to be metallic (if gap is judged purely based on the position of the Fermi level). I believe they’re changing this algorithm in a future release.

Otherwise, I agree, I think a new handler would be ideal.

We’re running VASP 6.2.0. Is there any way we can check what algorithm is being used and if the result is trustworthy? Do you have a reference regarding the planned change of band gap algorithm in a future version?

@mkhorton The band gap is calculated by the wf_dielectric_constant workflow in case that makes a difference. I’ve been wondering if the band gap from the DFPTFW firework is comparable with the one from the bandstructure_wf. Perhaps you know this?