APS 2026 Short Course Tutorial 2: Time-dependent density functional theory (TDDFT)

This tutorial shows how to compute neutral excitation energies of the negatively charged nitrogen-vacancy center (NV\(^-\)) in diamond using linear-response time-dependent density functional theory (TDDFT) in WEST, which computes the excitation energies by diagonalizing the Liouville superoperator. More details about the TDDFT implementation in WEST can be found in Jin et al., J. Chem. Theory Comput. 19, 8689–8705 (2023).

A TDDFT calculation using a local or semi-local exchange-correlation functional is performed in two steps:

  1. Perform a ground-state DFT calculation.

  2. Compute spin-conserving or spin-flip excitation energies using TDDFT.

1. DFT

We perform a ground-state DFT calculation using Quantum ESPRESSO (QE).

Download the following files to your working directory:

[ ]:
%%bash
wget -N -q https://west-code.org/doc/training/nv_diamond_215/tddft/pw.in
wget -N -q http://www.quantum-simulation.org/potentials/sg15_oncv/upf/C_ONCV_PBE-1.2.upf
wget -N -q http://www.quantum-simulation.org/potentials/sg15_oncv/upf/N_ONCV_PBE-1.2.upf

The pw.in file is the input for the pw.x code:

[1]:
%%bash
cat pw.in
! NV- in diamond 3x3x3 supercell
! V 0 0 0
&CONTROL
calculation = 'scf'
pseudo_dir = './'
/
&SYSTEM
ibrav = 0
ntyp = 2
nat = 215
tot_charge = -1.0
tot_magnetization = 2.0
nspin = 2
ecutwfc = 60.0
nbnd = 600
/
&ELECTRONS
diago_full_acc = .true.
/
ATOMIC_SPECIES
C  12.01099968  C_ONCV_PBE-1.2.upf
N  14.00699997  N_ONCV_PBE-1.2.upf
CELL_PARAMETERS angstrom
10.704  0.000  0.000
 0.000 10.704  0.000
 0.000  0.000 10.704
