diff options
| author | Connor Moore <connor@hhmoore.ca> | 2026-03-20 11:16:50 -0400 |
|---|---|---|
| committer | Connor Moore <connor@hhmoore.ca> | 2026-03-20 11:16:50 -0400 |
| commit | f7ad40d801e30f542baaf471e0b0d08aacc212ee (patch) | |
| tree | 6474c10e962b9591feb2d30d675e5c9620003e05 /class/putParticleInBox.f90 | |
| parent | 6ff45fe556d3b49a1506c5882036f909c143ed85 (diff) | |
Updated class code
Diffstat (limited to 'class/putParticleInBox.f90')
| -rw-r--r-- | class/putParticleInBox.f90 | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/class/putParticleInBox.f90 b/class/putParticleInBox.f90 new file mode 100644 index 0000000..d98a116 --- /dev/null +++ b/class/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 |
