I am modelling 3D motion of particles inside a force-field using second-order coupled PDEs, which I solve from time t=t0 to t=t1 with initial conditions x0,y0,z0. I have a total number of "particles" n with subscript i and for each of these particles I model j collisions.
It is relatively straightforward to obtain the position vector r[t1]=={x[t1],y[t1],z[t1]} and the velocity vector r'[t1] for a single particle p_i by solving the PDEs once, but what I want to do is keep track of these outputs and use them as inputs in the subsequent calculation. That is to say, I want to then solve my PDEs from t=t1 to t=t2 using initial conditions r[t1] and r'[t1], and so on until I'm done . My code so far is:
f[nn_] :=
Module[{n = nn},
temp = Quiet@
ParallelTable[(NDSolve[{x''[t] == -x'[t] - x[t],
y''[t] == -y'[t] - y[t], z''[t] == -z'[t] - z[t], x[0] == 1,
x'[0] == 1, y[0] == 1, y'[0] == 1, z[0] == 1,
z'[0] == 1}, {x, y, z}, {t, tjs[[i, j]], tjs[[i, j + 1]]}]) //
First, {i, n}, {j, Length[tjs[[i]]] - 1}]]
nn = 20;
et = 2.1 10^7;
p = 1;
pdft[t_, p_] = et p 10^-6 E^(-(et p 10^-6) t);
trndm[p_] :=
RandomVariate[ProbabilityDistribution[pdft[t, p], {t, 0, Infinity}]]
tj := Prepend[(sum = 0;
Reap[While[sum < 0.05, sum = Sow[sum + trndm[p]]]][[2, 1]]), 0]
tjs = Table[tj, nn];
Table[(tjs[[i, Length[tjs[[i]]]]] = 0.05), {i, nn}];
f[nn]
So, each time I run the module f[nn]
it properly solves j collisions for each particle i, but it does so using the same initial conditions every time.
I've tried to provide a MWE so if something is missing or needs clarification please let me know.