Skip to content

Electronic analysis

Electronic analysis should retain the method, basis, charge, spin, geometry, and population convention. The examples below use the same relaxed PBE/def2-SVP water state as the field guide.

from atomli.build import molecule
from atomli.calculators import QC
from atomli.optimize import BFGS
atoms = molecule("H2O")
atoms.calc = QC(xc="PBE", basis="def2-svp", device="cpu", scf={"energy_tolerance": 1e-8})
if not BFGS(atoms).run(fmax=1e-4, steps=60):
raise RuntimeError("Geometry did not converge")
state = atoms.calc.get_electronic_state()

Eigenvalue and occupation axes are (spin, kpoint, band). Coefficients and AO densities retain their AO and spin/k-point axes. Restricted density is spin summed. Changing the geometry invalidates the state for new property requests.

from atomli.visualize import plot
dos = atoms.calc.get_dos(width=0.3, window=(-27, 9), npts=1200) # eV relative to the Fermi level
plot.dos(dos).write_html("water-dos.html")

PBE def2 SVP water orbital density of states

The window runs from the O 2s level to just above the LUMO and omits the O 1s level near −510 eV. The energy axis is relative to the middle of the shaded HOMO–LUMO gap (script). Gaussian broadening changes the plotted resolution, not the eigenvalues. A molecular orbital gap is not an optical excitation energy. For a crystal the gap comes from eigenvalues along a k path; the silicon example shows the band structure with its gap.

pdos = atoms.calc.get_pdos(grouping="atom", width=0.3, npts=501)
plot.pdos(pdos).write_html("water-pdos.html")

Mulliken projections depend on the AO basis. Preserve the grouping and broadening with exported curves.

PBE water HOMO phase and nodal structure

The isosurface shows both signs of the HOMO amplitude. Blue/orange indicates orbital phase rather than electrical charge. The field guide provides contour controls and the corresponding LUMO.

charges = atoms.calc.get_atomic_charges()
from atomli.visualize import view
view(atoms, tags=[f"{q:+.3f} e" for q in charges]).write_html("charges.html")

Calculated Mulliken charges on PBE water

Charges use elementary-charge units and should sum to the requested total charge. Mulliken values are basis-dependent partitions. They should not be equated with an arbitrary isodensity volume or an ESP color.

Water ESP mapped onto a density surface for comparison with population charges

The ESP map samples a different observable at the same geometry. Color is autoscaled on the surface; quantitative comparison requires the underlying values and a common normalization.

Analysis shares the retained density matrix, overlap, and AO mapping across Mulliken, Löwdin, natural population, and orbital-composition requests:

from atomli.analysis import Analysis
analysis = Analysis(atoms)
mulliken = analysis.mulliken()
lowdin = analysis.lowdin()
natural = analysis.npa()
charges = analysis.charges("npa")
bond_table = mulliken.bond_table(atoms, threshold=.2)
composition = analysis.orbital_composition(method="lowdin", by_shell=False)

analysis.charges("mulliken") uses a charge-only reduction that skips the overlap-population and Mayer matrices, and reuses a cached analysis.mulliken() result when one exists. Atom and shell compositions for the same method and k point share one prepared set of per-AO weights, so the second grouping does not repeat the overlap products:

prepared = analysis.prepared_orbital_composition(method="lowdin")
by_atom = prepared.group(by_shell=False)
by_shell = prepared.group(by_shell=True)

Native calculators export only the tensors each analysis consumes, for the selected k point: overlap and density for charges and populations, overlap and coefficients for compositions. The session retains one export per selection, and calculators without that capability keep using the full get_electronic_state().

Without a session, atomli.analysis.mulliken_charges and atomli.analysis.prepare_orbital_composition take the same explicit tensors as mulliken_analysis and orbital_composition.

PBE water Mulliken Lowdin and natural atomic charges

The three partitions conserve the same total electron count and assign different atomic charges. The record retains all charges and the Mayer bond-order matrix. A bond-order threshold is an analysis choice rather than a unique chemical definition. Molecular matrix analysis requires compatible real AO tensors; preserve the spin and k-point selection, and check periodic support before applying it to a solid.

localized = analysis.localize_orbitals(method="pipek-mezey")
if not localized.converged:
raise RuntimeError("Localization did not converge")
classes = localized.classify_bonds(atoms, threshold=.2)
grid = localized.evaluate_orbital_grid(atoms, localized_index=0,
shape=[41, 41, 41], margin=2.5)

PBE occupied Pipek Mezey water O H bond orbital isosurface

The displayed occupied O–H orbital is selected by its shared O/H atomic populations. Pipek–Mezey localization rotates the occupied subspace while preserving its density and electron count. Localized orbitals are not generally canonical energy eigenstates. Threshold-based one-center/two-center labels depend on the population convention; orbital phase colors retain their usual arbitrary global sign.

The result also contains the unitary transform, per-atom weights, effective center counts, and convergence status. method="boys" and method="ibo" are additional native localization selections; retain their algorithm and population settings with comparisons.

frontier = analysis.conceptual_dft(method="frontier", charge_model="lowdin")
print(frontier.fukui_plus, frontier.fukui_minus, frontier.dual_descriptor)

The frontier mode estimates condensed Fukui descriptors from occupied/virtual orbital populations. Its global descriptors use orbital-energy approximations; a PBE LUMO is not a measured electron affinity, and a Kohn–Sham gap is not an optical gap.

conceptual_dft_analysis(..., method="delta_scf", cation_calc=..., anion_calc=...) alternatively compares integer N, N−1, and N+1 electronic states at the same geometry. Define charge, spin, basis, and charge partition consistently, and establish whether the anion is bound. These are separate electronic-state energies and populations; the operation does not supply a nuclear Hessian or an analytical polarizability.

Create a fresh analysis session after changing geometry or electronic settings. Conformer averages require the same atom mapping and population convention across members.

atoms.calc.write_wavefunction("water.h5", format="hdf5")
density = atoms.calc.make_rdm1()
overlap = atoms.calc.get_overlap()

A wavefunction archive and a sampled scalar-field file use different readers. For constrained structures, retain constraints separately from the electronic payload. The adsorption workflow combines fixed-host optimization, a density surface, and an analytical adsorbate Hessian.

Method and array records · Python generator