visualization
Visualization module.
After running calculations using the Simulation class, visualization
of the results is often desired. This module provides two classes for
plotting the simulation data. The Animation class creates an animated
three-dimensional plot of the complex-valued wave function alongside
the probability density. The Plot class creates a series of
two-dimensional plots for the recorded expectation values.
Examples:
Use the following commands to create an animation of data in a
directory simulation/. You have full control over figure and axes,
enabling you to set the figure size and the viewing angle for example.
>>> animation = Animation("simulation/")
>>> animation.fig.set_size_inches(10, 10)
>>> animation.ax.view_init(elev=50, azim=30)
>>> animation.animation.save("animation.mp4")
Run the following commands to create a series of plots of the
expectation values in a directory simulation/. Again, you can
customize the figure and axes to your liking. For example, you can
add vertical lines to indicate specific points in time or change the
color of specific lines.
>>> plot = Plot("simulation/")
>>> plot.axs["position"].axvline(x=5, linestyle="--")
>>> plot.lines["total_energy"].set_color("red")
>>> plot.fig.savefig("plot.png")
Animation
Helper class for animating simulation data.
Animates the time evolution of the complex-valued wave function and the real-valued probability density in a three-dimensional coordinate system. Additionally, the simulation time is displayed and the (rescaled) electrostatic potential is plotted as a guide for the eye.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory |
str or Path
|
Directory containing the simulation data. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
Matplotlib figure. |
ax |
Axes3D
|
Three-dimensional axes. |
lines |
dict[str, Line3D]
|
Dictionary of three-dimensional line artists. |
text |
Text
|
Matplotlib text artist. Displays the current time. |
animation |
FuncAnimation
|
Matplotlib animation object. |
Plot
Helper class for plotting expectation values.
Plots the expectation values of the total density, position, momentum, kinetic energy, potential energy, and total energy as functions of the simulation time. Each expectation value is displayed in a separate subplot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory |
str or Path
|
Directory containing the simulation data. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
Matplotlib figure. |
axs |
dict[str, Axes]
|
Dictionary of two-dimensional axes. |
lines |
list[Line2D]
|
Dictionary of two-dimensional line artists. |