Skip to content

Commit 27c1fa8

Browse files
Added variation and warning to particle exercise
1 parent 32343f7 commit 27c1fa8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

content/exercises/particle.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,21 @@ <h2>Random Migrating Particles</h2>
5555
<li>The pseudocode for the overall algorithm is:</li>
5656
<code>for(iteration=0; iteration&lt;ITERATION; iteration++){</code>
5757
<ul>
58-
<li>For each of the particles that belong to my chare: change its <i>x</i> and <i>y</i> coordinate by a small random amount.</li>
59-
<li>Move all the particles that do not belong to a chare's bounding box to their correct homes. Since the movement is small, this will mean communication to the eight near neighbor chares. Some of these messages may contain no particles.</li>
58+
<li>For each of the particles that belong to my chare: change its <i>x</i> and <i>y</i> coordinate by a small random amount.
59+
If this change causes the particle to move to an invalid coordinate, keep the particle in its original position.</li>
60+
<li>Move all the particles that do not belong to a chare's bounding box to their correct homes.
61+
Since the movement is small, this will mean communication to the eight near neighbor chares. Some of these messages may contain no particles.
62+
For both efficiency and ease of implementation, all communication with neighbor chares should happen at the end of an iteration rather than after each particle.</li>
6063
<li><code>if(iteration%10 == 0)</code></li>
6164
<ul>
6265
<li>Do reductions to calculate average and max number of particles</li>
6366
</ul>
6467
</ul>
6568
<code>}</code>
69+
</ul>
70+
71+
<p><u>Instructor's Note</u>: This exercise can be implemented in several ways, feel free to choose from the variations below or create your own based on your learning objectives:</p>
72+
<ul>
73+
<li>Choose to move the particle along either the <i>x</i> <i>or</i> <i>y</i> axis using an additional random variable, which simplifies communication as there are now only four neighbor chares.</li>
74+
<li>If a movement causes a particle to move to an invalid coordinate, move in the opposite direction instead.</li>
6675
</ul>

0 commit comments

Comments
 (0)