電子密度の解析

差電子密度 (結合による電子の再配置)

SCF 計算の電子密度から中性原子の電子密度の重ね合わせを差し引き、結合の形成による電子の移動を可視化します。

カテゴリ
電子密度の解析
使用する機能
calc.rhocalc.aofdft.charge_density.neutral_density()write_cube
スクリプト
density_difference.py

差電子密度 (deformation density) は、SCF 計算で得られた電子密度と、孤立した中性原子の電子密度を重ね合わせたものとの差です。化学結合の形成によって電子がどこに集まり、どこから減ったのかを表します。

Δρ(r)=ρSCF(r)−∑AρAatom(r−RA)

中性原子の電子密度の重ね合わせは、SCF 計算の初期値としても使われており、calc.aofdft.charge_density.neutral_density() で同じグリッド上のテンソルとして取得できます。

density_difference.pyダウンロード
"""
Advance/OF-DFT example: deformation density (SCF density minus superposed atomic densities).

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

import matplotlib.pyplot as plt
import numpy as np
from ase.build import bulk
from ase.io.cube import write_cube
from ase.units import Bohr

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"

a     = 5.43
atoms = bulk("Si", crystalstructure="diamond", a=a, cubic=True)

atoms.calc = AOFDFTCalculator(
    console      = False,
    logging_file = "si_deformation.log",
    kin_type     = "AS26",
    kin_model    = "Crystal26",
    vps_dir      = VPS_DIR,
    pao_dir      = PAO_DIR,
)
atoms.get_potential_energy()

calc = atoms.calc

# SCF electron density
rho_scf = calc.rho[0].detach().cpu().numpy()

# superposition of the neutral atomic densities on the same grid
rho_atom = calc.aofdft.charge_density.neutral_density().detach().cpu().numpy()

# deformation density: where electrons accumulate (> 0) or deplete (< 0) by bonding
delta = rho_scf - rho_atom

dv = atoms.get_volume() / Bohr**3 / delta.size  # volume of a grid cell (Bohr^3)
print(f"Integral of SCF density    : {rho_scf.sum() * dv:.6f}")
print(f"Integral of atomic density : {rho_atom.sum() * dv:.6f}")
print(f"Electrons moved by bonding : {0.5 * np.abs(delta).sum() * dv:.4f}")

with open("si_deformation.cube", "w") as f:
    write_cube(f, atoms, data=delta, comment="Deformation density (e/Bohr^3) by Advance/OF-DFT")
print("Saved si_deformation.cube")

# 2D map on the (1-10) plane (x = y), which contains the Si-Si bonds
na, nb, nc = delta.shape
idx   = np.arange(na)
plane = delta[idx, idx, :]
plane = np.vstack([plane, plane[:1]])
plane = np.hstack([plane, plane[:, :1]])

u = np.linspace(0.0, a * np.sqrt(2.0), na + 1)
z = np.linspace(0.0, a, nc + 1)
vmax = np.abs(plane).max()

fig, ax = plt.subplots(figsize=(6.4, 4.6))
cs = ax.contourf(u, z, plane.T, levels=np.linspace(-vmax, vmax, 25), cmap="RdBu_r")
fig.colorbar(cs, ax=ax, label=r"Deformation density ($e$/Bohr$^3$)")

for p in atoms.positions:
    if abs(p[0] - p[1]) < 1.0e-6:
        for du in (0.0, a * np.sqrt(2.0)):
            for dz in (0.0, a):
                uu, zz = p[0] * np.sqrt(2.0) + du, p[2] + dz
                if uu <= u[-1] + 1.0e-6 and zz <= z[-1] + 1.0e-6:
                    ax.plot(uu, zz, "o", color="black", markersize=6)

ax.set_xlabel("[110] (Angstrom)")
ax.set_ylabel("[001] (Angstrom)")
ax.set_aspect("equal")
fig.tight_layout()
fig.savefig("si_deformation_plane.png", dpi=150)
print("Saved si_deformation_plane.png")

実行結果の例

Si の (1-10) 面における差電子密度。赤は電子の増加、青は減少。Si-Si 結合の中央に電子が集まっています。
Si の (1-10) 面における差電子密度。赤は電子の増加、青は減少。Si-Si 結合の中央に電子が集まっています。

ポイント

  • calc.aofdft は SCF 計算の本体である AOFDFT オブジェクトで、charge_density プロパティから電子密度に関する情報にアクセスできます。
  • neutral_density() は形状 (na, nb, nc) の torch.Tensor を返します。単位は calc.rho と同じ電子数 / Bohr³ です。
  • 両者はどちらも価電子数に規格化されているため、差電子密度のセル全体での積分はゼロになります。
  • 出力した CUBE ファイルは正負の値をもちます。可視化ソフトでは正と負の等値面を色分けして表示してください。
  • 2 つの異なる計算の電子密度の差をとる方法は、吸着による電荷の再配置 と 電荷ドープ をご覧ください。