PLUGINS/STRUCTURE: Difference between revisions

From VASP Wiki
 
(4 intermediate revisions by 2 users not shown)
Line 11: Line 11:
The <code>structure</code> Python function expects the following inputs,
The <code>structure</code> Python function expects the following inputs,
<syntaxhighlight lang="python" line>
<syntaxhighlight lang="python" line>
    def structure(constants, additions):
def structure(constants, additions):
</syntaxhighlight>
</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>
<syntaxhighlight lang="python" line>
number_ions: int
@dataclass(frozen=True)
number_ion_types: int
class ConstantsStructure:
ion_types: NDArray[np.int32]
    number_ions: int
atomic_numbers: NDArray[np.int32]
    number_ion_types: int
lattice_vectors: NDArray[np.float64]
    ion_types: IndexArray
positions: NDArray[np.float64]
    atomic_numbers: IntArray
{{TAGBL|POMASS}}: NDArray[np.float64]
    lattice_vectors: DoubleArray
total_energy: float
    positions: DoubleArray
forces: NDArray[np.float64]
    POMASS: DoubleArray
stress: NDArray[np.float64]
    total_energy: float
shape_grid: NDArray[np.float64]
    forces: DoubleArray
charge_density: NDArray[np.float64]
    stress: DoubleArray
    shape_grid: IntArray
    charge_density: DoubleArray
</syntaxhighlight>
</syntaxhighlight>
Note that the {{FILE|INCAR}} tags are capitalized.
Note that the {{FILE|INCAR}} tags are capitalized.
Line 36: Line 38:
<code>lattice_vectors</code> and <code>positions</code> contain the lattice vectors and positions of the current SCF step
<code>lattice_vectors</code> and <code>positions</code> contain the lattice vectors and positions of the current SCF step
<code>forces</code> and <code>stress</code> are the computed forces and stress tensor and <code>charge_density</code> contains the charge density on the real space grid. <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}} and <code>charge_density</code> is the charge density on this real space grid.
<code>forces</code> and <code>stress</code> are the computed forces and stress tensor and <code>charge_density</code> contains the charge density on the real space grid. <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}} and <code>charge_density</code> is the charge density on this real space grid.
The <code>additions</code> dataclass consists of the following modifiable outputs
The <code>additions</code> dataclass consists of the following modifiable outputs
<syntaxhighlight lang="python" line>
<syntaxhighlight lang="python" line>
lattice_vectors: NDArray[np.float64]
@dataclass
positions: NDArray[np.float64]
class AdditionsStructure:
    lattice_vectors: DoubleArray
    positions: DoubleArray
</syntaxhighlight>
</syntaxhighlight>


Line 48: Line 53:
     additions.positions += np.ones((constants.number_ions,3))
     additions.positions += np.ones((constants.number_ions,3))
</syntaxhighlight>
</syntaxhighlight>
{{NB| mind | You may not make modifications to quantities in <code>constants</code>}}
{{WARN_PLUGINS_CONSTANTS}}
 
== Related tags and articles ==
[[Plugins]],
{{TAG|PLUGINS/FORCE_AND_STRESS}},
{{TAG|PLUGINS/LOCAL_POTENTIAL}},
{{TAG|PLUGINS/MACHINE_LEARNING}}


----
{{sc|PLUGINS/STRUCTURE|Examples|Examples that use this tag}}
<!--[[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:21, 19 December 2024

PLUGINS/STRUCTURE = .True. | .False.
Default: PLUGINS/STRUCTURE = .False. 

Description: PLUGINS/STRUCTURE calls the Python plugin for the structure interface for each ionic relaxation step


When PLUGINS/STRUCTURE=.TRUE., VASP calls the structure Python function at the end of each ionic relaxation step. The primary use-case of this tag is to modify the structure based on the computed energy, force and stress tensor.

Expected inputs

The structure Python function expects the following inputs,

def structure(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 ConstantsStructure:
    number_ions: int
    number_ion_types: int
    ion_types: IndexArray
    atomic_numbers: IntArray
    lattice_vectors: DoubleArray
    positions: DoubleArray
    POMASS: DoubleArray
    total_energy: float
    forces: DoubleArray
    stress: DoubleArray
    shape_grid: IntArray
    charge_density: DoubleArray

Note that the INCAR tags are capitalized. 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 forces and stress are the computed forces and stress tensor and charge_density contains the charge density on the real space grid. shape_grid is a three dimensional integer array which stores the shape of the real space grid, NGXF, NGYF and NGZF and charge_density is the charge density on this real space grid.

The additions dataclass consists of the following modifiable outputs

@dataclass
class AdditionsStructure:
    lattice_vectors: DoubleArray
    positions: DoubleArray

Modifying quantities

Modify the quantities listed in additions by adding to them.

def structure(constants, additions)
    additions.positions += np.ones((constants.number_ions,3))
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/LOCAL_POTENTIAL, PLUGINS/MACHINE_LEARNING

Examples that use this tag