All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Python for Mechanical EngineersBy Enos LeslieMechanical Engineer23rd October 2024AIMThis project aims to write a code in Python to simulate the behaviour of simple pendulum using ODE and animate it. PROCEDUREInitially, the math, matplotlib, numpy, and scipy modules were imported for their respective functionalities.…
Leslie Enos
updated on 23 Oct 2024
Python for Mechanical Engineers
By Enos Leslie
Mechanical Engineer
23rd October 2024
AIM
This project aims to write a code in Python to simulate the behaviour of simple pendulum using ODE and animate it.
PROCEDURE
Initially, the math
, matplotlib
, numpy
, and scipy
modules were imported for their respective functionalities. Key input values such as b
, g
, l
, and m
were defined based on the provided data. An array representing the initial angle (theta
) was created to specify the initial angular displacement and velocity. A time array was also generated, consisting of 100 equally spaced intervals between 0 and 20 seconds.
To solve the second-order ODE, a function named model was defined to incorporate the necessary matrix data. The second-order ODE was then solved using the odeint
function with appropriate syntax, and the results were used to plot the graph showing the variation of angular displacement and velocity with respect to time.
For animating the pendulum's harmonic motion, a for
loop was employed, along with a loop counter to track the iterations. The angular position values were stored in a variable called temp
and updated in each iteration of the loop. During the animation, one end of the pendulum's string was fixed, while the other end moved according to the ODE solution. The motion was plotted for each time interval in the time span. animated with Kapwing online
PYTHON CODE
RESULTS
CONCLUSION
The plot above of angular displacement and angular velocity shows the pendulum's motion to be gradually decreasing. This is because of the damping effect which exponentially decreases the velocity of motion.
The Pendulum motion was animated successfully.
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.
Other comments...
Week 3 - Solving second order ODEs
Python for Mechanical EngineersBy Enos LeslieMechanical Engineer23rd October 2024AIMThis project aims to write a code in Python to simulate the behaviour of simple pendulum using ODE and animate it. PROCEDUREInitially, the math, matplotlib, numpy, and scipy modules were imported for their respective functionalities.…
23 Oct 2024 01:09 PM IST
Week 2 Air standard Cycle
LS DYNA – Python for Mechanical EngineersBy Enos LeslieMechanical Engineer2nd October 2024AIMThis project aims to write a code in Python to solve and plot an otto cycle and solve for its thermal efficiency. PROCEDUREThe Otto cycle is an air-standard cycle, we will assume the gamma value to be 1.4. At the initial…
02 Oct 2024 03:07 PM IST
Week - 4 - Crash Box Simulation
LS DYNA – Crush SimulationBy Enos LeslieMechanical Engineer18th August 2024OBJECTIVEThe project aims to understand the crashworthiness of the crash box design and evaluate the effect of thickness on its energy absorption and structural integrity during an impact.PROCEDUREThe crush box is made up of a shell rectangular…
18 Aug 2024 06:16 PM IST
Bird Strike - Project - 2
LS DYNA – Bird StrikeBy Enos LeslieMechanical Engineer 09th August 2024Bird Strike in Aero EngineThis is a classic nonlinear transient dynamics problem similar to car crash and mobile drop. While accurate modelling of the problem requires advanced techniques such as SPH, this problem can be solved using generic…
11 Aug 2024 04:28 PM IST
Related Courses
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.