.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/chaos/continuous_systems/plot_rossler_attractor.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_continuous_systems_plot_rossler_attractor.py: Rossler Attractor ================= The Rossler system is three coupled nonlinear autonomous ODEs, deliberately designed to be simpler than Lorenz while still chaotic: .. math:: \dot{x} &= -y - z \\ \dot{y} &= x + a y \\ \dot{z} &= b + z (x - c) It produces a simpler-looking, ribbon-like strange attractor than Lorenz, built from a single stretch-and-fold mechanism: trajectories spiral outward in the :math:`(x, y)` plane (driven by the linear :math:`-y-z` and :math:`x+ay` terms) until :math:`x` exceeds :math:`c`, at which point the :math:`z (x - c)` term kicks the trajectory up and folds it back down onto the spiral. This example integrates a trajectory with :meth:`physicskit.chaos.systems.continuous.Rossler.trajectory` and plots it in 3D, using the classic chaotic parameters :math:`a=0.2`, :math:`b=0.2`, :math:`c=5.7`. .. GENERATED FROM PYTHON SOURCE LINES 24-32 .. code-block:: Python import matplotlib.pyplot as plt from physicskit.chaos.systems.continuous import Rossler from physicskit.chaos.visualizers.section import plot_poincare_map system = Rossler(a=0.2, b=0.2, c=5.7) .. GENERATED FROM PYTHON SOURCE LINES 33-35 Integrate --------- .. GENERATED FROM PYTHON SOURCE LINES 35-38 .. code-block:: Python t, states = system.trajectory(n_steps=40000, dt=0.02) states = states[1000:] .. GENERATED FROM PYTHON SOURCE LINES 39-41 Plot ---- .. GENERATED FROM PYTHON SOURCE LINES 41-51 .. code-block:: Python fig = plt.figure(figsize=(7, 6)) ax = fig.add_subplot(projection="3d") ax.plot(states[:, 0], states[:, 1], states[:, 2], lw=0.4, color="teal") ax.set_xlabel("x") ax.set_ylabel("y") ax.set_zlabel("z") ax.set_title("Rossler attractor") plt.show() .. image-sg:: /api/gallery/chaos/continuous_systems/images/sphx_glr_plot_rossler_attractor_001.png :alt: Rossler attractor :srcset: /api/gallery/chaos/continuous_systems/images/sphx_glr_plot_rossler_attractor_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 52-63 Poincare section: the stretch-and-fold mechanism, laid bare ------------------------------------------------------------------ Sampling the flow only at the instants it crosses the plane :math:`y = 0` moving outward (:math:`\dot{y} > 0`) -- the natural section for a spiral that winds around the :math:`z`-axis -- turns the ribbon-like 3D attractor into a near-one-dimensional curve of successive crossings' :math:`(x, z)`. That the points collapse almost onto a single folded curve (rather than filling a 2D patch) is the direct visual signature of the single stretch-and-fold mechanism described above: each pass around the spiral maps an interval of :math:`x` values into a slightly different, folded-over interval, iteration after iteration. .. GENERATED FROM PYTHON SOURCE LINES 63-79 .. code-block:: Python fig2, ax2 = plot_poincare_map( system, system.initial_state(), coord=1, value=0.0, direction=1.0, plot_coords=(0, 2), t_max=400.0, dt=0.005, s=4, ) ax2.set_xlabel("x") ax2.set_ylabel("z") ax2.set_title("Rossler Poincare section at y = 0 (ascending)") plt.show() .. image-sg:: /api/gallery/chaos/continuous_systems/images/sphx_glr_plot_rossler_attractor_002.png :alt: Rossler Poincare section at y = 0 (ascending) :srcset: /api/gallery/chaos/continuous_systems/images/sphx_glr_plot_rossler_attractor_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.084 seconds) .. _sphx_glr_download_api_gallery_chaos_continuous_systems_plot_rossler_attractor.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_rossler_attractor.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_rossler_attractor.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_rossler_attractor.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_