Dynamics Final Report

Similar documents
4.4 Energy in multiple dimensions, dot product

Phys 270 Final Exam. Figure 1: Question 1

LAB PHYSICS MIDTERM EXAMINATION STUDY GUIDE

Calculus II. Calculus II tends to be a very difficult course for many students. There are many reasons for this.

LAB 2 - ONE DIMENSIONAL MOTION

Unit 7: Oscillations

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Physics Department

MITOCW ocw-18_02-f07-lec02_220k

Problem Solving Session 1: Electric Dipoles and Torque

Modeling and Experimentation: Compound Pendulum

MITOCW ocw-18_02-f07-lec17_220k

University of Utah Electrical & Computer Engineering Department ECE 3510 Lab 9 Inverted Pendulum

1 Forces. 2 Energy & Work. GS 104, Exam II Review

Homework Assignment 4 Root Finding Algorithms The Maximum Velocity of a Car Due: Friday, February 19, 2010 at 12noon

MITOCW watch?v=rwzg8ieoc8s

of 8 28/11/ :25

( )( b + c) = ab + ac, but it can also be ( )( a) = ba + ca. Let s use the distributive property on a couple of

Gravity Pre-Lab 1. Why do you need an inclined plane to measure the effects due to gravity?

PHY2048 Physics with Calculus I

Chapter 6. Net or Unbalanced Forces. Copyright 2011 NSTA. All rights reserved. For more information, go to

Physics Motion Math. (Read objectives on screen.)

Physics 218 Lecture 21

Lab 6d: Self-Erecting Inverted Pendulum (SEIP)

Motion Part 2: Uniform Linear Motion

DIFFERENTIAL EQUATIONS

Experiment 1: The Same or Not The Same?

Worksheet for Exploration 6.1: An Operational Definition of Work

Mechanics, Heat, Oscillations and Waves Prof. V. Balakrishnan Department of Physics Indian Institute of Technology, Madras

MOMENTUM, IMPULSE & MOMENTS

Simple Harmonic Motion - MBL

Kinematics in Two Dimensions; 2D- Vectors

Grade 7/8 Math Circles March 8 & Physics

Student Performance Q&A:

MITOCW R11. Double Pendulum System

Test Wed, Feb 8 th 7pm, G20 MING HSIEH Bring your calculator and #2 pencil with a good eraser! 20 Multiple choice questions from:

Experiment 08: Physical Pendulum. 8.01t Nov 10, 2004

LAB 2: INTRODUCTION TO MOTION

Kinematics Lab. 1 Introduction. 2 Equipment. 3 Procedures

Inverted Pendulum. Objectives

Conservation of Energy

Experiment A11 Chaotic Double Pendulum Procedure

PHY 221 Lab 7 Work and Energy

Land-Use Land-Cover Change Detector

LAB 3 - VELOCITY AND ACCELERATION

PHY 123 Lab 1 - Error and Uncertainty and the Simple Pendulum

LAB 6 - GRAVITATIONAL AND PASSIVE FORCES

!T = 2# T = 2! " The velocity and acceleration of the object are found by taking the first and second derivative of the position:

Static and Kinetic Friction

ACTIVITY 5: Changing Force-Strength and Mass

Conservation of Momentum

Chemistry 125: Instructions for Erwin Meets Goldilocks

Main Ideas in Class Today

Lab #2: Newton s Second Law

Fluid Mechanics Prof. S. K. Som Department of Mechanical Engineering Indian Institute of Technology, Kharagpur

Egyptian Fractions: Part I

INTRODUCING NEWTON TO SECONDARY SCHOOL STUDENTS

The Physics of Boomerangs By Darren Tan

0153 Script - Using a Pendulum to find the Radius of Curvature of a Roundabout.docx Page 1 of 14

AP PHYSICS 1. Energy 2016 EDITION

NowGeen. Ridley Shetler, Sarah Martin and Chad Dorais. Engineering 151 s final project is to create a functioning Rube-Goldberg device that will

Name: Date: Partners: LAB 2: ACCELERATED MOTION

θ + mgl θ = 0 or θ + ω 2 θ = 0 (2) ω 2 = I θ = mgl sinθ (1) + Ml 2 I = I CM mgl Kater s Pendulum The Compound Pendulum

