As we showed, the horizontal displacements ξi of masses i = 1 . . . N satisfy equations of mo- tion md2ξ1 =k(ξ2−ξ1)+F1, dt2 md2ξi =k(ξi+1−ξi)+k(ξi−1−ξi)+Fi, dt2 md2ξN =k(ξN−1−ξN)+FN. dt2 where m is the mass, k is the spring constant, and Fi is the external force on mass i. In Exam- ple 6.2 we showed how these equations could be solved by guessing a form for the solution and using a matrix method. Here we'll solve them more directly. a) Write a python program to solve for the motion of the masses using the fourth-order Runge- Kutta method for the case we studied previously where m = 1 and k = 6, and the driving forces are all zero except for F1 = cos ωt with ω = 2. Plot your solutions for the displace- mentsξi ofallthemassesasafunctionoftimefromt=0tot=20onthesameplot. Write your program to work with general N, but test it out for small values—N = 5 is a reasonable choice. You will need first of all to convert the N second-order equations of motion into 2N first- order equations. Then combine all of the dependent variables in those equations into a single large vector r to which you can apply the Runge-Kutta method in the standard fashion. This is what I have so far. I do not need the graph I just can not figure out how to do f(r, t) (it must be f(r, t) to create an array where we convert the N-second order equation into 2N and then combining the dependent variables.
As we showed, the horizontal displacements ξi of masses i = 1 . . . N satisfy equations of mo- tion
md2ξ1 =k(ξ2−ξ1)+F1, dt2
md2ξi =k(ξi+1−ξi)+k(ξi−1−ξi)+Fi, dt2
md2ξN =k(ξN−1−ξN)+FN. dt2
where m is the mass, k is the spring constant, and Fi is the external force on mass i. In Exam- ple 6.2 we showed how these equations could be solved by guessing a form for the solution and using a matrix method. Here we'll solve them more directly.
a) Write a python program to solve for the motion of the masses using the fourth-order Runge- Kutta method for the case we studied previously where m = 1 and k = 6, and the driving forces are all zero except for F1 = cos ωt with ω = 2. Plot your solutions for the displace- mentsξi ofallthemassesasafunctionoftimefromt=0tot=20onthesameplot. Write your program to work with general N, but test it out for small values—N = 5 is a reasonable choice.
You will need first of all to convert the N second-order equations of motion into 2N first- order equations. Then combine all of the dependent variables in those equations into a single large
This is what I have so far. I do not need the graph I just can not figure out how to do f(r, t) (it must be f(r, t) to create an array where we convert the N-second order equation into 2N and then combining the dependent variables.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps