Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm looking for help with part 4 of the assignment. I have attached photos of my current code but it doesn't seem to be working.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

I'm looking for help with part 4 of the assignment. I have attached photos of my current code but it doesn't seem to be working. I am getting the following as a graph but I don't think it looks right.

image text in transcribed

Can you help?

A pendulum consisting of a mass connected by a string with length l is to a fixed point on a support, such as a ceiling. Considering that the pendulum has some friction, external forces, and large swing angles (nonlinear), the motion of equation is given by dt2d2=l8sinqdtd+FDsin(Dt) Use the code provided in class as a template to study the following problems with the EulerCromer or Verlet method. 1. (10 points) Algorithm: Describe the algorithm you choose to use. Write out the related formula in finite difference form for the derivative terms. (you can use Word to do this part) 2. (30 points) With parameters q=0.5,l=g=9.8,D=2/3,dt=0.04,(0)=0, and (0)=0.2, write a program to calculate (t) and the total energy of the system E(t) for FD=0.1,0.5, and 1.2. Setting tend=100, plot (t) and E(t) and discuss the results. Pay attention to the deviations from a purely sinusoidal form at high drive. 3. (15 points) Within your program, plot the angular velocity as a function of for FD= 0.5 and 1.2 with other parameters as in part 2. Briefly discuss results. 4. (15 points) Setting tend=10000, plot the angular velocity as a function of for FD=0.5 and 1.2 only at times that were in phase with the drive force; that is, at times t=2n/D, where n is an integer. This kind of plot is known as Poincare section, where the drawn trajectory is called as an attractor. Discuss the result, especially the difference between FD=0.5 and FD=1.2 \# Calculate theta(t), omega(t), and E(t) using the Verlet method if type =0 : for i in range(1, nsteps): \# Update position theta[i] = theta[i-1] + omega[i-1]*dt +0.5qnp.sin( theta[i-1])*dt**21 + Fadrive(i"dt, FD)"dtw* 2 \# Update velocity onega[i] = omega[i-1] +0.5dt(qnpsin( theta[i]) +qnpsin( theta[i-1]) 1 - g/1 *theta[i-1]) +Fddrive(idt,FP)dt \# Update energy E total[i] = E(theta[i], omega[i]) \# Update time r[3]=s*dt print(F_drive(itwt, FD)) if FD=0.1: return(theta, t, E_total) if FD=0.5 or 1.2: return(theta, omega, t, E_total) if type =1: for i in range( 1, nsteps ) : t[i]=idt if t[i](2nppi/OmD)=0 : \# Update position theta[i] = theta[i-1] + omega[i-1]*dt +0.5qnp.sin(t theta[i-1] ]dt21 + F_drive(i*dt, FD)*dt**2 \# Update velocity omega[i] = omega[i-1] +0.5dt(qnp.sin( theta[i] )+qnpsin(theta[i1]) g/1 theta[i-1]) +Fdrive(idt,FD)dt \# Update energy Etotal[i] =E( theta[i], omega[i]) else: theta[i] = theta[i-1] plt.plot (t, theta12, label =FD=1.2) plt.xlabel ('Time (s)') plt.ylabel( 'Angle (rad)') plt.title('Angle us. Time, FD={i.25}) plt. legend() plt.subplot (2,2,2) plt.plot(t, energyer, label =FD=0.1) plt. plot(t, energye5, label = " FD=0.5) plt.plot(t, energy12, label = FD=1.2) plt. slabel ('Time (s)') plt.ylabel('Total Energy (J)') plt.title( 'Total Energy us. Time, FD={.1f}) plt.tight_layout() plt. legend() plt.show() plt.plot (theta05, omega05, label ==FD=0.5 ) plt.plot (theta12, omega12, label=' FD=1.2 ) plt.xlabel ('Angle (rad)') plt.ylabel ('Angular Velocity (rad/s)') plt.title('Angular Velocity vs. Angle') plt.legend() plt.show() \# Part 3 theta5, omega5 = solve_pendulum (0.5,10000,1) theta2, omega2 = solve_pendulum (1.2,10000,1) plt.plot(theta5, omegas, label =D=0.5, , is =, ) plt.plot(theta2, omega2, label= FD=1.2, ls =, ) plt.ylabel ('Angular Velocity (rad/s) ') plt.title( "Poincare Section w/ t_end =10000 ) plt.legend() plt.show() \# Part 4 thetaM, omegaM = solve_pendulum (1.2,10000,2) plt. plot(thetaM. omegaM. label =FD=1.2 )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Identify and describe a suggested outline of a business plan.

Answered: 1 week ago