Any help/explanations will be highly appreciated:
This works:
sol = NDSolve[{x''[t] + x[t] == Sin[t], x[0] == 0, x'[0] == 1,
WhenEvent[Abs[t x[t]] > 1, {x'[t] -> -x'[t]}]},
x, {t, 0, 8}][[1]];
xt = x /. sol;
Plot[xt[t], {t, 0, 8}];
This does not:
TT = t;
sol = NDSolve[{x''[t] + x[t] == Sin[t], x[0] == 0, x'[0] == 1,
WhenEvent[Abs[TT x[t]] > 1, {x'[t] -> -x'[t]}]},
x, {t, 0, 8}][[1]];
xt = x /. sol;
Plot[xt[t], {t, 0, 8}]
This crashes the Kernel:
sol = NDSolve[{x''[t] + x[t] == Sin[t], x[0] == 0, x'[0] == 1,
WhenEvent[(Abs[x[t]] > 1) && (x[t] > 5), {x'[t] -> -x'[t]}]},
x, {t, 0, 8}][[1]];
xt = x /. sol;
Plot[xt[t], {t, 0, 8}]