Asymmetric spring with two different stiffnesses
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Paolo Alloisio
le 5 Juil 2020
Commenté : Paolo Alloisio
le 8 Juil 2020
I'm trying to model a mass spring damper system and I want to describe the spring with two different values of k in bump and in rebound. I wrote the system made by the free body equations and what now what I want to do is to solve it with ode45, but I cannot find the way to compare y(t) and y(t-1) and to understand what stifness I have to use. I tried to define a vector in the function I wrote to solve the differential system, and the idea was to write in the i position the current value of the displacement but I don't know the lenght of the vector and at the beginning of every new iteration it goes zeros(n,1). Is there any solution to save and compare different values from different iterations in this case?
5 commentaires
darova
le 6 Juil 2020
remember about clearing persistent variable before each run
clear functions % clear persistent variables from functions
Réponse acceptée
Bjorn Gustavsson
le 8 Juil 2020
Yeah, I think that should be the correct test. In the modeling you do you have rather big difference in spring constant. When I test with this simplified version:
f_assyspring = @(t,y) [y(2);-y(1)*(1+1*double(sign(y(1))==sign(y(2))))];
t = linspace(0,50,3001);
y0 = [1,1];
[T2,Y2] = ode45(f_assyspring,t,y0);
subplot(2,1,1)
ph = plot(T2,Y2);
axis([0 20 -2 2])
grid on
legend(ph,'y-displacement','y-velocity')
subplot(2,1,2)
plot(T2,gradient(Y2(:,2),T2))
axis([0 20 -2 2])
legend('y-acceleration')
grid on
The solution behaves OK - in a mathematical sense.
However, from a physical point-of-view, this physical model decays rapidly - because it dissipates energy at the turning-points when there is a switch to the smaller spring-constant - at that point the simple Hooksian sping has a lot of stored energy (proportional to |ky^2| IIRC). By switching spring-constant there the difference in stored energy is magiced-away - which feels dodgy to me, for dampers I can see that it would be possible to have different leveles of dissipation in different directions.
Plus de réponses (1)
Bjorn Gustavsson
le 6 Juil 2020
ODE45 takes a function, f(t,y), describing the differential equation.
You have a differential equation something like this
where k has one value if the spring moves in one direction (dy/dy < 0) and another value when the spring moves in the other direction - how you connect those forces at the points where the velocity is zero I do not know.
ODE45 takes functions describing first-order odes, so the way to implement equations of motions is to convert the second-order ODE to 2 coupled first-order odes. That way we get something like this:
function dydtdvdt = your_ode(t,y)
k_p = 12; % Or whatever your spring-constants over mass are...
k_n = 10;
if y(2) > 0
a = -k_p * y(1);
else
a = -k_n * y(1);
end
dydtdvdt = [y(2);
a];
end
Then you call ODE45 with this function the time-period of interest and the initial conditions (y(0) and v(0)), and then you get the numerical solution to your ODE. If you have a damper you'll have to add that force-term too.
HTH
9 commentaires
Bjorn Gustavsson
le 8 Juil 2020
So that characteristic you should be able to implement as a combination of checks on the velocity, and the sign of y, you get four cases to check for.
However, this model will have an assymetry around the turning-points where changes sign. That is where the |ky| will be at its maximum. How you see this connected to the physics of the springs is up to you, but to me it looks peculiar.
ODE45 uses a 4-5 version of Runge-Kutta, so the Wikipedia-page should be a good introduction. If you need to get into the details the function is implemented in plain .m-code so you can read it, there are also references to publications in the ode45.m file.
Voir également
Catégories
En savoir plus sur Assembly dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!