Here is a part of my code:
tmax = 0.1;
tmin = 0.;
nsteps = 10000.;
nparticles = 10000;
dt = (tmax - tmin)/nsteps;
xpa = Table[0, {ti, nsteps}, {i, nparticles}];
vpa = Table[0, {ti, nsteps}, {i, nparticles}];
Afterwards I have a loop in time that has nsteps in time and save the xpa and vpa in each iteration
Do[
v = v + dt/2.*elp;
x = x + dt*v;
x = xpcp[x, xgrid, nparticles, ngrid, dx];(*x=x1;*)
x = xpcm[x, xgrid, nparticles, ngrid, dx];(*x=x1;*)
\[Rho] =
rho2[x, xgrid, q, nparticles, ngrid, dx];(*\[Rho]=\[Rho];*)
\[Phi] = phi[\[Rho], ngrid, eps, dx]; \[Phi] = 1/(dx*dx)*\[Phi];
el = elg[\[Phi], ngrid, dx]; el = el*(eps*dx);
(*elpart[x,xgrid,nparticles,ngrid,dx,el];elp=elp;*)
elp = elpart2[x, xgrid, nparticles, ngrid, dx, el];
epa[[t]] = elp;
xpa[[t]] = x;
vpa[[t]] = v;
v = v + dt/2.*elp,
{t, 1, nsteps}] // AbsoluteTiming
Now I want to do a video animation where xpa will be the x coordinates, vpa will be the y coordinates (I need the something like this {xpa[[t]],vpa[[t]]} for all steps in time. As a trial I am trying to do this only for 65 iterations in time.
fplot = Compile[{{xp, _Real, 10000}, {vp, _Real,
10000}, {np, _Integer}, {ns, _Integer}, {temp, _Integer}},
Block[{data, plot},
data = Table[0, {ti, ns}, {i, np}];
Do[data[[ti]] = MapThread[{#1, #2} &, {xp[[ti]], vp[[ti]]}], {ti,
ns}];
plot = Table[ListPlot[data[[t]]], {t, temp}]; plot],
CompilationTarget -> "C", RuntimeOptions -> "Speed"];
plotf = fplot[xpa, vpa, nparticles, nsteps, 65]; // AbsoluteTiming
And when I run this it is extremely slow and gives this error
CompiledFunction::cfta: Argument {<<802080128 bytes>>} at position 1 should be a rank 10000 tensor of machine-size real numbers.
How can I correct this?