Skip to content

Commit

Permalink
Add sampling region shading to eFNV plots
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Nov 1, 2023
1 parent d6d05c4 commit dc94d51
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
5 changes: 3 additions & 2 deletions doped/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,9 @@ def get_stdrd_metadata(self):
self.defect_vr = get_vasprun(defect_vr_path)

run_metadata = { # TODO: Add check that incars, kpoints and potcars are compatible here
"defect_incar": self.defect_vr.incar,
"bulk_incar": self.bulk_vr.incar,
# incars need to be as dict without module keys otherwise not JSONable:
"defect_incar": {k: v for k, v in self.defect_vr.incar.as_dict().items() if "@" not in k},
"bulk_incar": {k: v for k, v in self.bulk_vr.incar.as_dict().items() if "@" not in k},
"defect_kpoints": self.defect_vr.kpoints,
"bulk_kpoints": self.bulk_vr.kpoints,
"defect_potcar_symbols": self.defect_vr.potcar_spec,
Expand Down
17 changes: 15 additions & 2 deletions doped/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,29 @@ def get_kumagai_correction(
fig = spp.plt.gcf()
ax = fig.gca()

# reformat plot slightly
# reformat plot slightly:
x_lims = ax.get_xlim()
y_lims = ax.get_ylim()
# shade in sampling region:
spp.plt.fill_between(
[spp.defect_region_radius, x_lims[1]],
*y_lims,
color="purple",
alpha=0.15,
label="Sampling Region",
)
spp.plt.ylim(*y_lims) # reset y-lims after fill_between

# update legend:
handles, labels = ax.get_legend_handles_labels()
labels = [
label.replace("point charge", "Point Charge (PC)").replace(
"potential difference", r"$\Delta V$"
)
for label in labels
]
# add entry for dashed red line

# add entry for dashed red line:
handles += [Line2D([0], [0], **spp._mpl_defaults.hline)]
labels += [
rf"Avg. $\Delta V$ = {spp.ave_pot_diff:.3f} V",
Expand Down
Binary file modified tests/data/remote_baseline_plots/F_O_+1_eFNV_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/remote_baseline_plots/F_O_+1_eFNV_plot_custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/remote_baseline_plots/Te_i_+2_eFNV_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/test_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ def test_plot_kumagai_custom(self):
"""
mpl.pyplot.clf()
_corr, fig = get_kumagai_correction(self.F_O_1_entry, dielectric=[40.7, 40.7, 25.2], plot=True)
# add shading to left part of plot (10 Angstrom on):
# add shading to plot:
ax = fig.gca()
ax.axvspan(10, 100, alpha=0.2, color="purple")
ax.axvspan(5, 100, alpha=0.2, color="yellow")

return fig

Expand Down

0 comments on commit dc94d51

Please sign in to comment.