CTRL+C to copy, CTRL-V to paste
2
@author: yacine.mezemate
6
from scipy.integrate import odeint
7
import matplotlib.pyplot as plt
14
x0 = np.array([theta0, omega0])
15
t = np.linspace(0,pi*2,100)
17
global k, damping_force
21
def SystemEquation((x1,x2), t0):
23
return [x2, -k*sin(x1) -damping_force*x1]
27
x_t = odeint(SystemEquation, x0, t)
31
plt.ylabel(r"$\theta$", fontsize=18)
32
plt.xlabel(r"time", fontsize=18)
36
plt.plot(x_t[:,1], x_t[:,0])
37
plt.ylabel(r"$\dot{\theta}$", fontsize=18)
38
plt.xlabel(r"$\theta$", fontsize=18)
"""
@author: yacine.mezemate
"""
import numpy as np
from math import *
from scipy.integrate import odeint
import matplotlib.pyplot as plt
g = 9.81
L = 1
theta0 = (10*2*pi)/360
omega0 = 5*2*pi/360
x0 = np.array([theta0, omega0])
t = np.linspace(0,pi*2,100)
global k, damping_force
damping_force = 0
k = g*L
def SystemEquation((x1,x2), t0):
return [x2, -k*sin(x1) -damping_force*x1]
x_t = odeint(SystemEquation, x0, t)
plt.figure(1)
plt.plot(t,x_t[:,0])
plt.ylabel(r"$\theta$", fontsize=18)
plt.xlabel(r"time", fontsize=18)
plt.show()
plt.figure(2)
plt.plot(x_t[:,1], x_t[:,0])
plt.ylabel(r"$\dot{\theta}$", fontsize=18)
plt.xlabel(r"$\theta$", fontsize=18)
plt.show()