Hi all i'm new to programming and I wanted to ask a quick question: Consider the following leapfrog integration for one particle:
time=100;steps=1000000;dt=time/(steps-1);v0=5theta=2*pi*rand(1);vx(1)=v0*sin(theta);vy(1)=v0*cos(theta);t(1)=0;x(1)=50;y(1)=50;for i=1:steps-1 t(i+1)=t(i)+dt; x(i+1)=x(i)+vx(1)*dt; y(i+1)=y(i)+vy(1)*dt;end
How do I increase the number of particles in the leapfrog integration? eg 1000? Thanks in advance!
Some info (edited after request): Ok so, basically the particle starts at time t=0, at position x,y and at velocity vx,vy.
The simulation lasts for 100 seconds and consists in a million step. Leapfrog integration, in this case, consists in the for loop that updates the particle position every 100/1000000.
The problem is that i dont know how to scale this for loop for multiple particles. Thanks!
Best Answer