Develop a computer program using python to model diffusion limited aggregation,
ID: 3887675 • Letter: D
Question
Develop a computer program using python to model diffusion limited aggregation, or DLA for short. Take a square grid (101x101) with a single particle in the middle. For this simulation, the particle will be restricted to moving up, down, left, or right. The particle performs a random walk until it reaches a point on the edge of the square, at which point it sticks to the edge, becoming immoveable. Then, a second particle starts at the center and does a random walk until it sticks to either a particle or a an edge. A third particle then starts at the center, and the process continues until a particle cannot move from it’s initial position. Repeat this with a 201x201 lattice.
Explanation / Answer
Write your paint method first, and test it using temporary “dummy” values for the boolean lattice variables and the current coordinates of the wandering particle. For now, draw each lattice site as a square that’s at least a few pixels across, so you can easily see each square. Plan to reduce the square size (and correspondingly, increase the size of the simulated space) later. Once your paint method is tested and working, write a method (call it addParticle) to add a single wandering particle to the cluster. This method should implement the algorithm described above, initializing the particle’s location and then moving it randomly until it finds a permanent home adjacent to an alreadyoccupied site. To make the simulation run faster, you can test whether the particle has wandered outside the initial circle and if so, move it back in to the circle (without changing its angle relative to the center). To calculate the angle unambiguously you’ll need the Math.atan2 function (look it up in the Java API reference, and make a note in your lab report describing how it works). Create a separate thread to call the addParticle method repeatedly (until the cluster grows too large), and use the Thread.sleep method to slow down the simulation so you can see each move during the particle’s random walk. Implementing the logic of the algorithm will require some thought and care, and probably some debugging. Take your time, and keep a record of your successes and failures in your lab report. Once the algorithm seems to be working (or perhaps before), you’ll want to add some buttons to control the simulation. At a minimum, create a “Run/Pause” button and also a checkbox to disable the sleeping (and thus speed up the simulation). (If you’ve never made a checkbox before, look it up in the Java API reference and again make notes in your lab report.) Optionally, you could add a button to clear the lattice so you can start over without quitting the program. In general, try to keep a record in your lab report of anything you learn or figure out that you think would be helpful to someone else who is trying to reproduce what you did.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.