原子電荷・スピン

軌道ポピュレーション

原子軌道ごとの電子占有数をファイルに出力し、s・p・d 殻ごとに集計します。

カテゴリ
原子電荷・スピン
使用する機能
population_file
スクリプト
orbital_population.py

population_file にファイル名を指定すると、SCF 計算のあとに、各原子の擬原子軌道ごとの電子占有数 (密度行列の対角成分) がテキストファイルに出力されます。Mulliken 電荷の内訳を軌道ごとに確認できます。

orbital_population.pyダウンロード
"""
Advance/OF-DFT example: orbital populations of each atom.

The populations are written to a text file by `population_file`. This script
also shows how to read the file and sum the populations for each shell.

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

import re
from collections import defaultdict

from ase.build import bulk

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"

POP_FILE = "sic_population.txt"


def read_population(filename):
    """
    Read the orbital population file.

    Returns:
        atoms (list[dict]): for each atom, {"element": str, "orbitals": {label: electrons}, "charge": float}
    """
    head  = re.compile(r"^Atom\s+index=\s*(\d+)\s+element=\s*(\w+)")
    orbit = re.compile(r"^\s+(\d+)\s+(\S+)\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)\s+(-?\d+\.\d+)")
    chrg  = re.compile(r"^\s+Charge\s+(-?\d+\.\d+)")

    atoms = []
    with open(filename, encoding="utf-8") as f:
        for line in f:
            if m := head.match(line):
                atoms.append({"element": m.group(2), "orbitals": {}, "charge": None})
            elif m := orbit.match(line):
                atoms[-1]["orbitals"][f"{m.group(1)} {m.group(2)}"] = float(m.group(3))
            elif m := chrg.match(line):
                atoms[-1]["charge"] = float(m.group(1))
    return atoms


# SiC: 2x2x2 repetition of the primitive cell (16 atoms)
atoms = bulk("SiC", crystalstructure="zincblende", a=4.36).repeat((2, 2, 2))

atoms.calc = AOFDFTCalculator(
    console         = False,
    logging_file    = "sic.log",
    population_file = POP_FILE,  # orbital populations are written here after the SCF
    kin_type        = "AS26",
    kin_model       = "Crystal26",
    vps_dir         = VPS_DIR,
    pao_dir         = PAO_DIR,
)
atoms.get_potential_energy()

# print the file as it is
with open(POP_FILE, encoding="utf-8") as f:
    print(f.read())

# sum the populations of each shell (s, p, d)
for index, atom in enumerate(read_population(POP_FILE)):
    shells = defaultdict(float)
    for label, electrons in atom["orbitals"].items():
        shells[label.split()[1][0]] += electrons  # "2 px" -> "p"

    summary = "  ".join(f"{shell} = {n:.3f}" for shell, n in shells.items())
    print(f"atom {index} ({atom['element']}): {summary}  charge = {atom['charge']:+.3f}")

出力ファイルの例

text
[ Orbital Populations of AOF-DFT ]

Atom  index=    1  element= Si
  ==========================================================
                Electron      Spin-X      Spin-Y      Spin-Z
  ----------------------------------------------------------
   1 s          1.520101    0.000000    0.000000    0.000000
   2 px         0.151772    0.000000    0.000000    0.000000
   2 py         0.151772    0.000000    0.000000    0.000000
   2 pz         0.151772    0.000000    0.000000    0.000000
   3 dz2        0.074063    0.000000    0.000000    0.000000
   3 dxz        0.196458    0.000000    0.000000    0.000000
   3 dyz        0.196458    0.000000    0.000000    0.000000
   3 dx2-y2     0.074063    0.000000    0.000000    0.000000
   3 dxy        0.196458    0.000000    0.000000    0.000000
  ----------------------------------------------------------
   Total        2.712918    0.000000    0.000000    0.000000
   Charge       1.287082
  ==========================================================

Atom  index=    2  element= C
  ==========================================================
                Electron      Spin-X      Spin-Y      Spin-Z
  ----------------------------------------------------------
   1 s          0.268646    0.000000    0.000000    0.000000
   2 px         1.672812    0.000000    0.000000    0.000000
   2 py         1.672812    0.000000    0.000000    0.000000
   2 pz         1.672812    0.000000    0.000000    0.000000
  ----------------------------------------------------------
   Total        5.287082    0.000000    0.000000    0.000000
   Charge      -1.287082
  ==========================================================

SiC 結晶 (16 原子) で出力されるファイルのうち、先頭の 2 原子の部分です。スクリプトの最後の部分では、全原子について殻ごとに集計して次のように表示します。

text
atom 0 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 1 (C): s = 0.269  p = 5.018  charge = -1.287
atom 2 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 3 (C): s = 0.269  p = 5.018  charge = -1.287
atom 4 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 5 (C): s = 0.269  p = 5.018  charge = -1.287
atom 6 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 7 (C): s = 0.269  p = 5.018  charge = -1.287
atom 8 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 9 (C): s = 0.269  p = 5.018  charge = -1.287
atom 10 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 11 (C): s = 0.269  p = 5.018  charge = -1.287
atom 12 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 13 (C): s = 0.269  p = 5.018  charge = -1.287
atom 14 (Si): s = 1.520  p = 0.455  d = 0.738  charge = +1.287
atom 15 (C): s = 0.269  p = 5.018  charge = -1.287

ファイルの読み方

  • 軌道のラベルは「動径関数の番号 + 軌道の種類」です。基底が s1p1 であれば 1 s、2 px, 2 py, 2 pz が出力され、d 軌道を含む基底では 3 dz2, 3 dxz, 3 dyz, 3 dx2-y2, 3 dxy が加わります。この例では、C の基底が s1p1、Si の基底が s1p1d1 です。
  • Electron 列が電子占有数です。スピン分極計算では Spin-Z 列にスピン占有数 (アップ − ダウン) が出力されます。
  • Total は原子に属する電子数の合計、Charge は Mulliken 電荷 (価電子数 − 電子数) です。
  • セルには、SiC の基本単位格子を 2×2×2 に繰り返したもの (16 原子) を使っています。v1.0.0 では、周期の短いセルで計算すると結果が変わるためです。
  • スクリプトの read_population() は、このファイルを原子ごとの辞書に読み込む関数の例です。殻ごとの集計や、構造を変えたときの比較に利用できます。