PLUGINS/LOCAL POTENTIAL: Difference between revisions

From VASP Wiki
No edit summary
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TAGDEF|PLUGINS/LOCAL_POTENTIAL| .TRUE. {{!}} .FALSE.}}
{{DISPLAYTITLE:PLUGINS/LOCAL_POTENTIAL}}
{{TAGDEF|PLUGINS/LOCAL_POTENTIAL| .True. {{!}} .False.|.False.}}


Description: {{TAG|PLUGINS/LOCAL_POTENTIAL}} calls the Python plugin for the local potential interface for each SCF step
Description: {{TAG|PLUGINS/LOCAL_POTENTIAL}} calls the Python plugin for the local potential interface for each SCF step
----
----


When {{TAG|PLUGINS/LOCAL_POTENTIAL}}=.TRUE., VASP calls the <code>local_potential</code> Python function.  
When {{TAG|PLUGINS/LOCAL_POTENTIAL}}=.TRUE., VASP calls the <code>local_potential</code> 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.
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==
==Expected inputs==


The <code>local_potential</code> Python function expects the following inputs,
The <code>local_potential</code> Python function expects the following inputs,
    def local_potential(constants, additions):
<syntaxhighlight lang="python" line>
def local_potential(constants, additions):
</syntaxhighlight>
where <code>constants</code> and <code>additions</code> and [https://docs.python.org/3/library/dataclasses.html Python dataclasses].
where <code>constants</code> and <code>additions</code> and [https://docs.python.org/3/library/dataclasses.html Python dataclasses].
The <code>constants</code> dataclass consists of the following inputs, listed here with their associated [https://numpy.org/doc/stable/user/basics.types.html datatypes]
The <code>constants</code> dataclass consists of the following inputs, listed here with their associated [https://numpy.org/doc/stable/user/basics.types.html datatypes]
<syntaxhighlight lang="python" line>
@dataclass(frozen=True)
class ConstantsLocalPotential:
     ENCUT: float
     ENCUT: float
     NELECT: float
     NELECT: float
     shape_grid: NDArray[np.int32]
     shape_grid: IntArray
     number_ions: int
     number_ions: int
     number_ion_types: int
     number_ion_types: int
     ion_types: NDArray[np.int32]
     ion_types: IndexArray
     atomic_numbers: NDArray[np.int32]
     atomic_numbers: IntArray
     lattice_vectors: NDArray[np.float64]
     lattice_vectors: DoubleArray
     positions: NDArray[np.float64]
     positions: DoubleArray
     ZVAL: NDArray[np.float64]
     ZVAL: DoubleArray
     charge_density: NDArray[np.float64]
     charge_density: Optional[DoubleArray] = None
     hartree_potential: NDArray[np.float64]
     hartree_potential: Optional[DoubleArray] = None
     ion_potential: NDArray[np.float64]
     ion_potential: Optional[DoubleArray] = None
     dipole_moment: NDArray[np.float64]
     dipole_moment: Optional[DoubleArray] = None
 
</syntaxhighlight>
{{NB| mind | The dipole moment is provided only if {{TAG|LDIPOL}}=.TRUE.}}
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,
If there are many tag options, making each option a heading may pay off. This way, the table of contents provides a good overview. However, for three options, the list below suffices.
<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,
*{{TAG|MYTAG}}=-1: Algorithm name 
<code>atomic_numbers</code> contains the atomic number for each atom type,
{{NB| deprecated | This functionality is not supported in VASP version > 5.4.4.|:}}
<code>lattice_vectors</code> and <code>positions</code> contain the lattice vectors and positions of the current SCF step
:A concise description of this algorithm. A long description deserves an overview article. 
<code>charge_density</code>,<code>hartree_potential</code>,<code>ion_potential</code> contains the charge density, the hartree potential and the ion potential respectively on the real space grid.
 
<code>dipole_moment</code> stores an array with three elements consisting of the dipole moment along x, y and z cartesian directions.
*{{TAG|MYTAG}}=0: Algorithm name
{{NB| mind | The dipole moment is provided only if {{TAG|LDIPOL}}{{=}}.TRUE.}}
:A concise description of this algorithm. A long description deserves an overview article. 
The <code>additions</code> dataclass consists of the following modifiable outputs
{{NB| warning | Do not combine with ...|:}}
<syntaxhighlight lang="python" line>
 
@dataclass
*{{TAG|MYTAG}}=1: Algorithm name
class AdditionsLocalPotential:
:You do not need to use a NB template everywhere, and it can be used anywhere before, after, and in between paragraphs.
    total_energy: float
{{NB| tip | Do not combine with ...|:}}
    total_potential: DoubleArray
 
</syntaxhighlight>
==Second section==
 
Give details about an issue that can arise here and offer some advice. The paragraph started with an indent. Add your references on '''Template:Cite''' and cite using a command like this{{cite|kresse:prb:96}}
 
::<math>
\tilde{P}(\xi_i)= \frac{\int  \delta\Big(\xi(q)-\xi_i\Big) \exp\left\{-\tilde{H}(q,p)/k_B\,T\right\} dq\,dp}{\int  \exp\left\{-\tilde{H}(q,p)/k_B\,T\right\}dq\,dp} = \langle\delta\Big(\xi(q)-\xi_i\Big)\rangle_{\tilde{H}},
</math>


where Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
==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,
<syntaxhighlight lang="python" line>
import numpy as np
def local_potential(constants, additions)
    additions.total_potential += np.ones(constants.shape_grid)
</syntaxhighlight>
{{WARN_PLUGINS_CONSTANTS}}


== Related tags and articles==
== Related tags and articles ==
{{TAG|MYOTHER}},
[[Plugins]],
{{TAG|MYTHIRD}}
{{TAG|PLUGINS/FORCE_AND_STRESS}},
{{TAG|PLUGINS/OCCUPANCIES}},
{{TAG|PLUGINS/STRUCTURE}}


{{sc|MYTAG|Examples|Examples that use this tag}}
{{sc|PLUGINS/LOCAL_POTENTIAL|Examples|Examples that use this tag}}
 
== References ==
<references/>
----
[[The_VASP_Manual|Contents]]


<!-- Link to categories like this: [[Category:INCAR]][[Category:Electronic Minimization]]
[[Category:INCAR tag]]
only comment it out when you want the page to show up on the category page, i.e., not when it is in the Construction namespace.-->

Latest revision as of 08:20, 19 December 2024

PLUGINS/LOCAL_POTENTIAL = .True. | .False.
Default: PLUGINS/LOCAL_POTENTIAL = .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. 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

@dataclass(frozen=True)
class ConstantsLocalPotential:
    ENCUT: float
    NELECT: float
    shape_grid: IntArray
    number_ions: int
    number_ion_types: int
    ion_types: IndexArray
    atomic_numbers: IntArray
    lattice_vectors: DoubleArray
    positions: DoubleArray
    ZVAL: DoubleArray
    charge_density: Optional[DoubleArray] = None
    hartree_potential: Optional[DoubleArray] = None
    ion_potential: Optional[DoubleArray] = None
    dipole_moment: Optional[DoubleArray] = None

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 respectively 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

@dataclass
class AdditionsLocalPotential:
    total_energy: float
    total_potential: DoubleArray

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)
Warning: You should not make modifications to quantities in constants. We implemented some safeguards to prevent accidental modifications. Intentional changes will lead to erratic behavior because we may change the VASP code assuming these quantities are constant.

Related tags and articles

Plugins, PLUGINS/FORCE_AND_STRESS, PLUGINS/OCCUPANCIES, PLUGINS/STRUCTURE

Examples that use this tag