K_POINTS gamma
ATOMIC_POSITIONS crystal
N                0.0915286000        0.0915286000        0.0915286000
C                0.0040609500        0.1665643500        0.1665643500
C                0.0837595600        0.2513210000        0.2513210000
C                0.1665643500        0.0040609500        0.1665643500
C                0.2513210000        0.0837595600        0.2513210000
C                0.1665643500        0.1665643500        0.0040609500
C                0.2513210000        0.2513210000        0.0837595600
C                0.0000847900        0.0000847900        0.3328336000
C                0.0833978600        0.0833978600        0.4167296500
C                0.0000156600        0.1665688100        0.5000487100
C                0.0832667100        0.2498956000        0.5835132300
C                0.1665688100        0.0000156600        0.5000487100
C                0.2498956000        0.0832667100        0.5835132300
C                0.1671315300        0.1671315300        0.3340842800
C                0.2502048700        0.2502048700        0.4171245800
C                0.9998433800        0.9998433800        0.6670281600
C                0.0828113500        0.0828113500        0.7507290900
C                0.9989598600        0.1648543100        0.8346114100
C                0.0825159100        0.2483673400        0.9182597400
C                0.1648543100        0.9989598600        0.8346114100
C                0.2483673400        0.0825159100        0.9182597400
C                0.1662218600        0.1662218600        0.6672099200
C                0.2495317700        0.2495317700        0.7505739400
C                0.0000847900        0.3328336000        0.0000847900
C                0.0833978600        0.4167296500        0.0833978600
C                0.0000156600        0.5000487100        0.1665688100
C                0.0832667100        0.5835132300        0.2498956000
C                0.1671315300        0.3340842800        0.1671315300
C                0.2502048700        0.4171245800        0.2502048700
C                0.1665688100        0.5000487100        0.0000156600
C                0.2498956000        0.5835132300        0.0832667100
C                0.0002768800        0.3338660300        0.3338660300
C                0.0833645600        0.4169749500        0.4169749500
C                0.0000168300        0.4999810500        0.4999810500
C                0.0832120400        0.5830634500        0.5830634500
C                0.1667094400        0.3333711400        0.5002891800
C                0.2499351300        0.4165741500        0.5835728400
C                0.1667094400        0.5002891800        0.3333711400
C                0.2499351300        0.5835728400        0.4165741500
C                0.9998560200        0.3334044700        0.6665437900
C                0.0831695000        0.4162288500        0.7503999300
C                0.9999816100        0.4998348900        0.8334697200
C                0.0832230400        0.5833510700        0.9166967700
C                0.1663854200        0.3323110800        0.8342765400
C                0.2499263900        0.4165205200        0.9168991500
C                0.1666589400        0.4997572900        0.6668741500
C                0.2499317600        0.5831910900        0.7500530100
C                0.9998433800        0.6670281600        0.9998433800
C                0.0828113500        0.7507290900        0.0828113500
C                0.9989598600        0.8346114100        0.1648543100
C                0.0825159100        0.9182597400        0.2483673400
C                0.1662218600        0.6672099200        0.1662218600
C                0.2495317700        0.7505739400        0.2495317700
C                0.1648543100        0.8346114100        0.9989598600
C                0.2483673400        0.9182597400        0.0825159100
C                0.9998560200        0.6665437900        0.3334044700
C                0.0831695000        0.7503999300        0.4162288500
C                0.9999816100        0.8334697200        0.4998348900
C                0.0832230400        0.9166967700        0.5833510700
C                0.1666589400        0.6668741500        0.4997572900
C                0.2499317600        0.7500530100        0.5831910900
C                0.1663854200        0.8342765400        0.3323110800
C                0.2499263900        0.9168991500        0.4165205200
C                0.0000818300        0.6661437500        0.6661437500
C                0.0828990400        0.7490297800        0.7490297800
C                0.0005385000        0.8334828900        0.8334828900
C                0.0871389400        0.9104854600        0.9104854600
C                0.1665746900        0.6665743000        0.8332240500
C                0.2503575200        0.7495764100        0.9168486400
C                0.1665746900        0.8332240500        0.6665743000
C                0.2503575200        0.9168486400        0.7495764100
C                0.3328336000        0.0000847900        0.0000847900
C                0.4167296500        0.0833978600        0.0833978600
C                0.3340842800        0.1671315300        0.1671315300
C                0.4171245800        0.2502048700        0.2502048700
C                0.5000487100        0.0000156600        0.1665688100
C                0.5835132300        0.0832667100        0.2498956000
C                0.5000487100        0.1665688100        0.0000156600
C                0.5835132300        0.2498956000        0.0832667100
C                0.3338660300        0.0002768800        0.3338660300
C                0.4169749500        0.0833645600        0.4169749500
C                0.3333711400        0.1667094400        0.5002891800
C                0.4165741500        0.2499351300        0.5835728400
C                0.4999810500        0.0000168300        0.4999810500
C                0.5830634500        0.0832120400        0.5830634500
C                0.5002891800        0.1667094400        0.3333711400
C                0.5835728400        0.2499351300        0.4165741500
C                0.3334044700        0.9998560200        0.6665437900
C                0.4162288500        0.0831695000        0.7503999300
C                0.3323110800        0.1663854200        0.8342765400
C                0.4165205200        0.2499263900        0.9168991500
C                0.4998348900        0.9999816100        0.8334697200
C                0.5833510700        0.0832230400        0.9166967700
C                0.4997572900        0.1666589400        0.6668741500
C                0.5831910900        0.2499317600        0.7500530100
C                0.3338660300        0.3338660300        0.0002768800
C                0.4169749500        0.4169749500        0.0833645600
C                0.3333711400        0.5002891800        0.1667094400
C                0.4165741500        0.5835728400        0.2499351300
C                0.5002891800        0.3333711400        0.1667094400
C                0.5835728400        0.4165741500        0.2499351300
C                0.4999810500        0.4999810500        0.0000168300
C                0.5830634500        0.5830634500        0.0832120400
C                0.3334705000        0.3334705000        0.3334705000
C                0.4167324700        0.4167324700        0.4167324700
C                0.3332971100        0.5000550300        0.5000550300
C                0.4166468400        0.5833494800        0.5833494800
C                0.5000550300        0.3332971100        0.5000550300
C                0.5833494800        0.4166468400        0.5833494800
C                0.5000550300        0.5000550300        0.3332971100
C                0.5833494800        0.5833494800        0.4166468400
C                0.3330993500        0.3330993500        0.6670267900
C                0.4165460400        0.4165460400        0.7501076800
C                0.3332091000        0.4998618500        0.8333646300
C                0.4167285600        0.5831677800        0.9167310600
C                0.4998618500        0.3332091000        0.8333646300
C                0.5831677800        0.4167285600        0.9167310600
C                0.4999774300        0.4999774300        0.6667223700
C                0.5833624200        0.5833624200        0.7500420300
C                0.3334044700        0.6665437900        0.9998560200
C                0.4162288500        0.7503999300        0.0831695000
C                0.3323110800        0.8342765400        0.1663854200
C                0.4165205200        0.9168991500        0.2499263900
C                0.4997572900        0.6668741500        0.1666589400
C                0.5831910900        0.7500530100        0.2499317600
C                0.4998348900        0.8334697200        0.9999816100
C                0.5833510700        0.9166967700        0.0832230400
C                0.3330993500        0.6670267900        0.3330993500
C                0.4165460400        0.7501076800        0.4165460400
C                0.3332091000        0.8333646300        0.4998618500
C                0.4167285600        0.9167310600        0.5831677800
C                0.4999774300        0.6667223700        0.4999774300
C                0.5833624200        0.7500420300        0.5833624200
C                0.4998618500        0.8333646300        0.3332091000
C                0.5831677800        0.9167310600        0.4167285600
C                0.3332305700        0.6666904400        0.6666904400
C                0.4166448000        0.7499960000        0.7499960000
C                0.3332229300        0.8333122100        0.8333122100
C                0.4164497300        0.9167237600        0.9167237600
C                0.4999530300        0.6666658100        0.8333175200
C                0.5831824800        0.7499521900        0.9166653600
C                0.4999530300        0.8333175200        0.6666658100
C                0.5831824800        0.9166653600        0.7499521900
C                0.6670281600        0.9998433800        0.9998433800
C                0.7507290900        0.0828113500        0.0828113500
C                0.6672099200        0.1662218600        0.1662218600
C                0.7505739400        0.2495317700        0.2495317700
C                0.8346114100        0.9989598600        0.1648543100
C                0.9182597400        0.0825159100        0.2483673400
C                0.8346114100        0.1648543100        0.9989598600
C                0.9182597400        0.2483673400        0.0825159100
C                0.6665437900        0.9998560200        0.3334044700
C                0.7503999300        0.0831695000        0.4162288500
C                0.6668741500        0.1666589400        0.4997572900
C                0.7500530100        0.2499317600        0.5831910900
C                0.8334697200        0.9999816100        0.4998348900
C                0.9166967700        0.0832230400        0.5833510700
C                0.8342765400        0.1663854200        0.3323110800
C                0.9168991500        0.2499263900        0.4165205200
C                0.6661437500        0.0000818300        0.6661437500
C                0.7490297800        0.0828990400        0.7490297800
C                0.6665743000        0.1665746900        0.8332240500
C                0.7495764100        0.2503575200        0.9168486400
C                0.8334828900        0.0005385000        0.8334828900
C                0.9104854600        0.0871389400        0.9104854600
C                0.8332240500        0.1665746900        0.6665743000
C                0.9168486400        0.2503575200        0.7495764100
C                0.6665437900        0.3334044700        0.9998560200
C                0.7503999300        0.4162288500        0.0831695000
C                0.6668741500        0.4997572900        0.1666589400
C                0.7500530100        0.5831910900        0.2499317600
C                0.8342765400        0.3323110800        0.1663854200
C                0.9168991500        0.4165205200        0.2499263900
C                0.8334697200        0.4998348900        0.9999816100
C                0.9166967700        0.5833510700        0.0832230400
C                0.6670267900        0.3330993500        0.3330993500
C                0.7501076800        0.4165460400        0.4165460400
C                0.6667223700        0.4999774300        0.4999774300
C                0.7500420300        0.5833624200        0.5833624200
C                0.8333646300        0.3332091000        0.4998618500
C                0.9167310600        0.4167285600        0.5831677800
C                0.8333646300        0.4998618500        0.3332091000
C                0.9167310600        0.5831677800        0.4167285600
C                0.6666904400        0.3332305700        0.6666904400
C                0.7499960000        0.4166448000        0.7499960000
C                0.6666658100        0.4999530300        0.8333175200
C                0.7499521900        0.5831824800        0.9166653600
C                0.8333122100        0.3332229300        0.8333122100
C                0.9167237600        0.4164497300        0.9167237600
C                0.8333175200        0.4999530300        0.6666658100
C                0.9166653600        0.5831824800        0.7499521900
C                0.6661437500        0.6661437500        0.0000818300
C                0.7490297800        0.7490297800        0.0828990400
C                0.6665743000        0.8332240500        0.1665746900
C                0.7495764100        0.9168486400        0.2503575200
C                0.8332240500        0.6665743000        0.1665746900
C                0.9168486400        0.7495764100        0.2503575200
C                0.8334828900        0.8334828900        0.0005385000
C                0.9104854600        0.9104854600        0.0871389400
C                0.6666904400        0.6666904400        0.3332305700
C                0.7499960000        0.7499960000        0.4166448000
C                0.6666658100        0.8333175200        0.4999530300
C                0.7499521900        0.9166653600        0.5831824800
C                0.8333175200        0.6666658100        0.4999530300
C                0.9166653600        0.7499521900        0.5831824800
C                0.8333122100        0.8333122100        0.3332229300
C                0.9167237600        0.9167237600        0.4164497300
C                0.6667656400        0.6667656400        0.6667656400
C                0.7500929000        0.7500929000        0.7500929000
C                0.6667985100        0.8334883100        0.8334883100
C                0.7502749000        0.9166719100        0.9166719100
C                0.8334883100        0.6667985100        0.8334883100
C                0.9166719100        0.7502749000        0.9166719100
C                0.8334883100        0.8334883100        0.6667985100
C                0.9166719100        0.9166719100        0.7502749000

