Question: please answer in python. Let's study the motion of a system of N identical masses joined by identical linear springs (see the picture below) 000
please answer in python.
Let's study the motion of a system of N identical masses joined by identical linear springs (see the picture below) 000 700 000 The horizontal displacements x; of masses i = 1 ... N satisfy equations of motion daxi = k(x2 - x1) + F1, dt2 m = k(Xi+1 x;) + k(xi-1 - x;) + F, d12 : dxN m = k(xN-1 - xn) + Fn. dt2 where m is the mass, k is the spring constant, and F is the external force on mass i. Here we'll solve them more directly. In this problem you are asked to use the fourth-order Runge--Kutta method to solve for the motion of the masses for the case m = 1 and k = 6, and the driving forces are all zero except for Fi = cos ot with a = 2. The initial conditions are zeroes for all displacements and zeroes for all velocities. The equations must be integrated from t = 0 to t = 30. a) Encode the righthand side of the system of the differential equations to work with general N (assuming N > 1). Put the righthand side of the equations in a class with attributes k, m and o. You will need first of all need to think how to convert the N second-order equations of motion into 2N first-order equations (N positions and N velocities). b) Solve the system of equations for N = 4. Plot your solutions for the displacements x; of all the masses as a function of time on the same plot (using different colors). Make your plot bigger using parameter figsize = (12,5). c) Solve the system of equations for N = 20. Plot your solutions for the displacements X2, X11 and x 19 as a function of time on the same plot (using different colors). Make your plot bigger using parameter figsize = (12,5). Let's study the motion of a system of N identical masses joined by identical linear springs (see the picture below) 000 700 000 The horizontal displacements x; of masses i = 1 ... N satisfy equations of motion daxi = k(x2 - x1) + F1, dt2 m = k(Xi+1 x;) + k(xi-1 - x;) + F, d12 : dxN m = k(xN-1 - xn) + Fn. dt2 where m is the mass, k is the spring constant, and F is the external force on mass i. Here we'll solve them more directly. In this problem you are asked to use the fourth-order Runge--Kutta method to solve for the motion of the masses for the case m = 1 and k = 6, and the driving forces are all zero except for Fi = cos ot with a = 2. The initial conditions are zeroes for all displacements and zeroes for all velocities. The equations must be integrated from t = 0 to t = 30. a) Encode the righthand side of the system of the differential equations to work with general N (assuming N > 1). Put the righthand side of the equations in a class with attributes k, m and o. You will need first of all need to think how to convert the N second-order equations of motion into 2N first-order equations (N positions and N velocities). b) Solve the system of equations for N = 4. Plot your solutions for the displacements x; of all the masses as a function of time on the same plot (using different colors). Make your plot bigger using parameter figsize = (12,5). c) Solve the system of equations for N = 20. Plot your solutions for the displacements X2, X11 and x 19 as a function of time on the same plot (using different colors). Make your plot bigger using parameter figsize = (12,5)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
