how can I resolve this key error in this section of program

191 Views Asked by At

I have a problem with this section of my code that it returns to the diffusion analysts of materials

from pymatgen.analysis.diffusion.analyzer import (
    DiffusionAnalyzer,
    fit_arrhenius,
    get_conversion_factor,
)
import json
from pymatgen.analysis.diffusion.aimd.van_hove import VanHoveAnalysis

%matplotlib inline

data = json.load(open(".../py.pro/mp-1138_LiF.json", "r"))

new_obj = DiffusionAnalyzer.from_dict(data)

vhfunc = VanHoveAnalysis(diffusion_analyzer=new_obj, avg_nsteps=5, ngrid=101, rmax=10.0, 
                         step_skip=5, sigma=0.1, species = ["Li", "F"])

vhfunc.get_3d_plot(mode="self")
vhfunc.get_3d_plot(mode="distinct")

and the key error says this

KeyError                                  Traceback (most recent call last)
<ipython-input-4-17584fdb7b1f> in <module>
      3 data = json.load(open("J:/py.pro/mp-1138_LiF.json", "r"))
      4 
----> 5 new_obj = DiffusionAnalyzer.from_dict(data)
      6 
      7 vhfunc = VanHoveAnalysis(diffusion_analyzer=new_obj, avg_nsteps=5, ngrid=101, rmax=10.0, 

~\Anaconda3\lib\site-packages\pymatgen\analysis\diffusion\analyzer.py in from_dict(cls, d)
    766         return cls(
    767             structure,
--> 768             np.array(d["displacements"]),
    769             specie=d["specie"],
    770             temperature=d["temperature"],

KeyError: 'displacements'

how it resolves? does it return to the program?

0

There are 0 best solutions below