5
$\begingroup$

Considering the following physical situation:

enter image description here

and writing the following code:

μs := 0.50
μk := 0.20

g := 9.81
M := 2.00
m := 0.30
L1 := 6.00
L2 := 1.00

xi := 0.00
vi1 := 0.50
Θi := 80.00 Pi/180
vi2 := 0.00

tmax := 10

T[t_] := Max[0, m g Cos[Θ[t]] + m (L2 + x[t]) Θ'[t]^2]

sol = NDSolve[{

    If[stop[t] == 1 || stuck[t] == 1, 0, Evaluate[-μk m g + T[t]]] == M x''[t],
    -m g Sin[Θ[t]] == m (L2 + x[t]) Θ''[t],

    stop[0] == If[L1 == 0, 1, 0],
    stuck[0] == If[vi2 == 0, Boole[μs M g >= T[0]], 0],
    x[0] == xi,
    x'[0] == vi1,
    Θ[0] == Θi,
    Θ'[0] == vi2/L2,

    WhenEvent[x[t] == L1, {stop[t] -> 1, x'[t] -> 0}],
    WhenEvent[x'[t] == 0, Evaluate[stuck[t] -> Boole[μs M g >= T[t]]]],
    WhenEvent[Evaluate[μs M g < T[t]], stuck[t] -> 0]

    }, {Θ, x}, {t, tmax},

    DiscreteVariables -> {stop, stuck}];

 Plot[Evaluate[{x[t], Θ[t], T[t]} /. sol],{t, 0, tmax},
          AxesLabel -> {"t", "fct[t]"},
          PlotLegends -> {"x", "Θ", "T"}, 
          PlotRange -> All]

you get:

enter image description here

which is finally what you want! ^.*

$\endgroup$
0

1 Answer 1

3
$\begingroup$

There is just a suitable example of static friction in NDSolve documentation. The trick is to use stuck[t] function as an indicator of whether the block is under the effect of friction or not. Here is the solution:

NDSolve[{-P2 Sin[\[CapitalTheta][t]] == 
    m (L + x[t]) \[CapitalTheta]''[t], 
   x''[t] == 
    If[stuck[t] == 1, 0.0, Evaluate[(-Fk + T[t])/M]], \[CapitalTheta][
     0] == \[CapitalTheta]i, \[CapitalTheta]'[0] == vi1/L, x[0] == xi,
    x'[0] == vi2, stuck[0] == 0, 
   WhenEvent[x'[t] == 0, 
    Evaluate[stuck[t] -> Boole[Fs >= Abs[T[t]]]]], 
   WhenEvent[Evaluate[Fs < Abs[T[t]]], 
    stuck[t] -> 0]}, {\[CapitalTheta], x, x'}, {t, tmax}, 
  DiscreteVariables -> stuck[t]];
$\endgroup$
5
  • $\begingroup$ @TeM Just use this same technique and add another discrete variable (e.g. stop[t]) into your equations and add event setting speed to zero x'[t]->0. $\endgroup$
    – swish
    Aug 16, 2017 at 19:00
  • 1
    $\begingroup$ @TeM As I said you need another variable and not the same stuck[t]. The block starts to move again, because the event of T > Fs triggers and unstucks it. $\endgroup$
    – swish
    Aug 17, 2017 at 21:22
  • 1
    $\begingroup$ You need to change the action stop[t] -> 1; x'[t] -> 0 to sequential {stop[t] -> 1, x'[t] -> 0}. Because the rule syntax for action is a special case and works only if it's the last one, so only x'[t] -> 0 applies and not stop[t] -> 1 in your case. $\endgroup$
    – swish
    Aug 17, 2017 at 22:12
  • $\begingroup$ I'm glad it's perfect now, but have you figured out what happens when you allow the block to reach L2 and angle just starts growing? Because I don't yet and I'm curious :) $\endgroup$
    – swish
    Aug 17, 2017 at 23:42
  • 1
    $\begingroup$ My guess it's fine, because the ball just starts rotating around the axis as some momentum got transfered to it. $\endgroup$
    – swish
    Aug 17, 2017 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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