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

Click For Summary

Discussion Overview

The discussion revolves around modeling a spring mass damper system in Matlab Simulink, specifically focusing on the impact of a mass moving at a known velocity hitting a spring. Participants explore the governing equations, expected outputs, and potential corrections to the model.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses confusion over the unexpected results from their Simulink model, which deviates from the anticipated sinusoidal displacement.
  • Another participant suggests that the energy equation used may not accurately reflect the signs of displacement and velocity, proposing a force-based approach instead.
  • Questions arise about why the energy-based governing equation fails to yield correct displacement values, with a focus on the role of velocity.
  • Participants discuss the necessity of incorporating initial conditions, particularly the initial velocity of the mass, into the force-based governing equation.
  • A suggestion is made to reformulate the second-order differential equation into a system of first-order equations for implementation in Simulink.
  • One participant notes their lack of expertise in Simulink while emphasizing their familiarity with Matlab, indicating a focus on the mathematical aspects of the problem.
  • A later reply indicates progress in the Simulink model but raises concerns about an unexpected damping effect observed in the results.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the effectiveness of the energy-based versus force-based governing equations, and the discussion remains unresolved regarding the damping effect observed in the Simulink model.

Contextual Notes

There are unresolved questions regarding the correct implementation of initial conditions in Simulink and the interpretation of the damping effect in the model outputs.

k.udhay
Messages
167
Reaction score
13
TL;DR
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
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   Reactions: k.udhay
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.
 
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)
 
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   Reactions: k.udhay
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   Reactions: k.udhay
Thanks a lot. I will try this and update you.
 
@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.
 

Similar threads

  • · Replies 0 ·
Replies
0
Views
2K
Replies
17
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
12K
  • · Replies 45 ·
2
Replies
45
Views
7K
  • · Replies 15 ·
Replies
15
Views
6K