0
$\begingroup$

Linking to what is discussed here, writing the following code:

m := 1.52
g := 9.81
us := 0.30
uk := 0.20
k := 10.12
F := 1.00
xi := 2.20
vi := 0.00

sol = NDSolve[{

    F - k x[t] - Sign[x'[t]] uk m g == m x''[t],
    x[0] == xi,
    x'[0] == vi,

    WhenEvent[
     x'[t] == 0 && us m g >= Abs[F - k x[t]],
     tmax = t; "StopIntegration"]

    }, x, {t, 0, 10^4}];

and recalling the theorem of work and kinetic energy: the work done by all the forces acting on a body is equal to the variation of its kinetic energy, that is $\sum_j W_j = K_f - K_i$, I calculated:

NIntegrate[Sign[x'[t]] F - k x[t] - uk m g /. sol[[1]], {t, 0, tmax}] // Chop

-19.3941

1/2 m x'[tmax]^2 - 1/2 m x'[0]^2 /. sol[[1]] // Chop

0

I don't understand why work is not zero as the kinetic energy variation! Ideas?


Writing:

NIntegrate[m x''[t] x'[t] /. sol[[1]], {t, 0, tmax}] // Chop

you have perfect match!

$\endgroup$
5
  • 1
    $\begingroup$ "the work done by all the forces acting on a body is equal to the variation of its kinetic energy":NIntegrate[Sign[x'[t]] F - k x[t] - uk m g /. sol[[1]], {t, 0, tmax}] // Chop does not calculate the work but Intergates the force over time (work is force integrated over distance). $\endgroup$
    – Ruud3.1415
    Aug 14 '17 at 16:48
  • $\begingroup$ @Ruud3.1415: Given a vector field: $\mathbf{F} : \mathbb{R}^3 \to \mathbb{R}^3$ and a curve arc $\mathbf{r} : \mathbb{R} \to \mathbb{R}^3$ of support $\gamma$ and defined by $\mathbf{r} := \mathbf{r}(t)$ for $t \in [t_i,\,t_f]$, we define the work of the vector field $\mathbf{F}$ long $\gamma$ the line integral $W_{\gamma}(\mathbf{F}) := \int_{\gamma} \mathbf{F} \cdot \text{d}\mathbf{r} = \int_{t_i}^{t_f} \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t)\,\text{d}t$. $\endgroup$
    – TeM
    Aug 14 '17 at 17:11
  • $\begingroup$ @Ruud3.1415: Based on this, I thought that in this case we have: $\mathbf{F} = (F(t),\,0,\,0)$, $\mathbf{r}(t) = (t,\,x(t),\,0)$, $\mathbf{r}'(t) = (1,\,x'(t),\,0)$ for $t \in [0,\,t_{max}]$, then $W = \int_0^{t_{max}} F(t)\,\text{d}t$. Evidently I'm wrong, but I do not understand what! $\endgroup$
    – TeM
    Aug 14 '17 at 17:11
  • 2
    $\begingroup$ This is a one dimensional problem; the force is constrained to point along or against the direction of x. I suspect you'll have more luck with: $W=\int\, dx\, F = \int \,dt\, x' F$. I recommend warming up by using the same code on simple harmonic oscillator, then Damped SHO, then Driven Damped SHO, etc. Debugging where you have complete analytic control. $\endgroup$ Aug 14 '17 at 17:22
  • $\begingroup$ @JohnJosephM.Carrasco: Now everything works perfectly; I corrected it above. Thank you and good day / night / evening ...! $\endgroup$
    – TeM
    Aug 14 '17 at 17:46

Your Answer

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

Browse other questions tagged or ask your own question.