stress

py4vasp.calculation.stress

(*args, **kwargs)

The stress describes the force acting on the shape of the unit cell.

The stress refers to the force applied to the cell per unit area. Specifically, VASP computes the stress for a given unit cell and relaxing to vanishing stress determines the predicted ground-state cell. The stress is 3 x 3 matrix; the trace indicates changes to the volume and the rest of the matrix changes the shape of the cell. You can impose an external stress with the tag PSTRESS.

When you relax the system or in a MD simulation, VASP computes and stores the stress in every iteration. You can use this class to read the stress for specific steps 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 stress, 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.stress.number_steps()
1

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

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

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

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

number_steps

()
Return the number of stress components in the trajectory.

path

Returns the path from which the output is obtained.

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

Read the stress and associated structural information for one or more selected steps of the trajectory.

Returns

dict
Contains the stress for all selected steps and the structural information to know on which cell the stress acts.

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 stress.

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

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

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

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

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