gigablochs.animation.bloch_sphere#
- gigablochs.animation.bloch_sphere(magnetization, B_field=None, time_increments=0.1, speed=None, traces=('magnetization', 'B_field_projection'), engine='manim-cairo', prologue=True, preview=True, quality='low_quality', progress_bar='display', max_files_cached=1000, max_width=85, **kwargs)[source]#
Animate magnetization and B-field vectors on a Bloch sphere.
This function creates a 3D animation of magnetization evolving on the Bloch sphere, optionally showing the magnetic field and various traces.
- Parameters:
magnetization (array_like) – Magnetization vectors to animate. Should be an array of shape (N, 3) where N is the number of time points and the last dimension contains the (x, y, z) components.
B_field (array_like, optional) – Magnetic field vectors corresponding to the magnetization. Should have the same shape as magnetization. If provided, the field will be rescaled. Default is None, and no field vector is displayed.
time_increments (float or array_like, optional) – Time increment(s) between consecutive frames. If scalar, the same increment is used for all time points. If array, should match the time dimension of magnetization. Default is 0.1.
speed (float or array_like, optional) – Playback speed multiplier relative to real time, for informational display only. Default is None.
traces (tuple of str, optional) – Trace types to display in the animation. Traces are either the projection of arrow tips onto the surface of the Bloch Sphere (ending in
_projection) or the 3D historical trajectory of the arrow tips in space, which can be useful to show when a vector has a smaller magnitude. Options include ‘magnetization’, ‘B_field’, and their ‘_projection’s. Default is (‘magnetization’, ‘B_field_projection’).engine (str, optional) – Animation engine to use. Currently only ‘manim-cairo’ is supported. Default is ‘manim-cairo’.
prologue (bool, optional) – Whether to include a prologue sequence in the animation which displays the definition of magnetization and B-field vectors, along with the max B-field amplitude and animaton speed relative to real time. Default is True.
preview (bool, optional) – Whether to preview the animation after rendering. When running in a Jupyter notebook environment, the animation is embedded and displayed as output. Default is True.
quality (str, optional) – Rendering quality. Options include ‘low_quality’, ‘medium_quality’, ‘high_quality’, etc. Default is ‘low_quality’ since it takes significantly less time to render. Once you are happy with the animation, you can re-render at higher quality for hours to produce high definition production quality visuals.
progress_bar (str, optional) – Progress bar display mode. Default is ‘display’.
max_files_cached (int, optional) – Maximum number of cached files for the rendering engine. Default is 1000 as there’s many little files for each rotation time step.
max_width (int, optional) – Maximum width percentage for video display in notebooks. Default is 85.
**kwargs (dict, optional) – Additional keyword arguments passed to the manim configuration.
Notes
Raw Bloch simulation time history signals can be quite large, so consider downsampling the magnetization and B-field signals before passing to this function, but be wary to preserve the key frequency content of the signal and avoid downsampling too far - always inspect your data.
See also
manim.ThreeDSceneBase class for creating 3D scenes in Manim.
manim.Arrow3D3D arrow object in Manim.
manim.TracedPathTrace the path of a moving object in Manim.
downsampleResample time-domain signals via Fourier or filtering methods.
gigablochs.backends.manim_cairo.BlochSceneManim Cairo backend for Bloch sphere animations.