The calculation is spin polarized (i.e., nspin = 2 and tot_magnetization = 2.0), representing the \(m_S = +1\) sublevel of the \(^3A_2\) many-body state of NV\(^-\) in diamond.

We run pw.x.

[ ]:
%%bash
mpirun -n 4 pw.x -i pw.in > pw.out

2.1 Perform a spin-conserving TDDFT calculation

We use the wbse.x code to compute the excitation energies of triplet states of NV\(^-\) in diamond using spin-conserving TDDFT.

Download the following file to your working directory:

[ ]:
%%bash
wget -N -q https://west-code.org/doc/training/nv_diamond_215/tddft/wbse.in

The wbse.in file is the input for the wbse.x code:

[2]:
%%bash
cat wbse.in
input_west:
  outdir: ./

wbse_init_control:
  wbse_init_calculation: S
  solver: TDDFT

wbse_control:
  wbse_calculation: D
  n_liouville_eigen: 2
  n_liouville_times: 16
  trev_liouville: 0.00000001
  trev_liouville_rel: 0.0001

The n_liouville_eigen: 2 keyword specifies that the two lowest excitation energies are computed.

We run wbse.x.

[ ]:
%%bash
mpirun -n 4 wbse.x -i wbse.in > wbse.out

If the reader does NOT have the computational resources to run the calculation, the output file needed for the next step can be downloaded as:

