.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/ode_dynamics/limit_cycles/plot_01_van_der_pol.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_limit_cycles_plot_01_van_der_pol.py: The Van der Pol limit cycle ================================ Trajectories starting both inside and outside the eventual limit cycle converge onto the *same* closed orbit -- the defining property that distinguishes a limit cycle from a linear center (whose orbit amplitude is set entirely by the initial condition). .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import matplotlib.pyplot as plt from mathematicskit.ode_dynamics.systems.limit_cycles import VanDerPolOscillator, estimate_limit_cycle_amplitude from mathematicskit.ode_dynamics.visualizers.plots import plot_phase_portrait .. GENERATED FROM PYTHON SOURCE LINES 18-20 Trajectories from very different initial conditions converge ----------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 20-30 .. code-block:: Python fig, ax = plt.subplots(figsize=(6, 6)) for state0 in ([0.1, 0.0], [4.0, 0.0], [0.0, 3.0]): system = VanDerPolOscillator(state0, mu=1.0) traj = system.integrate((0.0, 30.0), dt=1e-3, method="rk4") plot_phase_portrait(traj, ax=ax, lw=0.8, label=f"start={state0}") ax.legend() ax.set_title("Van der Pol (mu=1): all orbits approach the same limit cycle") fig.tight_layout() .. image-sg:: /api/gallery/ode_dynamics/limit_cycles/images/sphx_glr_plot_01_van_der_pol_001.png :alt: Van der Pol (mu=1): all orbits approach the same limit cycle :srcset: /api/gallery/ode_dynamics/limit_cycles/images/sphx_glr_plot_01_van_der_pol_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 31-33 Amplitude is independent of mu's transient details -------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 33-39 .. code-block:: Python for mu in (0.5, 1.0, 2.0, 5.0): amp = estimate_limit_cycle_amplitude(mu=mu, t_transient=150.0, t_observe=40.0) print(f"mu={mu}: limit-cycle amplitude ~ {amp:.4f}") plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none mu=0.5: limit-cycle amplitude ~ 2.0025 mu=1.0: limit-cycle amplitude ~ 2.0086 mu=2.0: limit-cycle amplitude ~ 2.0199 mu=5.0: limit-cycle amplitude ~ 2.0215 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.067 seconds) .. _sphx_glr_download_api_gallery_ode_dynamics_limit_cycles_plot_01_van_der_pol.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_van_der_pol.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_van_der_pol.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_van_der_pol.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_