0
$\begingroup$

I am new here and trying to simulate a very simple dynamical system with periodic force or Dirac function:

$$mx'' + bx' + kx = u(t)$$

I want to draw the displacement(position) and velocity of the system.

Any suggestion for start?

$\endgroup$
3
$\begingroup$

There is a DSolve and DSolveValue function for this. In case of $m$, $b$ and $k$ constant it can be easily solved:

DSolveValue[m x''[t] + b x'[t] + k x[t] == DiracDelta[t], x[t], t]
(* E^(1/2 (-(b/m) - Sqrt[b^2 - 4 k m]/m) t) C[1] + 
    E^(1/2 (-(b/m) + Sqrt[b^2 - 4 k m]/m) t)
      C[2] - ((E^(1/2 (-(b/m) - Sqrt[b^2 - 4 k m]/m) t) - E^(
       1/2 (-(b/m) + Sqrt[b^2 - 4 k m]/m) t)) HeavisideTheta[t])/Sqrt[
    b^2 - 4 k m] *)

Also, this can be solved for u[t]:

DSolveValue[m x''[t] + b x'[t] + k x[t] == u[t], x[t], t]

To Plot it you need to specify the constants and initial condition.


Let's say you have the initial condition in a form of $x(0) = x_0$ and $x'(0) = v$ and $u(t) = \sin t$ (and :

s = DSolveValue[{m x''[t] + b x'[t] + k x[t] == Sin[t], x[0] == x0, 
    x'[0] == v}, x[t], t];
Plot[Evaluate[
  s /. {m -> 2, b -> 1, k -> 1} /. {{x0 -> 0, v -> 1}, {x0 -> 0, 
     v -> 2}, {x0 -> 0, v -> 5}}], {t, 0, 10}, PlotTheme -> "Web"]

dsolve solution

Here I plot the solution (s) for a constants all equal to 1 and for a number of initial conditions. Check the ReplaceAll for /. understanding.

And plot of both displacement and velocity can be done with:

Plot[Evaluate[{s, D[s, t]} /. {m -> 2, b -> 1, k -> 1, x0 -> 0, 
    v -> 1}], {t, 0, 10}, PlotTheme -> "Web"]

Plot of s, which is a displacement, and D[s, t], which is a velocity.

enter image description here


To analyse for over, under and critical dumping you need to assign $b$, $m$ and $k$ values, based on relation:

  • $b^2 < 4 mk$ - underdamping;
  • $b^2 > 4 mk$ - overdamping;
  • $b^2 = 4 mk$ - critical damping.

To analyze this, it would be better to solve equation for particular values:

s[m_, b_, k_] := 
  DSolveValue[{m x''[t] + b x'[t] + k x[t] == Sin[t], x[0] == x0, 
    x'[0] == v}, x[t], t];

Plot[Evaluate[
  MapThread[s, {{1, 1, 1}, {1, 16, 2}, {1, 1, 1}}] /. {x0 -> 0, 
    v -> 1}], {t, 0, 10}, PlotTheme -> "Web"]

Where, blue - underdamping, orange - overdamping and yellow - critical.

enter image description here

$\endgroup$
  • $\begingroup$ Thank you very much for the complete answer. $\endgroup$ – Sam May 6 '15 at 11:23
  • $\begingroup$ @Sam I have extended with plots of displacement for over-, under- and critical dumping. $\endgroup$ – m0nhawk May 6 '15 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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