# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.9.4  (''venv'': venv)'
#     name: pythonjvsc74a57bd0029e6aad1ff8cb3d45bc1be2fd738f58b8646c513dd680732ee28823f0a05190
# ---

import numpy as np
from scipy.integrate import  odeint
import matplotlib.pyplot as plt


# +
def eqs(z, t):
    r, th, dr, dth = z
    l = 1  # length of the pendulum suspend
    # added dumping to get finite ampl.
    # solutiion dows not depend on ampl. of source
    return [
        dr,
        dth,
        -0.04 * dr  - r    + l * dth**2 + 0.0001*np.cos(t),
        -0.01 * dth - th/4 - 2*dr*dth
    ]

Tmax = 3000
t = np.linspace(0,Tmax,int(20*Tmax))
sol = odeint(eqs, [0, 1e-8, 0, 0], t)

plt.subplot(2,1,1)
plt.plot(t,sol[:,0])
plt.subplot(2,1,2)
plt.plot(t,sol[:,1])
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered