energy¶
The energy data for one or several steps of a relaxation or MD simulation.
You can use this class to inspect how the ionic relaxation converges or during an MD simulation whether the total energy is conserved. The total energy of the system is one of the most important results to analyze materials. Total energy differences of different atom arrangements reveal which structure is more stable. Even when the number of atoms are different between two systems, you may be able to compare the total energies by adding a corresponding amount of single atom energies. In this case, you need to double check the convergence because some error cancellation does not happen if the number of atoms is changes. Finally, monitoring the total energy can reveal insights about the stability of the thermostat.
Examples
If you access a method of this class, 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.energy.read()
To select the results for all steps, you don’t specify the array boundaries.
>>> calculation.energy[:].read()
You can also select specific steps or a subset of steps as follows
>>> calculation.energy[5].read()
>>> calculation.energy[1:6].read()
path
plot
Almost same as the to_graph() function.
All arguments will be passed to to_graph. If the to_graph() would
produce multiple graphs this method will merge them into a single one.
read
selections
dict[str, list[str]]
Return a dictionary describing what kind of energies are available.
Returns
dict[str, list[str]]- Dictionary containing available selection options with their possible values. Keys include the selection criteria “energy” and “component”.
to_csv
(
- *args,
- filename:
str | Path= None, - **kwargs
)
Writes the data to a csv file.
Writes out a csv file for data stored in a dataframe generated with
the to_frame() method. Useful for creating external plots
for further analysis.
If no filename is provided a default filename is deduced from the name of the class.
Note that the filename must be a keyword argument, i.e., you explicitly
need to write filename=”name_of_file” because the arguments are passed
on to the to_graph() method. Please check the documentation of that
method to learn which arguments are allowed.
Parameters
- filename:
str | Path= None - Name of the csv file which the data is exported to.
to_dict
str | None = None) → dict
Read the energy data and store it in a dictionary.
Parameters
- selection:
str | None= None - String specifying the labels of the energy to be read. If no energy is selected
this will default to selecting all energies. Separate distinct labels by commas or
whitespace. You can add or subtract different contributions e.g. TOTEN + EKIN.
For a complete list of all possible selections, please use
>>> calculation.energy.selections()
Returns
dict- Contains the exact labels corresponding to the selection and the associated energies for every selected ionic step.
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calculation.energy.to_dict()
To select the results for all steps, you don’t specify the array boundaries.
>>> calculation.energy[:].to_dict()
You can also select specific steps or a subset of steps as follows
>>> calculation.energy[5].to_dict()
>>> calculation.energy[1:6].to_dict()
to_frame
Dataframe
Convert data to pandas dataframe.
This will first convert use the to_graph() method to convert to a
Graph. All arguments are passed to that method. The resulting graph is then
converted to a dataframe.
Returns
Dataframe- Pandas dataframe corresponding to data in the graph
to_graph
str | None = ‘TOTEN’) → Graph
Read the energy data and generate a figure of the selected components.
Parameters
- selection:
str | None= ‘TOTEN’ - String specifying the labels of the energy to be read. If no energy is selected
this will default to selecting the total energy. Separate distinct labels by commas or
whitespace. You can add or subtract different contributions e.g. TOTEN + EKIN.
For a complete list of all possible selections, please use
>>> calculation.energy.selections()
Returns
Graph- figure containing the selected energies for every selected ionic step.
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calculation.energy.to_graph()
To select the results for all steps, you don’t specify the array boundaries.
>>> calculation.energy[:].to_graph()
You can also select specific steps or a subset of steps as follows
>>> calculation.energy[5].to_graph()
>>> calculation.energy[1:6].to_graph()
to_image
(
- *args,
- filename = None,
- **kwargs
)
Read the data and generate an image writing to the given filename.
The filetype is automatically deduced from the filename; possible are common raster (png, jpg) and vector (svg, pdf) formats. If no filename is provided a default filename is deduced from the name of the class and the picture has png format.
Note that the filename must be a keyword argument, i.e., you explicitly
need to write filename=”name_of_file” because the arguments are passed
on to the to_graph() method. Please check the documentation of that
method to learn which arguments are allowed.
to_numpy
str | None = ‘TOTEN’) → float or np.ndarray or tuple
Read the energy of the selected steps.
Parameters
- selection:
str | None= ‘TOTEN’ - String specifying the labels of the energy to be read. If no energy is selected
this will default to selecting the total energy. Separate distinct labels by commas or
whitespace. You can add or subtract different contributions e.g. TOTEN + EKIN.
For a complete list of all possible selections, please use
>>> calculation.energy.selections()
Returns
float or np.ndarray or tuple- Contains energies associated with the selection for the selected ionic step(s). When only a single step is inquired, result is a float otherwise an array. If you select multiple quantities a tuple of them is returned.
Examples
If you access this method, the result will depend on the steps of the class that you selected with the [] operator. Without any selection the results from the final step will be used.
>>> calculation.energy.to_numpy()
To select the results for all steps, you don’t specify the array boundaries.
>>> calculation.energy[:].to_numpy()
You can also select specific steps or a subset of steps as follows
>>> calculation.energy[5].to_numpy()
>>> calculation.energy[1:6].to_numpy()
to_plotly
Produces a graph and convertes it to a plotly figure.
The arguments to this function are passed on to the to_graph() method.
Takes the resulting graph and converts it to a plotly figure.