-1
$\begingroup$

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.

enter image description here

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.

$\endgroup$
3
  • 1
    $\begingroup$ 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? $\endgroup$
    – Umaxo
    Commented Oct 22, 2019 at 12:48
  • $\begingroup$ @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. $\endgroup$
    – alephzero
    Commented Oct 22, 2019 at 13:01
  • $\begingroup$ @Umaxo Sorry, my mistake I just meant to replace $cv$ by the drag force. There is still a spring. $\endgroup$ Commented Oct 22, 2019 at 13:09

2 Answers 2

2
$\begingroup$

You forget the direction of the damping force.

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)

$\endgroup$
2
  • $\begingroup$ Thanks for your reply. The graph definitely changed. But, when I look at the velocity vs time graph, it looks like a decay which limits to -20. I have added the main logic of my code in the question. $\endgroup$ Commented Oct 22, 2019 at 13:17
  • $\begingroup$ I gave some suggestions for solving the 1/0 problem to an unrelated PDE in this answer; it may be of some use here. $\endgroup$
    – Kyle Kanos
    Commented Oct 25, 2019 at 11:19
0
$\begingroup$

Change your equation to: $$ ma + kx + \frac{\rho Av^2C}{2} = 0 $$ and it should work.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.