Physics 121, Sections 1 and 2, Winter 2011 Instructor: Scott Bergeson Exam #3 April 16 April 21, 2011 RULES FOR THIS TEST:

Projectile Motion. v a = -9.8 m/s 2. Good practice problems in book: 3.23, 3.25, 3.27, 3.29, 3.31, 3.33, 3.43, 3.47, 3.51, 3.53, 3.

Unit 4 Patterns and Algebra

PHY2048 Exam 1 Formula Sheet. Vectors. a 2 x +a 2 y +a 2 z b = Motion. Equations of Motion for Constant Acceleration

Rotational motion of a rigid body spinning around a rotational axis ˆn;

Physics 351 Wednesday, January 10, 2018

SRV02-Series Rotary Experiment # 7. Rotary Inverted Pendulum. Student Handout

The Pendulum. The purpose of this tab is to predict the motion of various pendulums and compare these predictions with experimental observations.

ACTIVITY 2: Motion and Energy

LAB 6: WORK AND ENERGY

Newton s Laws and Free-Body Diagrams General Physics I

Physics 132 3/31/17. March 31, 2017 Physics 132 Prof. E. F. Redish Theme Music: Benny Goodman. Swing, Swing, Swing. Cartoon: Bill Watterson

POWER ALGEBRA NOTES: QUICK & EASY

Potential Energy & Conservation of Energy

July 19 - Work and Energy 1. Name Date Partners

Topic 1: Simple harmonic motion

* * MATHEMATICS (MEI) 4764 Mechanics 4 ADVANCED GCE. Thursday 11 June 2009 Morning. Duration: 1 hour 30 minutes. Turn over

LAB 3: VELOCITY AND ACCELERATION

Lab 4: Gauss Gun Conservation of Energy

PHY 221 Lab 9 Work and Energy

Lab 10 - Harmonic Motion and the Pendulum

Egyptian Fractions: Part I

Concepts in Physics. Friday, October 16th

Chapter 10: Friction A gem cannot be polished without friction, nor an individual perfected without

Newtonian mechanics: kinematics and dynamics Kinematics: mathematical description of motion (Ch 2, Ch 3) Dynamics: how forces affect motion (Ch 4)

The Nonlinear Pendulum

Unit 1: Equilibrium and Center of Mass

Game Physics. Game and Media Technology Master Program - Utrecht University. Dr. Nicolas Pronost

Chapter 2. Motion in One Dimension

Lab 5: Projectile Motion

Figure 2.1 The Inclined Plane

The dynamics of a Mobile Inverted Pendulum (MIP)

The PROMYS Math Circle Problem of the Week #3 February 3, 2017

Big Idea 4: Interactions between systems can result in changes in those systems. Essential Knowledge 4.D.1: Torque, angular velocity, angular

LABORATORY II DESCRIPTION OF MOTION IN TWO DIMENSIONS

PHYSICS 220 LAB #5: WORK AND ENERGY

Motion II. Goals and Introduction

PhysicsAndMathsTutor.com

Transcription:

Dynamics Final Report Sophie Li and Hannah Wilk 1 Abstract We set out to develop a n-rigid body solver in MatLab. We wanted a user to define how many rigid bodies there are, and our system creates the correct equations of motion and animates the system. using basic equations of motion,f = ma and M = d dt (ω I) we where able to develop our n-pendulum solver. Using a GUI developed in python, our users can now animate a pendulum of any size. Background Over the course of the semester, we have derived the equations to pendulums multiple times. With each problem every week, we learned more about the pendulum system, and how to properly assess the physical situation. With each iteration of solving similar problems, we began to notice patterns. We came to the conclusion that these patterns could be transformed into an n case. No matter how many equations of rigid body pendulums we were asked to find we could find them, if we developed a MatLab script. In parallel with noticing these mathematical patterns in the equations of motion, we discovered a physics based video game called Crayon Physics [1]. In this game the player was tasked with getting a ball to a goal. In their way are various obstacles, such as cliffs, water, or other physical barriers. Granted only a magic pencil, they have to draw various ramps and pendulum to get the ball to the goal. In this game, a lot of real time physics are used. Pendulums can be any size and need to work like pendulums. This inspired us to use our n-case equations to create a simplified GUI, so the user can control how large the n-case pendulums can be. Newtonian Physics, and simplified Euler s equations will be applied to each link of an n=pendulum system to create our system. Since we will have an n-pendulum generator, we realized that there needs to be a user input option. Using python, we will integrate a GUI interface to make our n-pendulum more user-friendly. 3 Learning Objectives After learning about the video game Crayon Physics, we decided we wanted to look more into allowing the user to define aspects of a dynamic system defined in MatLab. After our three years at Olin, we hadn t been asked to make a GUI in MatLab, this would allow us to try and tackle the complex feat. In addition to that, we wanted to work on fully understanding transformation matrices- how to set them up and how to properly use them. After taking the time to explore the possibilities in this area, we were able to develop even more learning goals. We wanted to understand how to generalize the pendulum s equations. After many weeks of working on p-sets involving pendulums we saw patterns start to emerge. Finally, we wanted to learn more about MatLab animation, and how a user can interact with MatLab s graphical interfaces. Will integrate a GUI interface to make our n-pendulum more user-friendly. 1

a) b) R1 y R y R1x Rx θ i F1 g θ final Ff g R x R y Figure 1: Free Body Diagram of System. a) of this figure shows a generic, non final, link in the pendulum. b) shows a generic final link in our n pendulum system. Note that R has an equal and opposite force for each pendulum 4 System Models 4.1 Free Body Diagram Each link in the system has a momentum and forces associated with it. Each link has two reaction forces, one from the link before and one from the link after. In addition to the reaction forces, there is the force associated with gravity. The only exception is the final link of the pendulum. There is only one reaction force, created by the link before the final one. When the moment is taken with respect to the center of gravity, the two reaction forces create moments, acting in the same direction. b b 1 z g j i θ 1 l 1 c c 1 θ l d d 1 θ 3 1 3 Figure : Shows how reference frames are defined in reference to each link. This and example of a three rod pendulum. An incredibly important step to solving an n case pendulum is to look at cases to develop patterns. One thing we did was set up a triple pendulum to create a starting point. With this pendulum we were able to

clearly set up how we were going to use reference frames. Each link of the pendulum has its own reference frame. These were used, along with the vertical angles to develop transformation matrices. It is important to note that the ˆb 3 direction is parallel to all of the other Z directions produced by the other reference frames. This means for all of our moment equations, whether it was made in the ˆb or ĉ direction, the final 3 direction were equivalent. ˆb3 = ĉ 3 4. Equations It is important to note that n is the total number of rigid bodies in the pendulum system. i is the index for the rigid bodies. For example: i=1, is the first body, or the top pendulum, i= is the second, i=n would be the final pendulum in the system. After going through math that was similar to math found in Problem set 5, we decided to make an n case model. Our first step was to analyze our absolute acceleration A n = (L i θ i ( cos(θ i )î+sin(θ i )ĵ) L iθi (sin(θi )î+cos(θ i )ĵ) L n θ n ( cos(θ i )î+sin(θ i )ĵ)+ L n θ n (sin(θ i )î+cos(θ i )ĵ) i=1 (1) We then looked into the sum of forces, or more simply:f = ma. From this we analyzed the FBD and came up with the equations for every pendulum. Fn = R nx î R ny ĵ + m n gĵ + R (n+1)x î + R (n+1)y ĵ () Equation represents our generalized sum of forces equation. Each force has an equal and opposite effect on the next consecutive link. We needed to develop an equation that took into account what link the index was on, and how many total n-pendulums there were. In order to account for the edge case- there only being two forces on the last pendulum instead of three- we needed to build a for loop into our solving logic, that removed the final force. After solving for the sum of moments, we set the equation to Euler s equations. Because of the geometry of the rods, we were able to drop many terms in euler s equation. We were able to use M = d dt (ω I). The sum of moments where the calculated equations we found from the center of gravity of each rod, using the FBD to choose the correct forces. The right side of the sum of moment equation became ω I Where I = ml, the mass moment inertia of the rod at its center of gravity. m n L n θ R nx L n n = 1 1 sin(θ n ) + R nyl n cos(θ n ) R (n+1)xl n sin(θ n ) + R (n+1)yl n cos(θ n ) (3) Equation 3 is the generalization of our findings of the equation M = d dt (ω I). Since we are setting up a matrix in order to generalize this problem, we needed to get the correct forces onto the correct sides. We needed to see all terms with θ and reaction forces on one side. On the other, terms with no unknown forces and θ. What we got in part where generalized equations split into the î and ĵ directions. i=0 ( m n L i cos(θ i ) θ i ) m nl n cos(θ n ) θ n R nx + R (n+1)x = m n L iθi sin(θi ) + m nl n θ n sin(θn ) (4) i=0 i=0 (m n L i sin(θ i ) θ i ) m nl n sin(θ n ) θ n R ny +R (n+1)y = m n L iθi cos(θi )+ m nl n θ n cos(θn ) m n g (5) These final two equations where the basis of our logic in creating n-case pendulums. These were input into loops to create the repetitive nature of the final pendulum equations. 4.3 Assumptions To simplify our system, we assumed that there were no dampening forces acting on the system. This includes the exclusion of drag and other effects due to external forces. We also assumed the force of gravity was a i=0 3

constant 9.81 m s, seeing as this system is being analyzed close to the ground on Earth. While looking at the pendulum links, we assumed that each link was a uniform rod with length L i and mass M i. Each rod had an angle, θ i, with respect to the vertical. While defining the equations of motion, we took them with respect to the center of mass-the center of the rod. While we were solving our rod problems, in order to validate our work, we were looking at position, velocity, acceleration, and most importantly energy. If our total energy ended up being a straight line, we said that the simulation was working correctly. This is physically a strong case, however there could be errors related to energy. However we ignored that potential and accepted the energy graphs as validation. 5 Results To make the experience more user friendly, we wrote a GUI that would allow users to define how many pendulums and its starting conditions. Figure 3: GUI with 3 pendulums (a) Position, Velocity, Acceleration (b) Energy Graphs for 3 pendulums One can see that the energy graphs aren t quite flat, though we attribute to calculation errors due to rounding as previously discussed. Theta, theta-dot, and theta-ddot behave as expected, with each additional mass having greater displacement than the previous. The acceleration graph shows sharp peaks where the pendulum would have hit the peak of it s motion and began moving in the opposite direction. 4

Since our code successfully generates Matlab scripts for n-case pendulums, we added additional rods to see what would happen. Figure 5: GUI with 7 pendulums (a) Position, Velocity, Acceleration (b) Energy Graphs for 7 pendulums With 7 pendulums and randomized starting conditions, we still see that energy is flat, which indicates that our model is working. For fun we simulated 0 pendulums: Figure 7: GUI with 0 pendulums 5

(a) Position, Velocity, Acceleration (b) Energy Graphs for 0 pendulums And energy is still flat! The auto-generated code for 0 pendulums was around 750 lines of MatLab. We observe that as additional rods are added, the motion of the pendulums becomes slower, as each rod adds both length and mass. As one can see in the energy graphs for each iteration of the test below, the 3-link pendulum had quite a few oscillations, while the 0-link pendulum only had three. 6 Using the Code-Animation To run the entire project, do the following: 1. Use the Python GUI to input the initial conditions. Click Simulate to generate the MatLab script. After Python creates the MatLab script with the proper matrices and equations, run the script n pen.m inside MatLab. Validate your solution by plotting energy for each test case After MatLab is done running the script, the user will be presented with three graphs. The first is the position, velocity, and acceleration of each theta in the pendulum. The second is the energe of the system. The third is a animation of the pendulum motion. An.avi file of the animation will be saved to the local folder after the animation is finished playing. 7 Diagnosis 7.1 Reference Frame Troubles Initially our pendulum did not behave properly. Our first pendulum was not being affected by the other links in the pendulum. After hours of debugging we realized we had switched the orientation of one of our forces. This meant that our transformation matrix was incorrect. While we understood the mathematical steps that had to be addressed in order to solve the pendulum problem, we did not realize we had made a simple FBD error. Instead of the 1 component of our reference frame going along the length of pendulum, [ it was ] going [ perpendicular to ] the base. This cause our transformation matrix to change from: cos(θ) sin(θ) sin(θ) cos(θ) to. They are not equal transformation matrices. This was causing our -sin(θ) cos(θ) -cos(θ) sin(θ) issues and was breaking our pendulum. While we caught the mistake, it was frustrating. The mathematical steps were straight forward but a small accounting error had caused us many hours of work. One should always make sure they understand how their reference frames are set up. 7. Matlab s Errors, Not Ours Initially, we accomplished an n-body pendulum solver by using for loops inside our Matlab ODE to generate the A matrix and r vector. (Where A matrix is composed of our unknown variables while the r vector is the 6

known.) However, we were unable to get flat energy graphs due to cumulative errors that occurred during our matrix evaluation phase. To validate that this was indeed a Matlab issue and not an implementation issue on our end, we compared the results from our n-body solver for a 3-link pendulum with another script that simulated the motion of the same 3-link pendulum using an A matrix and r vector that we defined like in previous problem sets instead of generating them on the fly like in our solver. The results between the two were identical for the first few time steps, but our solver produced values that increased faster than the second script. We concluded that this was a Matlab issue in matrix evaluation, so we set out to do n-body solving in a different manner. By writing a python program to generate a Matlab script, we could define the A and r matrices instead of generating them inside the ODE. Using this implementation, we were able to reduce both computational complexity and increase the accuracy of our results. 8 Improvement We currently have a rudimentary GUI for a user to interact with, but it is used in Python. As of right now the user can enter lengths, masses, θ initial, and velocity initial. Each is entered in its own field on the GUI. To indicate how many pendulum needed, one adds terms to each of these inputs, indicating different links, using commas. While the GUI is functional, it is lacking in design. What we mean by that it is not incredibly intuitive for the user to use. It is not as elegant as Crayon Physics, where the user can easily draw however many pendulums they want. Currently, it becomes difficult to input the conditions for a long pendulum. If one wants to make a 0 rod pendulum, one has to type out 0 different elements, 4 times, while making sure the input length is constant. If we were to continue to work on this project, one more iteration of GUI design could go a long way to making our experience function more like a video game. While the GUI was not written in MatLab, we still were able to learn about how GUI s are implemented into larger code. In addition to adding more of a GUI, we would also look more into the MatLab triggered errors. When we did our first iteration we had the correct equations and respective matrices, but MatLab was plotting incorrect graphs, that acted unstable. As time progressed, the instability got worse. This led us to believe that it was an ODE problem. We would need to look into different ODE solves to fix the problem to remove the python/matlab integration. This would allow us to stop calling a python script to make a MatLab script. 9 Reflection While working on this assignment, we did a lot of good work developing our understanding of reference frames, moments, and forces. While going through this project, we derived equations of motion for1,, 3, 4, and 5 bar pendulums. This meant that we were pushing our understanding of how to set up complicated reference frame based problems. We had to constantly be on the lookout for sign errors and had to make sure correct transformation matrices were correlated to the proper angles. We became master debuggers. With the errors that were made with transformation matrices, we can now solve them in our sleep (I guess we will see how we do on our final exam.). Overall we developed a lot of good skills that will help us solve more complicated problems in the future. It was a lot of fun even though the work was frustrating at times. 10 Conclusion When we began to work on this project we set out to make a complex video game that could produce user input pendulums of any length. We explored complex dynamic principals and learned more about animation in MatLab, in order to develop our n-case pendulum. We used the sum of forces and Euler s equations on rigid rods in order to develop equations of motion which allowed us to fully animate any n order pendulum. While there were issues with MatLab, we were able to work past it using python in order to create a GUI centered pendulum simulator, which acts as code validation for the Dynamics classes to come. Our final 7

iteration allows for a user to individually define inputs for the pendulum, while displaying an animation, along with plotting the all-important energy validation graph. 11 Future Use While we learned how to solve complicated equations of motion for this problem, we are not sure how much more added value a problem like this would add to the class. Seeing as we were looking for a generalized solution to solve and size pendulum problem, we found a lot of repetitious solutions. After the third pendulum, the equations become easy to create by hand. This would be more of a problem to intrinsically teach debugging techniques, which has its own value, but isn t necessarily the best use of the class s limited time. We created a set of scripts that can validate pendulum code. People in the future classes can use our code to check to see if their rigid pendulum is correct. 11.1 Problem Statement Pendulum Case Study: (a) Find the equations of motion for one rigid body pendulum, place equations into a matrix, plot energy (b) Find the equations of motion for a two mass rigid body pendulum (c) Analyze patterns found in the first two pendulum cases, and develop a generalized matrix (d) Show multiple examples of your code working, i.e. use different number of total rods. Validate your solution by plotting energy for each test case References [1] Crayon Physics, Petri Purho, Kloonigames,009 8