velocity

py4vasp.calculation.velocity

(*args, **kwargs)

The velocities describe the ionic motion during an MD simulation.

The velocities of the ions are a metric for the temperature of the system. Most of the time, it is not necessary to consider them explicitly. VASP will set the velocities automatically according to the temperature settings (TEBEG and TEEND) unless you set them explicitly in the POSCAR file. Since the velocities are not something you typically need, VASP will only store them during the simulation if you set VELOCITY = T in the INCAR file. In that case you can read the velocities of each step along the trajectory.

Examples

Let us create some example data so that we can illustrate how to use this class. Of course you can also use your own VASP calculation data if you have it available.

>>> from py4vasp import demo
>>> calculation = demo.calculation(path)

If you access the velocities, the result will depend on the steps that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calculation.velocity.number_steps()
1

To select the results for all steps, you don’t specify the array boundaries.

>>> calculation.velocity[:].number_steps()
4

You can also select specific steps or a subset of steps as follows

>>> calculation.velocity[3].number_steps()
1
>>> calculation.velocity[1:4].number_steps()
3

number_steps

()
Return the number of velocities in the trajectory.

path

Returns the path from which the output is obtained.

plot

(*args, **kwargs) → View

Wrapper around to_view() method.

This method will visualize the quantity in the structure. Please refer to the to_view() method for a documentation of the allowed arguments.

Returns

View
A visualization of the quantity within the crystal structure.

print

()
Print a string representation of this instance.

read

(*args, **kwargs)
Convenient wrapper around to_dict. Check that function for examples and optional arguments.

selections

() → dict

Returns possible alternatives for this particular quantity VASP can produce.

The returned dictionary contains a single item with the name of the quantity mapping to all possible selections. Each of these selection may be passed to other functions of this quantity to select which output of VASP is used. Some quantities provide additional elements which can be passed as selection for other routines.

Returns

dict
The key indicates this quantity and the values possible choices for arguments to other functions of this quantity.

to_dict

() → dict

Return the structure and ion velocities in a dictionary

Returns

dict
The dictionary contains the ion velocities as well as the structural information for reference.

Examples

First, we create some example data so that we can illustrate how to use this method. You can also use your own VASP calculation data if you have it available.

>>> from py4vasp import demo
>>> calculation = demo.calculation(path)

If you use the to_dict method, the result will depend on the steps that you selected with the [] operator. Without any selection the results from the final step will be used. The structure is included to provide the necessary context for the velocities.

>>> calculation.velocity.to_dict()
{'structure': {...}, 'velocities': array([[...]])}

To select the results for all steps, you don’t specify the array boundaries. Notice that in this case the velocities contain an additional dimension for the different steps.

>>> calculation.velocity[:].to_dict()
{'structure': {...}, 'velocities': array([[[...]]])}

You can also select specific steps or a subset of steps as follows

>>> calculation.velocity[1].to_dict()
{'structure': {...}, 'velocities': array([[...]])}
>>> calculation.velocity[0:2].to_dict()
{'structure': {...}, 'velocities': array([[[...]]])}

to_ngl

(*args, **kwargs) → NGLWidget

Convert the view to an NGL widget.

This method wraps the to_view() method and converts the resulting View to an NGL widget. The to_view() method documents all the possible arguments of this function.

Returns

NGLWidget
A widget to display the structure and other quantities in the unit cell.

to_numpy

() → ndarray

Convert the ion velocities for the selected steps into a numpy array.

The velocities are given in units of Å/fs.

Returns

ndarray
A numpy array of the velocities of the selected steps.

Examples

First, we create some example data so that we can illustrate how to use this method. You can also use your own VASP calculation data if you have it available.

>>> from py4vasp import demo
>>> calculation = demo.calculation(path)

If you use the to_numpy method, the result will depend on the steps that you selected with the [] operator. Without any selection the results from the final step will be used. The structure is included to provide the necessary context for the velocities.

>>> calculation.velocity.to_numpy()
array([[...]])

To select the results for all steps, you don’t specify the array boundaries. Notice that in this case the velocities contain an additional dimension for the different steps.

>>> calculation.velocity[:].to_numpy()
array([[[...]]])

You can also select specific steps or a subset of steps as follows

>>> calculation.velocity[1].to_numpy()
array([[...]])
>>> calculation.velocity[0:2].to_numpy()
array([[[...], [...]]])

to_vasp_viewer

(*args, **kwargs) → VASPViewerWidget

Convert the view to a VASP Viewer widget.

This method wraps the to_view() method and converts the resulting View to a VASP Viewer widget. The to_view() method documents all the possible arguments of this function.

Returns

VASPViewerWidget
A widget to display the structure and other quantities in the unit cell.

to_view

(supercell: int | np.ndarray = None) → View

Plot the velocities as vectors in the structure.

This method adds arrows to the atoms in the structure sized according to the size of the velocity. The length of the arrows is scaled by a constant velocity_rescale to convert from Å/fs to a length in Å.

Parameters

supercell: int | np.ndarray = None
If present the structure is replicated the specified number of times along each direction.

Returns

View
Contains all atoms and the velocities are drawn as vectors.

Examples

First, we create some example data so that we can illustrate how to use this method. You can also use your own VASP calculation data if you have it available.

>>> from py4vasp import demo
>>> calculation = demo.calculation(path)

If you use the to_view method, the result will depend on the steps that you selected with the [] operator. Without any selection the results from the final step will be used.

>>> calculation.velocity.to_view()
View(..., ion_arrows=[IonArrow(quantity=array([[...]]), label='velocities', ...)], ...)

To select the results for all steps, you don’t specify the array boundaries.

>>> calculation.velocity[:].to_view()
View(..., ion_arrows=[IonArrow(quantity=array([[[...]]]), label='velocities', ...)], ...)

You can also select specific steps or a subset of steps as follows

>>> calculation.velocity[1].to_view()
View(..., ion_arrows=[IonArrow(quantity=array([[...]]), label='velocities', ...)], ...)
>>> calculation.velocity[0:2].to_view()
View(..., ion_arrows=[IonArrow(quantity=array([[[...], [...]]]), label='velocities', ...)], ...)

You may also replicate the structure by specifying a supercell.

>>> calculation.velocity.to_view(supercell=2)
View(..., supercell=array([2, 2, 2]), ...)

The supercell size can also be different for the different directions.

>>> calculation.velocity.to_view(supercell=[2,3,1])
View(..., supercell=array([2, 3, 1]), ...)