diff --git a/examples/CdTe/CdTe_example_defect_dict.json.gz b/examples/CdTe/CdTe_example_defect_dict.json.gz index 84a13c89..a3e69125 100644 Binary files a/examples/CdTe/CdTe_example_defect_dict.json.gz and b/examples/CdTe/CdTe_example_defect_dict.json.gz differ diff --git a/examples/CdTe/CdTe_example_thermo.json.gz b/examples/CdTe/CdTe_example_thermo.json.gz index 0ef4f7a1..648ebd0b 100644 Binary files a/examples/CdTe/CdTe_example_thermo.json.gz and b/examples/CdTe/CdTe_example_thermo.json.gz differ diff --git a/examples/Sb2Si2Te6/Sb2Si2Te6_example_defect_dict.json.gz b/examples/Sb2Si2Te6/Sb2Si2Te6_example_defect_dict.json.gz index 96f1a5fa..e7cd938c 100644 Binary files a/examples/Sb2Si2Te6/Sb2Si2Te6_example_defect_dict.json.gz and b/examples/Sb2Si2Te6/Sb2Si2Te6_example_defect_dict.json.gz differ diff --git a/examples/Sb2Si2Te6/Sb2Si2Te6_example_thermo.json.gz b/examples/Sb2Si2Te6/Sb2Si2Te6_example_thermo.json.gz index 41fd9e05..2067bc8a 100644 Binary files a/examples/Sb2Si2Te6/Sb2Si2Te6_example_thermo.json.gz and b/examples/Sb2Si2Te6/Sb2Si2Te6_example_thermo.json.gz differ diff --git a/examples/YTOS/YTOS_example_defect_dict.json.gz b/examples/YTOS/YTOS_example_defect_dict.json.gz index 9fdfd511..88a956ec 100644 Binary files a/examples/YTOS/YTOS_example_defect_dict.json.gz and b/examples/YTOS/YTOS_example_defect_dict.json.gz differ diff --git a/examples/YTOS/YTOS_example_thermo.json.gz b/examples/YTOS/YTOS_example_thermo.json.gz index 3235428b..8284ac00 100644 Binary files a/examples/YTOS/YTOS_example_thermo.json.gz and b/examples/YTOS/YTOS_example_thermo.json.gz differ diff --git a/tests/data/Sb2Se3/Sb2Se3_O_example_thermo.json.gz b/tests/data/Sb2Se3/Sb2Se3_O_example_thermo.json.gz index 4ca87a2a..3db8e858 100644 Binary files a/tests/data/Sb2Se3/Sb2Se3_O_example_thermo.json.gz and b/tests/data/Sb2Se3/Sb2Se3_O_example_thermo.json.gz differ diff --git a/tests/data/Sb2Se3/defect/Sb2Se3_O_example_defect_dict.json.gz b/tests/data/Sb2Se3/defect/Sb2Se3_O_example_defect_dict.json.gz index d88e33c4..b6f17f85 100644 Binary files a/tests/data/Sb2Se3/defect/Sb2Se3_O_example_defect_dict.json.gz and b/tests/data/Sb2Se3/defect/Sb2Se3_O_example_defect_dict.json.gz differ diff --git a/tests/data/V2O5/V2O5_example_defect_dict.json.gz b/tests/data/V2O5/V2O5_example_defect_dict.json.gz index 4e943965..1bdff988 100644 Binary files a/tests/data/V2O5/V2O5_example_defect_dict.json.gz and b/tests/data/V2O5/V2O5_example_defect_dict.json.gz differ diff --git a/tests/data/V2O5/V2O5_example_thermo.json.gz b/tests/data/V2O5/V2O5_example_thermo.json.gz index aa3e63da..b359f073 100644 Binary files a/tests/data/V2O5/V2O5_example_thermo.json.gz and b/tests/data/V2O5/V2O5_example_thermo.json.gz differ diff --git a/tests/data/ZnS/ZnS_thermo.json.gz b/tests/data/ZnS/ZnS_thermo.json.gz index 1bf2273c..12a9f9c1 100644 Binary files a/tests/data/ZnS/ZnS_thermo.json.gz and b/tests/data/ZnS/ZnS_thermo.json.gz differ diff --git a/tests/test_analysis.py b/tests/test_analysis.py index 2826a9ed..c181a898 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -157,7 +157,8 @@ def _check_parsed_CdTe_defect_energies(self, dp): 7.661, atol=3e-3, ) # uncorrected energy - assert np.isclose(dp.defect_dict["v_Cd_-2"].get_ediff(), 8.398, atol=1e-3) + # slightly higher atol here, due to LOCPOT sub-sampling for file compression on repo: + assert np.isclose(dp.defect_dict["v_Cd_-2"].get_ediff(), 8.398, atol=2e-3) assert np.isclose(dp.defect_dict["Int_Te_3_2"].get_ediff(), -6.2009, atol=1e-3) def _check_default_CdTe_DefectsParser_outputs( @@ -346,7 +347,7 @@ def test_DefectsParser_CdTe(self): @custom_mpl_image_compare(filename="CdTe_example_defects_plot.png") def test_DefectsParser_CdTe_without_multiprocessing(self): shutil.move( # avoid overwriting - os.path.join(self.CdTe_EXAMPLE_DIR, "CdTe_example_thermo.json.gz.gz"), + os.path.join(self.CdTe_EXAMPLE_DIR, "CdTe_example_thermo.json.gz"), os.path.join(self.CdTe_EXAMPLE_DIR, "orig_CdTe_example_thermo.json.gz"), ) # test same behaviour without multiprocessing: @@ -615,8 +616,10 @@ def test_DefectsParser_corrections_errors_warning(self): "Estimated error in the Kumagai (eFNV) ", "charge correction for certain defects is greater than the `error_tolerance` (= " "1.00e-03 eV):", - "v_Cd_-2: 1.13e-02 eV", - "v_Cd_-1: 7.91e-03 eV", + "v_Cd_-2: 1.", + "e-02 eV", + "v_Cd_-1:", + "e-03 eV", "Int_Te_3_1: 3.10e-03 eV", "Te_Cd_+1: 2.02e-03 eV", "Int_Te_3_Unperturbed_1: 4.91e-03 eV", @@ -1340,8 +1343,6 @@ def tearDown(self): f"{self.CdTe_EXAMPLE_DIR}/v_Cd_-2/vasp_ncl/LOCPOT.gz", ) - if_present_rm(f"{self.CdTe_EXAMPLE_DIR}/Int_Te_3_2/vasp_ncl/LOCPOT.gz") - def test_auto_charge_determination(self): """ Test that the defect charge is correctly auto-determined. @@ -1363,8 +1364,8 @@ def test_auto_charge_determination(self): "with specified charge_state, but beware!" in str(w[-1].message) ) assert np.isclose( - parsed_v_cd_m1.corrections["freysoldt_charge_correction"], 0.26066457692529815 - ) + parsed_v_cd_m1.corrections["freysoldt_charge_correction"], 0.261, atol=1e-3 + ) # slightly higher atol, due to LOCPOT sub-sampling for file compression on repo # test YTOS, has trickier POTCAR symbols with Y_sv, Ti, S, O ytos_F_O_1 = defect_entry_from_paths( # with corrections this time @@ -1578,8 +1579,9 @@ def blockwise_average_ND(a, factors): atol=3e-3, ) # uncorrected energy assert np.isclose( - parsed_int_Te_2_fake_aniso.get_ediff(), -4.7620, atol=1e-3 - ) # -4.734 with old voronoi frac coords + parsed_int_Te_2_fake_aniso.get_ediff(), -4.7620, atol=2e-2 + ) # -4.734 with old voronoi frac coords, expanded atol now to account for LOCPOT sub-sampling + # compression if_present_rm(f"{self.CdTe_EXAMPLE_DIR}/Int_Te_3_2/vasp_ncl/LOCPOT.gz") @@ -1786,7 +1788,7 @@ def test_dielectric_initialisation(self): assert np.isclose( parsed_v_cd_m2.corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) # test float @@ -1800,7 +1802,7 @@ def test_dielectric_initialisation(self): assert np.isclose( new_parsed_v_cd_m2.corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) # test int @@ -1829,7 +1831,7 @@ def test_dielectric_initialisation(self): assert np.isclose( new_parsed_v_cd_m2.corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) # test 3x1 list @@ -1844,7 +1846,7 @@ def test_dielectric_initialisation(self): assert np.isclose( new_parsed_v_cd_m2.corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) # test 3x3 array @@ -1858,7 +1860,7 @@ def test_dielectric_initialisation(self): assert np.isclose( new_parsed_v_cd_m2.corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) # test 3x3 list @@ -1873,7 +1875,7 @@ def test_dielectric_initialisation(self): assert np.isclose( new_parsed_v_cd_m2.corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) def test_vacancy_parsing_and_freysoldt(self): @@ -1918,12 +1920,12 @@ def test_vacancy_parsing_and_freysoldt(self): }, ), ]: - assert np.isclose(parsed_vac_Cd_dict[name].get_ediff(), energy, atol=1e-3) + assert np.isclose(parsed_vac_Cd_dict[name].get_ediff(), energy, atol=2e-3) for correction_name, correction_energy in correction_dict.items(): assert np.isclose( parsed_vac_Cd_dict[name].corrections[correction_name], correction_energy, - atol=1e-3, + atol=2e-3, # slightly higher atol due to LOCPOT sub-sampling for file compression ) # assert auto-determined vacancy site is correct @@ -2209,16 +2211,20 @@ def test_extrinsic_substitution_parsing_and_freysoldt_and_kumagai(self): parse_projected_eigen=False, ) # check no correction error warning with default tolerance: print([str(warn.message) for warn in w]) + assert any( # break up warning message to allow slightly difference numbers after 3.XXe-04 eV: + f"Estimated error in the Freysoldt (FNV) charge correction for defect {F_O_1_ent.name} is 3" + in str(warning.message) + for warning in w + ) assert any( - f"Estimated error in the Freysoldt (FNV) charge correction for defect {F_O_1_ent.name} is " - f"3.54e-04 eV (i.e. which is greater than the `error_tolerance`: 1.00e-05 eV). You may want " - f"to check the accuracy of the correction by plotting the site potential differences (using " - f"`defect_entry.get_freysoldt_correction()` with `plot=True`). Large errors are often due " - f"to unstable or shallow defect charge states (which can't be accurately modelled with " - f"the supercell approach; see " - f"https://doped.readthedocs.io/en/latest/Tips.html#perturbed-host-states). " - f"If this error is not acceptable, you may need to use a larger supercell for more " - f"accurate energies." in str(warning.message) + "e-04 eV (i.e. which is greater than the `error_tolerance`: 1.00e-05 eV). You may want " + "to check the accuracy of the correction by plotting the site potential differences (using " + "`defect_entry.get_freysoldt_correction()` with `plot=True`). Large errors are often due " + "to unstable or shallow defect charge states (which can't be accurately modelled with " + "the supercell approach; see " + "https://doped.readthedocs.io/en/latest/Tips.html#perturbed-host-states). " + "If this error is not acceptable, you may need to use a larger supercell for more " + "accurate energies." in str(warning.message) for warning in w ) @@ -2483,6 +2489,9 @@ def tearDown(self): f"{self.Cu2SiSe3_EXAMPLE_DIR}/{dir}/vasp_std/vasprun.xml.gz", ) + if_present_rm(os.path.join(self.Cu2SiSe3_EXAMPLE_DIR, "Cu2SiSe3_defect_dict.json.gz")) + if_present_rm(os.path.join(self.Cu2SiSe3_EXAMPLE_DIR, "bulk/vasp_std/voronoi_nodes.json")) + def test_defect_name_from_structures(self): # by proxy also tests defect_from_structures for defect_gen_name in [ @@ -3181,6 +3190,7 @@ def _compare_band_edge_states_dicts(d1, d2, orb_diff_tol: float = 0.1): reloaded_defect_dict = loadfn("test.json") bes, fig = reloaded_defect_dict["v_Cu_0"].get_eigenvalue_analysis() _compare_band_edge_states_dicts(bes, v_Cu_0_bes_path, orb_diff_tol=0.001) + os.remove("test.json") return fig diff --git a/tests/test_thermodynamics.py b/tests/test_thermodynamics.py index 989e56bc..f578a1fd 100644 --- a/tests/test_thermodynamics.py +++ b/tests/test_thermodynamics.py @@ -555,7 +555,7 @@ def test_transition_levels_CdTe(self): Test outputs of transition level functions for CdTe. """ assert self.CdTe_defect_thermo.transition_level_map == { - "v_Cd": {0.46988348089141413: [0, -2]}, + "v_Cd": {0.47047144459596113: [0, -2]}, "Te_Cd": {}, "Int_Te_3": {0.03497090517885537: [2, 1]}, } @@ -563,8 +563,8 @@ def test_transition_levels_CdTe(self): tl_info = ["Defect: v_Cd", "Defect: Te_Cd"] tl_info_not_all = ["Transition level ε(0/-2) at 0.470 eV above the VBM"] tl_info_all = [ - "Transition level ε(-1*/-2) at 0.397 eV above the VBM", - "Transition level ε(0/-1*) at 0.543 eV above the VBM", + "Transition level ε(-1*/-2) at 0.399 eV above the VBM", + "Transition level ε(0/-1*) at 0.542 eV above the VBM", "*", ] @@ -707,8 +707,8 @@ def test_get_transition_levels_CdTe(self): tl_df = self.CdTe_defect_thermo.get_transition_levels(all=True) assert tl_df.shape == (5, 5) - assert list(tl_df.iloc[0]) == ["v_Cd", "ε(-1*/-2)", 0.397, True, 1] - assert list(tl_df.iloc[1]) == ["v_Cd", "ε(0/-1*)", 0.543, True, 1] + assert list(tl_df.iloc[0]) == ["v_Cd", "ε(-1*/-2)", 0.399, True, 1] + assert list(tl_df.iloc[1]) == ["v_Cd", "ε(0/-1*)", 0.542, True, 1] assert list(tl_df.iloc[2]) == ["Te_Cd", "None", np.inf, False, 0] assert list(tl_df.iloc[3]) == ["Int_Te_3", "ε(+2/+1)", 0.035, True, 0] assert list(tl_df.iloc[4]) == ["Int_Te_3", "ε(+2/+1*)", 0.09, True, 1] @@ -943,8 +943,8 @@ def test_formation_energies_CdTe(self): -1.499, "N/A", 0, - 0.738, - 3.607, + 0.739, + 3.608, f"{self.CdTe_EXAMPLE_DIR}/v_Cd_-2/vasp_ncl", ], [ @@ -1279,8 +1279,8 @@ def _check_formation_energy_methods(form_en_df_row, thermo_obj, fermi_level): -1.499, -1.016, -1.251, - 0.738, - 1.34, + 0.739, + 1.341, f"{self.CdTe_EXAMPLE_DIR}/v_Cd_-2/vasp_ncl", ], [ @@ -1394,8 +1394,8 @@ def _check_formation_energy_methods(form_en_df_row, thermo_obj, fermi_level): -6, -12, -1, - 0.738, - -13.895, + 0.739, + -13.893, ] assert list(manual_form_en_df.iloc[4])[:-1] == [ "Int_Te_3",