Electron density analysis

Charge doping and density differences

Dope one electron into GaAs with an As vacancy and locate it from the change in Mulliken charges and the density difference.

Category
Electron density analysis
APIs used
total_chargeatoms.arrays["charge"]calc.rhowrite_cube
Script
charge_doping.py

Setting total_charge to the net charge of the system gives electron- or hole-doped states: total_charge=-1.0 adds one electron and +1.0 adds one hole. This kind of analysis requires the electron density explicitly and is out of reach for machine-learning interatomic potentials.

Here one electron is doped into GaAs with an As vacancy, and the difference from the neutral state is examined in two ways.

charge_doping.pyDownload
"""
Advance/OF-DFT example: electron doping of GaAs with an As vacancy.

Compares the neutral and the electron-doped states: Mulliken charges of each atom
and the difference of the electron densities (saved as a CUBE file).

Copyright (C) 2026 AdvanceSoft Corporation, All rights reserved.
"""

from ase.build import bulk
from ase.io.cube import write_cube

from aofdft.calculator import AOFDFTCalculator

VPS_DIR = "path/to/DFT_DATA19_AS/VPS"  # edit these two paths for your environment
PAO_DIR = "path/to/DFT_DATA19_AS/PAO"

# zincblende GaAs (8 atoms) with one As atom removed
atoms   = bulk("GaAs", crystalstructure="zincblende", a=5.65, cubic=True)
vacancy = [atom.index for atom in atoms if atom.symbol == "As"][0]
del atoms[vacancy]

states   = {"neutral": 0.0, "doped": -1.0}  # total charge of the cell; -1.0 = one extra electron
charges  = {}
density  = {}

for label, total_charge in states.items():
    system = atoms.copy()
    system.calc = AOFDFTCalculator(
        console      = False,
        logging_file = f"gaas_{label}.log",
        kin_type     = "AS26",
        kin_model    = "Crystal26",
        vps_dir      = VPS_DIR,
        pao_dir      = PAO_DIR,
        total_charge = total_charge,
    )
    system.get_potential_energy()

    charges[label] = system.arrays["charge"].copy()                    # Mulliken charges
    density[label] = system.calc.rho[0].detach().cpu().numpy().copy()  # electron density (e/Bohr^3)
    print(f"{label:8s}: E_Fermi = {system.calc.e_fermi:8.4f} eV")

# where did the doped electron go?  (negative = gained electrons)
print("\nChange of Mulliken charge by doping (q_doped - q_neutral)")
print(f"{'index':>5s} {'symbol':>6s} {'dq':>10s}")
for i, atom in enumerate(atoms):
    print(f"{i:5d} {atom.symbol:>6s} {charges['doped'][i] - charges['neutral'][i]:+10.4f}")

# density difference on the common grid
delta = density["doped"] - density["neutral"]
with open("gaas_doping_difference.cube", "w") as f:
    write_cube(f, atoms, data=delta, comment="rho(doped) - rho(neutral) (e/Bohr^3)")
print("\nSaved gaas_doping_difference.cube")

Example output

text
neutral : E_Fermi =  -5.6586 eV
doped   : E_Fermi =  -5.3572 eV

Change of Mulliken charge by doping (q_doped - q_neutral)
index symbol         dq
    0     Ga    -0.1720
    1     Ga    -0.1720
    2     As    -0.1040
    3     Ga    -0.1720
    4     As    -0.1040
    5     Ga    -0.1720
    6     As    -0.1040

What to look at

  • Change in Mulliken charges: comparing the change Δq atom by atom shows a larger change on the Ga atoms (−0.172) than on the As atoms (−0.104). In this cell all four Ga atoms are next to the vacancy, and the three As atoms are equivalent. A larger cell is needed to see how the change depends on the distance from the vacancy. The case study GaAs Analysis reports Δq of −0.172 on Ga and −0.104 on As (−0.182 and −0.091 with Kohn-Sham DFT).
  • Density difference: both calculations use the same cell and cutoff energy, so the FFT grids coincide and the density arrays can be subtracted directly. Visualizing the CUBE file shows the doped electron localized around the vacancy.

Notes

  • For periodic systems with total_charge, the cell is kept neutral by a uniform background charge.
  • The density difference integrates to the number of doped electrons (1 in this example).
  • To estimate the band gap from the energy as a function of total_charge, see Band gap estimation.