# Animating with changeable parameters

I am constructing a demonstration to show how vibration depends on frequency. I wish to change the frequency with a slider and show how the vibration pattern is modified. The problem is that the animation is poor quality despite setting the PerformanceGoal to "Quality". I suspect I need to simplify the animation some how so that the animation looks good. Can you help?

The problem is set up using eigenvectors and values.

With[{L = 5, w = 0.5},
Ω =
RegionUnion[Disk[], Rectangle[{0, -w}, {L, w}], Disk[{L, 0}, 1]];
]
{vals, funs} =
NDEigensystem[{-Laplacian[u[x, y], {x, y}],
DirichletCondition[u[x, y] == 0, True]},
u, {x, y} ∈ Ω, 6];
TableForm[vals]


Now I use a dynamic module to show the vibration amplitude at one point and an animation of the whole region.

ClearAll[resonanceDemo];
resonanceDemo[{vals_, funs_}, Ω_] :=
DynamicModule[{f, sf = 1, ω = 10.2, ω1, x0 = 1,
y0 = 0, ζ = 0.01, amp},
f[{x0_, y0_}, {x_, y_}, ω_] :=
Evaluate[
sf Sum[ (ω^2 funs[[i]][x0, y0] funs[[i]][x, y])/
Sqrt[(ω^2 -
vals[[i]]^2)^2 + (2 ζ ω vals[[i]])^2], {i,
Length@vals}]];
amp = f[{x0, y0}, {x0, y0}, ω];
Column[{
Row[{"Frequency",
Slider[Dynamic[ω, (ω = #;
amp = f[{x0, y0}, {x0, y0}, ω];) &], {0, 20},
ContinuousAction -> True, Appearance -> "Labeled"]}],
Dynamic[
Plot[Evaluate[f[{x0, y0}, {x0, y0}, ω1]], {ω1, 0,
20}, Epilog -> {Red, PointSize[0.01], Point[{ω, amp}]},
PlotRange -> All, AspectRatio -> 1/4, ImageSize -> 12 72,
Frame -> True, FrameLabel -> {"Frequency", "FRF"}]],
Animate[Plot3D[Evaluate[
Sin[t] f[{x0, y0}, {x, y}, ω]
], {x, y} ∈ Ω,
PlotRange -> {All, All, {-40, 40}}, Boxed -> True,
BoxRatios -> {7, 2, 2},
AspectRatio -> Automatic, Axes -> True, Mesh -> True,
ImageSize -> 12 72, PerformanceGoal -> "Quality"
], {t, 0, 2 π}]
}]
]


Then I get

resonanceDemo[{vals, funs}, Ω]


What you see in this image is not what I see on my screen. On my screen the image is animated but the ends are not circular but polygonal as if the animation was using reduced quality for speed. Also there is no pink (showing an error) that only occurs when I stop the animation. How can I get a good quality animation?

• tip1: Dynamic@Point[{\[Omega], amp}] is enough, you don't need whole Plot in Dynamic. – Kuba Sep 29 '16 at 15:32
• @Kuba That should help a bit. Presumably I am redrawing the whole plot each time. Thanks – Hugh Sep 29 '16 at 15:42