Spring mass impact system in Matlab - How to correct it?

In summary, the mass has a velocity and starts to hit the spring at time t = 0. The spring experiences a deformation in x-axis direction.
  • #1
k.udhay
160
10
TL;DR Summary
A mass of constant velocity colliding on spring is modeled in simulink. Result expected was to be of sinusoidal displacement of spring. However result found was different.
I am new to Simulink and I wanted to start practicing using a spring mass damper system. My first tutorial was this:



Later, I wanted to model a spring system where a mass moving at a known velocity hits the spring. The governing equation and a similar modeling method given in the previous youtube link was also prepared:

244939
Here is the Matlab Simulink model:
https://1drv.ms/u/s!AiW7GXWiq-LLgitdmZqU4QhFeVU5?e=PiZxp3

The result I expected was a sinusoidal displacement of the spring. However the result was totally different:

244940


If someone can tell what exactly is my mistake and the correction, that will be of huge help. Thanks.
 
Physics news on Phys.org
  • #2
You're using an energy equation where all the terms are positive. It is not going to tell you the signs of ##x## or of ##v##.

To get the equation of motion, you want to use the fact that the force on the mass is related to the displacement ##F = -kx = m \frac {d^2x}{dt^2}## This force will change sign as ##x## changes sign, which will lead to the sinusoidal behavior.
 
  • Love
Likes k.udhay
  • #3
Please update at some point and let me know if my observation actually led to success. It was just something that jumped out at me looking at your equation.
 
  • #4
Thank you for your inputs, RPinPA. While I understand force based equation will give me sinusoidal displacement output (as mentioned in the youtube link in OP), I have two questions that I need a clarity:

1. Why will the energy based governing equation not give correct displacement values? It involves velocity (which is a derivative of position) too.

2. If I go with force based governing equation (as you have suggested), where do I input the initial velocity of the mass? This is critical as this determines the amount of deformation of spring (= amplitude of sine wave)
 
  • #5
k.udhay said:
Thank you for your inputs, RPinPA. While I understand force based equation will give me sinusoidal displacement output (as mentioned in the youtube link in OP), I have two questions that I need a clarity:

1. Why will the energy based governing equation not give correct displacement values? It involves velocity (which is a derivative of position) too.
Because you can't tell whether to take the velocity as positive or negative at any given time. Both are solutions.

k.udhay said:
2. If I go with force based governing equation (as you have suggested), where do I input the initial velocity of the mass? This is critical as this determines the amount of deformation of spring (= amplitude of sine wave)

Well if you were solving this analytically, you'd have a functional expression for ##x(t)## with some free parameters and you'd evaluate its derivative at ##t = 0## to use the information on ##v(0)##.

I don't know much about Simulink but I assume you are implementing differential equations and the software takes care of evolving a solution numerically from starting conditions. So here's a more convenient form for that.

A common transformation of 2nd order equations is to turn it into a system of 1st order equations.
So we have this:
$$-kx = m\frac {d^2x}{dt^2}$$

Change it to this equivalent system in the two variables ##v## and ##x##:
$$\frac {dx}{dt} = v \\
m\frac {dv}{dt} = -kx$$
Implement those two equations in those two unknowns with the desired initial conditions on ##x## and ##v##.
 
  • Love
Likes k.udhay
  • #6
I should emphasize that my comments are about the mathematics of the differential equations you're solving, as I have no expertise in Simulink. I have used Matlab for decades but managed to avoid ever using Simulink or even having it on a computer I was using.
 
  • Like
Likes k.udhay
  • #7
Thanks a lot. I will try this and update you.
 
  • #8
@RPinPA - I tried this in Simulink and there is actually a progress:

245203


However, I see some form of dampening effect in all position, velocity and acceleration plots. I am unable to understand the reason for this. This is my simulink model:
245204


The initial condition (40) tells that dx/dt = 40 when t = 0. I am not very sure if this way of inputting is right. I will be so glad if someone of PF helped me out of this issue. Thank you for guiding me very closely.
 

1. What is a spring mass impact system in Matlab?

A spring mass impact system in Matlab is a simulation of a physical system consisting of a mass attached to a spring, with an impact force applied to the mass. This system is commonly used to model various real-world scenarios, such as car collisions or bouncing balls.

2. What is the purpose of correcting a spring mass impact system?

The purpose of correcting a spring mass impact system is to ensure that the simulation accurately reflects the real-world scenario it is modeling. This involves adjusting the parameters and equations used in the simulation to match the physical properties and behavior of the system being simulated.

3. How do I know if my spring mass impact system in Matlab needs to be corrected?

If your simulation results do not match the expected behavior of the system in the real world, then it is likely that your spring mass impact system needs to be corrected. This can be confirmed by comparing the simulation results to experimental data or other reliable sources.

4. What are some common mistakes when creating a spring mass impact system in Matlab?

Some common mistakes when creating a spring mass impact system in Matlab include using incorrect equations or parameters, not accounting for all relevant forces and factors, and not properly setting initial conditions. It is also important to regularly check for errors and bugs in the code.

5. How can I correct my spring mass impact system in Matlab?

To correct a spring mass impact system in Matlab, you can adjust the equations and parameters used in the simulation, make sure all relevant forces and factors are included, and ensure that initial conditions are properly set. It may also be helpful to consult with other experts or references to ensure accuracy.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
0
Views
776
Replies
3
Views
637
Replies
4
Views
986
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Mechanical Engineering
Replies
16
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
805
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Introductory Physics Homework Help
Replies
5
Views
4K
Replies
6
Views
1K
Back
Top