Example 5 — Pyrene dimer dissociation: DFTB vs DFTB-CI
Pyrene dimer dissociation profile: DFTB vs DFTB-CI. A cationic pyrene dimer, stacked along z, is pulled apart: the energy of the dimer is computed with plain DFTB and with DFTB-CI at each inter-ring distance. The CI recovers the inter-ring interaction missed by plain DFTB.
Prerequisites: a deMonNano installation + global.json (see the
DeMonNanoPy Quickstart page).
Run with:
python3 example_ci.py
7 distances by default, 2 runs each.
The code below is the full script, split by part. Runnable version: demonnano/examples/example_ci.py.
Setup
Pyrene dimer dissociation profile: DFTB vs DFTB-CI. A cationic pyrene dimer, stacked along z, is pulled apart: the energy of the dimer is computed with plain DFTB and with DFTB-CI at each inter-ring distance. base_parameters uses the MAT basis and activates SCC-DFTB with the London dispersion correction (DISP=2) and Fermi smearing (FERMI=10) for a cationic molecule (CHARGE: 1.0); positions holds the 26 atoms of one pyrene.
"""Pyrene dimer dissociation profile: DFTB vs DFTB-CI.
A cationic pyrene dimer, stacked along z, is pulled apart: the energy of the
dimer is computed with plain DFTB and with DFTB-CI at each inter-ring
distance. The CI recovers the inter-ring interaction missed by plain DFTB.
Run with:
python3 example_ci.py
Requires a deMonNano installation and a global.json file (see the
DeMonNanoPy README).
"""
import copy
import ase
import matplotlib.pyplot as plt
import numpy as np
from ase import Atoms
import deMonPy
from deMonPy.deMonNano import deMonNano
deMonPy.configure_from_file("global.json")
base_parameters = {
"DEMON_EXECUTABLE": deMonPy.DEMON_EXECUTABLE,
"BASIS": {"PTYPE": "MAT", "SKFILE": deMonPy.DEMON_BASIS},
"DEMON_PARAMETERS": {
"ACTIVE": {
"DFTB": {"SCC": True, "DISP": 2, "FERMI": 10},
"CHARGE": 1.0,
},
},
}
WORKDIR = ".run/example-ci"
positions = np.array(
[
[0.713108, 0.000000, 0.000000],
[-0.713108, 0.000000, 0.000000],
[1.427512, 1.232835, 0.000000],
[-1.427512, 1.232835, 0.000000],
[-1.427512, -1.232835, 0.00000],
[1.427512, -1.232835, 0.000000],
[2.831510, 1.208118, 0.000000],
[-2.831510, 1.208118, 0.000000],
[-2.831510, -1.208118, 0.00000],
[2.831510, -1.208118, 0.000000],
[0.680302, 2.459268, 0.000000],
[-0.680302, 2.459268, 0.0000000],
[-0.680302, -2.459268, 0.00000],
[0.680302, -2.459268, 0.0000000],
[3.520334, 0.000000, 0.000000],
[-3.520334, 0.000000, 0.000000],
[4.622312, 0.000000, 0.000000],
[-4.622312, 0.000000, 0.000000],
[-3.392693, 2.156285, 0.000000],
[-3.392693, -2.156285, 0.000000],
[3.392693, -2.156285, 0.0000008],
[3.392693, 2.156285, 0.000000],
[1.230247, 3.414570, 0.000000],
[-1.230247, -3.41457, 0.00000],
[1.230247, -3.414570, 0.000000],
[-1.230247, 3.414570, 0.000000],
]
)
Dissociation sweep
Build the dimer, then at each inter-ring distance compute the energy with plain DFTB and with DFTB-CI. The DeMonNanoPy original sweeps 65 distances for the full profile. The dimer is two copies of the pyrene stacked along z; at each of the 7 distances (2.8-14.0 Angstrom), the z coordinate of the second pyrene is set and two runs are performed — plain DFTB with the C-H CM3 bond parameter, and DFTB-CI (SIZECI=2, the system cut into the two 26-atom fragments). The two energy series are collected in trace and ci.
def exemple_ci_pyrene(np_points=7):
atoms = Atoms(["C"] * 16 + ["H"] * 10, positions=positions)
tmp_atoms = atoms.copy()
tmp_atoms.positions[:, 2] = 3.4
images = [atoms + tmp_atoms]
parameter_config = copy.deepcopy(base_parameters)
parameter_config["DEMON_PARAMETERS"]["ACTIVE"].update(
{
"CM3": {
"BONDPARAMS": {"C H": 0.10},
},
"CI": {
"SIZECI": 2,
},
"CUTSYS": {"FRAGMENT": [26, 26]},
}
)
base_parameters2 = copy.deepcopy(base_parameters)
base_parameters2["DEMON_PARAMETERS"]["ACTIVE"].update(
{
"CM3": {
"BONDPARAMS": {"C H": 0.10},
},
}
)
dist, trace, ci = [], [], []
# The DeMonNanoPy original sweeps 65 distances for the full profile
for r_ in np.linspace(2.8, 14.0, np_points):
pyrenes = images[-1].copy()
pyrenes.positions[26:, 2] = r_
dist.append(r_)
dem = deMonNano(title="CALCULATION DEMONANO", workdir=WORKDIR, **base_parameters2)
dem.calculate(symbols=pyrenes.symbols, positions=pyrenes.positions)
energy = dem.results["energy"]
trace.append(energy["energy"])
dem = deMonNano(title="CALCULATION DEMONANO", workdir=WORKDIR, **parameter_config)
dem.calculate(symbols=pyrenes.symbols, positions=pyrenes.positions)
energy = dem.results["energy"]
ci.append(energy["energy"])
trace = np.array(trace)
ci = np.array(ci)
Plot
Plot the DFTB and DFTB-CI energy curves against the inter-ring distance and save the figure; the __main__ block runs the sweep with the default number of distances. Both curves are reported relative to the DFTB-CI energy at the largest distance, converted to eV, and the figure is saved as dissociation-profile.png.
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.plot(dist, (trace - ci[-1]) * ase.units.Hartree, color="black", label="DFTB")
ax.plot(dist, (ci - ci[-1]) * ase.units.Hartree, color="red", label="DFTB-CI")
ax.legend()
ax.set_xlabel("Distances (A)")
ax.set_ylabel("Energy (eV)")
fig.tight_layout()
fig.savefig("./dissociation-profile.png", dpi=150)
print("Figure : ./dissociation-profile.png")
if __name__ == "__main__":
exemple_ci_pyrene()
Summary
The script computes the dissociation profile of a cationic pyrene dimer stacked along z: at 7 inter-ring distances (2.8-14.0 Angstrom), two runs are performed each — plain DFTB and DFTB-CI — and the CI recovers the inter-ring interaction missed by plain DFTB. The two energy curves are plotted against the distance and saved as dissociation-profile.png.