defectpl.defectpl¶
Photoluminescence
dataclass
¶
Photoluminescence(
frequencies,
eigenvectors,
masses,
EZPL,
dR=None,
dF=None,
resolution=1000,
max_energy=5.0,
sigma=0.006,
gamma=2.0,
)
Bases: MSONable
Core engine for first-principles photoluminescence lineshape calculations.
Implements the generating-function formalism of Alkauskas et al. (New J. Phys. 16, 073026, 2014) to compute the full multi-phonon PL spectrum of a point defect from DFT inputs.
Two input modes are supported:
- Displacement mode — supply
dR(atomic displacements between ground and excited equilibrium geometries). - Force mode — supply
dF(forces on the ground-state atoms when the system is in the excited-state charge state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frequencies
|
(ndarray, shape(nmodes))
|
Phonon mode frequencies at the Γ point in eV. |
required |
eigenvectors
|
(ndarray, shape(nmodes, natoms, 3))
|
Mass-normalised phonon displacement eigenvectors (real part only). |
required |
masses
|
(ndarray, shape(natoms))
|
Atomic masses in atomic mass units (amu). |
required |
EZPL
|
float
|
Zero-phonon line (ZPL) energy in eV. |
required |
dR
|
(ndarray, shape(natoms, 3))
|
Atomic displacement vector (excited − ground equilibrium) in Å. Used in displacement mode. |
None
|
dF
|
(ndarray, shape(natoms, 3))
|
Atomic force difference (excited charge − ground charge) in eV/Å.
Used in force mode. |
None
|
resolution
|
int
|
Number of energy grid points per eV; sets spectral resolution. Default 1000. |
1000
|
max_energy
|
float
|
Upper bound of the energy axis in eV. Default 5.0. |
5.0
|
sigma
|
float
|
Gaussian broadening width applied to the spectral function S(ω) in eV. Default 6 meV. |
0.006
|
gamma
|
float
|
Lorentzian (homogeneous) broadening of the ZPL in meV. Default 2.0 meV. |
2.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
natoms |
int
|
Number of atoms in the supercell. |
delR |
float
|
Root-mean-square atomic displacement ΔR in Å. |
delQ |
float
|
Mass-weighted configuration coordinate displacement ΔQ in
amu\ :sup: |
qks |
(ndarray, shape(nmodes))
|
Mode-projected configurational displacement q\ :sub: |
Sks |
(ndarray, shape(nmodes))
|
Partial (mode-resolved) Huang–Rhys factors S\ :sub: |
HR_factor |
float
|
Total Huang–Rhys factor S = Σ S\ :sub: |
DW_factor |
float
|
Debye–Waller factor exp(−S). |
iprs |
(ndarray, shape(nmodes))
|
Phonon inverse participation ratio (IPR) per mode; range [1/N, 1]. |
localization_ratio |
(ndarray, shape(nmodes))
|
Localization ratio β\ :sub: |
S_omega |
ndarray
|
Continuous Huang–Rhys spectral density S(ω) (eV\ :sup: |
Sts |
ndarray
|
Fourier transform of S(ω) used in the generating function. |
Gts |
ndarray
|
Generating function G(t) = exp[S(t) − S] · exp(−γ|t|). |
A_line |
ndarray
|
Photon energy axis for the lineshape in eV. |
intensity |
ndarray
|
Normalised PL intensity as a function of photon energy. |
Notes
The PL lineshape is obtained via the Fourier transform of the generating function G(t):
.. math::
L(\hbar\omega) = \int_{-\infty}^{\infty} G(t)\,
e^{i(E_{\mathrm{ZPL}} - \hbar\omega)t/\hbar}\, dt
where
.. math::
G(t) = e^{S(t) - S} \cdot e^{-\gamma|t|}
and :math:S(t) = \int_0^{\infty} S(\hbar\omega)\,
e^{-i\omega t}\, d(\hbar\omega).
References
Alkauskas, Buckley, Awschalom & Van de Walle, New J. Phys. 16, 073026 (2014).
Examples:
>>> from defectpl.phonon import read_band_yaml
>>> import numpy as np
>>> freqs, evecs, masses = read_band_yaml("band.yaml")
>>> dR = np.load("dR.npy") # shape (natoms, 3), in Å
>>> pl = Photoluminescence(
... frequencies=freqs,
... eigenvectors=evecs,
... masses=masses,
... EZPL=1.945,
... dR=dR,
... )
>>> print(f"S = {pl.HR_factor:.3f}, DW = {pl.DW_factor:.4f}")
compute_properties
¶
Run the full calculation pipeline and populate all derived attributes.
Source code in defectpl\defectpl.py
as_dict
¶
Serialize to a JSON-compatible dictionary.
Complex-valued arrays (Sts, Gts) and derived spectral arrays
(A_line, intensity) are intentionally omitted; they are
cheaply recomputed by :meth:from_dict.
Source code in defectpl\defectpl.py
from_dict
classmethod
¶
Deserialize from a dictionary produced by :meth:as_dict.
Core inputs and real-valued computed properties are loaded directly;
complex arrays (Sts, Gts) and the intensity spectrum are
recomputed on the fly from the stored S(ω).
Source code in defectpl\defectpl.py
from_dict_expensive
classmethod
¶
Reconstruct by replaying the full pipeline from primary inputs only.
Slower than :meth:from_dict because __post_init__ recomputes
everything from scratch; useful when stored arrays may be stale.
Source code in defectpl\defectpl.py
generate_plots
¶
Generate all standard diagnostic plots and save them to out_dir.
Produces ten figures: phonon energy vs mode index, IPR vs energy,
localization ratio vs energy, q\ :sub:k vs energy,
S\ :sub:k vs energy, S(ω) alone, S(ω)+S\ :sub:k, S(ω)+S\ :sub:k
coloured by localization ratio, S(ω)+S\ :sub:k coloured by IPR,
and the final PL intensity spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
out_dir
|
str or Path
|
Directory where figure files are written (created if absent). |
required |
max_freq
|
float
|
Upper frequency cut-off for S(ω) plots in meV. If |
None
|
iylim
|
tuple of float
|
|
None
|
fig_format
|
(pdf, png, svg, jpg)
|
Output figure format. Default |
'pdf'
|
Source code in defectpl\defectpl.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | |
VibrationalSpectra1D
dataclass
¶
VibrationalSpectra1D(
EZPL,
w1_meV,
w2_meV,
DQ,
T,
E0,
dE,
M,
NN1=22,
NN2=52,
K2EV=8.617333262e-05,
)
Bases: MSONable
1D harmonic-oscillator model for the vibrational lineshape of a luminescence band.
Computes Franck–Condon overlaps between vibrational levels of two displaced harmonic potentials (ground and excited state) with potentially different effective frequencies, following Alkauskas, Yan & Van de Walle (Phys. Rev. B 90, 075202, 2014).
This model is complementary to :class:Photoluminescence — it replaces
the multi-phonon generating function with an explicit sum over
vibrational quantum numbers, which is exact within the harmonic
approximation and more suitable when ω\ :sub:1 ≠ ω\ :sub:2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
EZPL
|
float
|
Zero-phonon line energy in eV. |
required |
w1_meV
|
float
|
Ground-state effective phonon frequency in meV. |
required |
w2_meV
|
float
|
Excited-state effective phonon frequency in meV. |
required |
DQ
|
float
|
Configuration coordinate displacement ΔQ in amu\ :sup: |
required |
T
|
float
|
Temperature in K (sets Boltzmann weights for ground-state levels). |
required |
E0
|
float
|
Starting photon energy for the output lineshape grid in eV. |
required |
dE
|
float
|
Energy step of the output lineshape grid in eV. |
required |
M
|
int
|
Number of energy grid points. |
required |
NN1
|
int
|
Maximum vibrational quantum number included for the ground state. Default 22. |
22
|
NN2
|
int
|
Maximum vibrational quantum number included for the excited state. Default 52. |
52
|
Attributes:
| Name | Type | Description |
|---|---|---|
overlap_matrix |
(ndarray, shape(NN1 + 1, NN2 + 1))
|
Franck–Condon overlap integrals ⟨i|j⟩. |
overlap_data |
dict
|
Keys |
spectral_data |
dict
|
Keys |
Notes
The overlap integral between vibrational levels :math:i (ground) and
:math:j (excited) is evaluated recursively using the displaced harmonic
oscillator recurrence relation. The full lineshape is then obtained by
Gaussian broadening with width σ = 0.70·ω\ :sub:2.
The ω³-weighted density dosw3 approximates the spontaneous emission
rate and is normalized to unit area.
Examples:
>>> spec = VibrationalSpectra1D(
... EZPL=1.945, w1_meV=65.0, w2_meV=62.0,
... DQ=1.8, T=300.0, E0=1.3, dE=0.001, M=700
... )
>>> spec.compute_lineshape()
>>> e_peak, _ = spec.get_peak_position()
>>> print(f"Peak at {e_peak:.3f} eV, FWHM = {spec.get_fwhm():.3f} eV")
compute_overlap_matrix
¶
Fill overlap_matrix with Franck–Condon overlaps ⟨i|j⟩ for all (i, j) pairs.
Source code in defectpl\defectpl.py
compute_spectrum
¶
Compute Boltzmann-weighted Franck–Condon transition intensities.
Populates overlap_data with per-transition contributions and
energies, and prints the closure-relation sum (should be ≈ 1).
Source code in defectpl\defectpl.py
compute_lineshape
¶
Gaussian-broaden the FC transitions to produce the PL lineshape.
Calls :meth:compute_spectrum if not already done, then builds the
energy-resolved transition density dos and the ω³-weighted
normalised intensity dosw3 on the grid [E0, E0 + M·dE].
Results are stored in spectral_data.
Source code in defectpl\defectpl.py
save_results
¶
Write results to JSON files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlap_file
|
str
|
Destination for the MSONable object JSON (includes all inputs).
Default |
'overlap.json'
|
lineshape_file
|
str
|
Destination for the |
'lineshape.json'
|
Source code in defectpl\defectpl.py
plot_lineshape
¶
Plot the normalised PL lineshape (ω³-weighted intensity vs energy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_file
|
str
|
If given, save to this path (dpi 600); otherwise |
None
|
figsize
|
tuple of float
|
Matplotlib figure size in inches. Default |
(4.4, 4.4)
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in defectpl\defectpl.py
get_peak_position
¶
Return the energy and intensity at the lineshape peak.
Returns:
| Type | Description |
|---|---|
(energy, intensity) : tuple of float
|
Peak photon energy in eV and the corresponding normalised intensity. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in defectpl\defectpl.py
get_fwhm
¶
Compute the Full Width at Half Maximum (FWHM) of the PL lineshape.
Returns:
| Type | Description |
|---|---|
float
|
FWHM in eV. Returns 0.0 if fewer than two points exceed half-maximum. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in defectpl\defectpl.py
ConfigurationCoordinateDiagram
dataclass
¶
Bases: MSONable
Configuration coordinate diagram for a two-state defect transition.
Manages interpolation of structures between the ground and excited equilibrium geometries, DFT input-file generation, potential energy surface (PES) extraction from completed Vasprun files, and harmonic fitting of the resulting parabolic wells.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ground_struct
|
Structure
|
DFT-relaxed ground-state supercell geometry. |
required |
excited_struct
|
Structure
|
DFT-relaxed excited-state supercell geometry (same species ordering). |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
dQ |
float
|
Mass-weighted configuration coordinate displacement ΔQ in
amu\ :sup: |
Notes
The configuration coordinate is defined as
.. math::
\Delta Q = \sqrt{\sum_i m_i\,|\Delta\mathbf{R}_i|^2}
where the sum runs over all atoms and :math:\Delta\mathbf{R}_i is
the displacement of atom i between the two equilibrium geometries
(minimum-image convention with periodic boundary conditions).
The zero-phonon line energy and Stokes shift can be read from the
fitted parabola minima returned by :meth:analyze_ccd.
Examples:
>>> from pymatgen.core import Structure
>>> gs = Structure.from_file("CONTCAR_gs")
>>> es = Structure.from_file("CONTCAR_es")
>>> ccd = ConfigurationCoordinateDiagram(gs, es)
>>> print(f"ΔQ = {ccd.dQ:.3f} amu^1/2 Å")
>>> ccd.setup_calculations(
... displacements=[-0.5, -0.25, 0.25, 0.5, 0.75],
... output_dir="ccd_calcs",
... ground_input_dir="inputs/ground",
... excited_input_dir="inputs/excited",
... )
generate_structures
¶
Linearly interpolate structures at fractional displacements along ΔQ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
displacements
|
array-like of float
|
Fractional displacements along the ground→excited path. A value of 0.0 is the ground minimum; 1.0 is the excited minimum. Values outside [0, 1] extrapolate. |
required |
remove_zero
|
bool
|
Drop any entries equal to 0.0 (ground minimum already exists). Default True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
ground_structs |
list of Structure
|
Structures displaced from ground toward excited (for ground-state PES). |
excited_structs |
list of Structure
|
Structures displaced from ground + 1.0 (for excited-state PES). |
Source code in defectpl\defectpl.py
setup_calculations
¶
setup_calculations(
displacements,
output_dir,
ground_input_dir,
excited_input_dir,
input_files=None,
)
Write interpolated POSCAR files and copy VASP input files.
Creates the directory tree::
output_dir/
ground/0/POSCAR KPOINTS POTCAR INCAR
ground/1/...
excited/0/...
...
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
displacements
|
array-like of float
|
Fractional displacements (see :meth: |
required |
output_dir
|
str or Path
|
Root directory for the calculation tree (created if absent). |
required |
ground_input_dir
|
str or Path
|
Directory containing the VASP input files for ground-state runs. |
required |
excited_input_dir
|
str or Path
|
Directory containing the VASP input files for excited-state runs. |
required |
input_files
|
list of str
|
File names to copy from each input directory.
Default |
None
|
Source code in defectpl\defectpl.py
extract_pes_profile
¶
Extract (Q, E) data points from a list of completed Vasprun files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vasprun_paths
|
list of str or Path
|
Paths to |
required |
tol
|
float
|
Fractional-coordinate tolerance for projecting each structure onto the configuration coordinate axis. Default 0.001. |
0.001
|
Returns:
| Name | Type | Description |
|---|---|---|
q_values |
ndarray
|
Configuration coordinate values Q in amu\ :sup: |
energies |
ndarray
|
Total DFT energies shifted so the minimum is zero (eV). |
Source code in defectpl\defectpl.py
analyze_ccd
¶
analyze_ccd(
ground_vaspruns,
excited_vaspruns,
dE=0.0,
plot=True,
figsize=(3.3, 3.3),
xlim=(-3.0, 10.0),
ylim=(-0.5, 4.0),
save_plot=None,
)
Fit harmonic wells to the ground- and excited-state PES data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ground_vaspruns
|
list of str or Path
|
|
required |
excited_vaspruns
|
list of str or Path
|
|
required |
dE
|
float
|
Rigid energy offset applied to the excited-state PES in eV (e.g. to set the excited minimum to the ZPL energy). Default 0.0. |
0.0
|
plot
|
bool
|
If True, show a matplotlib figure. Default True. |
True
|
figsize
|
tuple of float
|
Figure size in inches. Default |
(3.3, 3.3)
|
xlim
|
tuple of float
|
x-axis limits for the CCD plot in amu\ :sup: |
(-3.0, 10.0)
|
ylim
|
tuple of float
|
y-axis limits for the CCD plot in eV. |
(-0.5, 4.0)
|
save_plot
|
str
|
If given, save the figure to this path instead of showing. |
None
|
Returns:
| Type | Description |
|---|---|
(omega_ground, omega_excited) : tuple of float
|
Fitted effective angular frequencies in eV for the ground and excited harmonic potentials. |
Source code in defectpl\defectpl.py
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 | |
estimate_vertical_transitions
¶
Calculate vertical absorption and emission energy transitions.