原子電荷・スピン
原子ごとの固有値と占有数
AOF-DFT が原子ごとに解く固有値問題の固有値・占有数・軌道係数をファイルに出力して読み取ります。
Kohn-Sham DFT が系全体の固有値問題を解くのに対して、AOF-DFT は原子ごとの小さな固有値問題を解き、すべての原子に共通のフェルミエネルギーで占有数を決めます (技術解説 を参照)。wavefunc_file を指定すると、その固有値、占有数、擬原子軌道の展開係数が出力されます。
"""
Advance/OF-DFT example: eigenvalues and occupations of the atom-wise eigenvalue problems.
AOF-DFT solves a small eigenvalue problem for each atom. `wavefunc_file` writes the
eigenvalues (Hartree), occupations and coefficients of the pseudo-atomic orbitals.
Copyright (C) 2026 AdvanceSoft Corporation, All rights reserved.
"""
import re
from ase.build import bulk
from ase.units import 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"
WF_FILE = "gaas_wavefunc.txt"
def read_levels(filename):
"""
Read eigenvalues and occupations from the wave-function file.
Returns:
blocks (list[dict]): for each atom and spin, {"index", "element", "spin", "energies", "occupations"}
"""
head = re.compile(r"^Atom\s+index=\s*(\d+)\s+element=\s*(\w+)\s+spin=\s*(\d+)")
blocks = []
with open(filename, encoding="utf-8") as f:
for line in f:
if m := head.match(line):
blocks.append({"index": int(m.group(1)), "element": m.group(2), "spin": int(m.group(3))})
elif line.strip().startswith("Energy"):
blocks[-1]["energies"] = [float(x) for x in line.split()[1:]]
elif line.strip().startswith("Occup."):
blocks[-1]["occupations"] = [float(x) for x in line.split()[1:]]
return blocks
atoms = bulk("GaAs", crystalstructure="zincblende", a=5.65, cubic=True) # 8 atoms
atoms.calc = AOFDFTCalculator(
console = False,
logging_file = "gaas.log",
wavefunc_file = WF_FILE, # eigenvalues, occupations and coefficients for each atom
kin_type = "AS26",
kin_model = "Crystal26",
vps_dir = VPS_DIR,
pao_dir = PAO_DIR,
)
atoms.get_potential_energy()
e_fermi = atoms.calc.e_fermi # eV
print(f"Fermi energy: {e_fermi:.4f} eV\n")
# all atoms of an element are equivalent in this crystal: print the first one of each element
shown = set()
for block in read_levels(WF_FILE):
if block["element"] in shown:
continue
shown.add(block["element"])
print(f"atom {block['index']} ({block['element']}), spin {block['spin']}")
print(f" {'level':>5s} {'E - E_F (eV)':>13s} {'occupation':>11s}")
for n, (energy, occ) in enumerate(zip(block["energies"], block["occupations"]), start=1):
print(f" {n:5d} {energy * Hartree - e_fermi:13.4f} {occ:11.5f}")
出力ファイルの例
[ Wave-Functions of AOF-DFT ]
Atom index= 1 element= Ga spin= 1
==================================================
1 2 3 4
Energy -0.26727 -0.18950 -0.18950 -0.18950
Occup. 1.83972 0.38048 0.38048 0.38048
--------------------------------------------------
1 s 1.00000 0.00000 0.00000 -0.00000
2 px -0.00000 0.22209 0.95651 -0.18913
2 py -0.00000 0.66889 -0.29060 -0.68420
2 pz 0.00000 -0.70941 0.02544 -0.70434
==================================================
Atom index= 2 element= As spin= 1
==================================================
1 2 3 4
Energy -0.36295 -0.21874 -0.21874 -0.21874
Occup. 1.99854 1.00676 1.00676 1.00676
--------------------------------------------------
1 s 1.00000 0.00000 0.00000 -0.00000
2 px -0.00000 0.02940 0.99946 -0.01444
2 py 0.00000 -0.70787 0.01061 -0.70627
2 pz 0.00000 -0.70573 0.03099 0.70780
==================================================
GaAs 結晶 (8 原子の立方セル) で出力されるファイルのうち、先頭の 2 原子の部分です。スクリプトはこのファイルを読み取り、元素ごとに最初の 1 原子の準位を、フェルミエネルギーを基準にして次のように表示します。
Fermi energy: -5.9447 eV
atom 1 (Ga), spin 1
level E - E_F (eV) occupation
1 -1.3280 1.83972
2 0.7882 0.38048
3 0.7882 0.38048
4 0.7882 0.38048
atom 2 (As), spin 1
level E - E_F (eV) occupation
1 -3.9316 1.99854
2 -0.0075 1.00676
3 -0.0075 1.00676
4 -0.0075 1.00676
Ga と As のどちらでも、s 軌道に由来する準位がフェルミエネルギーより深い位置にあり、占有数は 2 に近い値です (Ga 1.84、As 2.00)。p 軌道に由来する 3 重に縮退した準位は、部分的に占有されています。
ファイルの読み方
- 原子ごと (スピン分極計算ではスピンごと) に 1 つのブロックが出力されます。
- この結晶では、同じ元素の原子はすべて等価で、準位と占有数も同じになります。そのため、スクリプトでは元素ごとに 1 原子だけを表示しています。
- セルには、GaAs の立方セル (8 原子) を使っています。v1.0.0 では、基本単位格子 (2 原子) のように周期の短いセルで計算すると結果が変わるためです。
Energy行は固有値で、単位は Hartree です。Occup.行は各準位の占有数です。- その下の行列は、各固有状態を擬原子軌道で展開したときの係数です。
- これらは原子に局在した準位であり、Kohn-Sham DFT のバンド構造や状態密度に対応するものではない点にご注意ください。
- フェルミエネルギーは
calc.e_fermiで eV 単位の値を取得できます。スクリプトでは固有値を eV に換算し、フェルミエネルギーを基準にして表示しています。