.. _04_dft_calculations: .. include:: ../../examples/04_dft_calculations/README.rst ---- .. code-block:: python from eminus import Atoms, SCF Start by creating an :code:`Atoms` object for helium Use a very small :code:`ecut` for a fast calculation .. code-block:: python atoms = Atoms("He", [0, 0, 0], ecut=5) Optional parameters with examples are listed as follows Dictionary to set the maximum amount of steps per minimization method and their order Set it to a very small value for a short output .. code-block:: python opt = {"pccg": 5} The :code:`SCF` class only needs an :code:`Atoms` object, but only calculate 5 steps for less output .. code-block:: python print("First calculation:") SCF(atoms, opt=opt).run() Exchange-correlation functional description (case insensitive), separated by a comma .. code-block:: python xc = "lda,pw" The Libxc interface can be used by adding :code:`libxc:` before a functional (you can also neglect the :code:`libxc` part) Names and numbers can be used, and mixed with the internal functionals as well .. code-block:: python # xc = "libxc:LDA_X,:LDA_C_PW" # xc = "libxc:1,pw" Type of potential (case insensitive) .. code-block:: python pot = "gth" Initial guess method for the basis functions (case insensitive) Adding :code:`sym` to the string will use the same guess for all spin channels An unsymmetric guess will be used by default .. code-block:: python guess = "random" Convergence tolerance of the total energy .. code-block:: python etol = 1e-8 Convergence tolerance of the gradient norm .. code-block:: python gradtol = 1e-7 Calculate a self-interaction correction from the Kohn-Sham orbitals after an SCF calculation. .. code-block:: python sic = True Calculate a dispersion correction after an SCF calculation (need the dispersion extra). .. code-block:: python disp = False The amount of output can be controlled with the verbosity level By default the verbosity level of the :code:`Atoms` object will be used .. code-block:: python verbose = 4 Start a new calculation with new parameters .. code-block:: python print("\nSecond calculation with more output:") scf = SCF( atoms=atoms, xc=xc, pot=pot, guess=guess, etol=etol, gradtol=gradtol, opt=opt, sic=sic, disp=disp, verbose=verbose, ) Arguments for the minimizer can be passed through via the run function, e.g., for the conjugated-gradient form .. code-block:: python etot = scf.run(cgform=2) The total energy is a return value of the :code:`SCF.run` function, but it is saved in the :code:`SCF` object as well with all energy contributions .. code-block:: python print(f"\nEnergy from SCF function = {etot} Eh") print(f"\nEnergy in Atoms object:\n{scf.energies}") Download :download:`04_dft_calculations.py <../../examples/04_dft_calculations/04_dft_calculations.py>`