program LangevinDynamics2d_active
use TPS2d_active_def_enhanced
implicit none
	integer oldtraiet
	integer i,ntpt,l,j,k,nstep1,nstep2,m,u,n,ns
	real*8 x,y,phi,xnew,ynew,phinew,xstart,xfinal,tpt,DW,DW2,s,mm,phi2,dist,inphi,rdist1
	
	idum = -13
	iduv = -7
	x = 0.d0
	y = 0.d0
	phi = 0.d0
	ns = 0
	file_name1 = 'trajectory_final_par_v001Dr005_correct.dat'
	
	open(unit=10,file=file_name1,status='unknown')
	write(10,*) x,y,phi
	do while (ns .lt. 400000000)
		call GaussianVariable (DW,DW2)
!~ 		xnew = x + v*dcos(phi)*dt + fwx2d(x,y)/zeta + sigma * DW		!if you also have traslational diffusion, the code traj_analysis.f90 will not compute exact values for Dr
!~ 		ynew = y + v*dsin(phi)*dt + fwy2d(x,y)/zeta + sigma * DW2
		xnew = x + v*dcos(phi)*dt + fwx2d(x,y)/zeta
		ynew = y + v*dsin(phi)*dt + fwy2d(x,y)/zeta
!~ 		xnew = x + fwx2d(x,y)/zeta + sigma * DW
!~ 		ynew = y + fwy2d(x,y)/zeta + sigma * DW2
		call GaussianVariable (DW,DW2)
		phinew = phi + sigmar * DW2
		rdist1 = dsqrt(xnew**2+ynew**2)
!~ 		write(10,*) xnew,ynew,phinew									!if this is not commented, you can compute istantaneous speeds with code traj_analysis.f90
		if (mod(ns,20) .eq. 0) write(10,*) xnew,ynew,phinew				!if this is not commented, you cant compute istantaneous speeds from simulations but only average speeds every 20 steps, that is different!
		if (mod(ns,1000000) .eq. 0) print*, ns, xnew, ynew
		ns = ns + 1
		x = xnew
		y = ynew
		phi = phinew
	enddo
	close(10)

end program LangevinDynamics2d_active
