電子密度の解析
面平均静電ポテンシャルと仕事関数
スラブモデルの電子密度から静電ポテンシャルを求め、XY 面で平均したプロファイルと真空準位・フェルミエネルギーから仕事関数を計算します。
仕事関数 は、真空準位 とフェルミエネルギー の差です。
フェルミエネルギーは calc.e_fermi で取得できます。真空準位は、スラブから十分に離れた真空領域での静電ポテンシャルの値です。電子密度を陽に扱う Advance/OF-DFT では、電子密度から Poisson 方程式を解くことで静電ポテンシャルを求められます。
計算の流れ
- 表面に垂直な方向に真空層を設けたスラブモデル (ここでは Al(111) の 6 層、24 原子) で SCF 計算を行う
- 電子密度
calc.rhoと、中性原子の電子密度の重ね合わせneutral_density()の差 を求める - がつくる静電ポテンシャルを、逆空間で Poisson 方程式を解いて求める
- XY 面で平均して、表面に垂直な方向 (z) のプロファイルにする
- 真空領域での平均値を真空準位とし、フェルミエネルギーとの差をとる
中性原子がつくるポテンシャルは短距離で、真空領域ではゼロになります。そのため、真空準位は差電子密度 の静電ポテンシャルだけで決まります。
"""
Advance/OF-DFT example: planar-averaged electrostatic potential and work function of a slab.
The electrostatic potential is obtained from the electron density by solving the
Poisson equation in reciprocal space. The work function is the vacuum level minus
the Fermi energy.
Copyright (C) 2026 AdvanceSoft Corporation, All rights reserved.
"""
import matplotlib.pyplot as plt
import numpy as np
from ase.build import fcc111
from ase.units import Bohr, Hartree
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"
def hartree_potential(delta_rho, cell):
"""
Solve the Poisson equation for a periodic charge distribution with FFT.
Args:
delta_rho (np.ndarray): density difference in e/Bohr^3. Its shape is (na, nb, nc).
cell (np.ndarray): lattice vectors in Bohr. Its shape is (3, 3).
Returns:
potential (np.ndarray): potential energy of an electron in Hartree. Its shape is (na, nb, nc).
"""
recip = 2.0 * np.pi * np.linalg.inv(cell).T
freqs = [np.fft.fftfreq(n, d=1.0 / n) for n in delta_rho.shape]
ia, ib, ic = np.meshgrid(*freqs, indexing="ij")
g = ia[..., None] * recip[0] + ib[..., None] * recip[1] + ic[..., None] * recip[2]
g2 = np.sum(g * g, axis=-1)
g2[0, 0, 0] = 1.0 # avoid division by zero
v_g = 4.0 * np.pi * np.fft.fftn(delta_rho) / g2
v_g[0, 0, 0] = 0.0 # the G = 0 term vanishes for a neutral cell
return np.fft.ifftn(v_g).real
# 1) slab model: 6 layers of Al(111), 2x2 in the surface plane (24 atoms),
# with 10 Angstrom of vacuum on both sides
slab = fcc111("Al", size=(2, 2, 6), a=4.05, vacuum=10.0)
slab.calc = AOFDFTCalculator(
console = False,
logging_file = "al111.log",
kin_type = "AS26",
kin_model = "Crystal26",
vps_dir = VPS_DIR,
pao_dir = PAO_DIR,
scf_style = "bulk", # the preset for bulk crystals also suits this metal slab
mix_precond = None, # without the Thomas-Fermi preconditioner of the preset
)
slab.get_potential_energy()
calc = slab.calc
# 2) density difference from the superposition of neutral atoms.
# The potential of a neutral atom is short-ranged and vanishes in the vacuum,
# so the vacuum level is given by the Hartree potential of this difference.
rho_scf = calc.rho[0].detach().cpu().numpy()
rho_atom = calc.aofdft.charge_density.neutral_density().detach().cpu().numpy()
potential = hartree_potential(rho_scf - rho_atom, slab.cell.array / Bohr) * Hartree # eV
# 3) average over the xy plane
v_z = potential.mean(axis=(0, 1))
z = np.arange(len(v_z)) * slab.cell[2, 2] / len(v_z) # Angstrom
# 4) vacuum level: average over the grid points far (> 6 Angstrom) from the surfaces
z_atoms = slab.positions[:, 2]
in_vac = (z < z_atoms.min() - 6.0) | (z > z_atoms.max() + 6.0)
e_vac = v_z[in_vac].mean()
e_fermi = calc.e_fermi
print(f"Vacuum level : {e_vac:8.4f} eV")
print(f"Fermi energy : {e_fermi:8.4f} eV")
print(f"Work function : {e_vac - e_fermi:8.4f} eV")
# 5) plot
fig, ax = plt.subplots(figsize=(6.4, 4.0))
ax.plot(z, v_z, color="#40266e", label="Planar-averaged potential")
ax.axhline(e_vac, color="gray", linestyle="--", label="Vacuum level")
ax.axhline(e_fermi, color="#d1495b", linestyle="--", label="Fermi energy")
for za in z_atoms:
ax.axvline(za, color="lightgray", linewidth=0.8, zorder=0)
ax.annotate("", xy=(z[-1] * 0.92, e_vac), xytext=(z[-1] * 0.92, e_fermi), arrowprops=dict(arrowstyle="<->"))
ax.text(z[-1] * 0.90, 0.5 * (e_vac + e_fermi), "work function", ha="right", va="center")
ax.set_xlabel("z (Angstrom)")
ax.set_ylabel("Energy (eV)")
ax.set_xlim(z[0], z[-1])
ax.legend(loc="center left")
fig.tight_layout()
fig.savefig("al111_potential.png", dpi=150)
print("Saved al111_potential.png")
実行結果の例
Vacuum level : -0.4747 eV
Fermi energy : -5.1437 eV
Work function : 4.6691 eV
Saved al111_potential.png

