Question

In: Computer Science

python code: Create a phase plot of a damped driven pendulum using odeint. Show a graph...

python code: Create a phase plot of a damped driven pendulum using odeint. Show a graph of angle as a function of time and angular velocity as a function of angle. Show each step in the code.

Solutions

Expert Solution

Python Code :

import numpy as np
from scipy.integrate import odeint
import math
import matplotlib.pyplot as plt
#finding the differentiation
def differentiation(variables,time,a,b,c,d):
   x = variables[0]
   y = variables[1]
   dx = y
   dt = -(a/d)*y-c*math.sin(x)
   dx_dt =[dx,dt]
   return dx_dt
#input data
a=0.05
b=9.81
c=1
d=1
#initial condition
initial = [0,3]
#plot the time
time = np.linspace(0,20,240)

data = odeint(differentiation,initial,time,args = (a,b,c,d))
#creating the
name=1
for i in range(0,240):
   name_of_file = str(name)+'.png'
   name= name+1
   plt.figure()
   plt.plot([10,c*math.sin(data[i,0])+10],[10,10-c*math.cos(data[i,
   0])],marker="o")
   plt.xlim([0,20])
   plt.ylim([0,20])
   plt.savefig(name_of_file)
plt.plot(time,data[:,0],'b-')
plt.plot(time,data[:,1],'r--')
plt.show()

You will 240 images as output.Few are given below.FInal output will be in final image ie.., 240.png

output 1 :

output 2 :

output 3 :

Output 4 :

Output5 :

Final ouput :


Related Solutions

"Using Python, code to find the smallest and largest planet mass (if known), and plot these...
"Using Python, code to find the smallest and largest planet mass (if known), and plot these as two curves against the year of discovery" Basically looking to use data from an excel sheet where 'disc_year' and 'pl_mass' are columns of data; and code Python to find the maximum value of mass and the minimum value of mass for each year, then plot this as two curves. There are multiple planets for any given year hence multiple values for mass. Below...
(a) Using the root locus plot shown in figure Q2 (a), find the system damped natural...
(a) Using the root locus plot shown in figure Q2 (a), find the system damped natural frequency ( d) when the system is marginally stable, then find the maximum gain for stable system. [5 Marks ] (b) Using the Root locus plot shown in figure Q2 (a), determine the open loop transfer function. [ 5 Marks ] Figure Q2 (a) open-loop Transfer function Root Locus Plot (c) G(s) is an open loop system transfer functions that include an adjustable gain...
This is using Python, it is utilizing code from a Fraction class to create a Binary...
This is using Python, it is utilizing code from a Fraction class to create a Binary Class Please leave comments so I may be able to learn from this. Instruction for Binary Class: Exercise 6.18: Design an immutable class BinaryNumber, in the style of our Fraction class. Internally, your only instance variable should be a text string that represents the binary value, of the form '1110100'. Implement a constructor that takes a string parameter that specifies the original binary value....
v Create a graph (either a histogram, box plot or stem and leaf plot … pick...
v Create a graph (either a histogram, box plot or stem and leaf plot … pick just one). Your graph could have either 5, 6 or 7 classes, depending on how you set it up. Create a table and list the class boundaries and the frequency in each class. You must explain to me in detail if you used fewer than 5 classes or more than 7 classes.
Create the following 3D plot in boxed format using MAPLE. Include a title and the code...
Create the following 3D plot in boxed format using MAPLE. Include a title and the code for the plot in the same page. -A pair of concentric cylinders about the z axis, with a height of 7.
Create the following 3D plot in boxed format using MAPLE. Include a title and the code...
Create the following 3D plot in boxed format using MAPLE. Include a title and the code for the plot in the same page. -3 spheres of radius 5 centered at (0,-8,0) , (0,8,0) and (0,0,0)
The following code must be written using matlab Create a contour plot of the following function...
The following code must be written using matlab Create a contour plot of the following function f(x,y) = (x+y^2-10)^2 +(x^2+y^2+8) in range [-6,6] for both x and y Clearly indicate in the plot the coordinates of the minimum ponts and the the corresponding function values in these points
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2....
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2. How do you graph a zero 3.How do you graph a pole at origin(what does that mean) 4. How do you graph a zero at origin. Please illustrate 1-4 on a graph. indicating which is which please
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2....
How do you Plot a Bode Phase Plot 1. how do you graph a pole 2. How do you graph a zero 3.How do you graph a pole at origin(what does that mean) 4. How do you graph a zero at origin. Please illustrate 1-4 on a graph. indicating which is which please
Using Python code create a program only with beginners code. You are taking online reservations at...
Using Python code create a program only with beginners code. You are taking online reservations at the The inn Ask for your client’s name and save in a variable Ask how many nights your client will be staying and save in a variable Room rental is $145 per night Sales tax is 8.5% Habitation tax is $5 per night (not subject to sales tax) Print out: Client’s name Room rate per night Number of nights Room cost (room rate *...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT