Vous êtes sur la page 1sur 7

8th Dec 2011

Coupled Spring Systems using Matlab and GeoGebra Paul Robinson, IT Tallaght Websites Geogebra Homepage: http://www.geogebra.org/cms/ Use the Webstart Version of Geogebra or download a stand alone version. Geogebra Forum: http://www.geogebra.org/forum/ Community of Geogebra users, bug reports and feature requests. Geogebra Wiki: http://www.geogebra.org/en/wiki/index.php/English Collection of re-usable teaching resources. University of Limerick: http://www.ul.ie/cemtl/resources.htm Excellent GeoGebra step by step demos. Math 247: http://math247.pbworks.com/Learn-and-Use-GeoGebra Fantastic Step-by-Step Help on How to Use GeoGebra by Dr Linda Fahlberg-Stojanovska. Includes accessing Geogebra properties and methods using Javascript very cool. LaTeX online equation editor: http://www.numberempire.com/texequationeditor/equationeditor.php Indispensible if you want to put mathematics into Moodle and dont know any LaTeX! A bit of Theory A set of N masses M1, M2, , MN are connected together by (N+1) springs with spring constants k1, k2, , kN with the left and right most springs attached to a wall. The diagram below shows 6 such masses connected by 7 springs,

Here, the second and fourth masses from the left are different from the other 4. The second and fifth springs differ from the other 5. If the masses are moved from their equilibrium positions and then released they will move in a complex set of motions. If y1, y2, , yN are the displacements of each mass at time t then using Hookes Law the force on each mass is Force on M1 = k1y 1 + k2 (y 2 y 1) = (k1 + k2 )y1 + k2 y 2 Force on M2 = k2 (y 2 y1) + k3(y 3 y 2 ) = k2 y1 (k2 + k3 )y 2 + k3 y 3 M Force on MN = kN (y N y N 1) kN +1y N = kN y N 1 (kN + kN +1)y N

8th Dec 2011

Using Newtons Third Law on each mass we obtain the following differential equations, d 2 y1 M1 2 = (k1 + k2 )y1 + k2 y 2 dt d 2y 2 M2 = k2 y 1 (k2 + k3 )y 2 + k3 y 3 dt 2 M MN d 2yN = kN y N 1 (kN + kN +1)y N dt 2

which can be written in matrix form as k2 0 M1y1 (k1 + k2 ) k2 (k2 + k3 ) k3 d M2 y 2 = 2 M 0 M M dt M y 0 0 0 N N


2

K K K kN

0 y1 0 y 2 M 0 (kN + kN +1) y N

We will look in detail at the motions of the masses when we have 6 equal masses of value M = 1, and 7 springs each with a spring constant k = 1. Then the matrix equation becomes y 1 2 1 0 0 0 0 y 1 y 2 1 2 1 0 0 0 y 2 1 2 1 0 0 y 3 d 2 y3 0 = 2 1 2 1 0 y 4 dt y 4 0 0 y 0 0 0 1 2 1 y 5 5 y 0 0 0 0 y 1 2 6 6

or

d 2Y = KY dt 2

When the masses are released from rest, theory shows that we can write the solution vector Y as / = A1e1 cos(1t) + A2 e2 cos(2t) + A3e3 cos(3t) + K + A6 e6 cos(6t) Y
2 where k = k for k = 1 to 6 and each k is an eigenvalue of M with eigenvector ek. The numbers A1 to A6 are constants which can be calculated from the initial displacements of the masses at time t = 0. In what follows we will use Matlab to find the eigenvalues and eigenvectors of K. We will then use these values and vectors in GeoGebra to animate the motions of the masses in their normal modes. / = ek cos(kt) are called Normal Modes of the spring system. We will The particular cases where Y use GeoGebra to see what these modes look like.

Eigenvalues and Eigenvectors of K Open Matlab and in the Command Window type K = [-2,1,0,0,0,0; 1,-2,1,0,0,0; 0,1,-2,1,0,0; 0,0,1,-2,1,0; 0,0,0,1,-2,1; 0,0,0,0,1,-2] and press return. This is each row of M above, separated by a semi-colon. 2

8th Dec 2011

Also type Evalues = eig(K) and [V,D]=eig(K) Evalues is the eigenvalues of K. The columns of V are the corresponding eigenvectors of K, in the same order as their eigenvalues are listed in D. Matlab has now done its job. Keep Matlab open and open up GeoGebra too (if you do not have it installed you can run it from http://www.geogebra.org/cms/, then click Download and AppletStart). Transfer Matlab data to GeoGebra Go to View and click on Spreadsheet View. In cell A1 of the GeoGebra spreadsheet type Evalues. Go to the Matlab Workspace Window (if you cant see it click on Desktop, Workspace) and double click the variable Evalues. Select the 6 values with the mouse, copy, and paste into A2 in the GeoGebra spreadsheet. In the Input Line at the bottom of the GeoGebra window type w_1 = sqrt(-A2) and press return. This is the highest frequency mode of the spring system. Repeat this for the other five frequencies w_2 = sqrt(-A3), w_3 = sqrt(-A4) etc. In cell A9 of the GeoGebra spreadsheet type Evectors. Go to the Matlab Workspace Window and double click the variable V. Copy the 6 by 6 block of numbers and paste it into A10 in the GeoGebra spreadsheet. Each column of six numbers is an eigenvector (or Normal Mode) of the spring system. Select the first column of 6 numbers with the mouse and right click. Go to Create, Matrix and you will see a column vector (probably called matrix2) in the Algebra Window on the left. Right click this vector, choose Rename, and change the name to e_1. Repeat for the other 5 columns of Evectors, changing their names to e_2, e_3, , e_6. In cell C1 of the GeoGebra spreadsheet type Amounts. In C2 put a 1 and in C3 to C7 put a 0. These will be the amounts of each normal mode to include in the general solution Y. We will start by having the e1 mode and none of the others. Select and right click this column of 6 numbers and go to Create, Matrix. Rename this A as you did previously. Save the GeoGebra file! We can now hide the spreadsheet (View, Spreadsheet View) and close Matlab. In what follows, we could have done all of our calculations within the spreadsheet instead. The logic should, hopefully, be clearer if we use the frequencies 1 to 6, the normal modes e1 to e6 and the amounts in A. Set up the GeoGebra Screen On the drawing pad, in the input line at the bottom of the screen type Segment[(0,1),(0,-1)] and press return. Repeat for Segment[(14,1),(14,-1)]. You may need to zoom out a bit to see the two segments. Right click on each, go to Object Properties and make them much thicker. These will form the plates to which our first and last spring are fixed. 3

8th Dec 2011

Put a slider on the screen by clicking on the slider tool, then on the drawing pad. Call it t and set its values from 0 to 20. Slide its value to t = 0. Finally, go to View and click off Axes. Create the mass positions at time t In the input line type Y = Element[A, 1, 1]*e_1*cos( _1*t) + Element[A, 2, 1]*e_2*cos( _2*t) + + Element[A, 6, 1]*e_6*cos( _6*t) so that you have a sum of 6 things. With the present values in A this is Y = e_1*cos( _1*t). This vector represents the displacement of each mass at time t from its equilibrium position when it starts at time 0 in the normal mode positions e1 i.e it is the solution of the system of differential equations d 2Y = KY Y (0) = e1 dt 2 We will assume that the equilibrium positions of the masses are 2 apart on the x-axis and at positions 2, 4, 6, 8, 10 and 12. In the input line type P_1 = (2, 0) + (Element[Y, 1, 1], 0) P_2 = (4, 0) + (Element[Y, 2, 1], 0) and so on till you get the 6th point P_6 = (12, 0) + (Element[Y, 6, 1], 0) (press return) Tip: If you press the up arrow after pressing return, the last command will appear in the input line and you can edit it. This will create 6 points along the x axis which are at their equilibrium points + their displacement. Y is a column vector so we need the number in row k in column 1 each time. [Note that we could have done this in one line with Sequence[(2*k,0) + (Element[Y, k,1], 0), k, 1, 6] However, the sequence command creates a list of points which we cannot access Properties for.] Right click the slider t and click Animate On. Your six points should start to move. Note that if movement is very slow you can speed it up in the slider Properties, Speed box. Save the GeoGebra file! Make the animation look better Stop the animation (right click the slider). Right click each of the points, go to Object Properties and make them much bigger. Make them all red. A trick here, when changing properties of several objects, is to select all the ones you want to change in the Properties list (use Ctrl+click to select 2 or more points at once). Now change properties and it updates all the points. (press return) (press return)

8th Dec 2011

Click the Segment Tool then two adjacent points. Connect the other adjacent points in the same way. Finally, click the middle of the left hand segment and the point next to it. Do the same for the right segment. You can right click each segment and change their thickness etc. Switch on animation again to see your spring system. You are looking at the system in its highest frequency normal mode. You can make better looking springs than segments too. Go to http://www.geogebratube.org/ and in the Material Types section click on Tool. Look for the Spring Tool. To download and use it you will need to Register, which is a small link at the top right of the screen. After downloading, open it in GeoGebra using File, Open and you will see a spring icon appear on the toolbar. Click the spring icon then 2 adjacent points you will be asked for 2 numbers. Put 6 for the first and 0.1 for the second. Repeat for the other 6 springs and delete the original segments (from the Algebra Window is easiest). Problems Before doing these problems turn off animation and set t to 0! 1. Open the Geogebra spreadsheet and change the value in C2 to 0 and that in C3 to 1. This will give us the second normal mode Y = e_2*cos( _2*t). Animate t. Repeat for the other 4 modes. Can you describe in words what each mode looks like? 2. If the masses do not start in a normal mode then the displacements Y are given by / = A1e1 cos(1t) + A2 e2 cos(2t) + A3e3 cos(3t) + K + A6 e6 cos(6t) Y where the numbers A1 to A6 are constants; which can be calculated from the initial displacements of the masses at time t = 0. If Y0 is the displacements at time t = 0 then /0 = A1e1 + A2 e2 + A3e3 + A4 e4 + A5e5 + A6 e6 Y /0 = VA where V is the 6 by 6 matrix since cos(kt) = 1 when t = 0 for each k. We can rewrite this as Y V of column vectors you found in Matlab and A is an unknown column vector with components A 1 to A6. Since Y0 is known this is essentially a set of six simultaneous equations for the unknowns A 1 to A6. Return to Matlab. If the matrix V is not in the command history already then recreate it now (See the section Eigenvalues and Eigenvectors of K). We will look at the spring system when the first mass is moved right by 1 and the rest are kept at 0. In Matlab type Y_0 = [1; 0; 0; 0; 0; 0] To find A type A = linsolve(V, Y_0) You can check this works by typing V*A you should get Y_0. Double click the A variable in the Matlab Workspace, select and copy the range of values. Return to GeoGebra, open the spreadsheet and paste into C2. 5

8th Dec 2011

You should now see the first mass on the left moved 1 to the right and the others in their original positions. Animate t to see the motion with this starting point. 3. Solve for A in Matlab for some other starting mass positions. Pasting the A values from Matlab into GeoGebra will be enough to reset the problem and you will be able to animate the new motion. There is no need to edit Y. 5. So far, we have a complete description of the motions of the masses when we have 6 equal masses of value M = 1, and 7 springs each with a spring constant k = 1. In the general case the motion is described by the equations k2 0 M1y1 (k1 + k2 ) k2 (k2 + k3 ) k3 d 2 M2 y 2 = 2 M 0 M M dt M y 0 0 0 N N M1 0 0 0 M2 0 where M = M M M 0 0 K K K K 0 K K K kN 0 y1 0 y 2 M 0 (kN + kN +1) y N

This can be written as

M So that

d 2Y = KY dt 2

0 0 a diagonal matrix 0 MN

d 2Y = M1KY dt 2 Lets look at the case where the third mass has a value of 3, the rest are 1 and all the k = 1. Create the matrix M in Matlab. To create the matrix M-1*K you will need the Matlab command inv(M)*K Find the eigenvalues and eigenvectors of this matrix and examine the normal modes in GeoGebra. Again, there is no need to change the definition of Y in GeoGebra. Simply copy the new eigenvalues to A2 and the new V to A10 in the GeoGebra spreadsheet . Put a single 1 in the C2 to C7 cells (the others 0) to see the 6 normal modes. What happens if one mass is much larger than all the others? What if one mass is much smaller than the others? 6. Experiment with changing the spring constant values in K. What if one spring constant is much larger (smaller) than the others?

8th Dec 2011

Further Problems 1. The previous problems all concerned a system with springs clamped at both ends. If the right hand mass is left free to move we have this system.

Write down the K matrix you get for this system (think about the forces on the right most mass) and investigate the normal modes when each mass and k value is 1. 2. A set of coupled pendulums is a spring system with both ends free

For small oscillations (M values and k values 1) we have d 2 = K dt 2 where the vector is the 6 angles that the pendulums make with the vertical (in radians) and K is similar to the one in problem 1 above. Write down K (think about the forces on the left most mass and right most mass) and investigate the normal modes. In Geogebra, edit your construction so that it looks like the picture above (use segments between two points to represent the pendulum strings). If the values are small then the horizontal displacements Y are essentially (infact L where L is a pendulum length).

Vous aimerez peut-être aussi