I have drawn one position(x,y,z) of N particles in an enclosed volume.
x[i] = random.uniform(a,b) ...
I also found the constant velocity(vx,vy,vz) of the N particles.
vx[i] = random.gauss(mean,sigma) ...
Now I want to find the position of the N(=100) particles over time. I used the Euler-Cromer method to this.
delta_t = linspace(0,2,n-1)
n = 1000
v = vx;...
r = x;...
for i in range(n-1):
v[i+1,:] = v[i,:]
r[i+1,:] = r[i,:] + delta_t*v[i+1,:]
t[i+1] = t[i] + delta_t
But I want to find the position over time for every particle. How can I do this? Also, how do I plot the particles position over time in 3D?
To find the position of the particles at a given time you can use the following code:
import numpy as np # assign random positions in the box 0,0,0 to 1,1,1 x = np.random.random((100,3)) # assign random velocities in the range around 0 v = np.random.normal(size=(100,3)) # define function to project the position in time according to # laws of motion. x(t) = x_0 + v_0 * t def position(x_0, v_0, t): return x_0 + v_0*t # get new position at time = 3.2 position(x, v, 3.2)