I model the propagation of a pulsating wave. Below is a system of partial differential equations with free boundaries (Neumann conditions), as well as a pulsating component.
Individual components of the field gradient $D[g_x(t, x, y), \{t, 1\}] = D[u(t, x, y), x]$ and $D[g_y(t, x, y), \{t, 1\}] = D[u(t, x, y), y]$ are added for further calculation of the trajectory of a particle moving in this scalar field (there may be an easier way, for now I did it this way).
Below is the code that calculates the solution of the PDE, and then plots the expected trajectory for a single particle that will move in this field.
What is the problem: the field itself is calculated and animated without problems. The problem is in the numerical solution of the ODE system for the generated initial position of the particle in the field and the gradient components. At certain values of time ($t>~7.8$), the solution becomes unstable. A harbinger of this is visible in the plots up to this point - the particle begins to move in the opposite direction. Expected result: the particle will spread along a uniform trajectory further and further from the center of the pulsations.
Below is the animation. Just keep in mind: I chose a lower frame rate, because preparing for the animation takes a significant amount of time, but that's another problem.
(*Define the parameters*) pars = {T = 7}; pulsatingComponent = Sin[3 t] 5 Exp[-5 ((x - 10/2)^2 + (y - 10/2)^2)/5]; (*Define the equations*) eqn = {D[u[t, x, y], {t, 2}] - Laplacian[u[t, x, y], {x, y}] == pulsatingComponent + NeumannValue[-Derivative[1, 0, 0][u][t, x, y], x == 0 || x == 10] + NeumannValue[-Derivative[1, 0, 0][u][t, x, y], y == 0 || y == 10], D[gx[t, x, y], {t, 1}] == D[u[t, x, y], x], D[gy[t, x, y], {t, 1}] == D[u[t, x, y], y]}; (*Initial condition function*) u0[x_, y_] := 5 Exp[-5 ((x - 10/2)^2 + (y - 10/2)^2)/5]; (*Define initial conditions*) ic = {u[0, x, y] == u0[x, y], Derivative[1, 0, 0][u][0, x, y] == 0, gx[0, x, y] == D[u0[x, y], x], gy[0, x, y] == D[u0[x, y], y]}; (*Solve the system of equations*) solutions = NDSolve[{eqn, ic}, {u, gx, gy}, {t, 0, T}, {x, 0, 10}, {y, 0, 10}, Method -> {"MethodOfLines", "SpatialDiscretization" -> {"FiniteElement"}}]; (*Calculate the time derivatives for gx and gy*) gxTimeDerivative = D[gx[t, x, y], t] /. solutions; gyTimeDerivative = D[gy[t, x, y], t] /. solutions; (*Generate random initial coordinates for particle*) seed = RandomReal[{1/2, 1/2}, 2]; (*Define the system of ODEs for particle trajectories*) trajectories = NDSolve[{w'[tValue] == First[gxTimeDerivative /. {t -> tValue, x -> w[tValue], y -> v[tValue]}], v'[tValue] == First[gyTimeDerivative /. {t -> tValue, x -> w[tValue], y -> v[tValue]}], w[0] == seed[[1]], v[0] == seed[[2]]}, {w, v}, {tValue, 0, T}]; (*Parametric plot of particle trajectories*) trajectoryPlot = ParametricPlot[ Evaluate[{w[tValue], v[tValue]} /. trajectories], {tValue, 0, T}, PlotRange -> All, AspectRatio -> 1, AxesLabel -> {"x(t)", "y(t)"}, PlotLabel -> "Particle Trajectory Over Time"] (*Plot of w(t) over time*) wPlot = Plot[w[tValue] /. trajectories, {tValue, 0, T}, PlotRange -> All, AxesLabel -> {"t", "w(t)"}, PlotLabel -> "Change of w(t) Over Time", PlotStyle -> Blue] (*Plot of v(t) over time*) vPlot = Plot[v[tValue] /. trajectories, {tValue, 0, T}, PlotRange -> All, AxesLabel -> {"t", "v(t)"}, PlotLabel -> "Change of v(t) Over Time", PlotStyle -> Red] Code for animation:
(* Compute the values of the derivative w[t,x,y] for different t *) dwdtFrames = Table[gxTimeDerivative /. {t -> tValue}, {tValue, 0, 8, 0.5}]; dvdtFrames = Table[gyTimeDerivative /. {t -> tValue}, {tValue, 0, 8, 0.5}]; (* Create animation for the derivative of w with respect to t *) dwdtAanimatedPlot = ListAnimate[ Table[Plot3D[Evaluate[dwdtFrames[[i]]], {x, 0, 10}, {y, 0, 10}, PlotRange -> All, AxesLabel -> {"x", "y", "\[PartialD]w/\[PartialD]t"}], {i, 1, Length[dwdtFrames]}]]; (* Create animation for the derivative of v with respect to t *) dvdtAanimatedPlot = ListAnimate[ Table[Plot3D[Evaluate[dvdtFrames[[i]]], {x, 0, 10}, {y, 0, 10}, PlotRange -> All, AxesLabel -> {"x", "y", "\[PartialD]v/\[PartialD]t"}], {i, 1, Length[dvdtFrames]}]]; (* Run the animation for the derivative of w *) dwdtAanimatedPlot (* Run the animation for the derivative of v *) dvdtAanimatedPlot 




seed = RandomReal[{1/2, 1/2}, 2]is{0.5, 0.5}. $\endgroup$