Mohammad Maymoun
unread,Jul 16, 2025, 11:36:10 AMJul 16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to koopmans-users
Greetings,
Hope are you wells,
I am trying to construct a PDOS for a molecule systeme, using the in-built functionalities in ASE, using KOOPMANS code, and I am generated a script.py as you see below. However, I did not find the PDOS when I ran it.
Can you please appreciate your assistances in resolving this issue?
script.py:
import pickle
import numpy as np
import matplotlib.pyplot as plt
from koopmans import io
from ase_koopmans.dft.dos import DOS
from scipy.ndimage import gaussian_filter1d
# === Load Koopmans workflow ===
wf = io.read("aa.pkl")
# === Access the final KI calculation ===
final_calc = wf.calculations[-1]
atoms = final_calc.atoms
# === Construct DOS object ===
dos = DOS(final_calc)
# === Extract projected DOS ===
energies, pdos = dos.get_projected_dos() # pdos shape: (n_atoms, n_energies)
# === Group PDOS by element symbol ===
atom_indices_by_symbol = {}
for i, atom in enumerate(atoms):
atom_indices_by_symbol.setdefault(atom.symbol, []).append(i)
# === Plot PDOS with optional Gaussian smoothing ===
plt.figure(figsize=(8, 5))
sigma = 1.0 # Gaussian broadening in energy points (adjust if needed)
for symbol, indices in atom_indices_by_symbol.items():
pdos_sum = np.sum([pdos[i] for i in indices], axis=0)
pdos_smoothed = gaussian_filter1d(pdos_sum, sigma=sigma)
plt.plot(energies, pdos_smoothed, label=f"{symbol} atoms")
# === Customize plot ===
plt.xlabel("Energy (eV)")
plt.ylabel("Projected DOS (a.u.)")
plt.title("Projected DOS (Koopmans KI) - aa")
plt.axhline(0, color="black", linewidth=0.5)
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()