# Explicit time dependent force in NBodySimulation

I'm looking for a way to use [NBodySimulation](https://reference.wolfram.com/language/ref/NBodySimulation.html) to simulate the application of a force stemming from a laser-chirp - which means the force will change in time (also in space and as a function of velocity). I think I'm supposed to use "ExternalForce" to apply a "blanket" force to all particles, but following the instructions there doesn't seem to be a way to make it time dependent. How could I achieve that?

Below is a simple example of what I'm trying to do using NDSolve many times... which may already be a rather simplistic approach.

Clear[z]; anu = 5.1 10^9; \[Beta]nu = 1.5 10^16; qnu = 1.2 10^7; npart = 1000; time = 100 10^-9;
Velocities = RandomVariate[NormalDistribution[0, 18], npart];
Positions = RandomReal[{-0.13/2, 0.13/2}, npart];

xsol = Table[NDSolve[{z''[t] == -anu Sin[qnu z[t] - \[Beta]nu t^2],
z'[0] == Velocities[[i]], z[0] == Positions[[i]]},
z, {t, 0, time}], {i, 1, npart}];

FinalVelocities = Table[Evaluate[z'[time] /. xsol[[i]]][[1]], {i, 1, npart}];

• Could you include the code you have so far? Edit your question to add the code as text, properly formatted. Please include all definitions necessary to run it as well. – MarcoB Jun 10 '20 at 16:45
• You can always formulate the equations of motion yourself. I suppose this is even a part of your project. Sooner or later you will want to simulate larger and larger systems, and linear scaling (with the system size) methods will be needed. You can use MA to solve the resulting ODEs. – yarchik Jun 10 '20 at 19:55