Given a partial differential equation, we can NDSolve for its solution. In my case I got a function of three variables $u(t,x,z)$. I wish to study the case when we restrict $z=0$. Most importantly, I wish to animate how $u(t,x,0)$ changes with time $t$ when we plot the function against $x$, and at each instant of time $t$ add, along with the graph, a modified centroid point which is defined to be the usual centroid point of the function $(u(t,x,0))^2$. While I am able to plot the function in animation, I find difficulty in plotting the point. The code is as follows:
\[CapitalOmega] = Region[Rectangle[{-10, -10}, {10, 10}]]
IC11 = u[0, x, z] == x*Exp[-(x/s)^2 - (z/3)^2]
IC12 = Derivative[1, 0, 0][u][0, x, z] == 0
s = 1
\[Rho]0 = 3
\[Rho]max = 1
\[Rho][x_] := (\[Rho]0 - \[Rho]max) (Sech[x/s])^2 + \[Rho]max
CA[x_] := 1/(B0/Sqrt[\[Rho][0] \[Mu]0])*B0/Sqrt[\[Rho][x] \[Mu]0]
uwave1 =
NDSolveValue[{1/(CA[x])^2 D[u[t, x, z], {t, 2}] -
D[u[t, x, z], {x, 2}] - D[u[t, x, z], {z, 2}] == 0,
u[0, x, z] == x*Exp[-(x/s)^2 - (z/3)^2],
Derivative[1, 0, 0][u][0, x, z] == 0,
DirichletCondition[u[t, x, z] == 0, True]},
u, {t, 0, 4 \[Pi]}, {x, z} \[Element] \[CapitalOmega], Method -> {
"PDEDiscretization" -> {"MethodOfLines",
"SpatialDiscretization" -> {"FiniteElement",
"MeshOptions" -> {"MaxCellMeasure" -> 0.2},
"InterpolationOrder" -> {u -> 2}}}}];
Animate[Plot[(uwave1[t, x, 0])^2, {x, 0, 10},
PlotRange -> {0, 0.2}], {t, 0, 4 \[Pi]}, AnimationRunning -> False]
where in the last part I plotted the animation. How should I proceed from here to add the centroid point into the animation? To clarify, the region is the region under the curve $u[t,x,0]^2$ at any specific time $t$ when plotted against x-axis.
centroid point
only define on a regions instead of functions. $\endgroup$uwave1[t,x,0]^2==uwave1[t,-x,0]^2
, that's whycentroid[t]==0
$\endgroup$