PLUGINS/LOCAL POTENTIAL: Difference between revisions

From VASP Wiki
(Created page with "{{TAGDEF|MYTAG|-1 {{!}} 0 {{!}} 1}} {{DEF|MYTAG|0|for VASP.X.X and older|1|else (if {{TAG|MYTAG}} is not set)}} Description: {{TAG|MYTAG}} sets/selects ... ---- Describe the general function of this tag and introduce all acronyms, symbols, or formulas required to understand multiple tag options. The details of the tag options are discussed below. If an abbreviation, e.g., PAW, is used in many articles, link it to the main article or category. Otherwise, the acronym shou...")
 
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TAGDEF|MYTAG|-1 {{!}} 0 {{!}} 1}}
{{DISPLAYTITLE:PLUGINS/LOCAL_POTENTIAL}}
{{DEF|MYTAG|0|for VASP.X.X and older|1|else (if {{TAG|MYTAG}} is not set)}}
{{TAGDEF|PLUGINS/LOCAL_POTENTIAL| .True. {{!}} .False.|.False.}}


Description: {{TAG|MYTAG}} sets/selects ...
Description: {{TAG|PLUGINS/LOCAL_POTENTIAL}} calls the Python plugin for the local potential interface for each SCF step
----
----
Describe the general function of this tag and introduce all acronyms, symbols, or formulas required to understand multiple tag options. The details of the tag options are discussed below. If an abbreviation, e.g., PAW, is used in many articles, link it to the main article or category. Otherwise, the acronym should be explained in a nutshell.
{{NB| mind | Pay attention to ''common pitfall'' and the interplay with {{TAG|MYOTHER}}.}}
==First section==


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


*{{TAG|MYTAG}}=-1: Algorithm name 
==Expected inputs==
{{NB| deprecated | This functionality is not supported in VASP version > 5.4.4.|:}}
:A concise description of this algorithm. A long description deserves an overview article. 


*{{TAG|MYTAG}}=0: Algorithm name
The <code>local_potential</code> Python function expects the following inputs,
:A concise description of this algorithm. A long description deserves an overview article.
<syntaxhighlight lang="python" line>
{{NB| warning | Do not combine with ...|:}}
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].
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
    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
</syntaxhighlight>
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</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.
{{NB| mind | The dipole moment is provided only if {{TAG|LDIPOL}}{{=}}.TRUE.}}
The <code>additions</code> dataclass consists of the following modifiable outputs
<syntaxhighlight lang="python" line>
@dataclass
class AdditionsLocalPotential:
    total_energy: float
    total_potential: DoubleArray
</syntaxhighlight>


*{{TAG|MYTAG}}=1: Algorithm name
==Modifying quantities==
:You do not need to use a NB template everywhere, and it can be used anywhere before, after, and in between paragraphs.
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,
{{NB| tip | Do not combine with ...|:}}
<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}}


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


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}}
{{sc|PLUGINS/LOCAL_POTENTIAL|Examples|Examples that use this tag}}


::<math>
[[Category:INCAR tag]]
\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.
 
== Related tags and articles==
{{TAG|MYOTHER}},
{{TAG|MYTHIRD}}
 
{{sc|MYTAG|Examples|Examples that use this tag}}
 
== References ==
<references/>
----
[[The_VASP_Manual|Contents]]
 
<!-- Link to categories like this: [[Category:INCAR]][[Category:Electronic Minimization]]
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