.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/chaos/billiards/plot_truncated_circle_billiard.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_chaos_billiards_plot_truncated_circle_billiard.py: Truncated Circle Billiard (Mixed Phase Space) ============================================== A billiard particle moves in a straight line at constant speed inside a closed boundary and undergoes specular reflection, :math:`\mathbf{v}' = \mathbf{v} - 2(\mathbf{v}\cdot\mathbf{n})\,\mathbf{n}`, whenever it strikes the boundary. This billiard's boundary keeps the major arc of a circle of radius :math:`r`, :math:`x^2+y^2=r^2`, and closes it off with a straight chord at :math:`x = r - c`, where :math:`c` (``cut``) is how far the chord is cut in from the circle's edge. Slicing this flat chord off a circular billiard breaks integrability without making the system fully chaotic: depending on how large :math:`c` is, the Poincare section shows a mix of regular invariant curves (surviving islands near the untouched part of the circle) and a chaotic sea near the chord. This "mixed" behavior sits between the fully integrable Circle/Rectangle billiards and the fully chaotic Sinai/Stadium billiards. .. GENERATED FROM PYTHON SOURCE LINES 19-29 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.chaos.systems.billiards import TruncatedCircleBilliard from physicskit.chaos.visualizers.dynamic_plots import animate_billiard_trajectory from physicskit.chaos.visualizers.phase_space import plot_billiard_trajectory, plot_poincare_section billiard = TruncatedCircleBilliard(radius=1.0, cut=0.3) .. GENERATED FROM PYTHON SOURCE LINES 30-34 Animation --------- Watch for the ray alternating between long, regular runs around the untouched circular arc and short, erratic bounces near the flat chord. .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: Python anim = animate_billiard_trajectory(billiard, pos=billiard.sample_interior_point(), vel=(0.2, 1.0), n_bounces=100, interval=50) plt.show() .. container:: sphx-glr-animation .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 39-43 To save the animation to a file instead of (or in addition to) displaying it interactively, use e.g.:: anim.save("truncated_circle_billiard_animation.gif", writer="pillow", fps=25) .. GENERATED FROM PYTHON SOURCE LINES 45-47 Trajectory ---------- .. GENERATED FROM PYTHON SOURCE LINES 47-49 .. code-block:: Python fig, ax = plot_billiard_trajectory(billiard, pos=billiard.sample_interior_point(), vel=np.array([0.2, 1.0]), n_bounces=100) .. image-sg:: /api/gallery/chaos/billiards/images/sphx_glr_plot_truncated_circle_billiard_002.png :alt: TruncatedCircleBilliard trajectory :srcset: /api/gallery/chaos/billiards/images/sphx_glr_plot_truncated_circle_billiard_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 50-55 Poincare section ---------------- Look for a mix of smooth horizontal-ish bands (regular islands, inherited from the untouched circular arc) alongside a scattered chaotic sea (from rays that repeatedly strike near the flat chord). .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python fig, ax = plot_poincare_section(billiard, n_rays=40, n_bounces=200) plt.show() .. image-sg:: /api/gallery/chaos/billiards/images/sphx_glr_plot_truncated_circle_billiard_003.png :alt: TruncatedCircleBilliard Poincare section :srcset: /api/gallery/chaos/billiards/images/sphx_glr_plot_truncated_circle_billiard_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 60-73 Watching the mix change: a sweep over the cut depth --------------------------------------------------------- ``cut = 0.3`` above is just one point along a continuum from "barely truncated" to "truncated almost in half". Building a fresh :class:`~physicskit.chaos.systems.billiards.TruncatedCircleBilliard` at each of several `cut` values and plotting each one's Poincare section side by side (the same :func:`~physicskit.chaos.visualizers.phase_space.plot_poincare_section` used above, just swept) shows the regular-to-chaotic transition directly: a razor-thin chord leaves the section almost entirely covered by the circle's smooth invariant curves, with only a sliver of chaotic sea near ``sin(phi) = 0``; as the cut deepens, that chaotic sliver eats into more and more of the section, squeezing the surviving regular islands into thinner bands near the top and bottom. .. GENERATED FROM PYTHON SOURCE LINES 73-82 .. code-block:: Python cut_values = [0.02, 0.1, 0.3, 0.6] fig2, axes2 = plt.subplots(1, len(cut_values), figsize=(16, 4.5), sharey=True) for ax_i, cut in zip(axes2, cut_values): plot_poincare_section(TruncatedCircleBilliard(radius=1.0, cut=cut), n_rays=40, n_bounces=200, ax=ax_i, s=1.0, seed=0) ax_i.set_title(f"cut = {cut}") fig2.suptitle("Truncated circle: regular islands give way to chaotic sea as the cut deepens") fig2.tight_layout() plt.show() .. image-sg:: /api/gallery/chaos/billiards/images/sphx_glr_plot_truncated_circle_billiard_004.png :alt: Truncated circle: regular islands give way to chaotic sea as the cut deepens, cut = 0.02, cut = 0.1, cut = 0.3, cut = 0.6 :srcset: /api/gallery/chaos/billiards/images/sphx_glr_plot_truncated_circle_billiard_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 9.179 seconds) .. _sphx_glr_download_api_gallery_chaos_billiards_plot_truncated_circle_billiard.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_truncated_circle_billiard.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_truncated_circle_billiard.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_truncated_circle_billiard.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_