Grids for Neighbor Finding

com.srbenoit.modeling.grid

This package provides classes to manage a grid that manages a objects within a two dimensional rectangle for molecular and granular dynamics simulations. Each object is assigned to a grid cell based on its coordinates, making the location of nearby objects much faster than searching all objects in the grid.

AbstractGrid2D
The base class for grid that may contain objects . Contained objects must be derived from GridMember.
BasedVectorGridMember2.java
A basic grid member based on BasedVector2.
DynamicGridMember2D
A base class for objects that may be contained in a 2-dimensional grid. Each object has an X and Y position, a radius, and a grid address.
EnumElementType
The possible element types in a simulation.
FastLennardJones
A class that precomputes Lennard-Jones forces and energies at some number of discrete points then returns an energy or force magnitude based on a square of the ratio of actual distance to equilibrium distance. This class adjusts the forces and energies so they go smoothly to zero at a distance of 2.5 * the equilibrium distance. For any distance ratio greater than 2.5, the class returns zero energy and force.
FastSoftSphere
A class that precomputes soft-sphere forces and energies at some number of discrete points then returns an energy or force magnitude based on a square of the ratio of actual distance to equilibrium distance. For any distance ratio greater than 1, the class returns zero energy and force.
Granular2D
Run a time evolution of a collection of granules.
Granule
A granule that interacts with Lennard-Jones potential.
Grid2D
A two-dimensional grid that may contain objects . Contained objects must be derived from GridMember. This class provides a fast way to iterate over the set of potential neighbors of an object.
GridIterator2D
An iterator that will iterate over a grid's elements.
GridMember2Int
A base class for objects that may be contained in a 2-dimensional grid. Each object has an X and Y position, a radius, and a grid address.
GridPanel2D
A panel that renders the state of a grid.
GridTest2D
A class to test the Grid class by constructing a grid and randomly adding and removing many objects, then testing the grid state for correctness and ensuring that neighbor lists returned are valid.
LinkedListGridMember2D
A base class for objects that may be contained in a 2-dimensional grid. Each object has an X and Y position, a radius, and a grid address.
PointGridMember2
A basic grid member based on Point2.

As the author of the source code available by following the links above, I hereby place this source code in the public domain. You can use, modify, and distribute the source code and executable programs based on the source code. However, note the following:
DISCLAIMER OF WARRANTY
This source code is provided "as is" and without any express or implied warranties whatsoever. The user must assume the entire risk of using the source code.