Attempt to use 'pymatgen.analysis.defects.core', 'Defect'

Hi, as mentioned in the subject, I am trying to use ‘pymatgen.analysis.defects.core’, but somehow it keeps giving me an error.

In my jupyternotebook, I used ‘pymatgen.core.sites’ as well, and it seems like there wasn’t an error at this part.

I’m assuming that it would be a problem with giving the parameters in a wrong form, but could find where I made the mistake.

from pymatgen.core import Structure
CsCu2I3 = Structure.from_file("CONTCAR_perfect")
CsCu2I3_V_Cs1_1m1 = Structure.from_file("CONTCAR_V_Cs1_1m1")

from pymatgen.core.sites import Site as st
import numpy as np
coords = [0.3310489327811865, 0.6689510672199646, 0.8750000000000000]
site = st("Cs", coords)

from pymatgen.analysis.defects.core import Defect as df
defect = df(structure = CsCu2I3, defect_site = site, charge = -1.0)

below is the captured screen of my jupyer notebook.

I don’t know the cause of this problem,
but i can recommend a helpful website for using the pymatgen.analysis.defect module.

Good luck!

Hi @bluepicture61,

Sorry for the late response – hope you were able to identify the cause of this problem.

For anyone who encounters this same issue later, the answer is that the pymatgen.analysis.defects.core.Defect class is an abstract class that the other defect classes inherit from, and thus cannot be used directly.

Instead, try importing a specific type of defect (i.e., vacancy, substitution, …). For a vacancy, this would require importing:

from pymatgen.analysis.defects.core import Vacancy
1 Like