PLUGINS/LOCAL POTENTIAL: Difference between revisions

From VASP Wiki
No edit summary
Line 28: Line 28:
     ion_potential: NDArray[np.float64]
     ion_potential: NDArray[np.float64]
     dipole_moment: NDArray[np.float64]
     dipole_moment: NDArray[np.float64]
Note that the {{FILE|INCAR}} tags are capitalized.
<code>shape_grid</code> is a three dimensional integer array which stores the shape of the real space grid, {{TAG|NGXF}}, {{TAG|NGYF}} and {{TAG|NGZF}},
<code>number_ions</code> is the total number of ions listed in the {{FILE|POSCAR}} file,
<code>number_ion_types</code> is the number of ion corresponding to each ion type in the convention of the {{FILE|POSCAR}} file,
<code>ion_types</code> stores the total number of ion types,
<code>atomic_numbers</code> contains the atomic number for each atom type,
<code>lattice_vectors</code> and <code>positions</code> contain the lattice vectors and positions of the current SCF step.
<code>charge_density,hartree_potential,ion_potential</code> contains the charge density, the hartree potential and the ion potential on the real space grid.
<code>dipole_moment> stores an array with three elements consisting of the dipole moment along x, y and z cartesian directions.
{{NB| mind | The dipole moment is provided only if {{TAG|LDIPOL}}{{=}}.TRUE.}}
{{NB| mind | The dipole moment is provided only if {{TAG|LDIPOL}}{{=}}.TRUE.}}
The <code>additions</code> dataclass consists of the following modifiable outputs
The <code>additions</code> dataclass consists of the following modifiable outputs

Revision as of 07:51, 11 June 2024

PLUGINS/LOCAL_POTENTIAL = .TRUE. | .FALSE. 

Description: PLUGINS/LOCAL_POTENTIAL calls the Python plugin for the local potential interface for each SCF step


When PLUGINS/LOCAL_POTENTIAL=.TRUE., VASP calls the local_potential Python function at the end of each SCF step. See here for details on how to setup your Python script such that VASP can recognize it. The primary use-case of this tag is to add a quantity on the real space grid to the local potential and a scalar quantity to the total energy of a VASP calculation through a Python plugin.

Expected Inputs

The local_potential Python function expects the following inputs,

   def local_potential(constants, additions):

where constants and additions and Python dataclasses. The constants dataclass consists of the following inputs, listed here with their associated datatypes

   ENCUT: float
   NELECT: float
   shape_grid: NDArray[np.int32]
   number_ions: int
   number_ion_types: int
   ion_types: NDArray[np.int32]
   atomic_numbers: NDArray[np.int32]
   lattice_vectors: NDArray[np.float64]
   positions: NDArray[np.float64]
   ZVAL: NDArray[np.float64]
   charge_density: NDArray[np.float64]
   hartree_potential: NDArray[np.float64]
   ion_potential: NDArray[np.float64]
   dipole_moment: NDArray[np.float64]

Note that the INCAR tags are capitalized. shape_grid is a three dimensional integer array which stores the shape of the real space grid, NGXF, NGYF and NGZF, number_ions is the total number of ions listed in the POSCAR file, number_ion_types is the number of ion corresponding to each ion type in the convention of the POSCAR file, ion_types stores the total number of ion types, atomic_numbers contains the atomic number for each atom type, lattice_vectors and positions contain the lattice vectors and positions of the current SCF step. charge_density,hartree_potential,ion_potential contains the charge density, the hartree potential and the ion potential on the real space grid. dipole_moment> stores an array with three elements consisting of the dipole moment along x, y and z cartesian directions.

Mind: The dipole moment is provided only if LDIPOL=.TRUE.

The additions dataclass consists of the following modifiable outputs

   total_energy: float
   total_potential: NDArray[np.float64]

Modifying quantities

Modify the quantities listed in additions by adding to them. For example, if you wanted to add one to every real space local potential grid point,

   import numpy as np
   def local_potential(constants, additions)
       additions.total_potential += np.ones(constants.shape_grid)
Mind: You may not make modifications to quantities in constants