[ ]:
%%bash
mkdir -p west.wbse.save
wget -N -q https://west-code.org/doc/training/nv_diamond_215/tddft/wbse.json -O west.wbse.save/wbse.json

The calculated excitation energys (in Rydberg) can be found in a file named west.wbse.save/wbse.json.

[3]:
import json
import numpy as np

Rydberg2eV = 13.6057

fname = "west.wbse.save/wbse.json"

with open(fname, "r") as f:
    j = json.load(f)

vees = np.array(j["exec"]["davitr"][-1]["ev"]) * Rydberg2eV

print("Vertical excitation energies (eV): ", vees)
Vertical excitation energies (eV):  [2.06552077 2.06831693]

We run the westpp.x code to analyze the composition of the excited states. We create the input file westpp.in:

[4]:
import yaml

d = {}
d["westpp_control"] = {}
d["westpp_control"]["westpp_calculation"] = "C"
d["westpp_control"]["westpp_n_liouville_to_use"] = 2  # Number of excited states to read from file
d["westpp_control"]["westpp_range"] = [1, 2]  # Excited states to analyze

with open("westpp.in", "w") as f:
    yaml.dump(d, f, sort_keys=False)
[5]:
%%bash
cat westpp.in
westpp_control:
  westpp_calculation: C
  westpp_n_liouville_to_use: 2
  westpp_range:
  - 1
  - 2

The westpp_calculation: C keyword specifies that the code performs a decomposition of the excited states into transitions from occupied to empty Kohn-Sham wavefunctions. Here we consider two excited states as specified by westpp_range: [1, 2].

We run westpp.x.

[ ]:
%%bash
mpirun -n 4 westpp.x -i westpp.in > westpp.out

The output file westpp.out would include the following:

*-------------* THE PRINCIPLE PROJECTED COMPONENTS *-------------*

#     Exciton :          1 |   Excitation energy :       0.151813
#     Transition_from      |   Transition_to       |    Coeffcient
      1         432        |   1         435       |     0.131741
      2         430        |   2         432       |    -0.968844

#     Exciton :          2 |   Excitation energy :       0.152018
#     Transition_from      |   Transition_to       |    Coeffcient
      1         431        |   1         435       |     0.132307
      2         430        |   2         431       |    -0.968652

The first excited state has an excitation energy of 0.151813 Ry (2.066 eV). This excitation has a major contribution by a transition from band 430 (a\(_1\) defect orbital) in the spin down channel to band 432 (one of two degenerate e defect orbitals) in the same spin channel. The second excited state has an excitation energy of 0.152018 Ry (2.068 eV). These are the \(m_S = +1\) sublevel of the \(^3E\) excited states of NV\(^-\) in diamond.

2.2. Perform a spin-flip TDDFT calculation

Now we run the wbse.x code to compute the excitation energies of the singlet states of NV\(^-\) in diamond using spin-flip TDDFT.

We modify the wbse.in file:

[6]:
with open("wbse.in", "r") as f:
    d = yaml.load(f, Loader=yaml.SafeLoader)

d["wbse_control"]["n_liouville_eigen"] = 4  # Number of excited states to compute
d["wbse_control"]["l_spin_flip"] = True
d["wbse_control"]["l_spin_flip_kernel"] = True

with open("wbse_sf.in", "w") as f:
    yaml.dump(d, f, sort_keys=False)
[7]:
%%bash
cat wbse_sf.in
input_west:
  outdir: ./
wbse_init_control:
  wbse_init_calculation: S
  solver: TDDFT
wbse_control:
  wbse_calculation: D
  n_liouville_eigen: 4
  n_liouville_times: 16
  trev_liouville: 1.0e-08
  trev_liouville_rel: 0.0001
  l_spin_flip: true
  l_spin_flip_kernel: true

The l_spin_flip: True and l_spin_flip_kernel: True keywords specify that the code performs a spin-flip TDDFT calculation with the spin-flip kernel.

We run wbse.x.

[ ]:
%%bash
mpirun -n 4 wbse.x -i wbse_sf.in > wbse_sf.out

If the reader does NOT have the computational resources to run the calculation, the output file needed for the next step can be downloaded as:

[ ]:
%%bash
mkdir -p west.wbse.save
wget -N -q https://west-code.org/doc/training/nv_diamond_215/tddft/wbse_sf.json -O west.wbse.save/wbse_1.json

The calculated excitation energys (in Rydberg) can be found in a file named west.wbse.save/wbse_1.json.

[8]:
fname = "west.wbse.save/wbse_1.json"

with open(fname, "r") as f:
    j = json.load(f)

vees = np.array(j["exec"]["davitr"][-1]["ev"]) * Rydberg2eV

print("Vertical excitation energies (eV): ", vees)
Vertical excitation energies (eV):  [0.0909167  0.59940457 0.60064678 1.42054327]

The four singlet states are the \(m_S = 0\) sublevel of the \(^3A_2\) state, the doubly degenerate \(^1E\) states, and the \(^1A_1\) state.