File: run_energy.py

package info (click to toggle)
votca 2025.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 132,420 kB
  • sloc: xml: 345,964; cpp: 80,067; python: 15,957; sh: 4,580; perl: 2,169; javascript: 202; makefile: 34
file content (37 lines) | stat: -rwxr-xr-x 1,040 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
"""Example to compute energies using XTP."""
from pyxtp import xtp, Visualization
from ase import Atoms

def run_energy(save_figure: bool = False):
    """Run energy workflow."""
    # define a molecule
    atoms = Atoms('CO', positions=([0,0,0],[1.4,0,0]))

    # define the calculator
    calc = xtp(nthreads=2)

    # change basis sets to a smaller one
    calc.options.dftpackage.basisset = 'def2-svp'
    calc.options.dftpackage.auxbasisset = 'aux-def2-svp'
    calc.options.logging_file = 'CO_energy.log'

    # attach the calculator
    atoms.calc = calc

    # run the calculations
    atoms.get_potential_energy()

    # only needed, if no run was performed but an existing HDF5 is read
    # atoms.read('pyvotca/examples/example.orb')

    # Getting the plotting functions
    viz = Visualization(atoms, save_figure=save_figure)
    # plotting QP corrections
    # viz.plot_qp_corrections()
    # plotting absorption spectrum
    viz.plot_absorption_gaussian()


if __name__ == "__main__":
    run_energy()