.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/ode_dynamics/chaotic_flows/plot_02_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_ode_dynamics_chaotic_flows_plot_02_rossler_attractor.py: The Rossler attractor =========================== Rossler's flow has a single nonlinear term, yet for :math:`a = b = 0.2`, :math:`c = 5.7` it settles onto a chaotic attractor: orbits spiral outward near the plane :math:`z \approx 0`, are lifted and folded back when :math:`x` exceeds :math:`c`, and never exactly repeat. Plotting each loop's maximum of :math:`x` against the previous one gives a Lorenz-style return map, a thin single-humped curve. .. GENERATED FROM PYTHON SOURCE LINES 14-26 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from mathematicskit.ode_dynamics.systems.chaotic_flows import RosslerSystem, rossler_fixed_points print("fixed points:\n", np.round(rossler_fixed_points(), 4)) system = RosslerSystem([1.0, 1.0, 0.0]) system.integrate((0.0, 100.0), dt=1e-2, method="rk4") traj = system.integrate((100.0, 1100.0), dt=1e-2, method="rk4") x, y, z = traj.y.T .. rst-class:: sphx-glr-script-out .. code-block:: none fixed points: [[ 7.00000e-03 -3.51000e-02 3.51000e-02] [ 5.69300e+00 -2.84649e+01 2.84649e+01]] .. GENERATED FROM PYTHON SOURCE LINES 27-29 The attractor and its return map -------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 29-46 .. code-block:: Python peaks = x[1:-1][(x[1:-1] > x[:-2]) & (x[1:-1] > x[2:])] fig = plt.figure(figsize=(11, 4.5)) ax3d = fig.add_subplot(1, 2, 1, projection="3d") ax3d.plot(x, y, z, lw=0.3) ax3d.set_xlabel("x") ax3d.set_ylabel("y") ax3d.set_zlabel("z") ax3d.set_title("Rossler attractor (a=b=0.2, c=5.7)") ax = fig.add_subplot(1, 2, 2) ax.plot(peaks[:-1], peaks[1:], ".", ms=3) ax.set_xlabel("x_max (n)") ax.set_ylabel("x_max (n+1)") ax.set_title("Return map of successive maxima") fig.tight_layout() plt.show() .. image-sg:: /api/gallery/ode_dynamics/chaotic_flows/images/sphx_glr_plot_02_rossler_attractor_001.png :alt: Rossler attractor (a=b=0.2, c=5.7), Return map of successive maxima :srcset: /api/gallery/ode_dynamics/chaotic_flows/images/sphx_glr_plot_02_rossler_attractor_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.309 seconds) .. _sphx_glr_download_api_gallery_ode_dynamics_chaotic_flows_plot_02_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_02_rossler_attractor.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_rossler_attractor.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_rossler_attractor.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_