🌍 Become a marimo ambassador!

Apply
103 / 103
Molecular Trajectory Animation

Molecular Trajectory Animation

by Pedro Juan Royo

Animate and record a vibrating water molecule with marimol's 3D structure viewer.

About this notebook

This notebook animates a vibrating water molecule and records the animation. Each frame moves the two hydrogen atoms and the oxygen atom through a symmetric stretch and bend, and stores the atom positions, the two O-H bond distances, and the H-O-H bond angle. The marimol library draws the molecule with its view_structure function.

The viewer shows the molecule as a ball-and-stick model and plays the trajectory. Controls above the viewer set the animation speed in frames per second, the background color, and whether the viewer draws atom labels and outlines. A timeline slider moves to any single frame. The viewer also includes a measuring tool and screenshot and video recording tools.

A panel below the viewer reacts to the current frame. It reads the frame index from the viewer and shows the frame number, the O-H1 bond distance, and the H-O-H angle for that frame. Move the timeline or play the animation and the panel updates.

Related notebooks