From 5b08f435327695bb633cd21ae8252b25528de3f6 Mon Sep 17 00:00:00 2001 From: Connor Moore Date: Mon, 23 Mar 2026 01:40:30 -0400 Subject: New report and code for final submission. --- putParticleInBox.f90 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 putParticleInBox.f90 (limited to 'putParticleInBox.f90') diff --git a/putParticleInBox.f90 b/putParticleInBox.f90 new file mode 100644 index 0000000..d98a116 --- /dev/null +++ b/putParticleInBox.f90 @@ -0,0 +1,33 @@ + ! intakes coordinates and outputs index + integer function indexfxn(px, py) result(idx) + double precision, intent(in) :: px, py + double precision :: boxSize,yCoord + integer :: ix, iy + + !> Check if particle is in box + if(abs(px).GT.L/2 .OR. abs(py).GT.L/2) then + !> Particle is outside, don't track it + idx=b*b ! This is the "recycle bin" for untracked particles. + else + ! the sector size + ! M = floor(L / rc) + yCoord = - py + ! coordinate + half length of boundary [-L/2,L/2] -> [0,L] + ! divided by effective particle size to give coordinate + boxSize=L/real(b,8) + ix = floor((px + L/2.0d0)/boxSize) + iy = floor((yCoord + L/2.0d0)/boxSize) + + ! for particles on the boundary + ix = min(max(ix, 0), b-1) + iy = min(max(iy, 0), b-1) + if (ix < 0 .or. ix >= b .or. iy < 0 .or. iy >= b) then + print *, "ERROR: particle outside sector grid" + print *, "px, py =", px, py + stop + end if + + ! call rey's function + idx = TWOtoONE(ix,iy) + end if + end function indexfxn -- cgit v1.2.3