# Damping of horizontal mass-spring system at high velocities [closed]

I am trying to study the damping of a horizontal mass-spring system at high velocities. The equation for damping due to a viscous fluid at low velocities is:

$$ma+cv+kx=0$$

I changed the equation to :

$$ma + kx +\frac{\rho A v^2 C}{2} = 0.$$ However, when I graph displacement vs time, I get a weird graph.

Why does this not look like a normal damped sine/cosine wave. How can I make it look so? Have I made a mistake in the formula?

code snippet:

for run in range(runs):

times.append(times[run] + dt)

x = positions[run]
v = velocities[run]
dxdt = v
v2 = (v**3)/abs(v)
dvdt = -(k/m) - (l30*v2)/m

positions.append(x+dxdt*dt)
velocities.append(v+dvdt*dt)


positions, times and velocities are all arrays.

• where is the spring in the second equation? Also, you seem to start with zero displacement and zero velocity. With such initial conditions, the system should remain at rest. Curious it did not. How did you compute the displacement as function of time? – Umaxo Oct 22 '19 at 12:48
• @Umaxo Look closer at the graph. The displacement scale is multiplied by $10^{277}$. There is no physical reason why there must be a spring, and that is not why the calculation blew up. – alephzero Oct 22 '19 at 13:01
• @Umaxo Sorry, my mistake I just meant to replace $cv$ by the drag force. There is still a spring. – NoLand'sMan Oct 22 '19 at 13:09

In the linear equation the $$-v$$ term always has the opposite sign to $$v$$, which is correct.
But in your quadratic damping equation $$-v^2$$ is always negative. If $$v$$ is negative, that force is increasing the speed of the particle, not decreasing it, and the particle shot off to infinity as in your graph.
Change $$-v^2$$ to something like $$-v^3/|v|$$, which has the same magnitude as $$-v^2$$ but the sign is always opposite to $$v$$. Note, in a computer program you probably have to handle $$v=0$$ as a special case, to avoid calculating $$0/0$$. (The force is $$0$$ when $$v=0$$, of course)
• I gave some suggestions for solving the 1/0 problem to an unrelated PDE in this answer; it may be of some use here. – Kyle Kanos Oct 25 '19 at 11:19
Change your equation to: $$ma + kx + \frac{\rho Av^2C}{2} = 0$$ and it should work.