* classes. Except of the interpolator class itself it also relies on the
* proper functioning of grid accessors as well as on the Cell class.
*/
public void testChargeInterpolation() {
Settings stt = new Settings();
stt.setSimulationWidth(100);
stt.setSimulationHeight(100);
stt.setGridCellsX(100);
stt.setGridCellsY(100);
Grid grid = new Grid(stt);
//We iterate over all the grid cells manually to avoid dependence of this
//test on the cellIterator implementation. But using the grid method
//grid.resetCharge() should also work!
for (int x = -grid.EXTRA_CELLS_BEFORE_GRID; x <
(grid.getNumCellsX()+grid.EXTRA_CELLS_AFTER_GRID); x++) {
for (int y = -grid.EXTRA_CELLS_BEFORE_GRID; y <
(grid.getNumCellsY()+grid.EXTRA_CELLS_AFTER_GRID); y++) {
grid.getCell(x, y).resetCharge();
}
}
ArrayList<Particle> particles = new ArrayList<Particle>();
for (int i=0; i < 100; i++) {
Particle p = new ParticleFull();
p.setX(random.nextDouble()*stt.getSimulationWidth());
p.setY(random.nextDouble()*stt.getSimulationHeight());
//Assign random integer charge in the range (-10,10)
//Accuracy decreases with non integer charge, more particles
//as well as more cells.
p.setCharge((random.nextInt(20)-10));
particles.add(p);