Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Placements

Student Reviews


For Business


More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Loading...

All Courses

All Courses

logo

Loading...
Executive Programs
Workshops
For Business

Success Stories

Placements

Student Reviews

More

Projects

Blogs

Academic Training

Find Jobs

Informative Articles

We're Hiring!

phone+91 9342691281Log in
  1. Home/
  2. KANNAN SARAVANAN/
  3. Week 3 - Solving second order ODEs

Week 3 - Solving second order ODEs

Gdrive: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ AIM Your objective is to write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping.   Program import numpy as np from scipy.integrate import odeint # for intagration purpose…

    • KANNAN SARAVANAN

      updated on 09 Nov 2020

    Gdrive: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ

    AIM

    • Your objective is to write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping.

     

    Program

    • import numpy as np
      from scipy.integrate import odeint # for intagration purpose
      import matplotlib.pyplot as plt
      import math
      
      def model (theta,t,b,g,l,m):
      	theta1= theta[0] # coverting the second order ODE into simpleform
      	theta2= theta[1]
      	dtheta1_dt = theta2
      	dtheta2_dt = -(b/m)*theta2-(g/l)*math.sin(theta1)
      	dtheta_dt=[dtheta1_dt,dtheta2_dt]
      	return dtheta_dt
      
      b=0.02 #damping coefficient.
      g=9.81 #gravity m/sec2
      l=1	   # length of the pendulum in m,	
      m=0.1  #mass of the ball in kg,
      
      #initial conditions
      theta_0=[0,5] #the angle between string and plane is 5
      
      #time points
      t=np.linspace(0,20,150)
      
      #solve ode
      theta= odeint(model,theta_0,t,args=(b,g,l,m))
      #plot results
      plt.plot(t,theta[:,0])
      plt.plot(t,theta[:,1])
      plt.ylabel('plot')
      plt.xlabel('time')
      plt.show()
      
      
      ct=1
      for theta in theta[:,0]:
      	x0=0
      	y0=0
      	x1=l*math.sin(theta)
      	y1=-l*math.cos(theta)
      	plt.figure()
      	plt.plot([-1,1],[0,0])
      	plt.plot([0,x1],[0,y1])
      	plt.plot(x1,y1,marker='o', markersize =30)
      	plt.xlim([-1.5,1.5])
      	plt.ylim([-1.5,1.5])
      	#plt.show()
      	
      	filename='test%05d.png' % ct
      	plt.savefig(filename)
      	ct=ct+1
      
      
      
      

     

    Procedure

    • Import the required module. as in case we need the ODE scipy module
    • convert the second order ODE into simple single order ODE
    • Applying or define the inputs in python such mass,gravity,daming factor 
    • Intial displacement is 0 and velcoity is 5m/s
    • the total time is 20ms and the input 20 is spillited into 150 to plot curve
    • the Orange line indicate the velcoity and the bule is displacement

     

    OUTPUT

     

    Result

    from this assignment we learn the how to slove the second order ode by using the python

    Leave a comment

    Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.

    Please  login to add a comment

    Other comments...

    No comments yet!
    Be the first to add a comment

    Read more Projects by KANNAN SARAVANAN (41)

    Week 3 - Solving second order ODEs

    Objective:

    Gdrive: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ AIM Your objective is to write a program that solves the following ODE. This ODE represents the equation of motion of a simple pendulum with damping.   Program import numpy as np from scipy.integrate import odeint # for intagration purpose…

    calendar

    09 Nov 2020 10:30 AM IST

      Read more

      Week 2 Air standard Cycle

      Objective:

             g_drive link: https://drive.google.com/drive/folders/1mwlGUaGJyMrs0zaj7CcsVDp8T3jkt2CQ   Aim write the code for otto cycle and ploting the pv diagram and output the thermal efficiency of the engine. Introduction  the cycle is defined as the series of operation or processes performed…

      calendar

      06 Nov 2020 08:02 AM IST

        Read more

        Bird Strike - Project - 2

        Objective:

           G dive link: https://drive.google.com/drive/folders/1S18pT4BTUAOJ-_CcfmpdcvvKG5dY2Guq Aim: The bird, casing, and the blades should be in different input files and there should be one main file referencing all the input files. The main file should contain only references. Control cards and boundary conditions…

        calendar

        01 Oct 2020 02:53 PM IST

          Read more

          week-11 Joint creation and Demonstration

          Objective:

              G-drive link: https://drive.google.com/drive/u/0/folders/1S18pT4BTUAOJ-_CcfmpdcvvKG5dY2Guq Simulation video link: https://drive.google.com/drive/u/0/folders/16dxW1p2dg8mwujoqqLEpOK45ycAKQg3g Aim: to create the various type of joints based on the ls dyna user guide 1.revoulte joints 2.spherical joints 3.cyclinderical…

          calendar

          17 Sep 2020 02:56 PM IST

            Read more

            Schedule a counselling session

            Please enter your name
            Please enter a valid email
            Please enter a valid number

            Related Courses

            coursecard

            Design loads considered on bridges

            Recently launched

            10 Hours of Content

            coursecard

            Design of Steel Superstructure in Bridges

            Recently launched

            16 Hours of Content

            coursecard

            Design for Manufacturability (DFM)

            Recently launched

            11 Hours of Content

            coursecard

            CATIA for Medical Product Design

            Recently launched

            5 Hours of Content

            coursecardcoursetype

            Accelerated Career Program in Embedded Systems (On-Campus) Courseware Partner: IT-ITes SSC nasscom

            Recently launched

            0 Hours of Content

            Schedule a counselling session

            Please enter your name
            Please enter a valid email
            Please enter a valid number

                        Do You Want To Showcase Your Technical Skills?
                        Sign-Up for our projects.