I am using Animate to animate the result of a system of coupled differential equations as I vary an initial condition A:
l = 1.0;
m = 1.0;
g = 10.0;
h = 10;
u = 0.05;
Animate[sol3 =
NDSolve[{m*
x''[t] == ((((m*g)/l)*(l/2 - (x[t]))*k[t]*
u) - (((m*g)/l)*(l/2 + (x[t])))*j[t]*u),
WhenEvent[x[t] == 0, {Tn[t] -> t, V0[t] -> Abs[x'[t]]}],
WhenEvent[
t == Tn[t] + ((3.14*(2*l/(u*g))^0.5)/
4) + ((3.0*V0[t]*h)/(4*g*(l/2 - r[t]))) + 0.01,
x'[t] ->
x'[t]*(1 - (((V0[t] + 1)*h*u)/(20*(1 + 1.2*V0[t])*Abs[x'[t]]*2*
l)))], WhenEvent[x'[t] == 0, r[t] -> Abs[x[t]]],
x[0] == A, x'[0] == 0, V0[0] == 0, Tn[0] == 0,
a[t] == Piecewise[{{0,
Tn[t] + ((3.14*(2*l/(u*g))^0.5)/
4) + ((3*V0[t]*h)/(4*g*(l/2 - r[t]))) > t >
Tn[t] + ((3.14*(2*l/(u*g))^0.5)/
4) - ((1*V0[t]*h)/(4*g*(l/2 - r[t])))}, {1,
t < Tn[t] + ((3.14*(2*l/(u*g))^0.5)/
4) - ((1*V0[t]*h)/(4*g*(l/2 - r[t])))}, {1,
t > Tn[t] + ((3.14*(2*l/(u*g))^0.5)/
4) + ((3*V0[t]*h)/(4*g*(l/2 - r[t])))}}],
WhenEvent[x[t] <= 0, b[t] -> 1], WhenEvent[x[t] > 0, b[t] -> 0],
WhenEvent[x[t] <= 0, c[t] -> 0], WhenEvent[x[t] > 0, c[t] -> 1],
d[t] == a[t] + b[t], f[t] == a[t] + c[t], k[t] == Tanh[100*d[t]],
j[t] == Tanh[100*f[t]]}, {a, x, Tn, V0, b, c, d, f, k, j, r}, {t,
0, 100}, DiscreteVariables -> {Tn, V0, b, c, r}];
Plot[x[t] /. sol3[[1]], {t, 0, 100}, PlotRange -> All], {A, 0.03,
0.045}]
However, the result I obtain by doing this is an extremely sloppy and non smooth animation. What could I do to make this animation smooth?