プロットしているのは がつくるポテンシャルです。真空領域でポテンシャルが平坦になっていること (真空層が十分に厚いこと) を確認してください。
ポイント
- 関数
hartree_potential()は、周期的な電荷分布に対する Poisson 方程式を FFT で解きます。入力は Bohr⁻³ 単位の電子密度と Bohr 単位のセル、出力は Hartree 単位のポテンシャル (電子が感じるポテンシャルエネルギー) です。 - プロットしているのは がつくるポテンシャルです。スラブの内部では、これに中性原子のポテンシャルを加えたものが全静電ポテンシャルになりますが、真空準位の決定には影響しません。
- 上下の表面が等価な対称スラブを使ってください。上下が非対称なスラブでは、周期境界条件のために真空領域のポテンシャルが傾き、真空準位を一意に決められません。
- スラブは、表面に平行な方向に 2×2 の周期をとっています。v1.0.0 では、1×1 のように周期の短いセルで計算すると結果が変わるためです。新しく計算する系では、セルを大きくしても結果が変わらないことを確認してください。
- SCF の設定は、バルク結晶用のプリセット
scf_style="bulk"から Thomas-Fermi 型の前処理を外したもの (mix_precond=None) です。前処理を付けたままでも同じ結果に収束しますが、このスラブでは外した方が少ない反復回数で収束します。プリセットの内容は SCF 計算の制御と収束の確認 を参照してください。 - 吸着による仕事関数の変化量は、解析事例 K/Mg(0001) 吸着系の仕事関数 で評価しています。深層学習運動エネルギー汎関数による変化量 ΔΦ は −1.746 eV で、Kohn-Sham DFT の −1.650 eV との差は 0.096 eV でした。
表面・真空領域を含む系に対する AdvanceSoft26 の精度と収束性の改善は、開発ロードマップ に含まれています。