defermi is a python library for the analysis and visualization of point defects. Simple and intuitive for new users and non-experts, flexible and customizable for power users. A user interface is available at this link: https://defermi.streamlit.app/ (no installation required). For more details check out the complete documentation.
If you are using conda or mamba, creating a new environment is recommended:
mamba create env -n defermi python
mamba activate defermi
The package can be installed with PyPI:
pip install defermi
The library comes with a simple and intutitive graphical user interface. It runs in the brouwser without installation on this link:
https://defermi.streamlit.app/
It can also be run locally. Install it first:
pip install defermi-gui
and run it with:
defermi-gui
VASP calculations using pymatgen.VASP calculations : Import dataset directly from your VASP calculation directory. Support forgpaw will soon be included.DefectsAnalysis class.list,dict,DataFrame), no unnecessary dependencies on specific objects. Fast learning curve: getting started is as simple as loading a DataFrame or a csv file.The central class of the library is DefectsAnalysis. The most flexible way to initialize it is using a pandas.DataFrame. Details on formats and conventions can be found in this tutorial.
Let’s create an example DataFrame with made-up energies. We are studying $SrO$ and have energies for the neutral and charged $Sr$ and $O$ vacancies.
import pandas as pd
from defermi import DefectsAnalysis
bulk_volume = 800 # cubic Amstrong
data = [
{'name': 'Vac_O','charge': 2,'multiplicity': 1,'energy_diff': 7,'bulk_volume': bulk_volume},
{'name': 'Vac_O','charge':0,'multiplicity':1,'energy_diff': 10.8, 'bulk_volume': bulk_volume},
{'name': 'Vac_Sr','charge': -2,'multiplicity': 1,'energy_diff': 8,'bulk_volume': bulk_volume},
{'name': 'Vac_Sr','charge': 0,'multiplicity': 1,'energy_diff': 7.8,'bulk_volume': bulk_volume},
]
df = pd.DataFrame(data)
df
| name | charge | multiplicity | energy_diff | bulk_volume | |
|---|---|---|---|---|---|
| 0 | Vac_O | 2 | 1 | 7.0 | 800 |
| 1 | Vac_O | 0 | 1 | 10.8 | 800 |
| 2 | Vac_Sr | -2 | 1 | 8.0 | 800 |
| 3 | Vac_Sr | 0 | 1 | 7.8 | 800 |
# Initialize DefectsAnalysis object
da = DefectsAnalysis.from_dataframe(df,band_gap=2,vbm=0) # band gap and valence band maximum in eV
import matplotlib.pyplot as plt
chempots = {'O':-5,'Sr':-2} # Define chemical potentials for each element in a dictionary
# Plot formation energies
da.plot_formation_energies(chemical_potentials=chempots,title='Formation energies',figsize=(5,5)).show()
# Plot charge transition levels
da.plot_ctl(figsize=(4,4),fontsize=12)
plt.title('Charge transition levels');


defermi also offers an easy way to study the defect equilibrium dictated by charge neutrality in different conditions. Defect concentrations can be plotted as a function of the oxygen partial pressure (Brouwer diagram) and dopant concentration (doping diagram) with one line of code.
# Brouwer diagram
precursors = {'SrO':-10} # Reservoir and energy p.f.u for the chemical potentials definition
oxygen_ref = -4.95 # chemical potential of oxygen at 0 K and standard pressure
bulk_dos = {'m_eff_e':0.5, 'm_eff_h':0.4} # effective masses for the charge carriers calculation
da.plot_brouwer_diagram(
bulk_dos=bulk_dos,
temperature=1000, # Kelvin
precursors=precursors,
oxygen_ref=oxygen_ref,
pressure_range=(1e-35,1e25), # atm
figsize=(5,5))
plt.title('Brouwer diagram')
plt.show()
# Doping diagram
da.plot_doping_diagram(
variable_defect_specie={'name':'Donor','charge':1},
concentration_range=(1e11,1e20), # cm^-3
chemical_potentials=chempots,
bulk_dos=bulk_dos,
temperature=1000, # Kelvin
figsize=(5,5))
plt.title('Doping diagram');

