SMTG-Bham / ShakeNBreak

Defect structure-searching employing chemically-guided bond distortions
https://shakenbreak.readthedocs.io
MIT License
82 stars 18 forks source link

Missing "Defects_dict" when importing Json from doped #50

Closed geli7676 closed 1 year ago

geli7676 commented 1 year ago

I am following the doped example workbook as well as the SNB examples page to generate a defect via doped, export to json then reimport using loadfn and inputing into Distortions. The traceback gives:

6 # Create an instance of Distortion class with the defect dictionary and the distortion parameters
----> 8 Dist = Distortions(
      9     defects=doped_defect_dict,  # the defects dictionary
     10     #oxidation_states=oxidation_states,  # explicitly specify oxidation states
     11 )

TypeError: Distortions.__init__() missing 1 required positional argument: 'defects_dict'

I am not sure if this is an issue with doped dumpfn where it's supposed to have a certain section title or if it's because SNB has since been updated as I assume this used to work when the workbook was created.

Any help would be greatly appreciated.

geli7676 commented 1 year ago

For reference, the lines before are:

from monty.serialization import dumpfn, loadfn
dumpfn(doped_defect_dict, "Si/Si_generated_defect_dict.json")

from shakenbreak import input, energy_lowering_distortions
from shakenbreak.input import Distortions

from monty.serialization import dumpfn, loadfn
doped_defect_dict = loadfn("Si/Si_generated_defect_dict.json")

Dist = Distortions(
    defects=doped_defect_dict,  # the defects dictionary
    #oxidation_states=oxidation_states,  # explicitly specify oxidation states
)
geli7676 commented 1 year ago

It turns out that the syntax has changed and hasn't been updated on the wiki: should now be defects_dict=doped_defect_dict Working now!