diffuse

 

diffuse is an observer primitive that acts on every patch in the model. It causes each patch to diffuse (or spread around) the value of a given patch variable to their 8 neighboring patches. This primitive is very useful when we want to simulate processes where diffusion happens such as the diffusion of a smell or pollution in the air.

For example, if every patch owned a pollution variable that kept track of how polluted that patch was, you could use (as the observer, not inside of an ask patches block) diffuse heat 0.5 and every patch would equally distribute half of its heat to its 8 surrounding neighbors. Each neighbor would get 1/8th of the 1/2 of the original heat, resulting in each neighbor's heat increasing but the original patch's heat halving.

Things to keep in mind when using diffuse:

In the model example below, we use diffuse to model air pollution from a factory. At each tick, the factory releases some pollutant into the air by increasing the pollution variable of the patch there by 1. Then, the pollution diffuses from this original patch to its neighbors, and then from its neighbors to its neighbors' neighbors, and so on. As a result, the pollutant spreads through the air, creating zones and hotspots of pollution.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the diffuse primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the diffuse primitive:
 
 
Similar primitives:
patches-own

Defines custom characteristics (variables) for patches. Each custom characteristic can have a different value for each patch.

Read more
patches

Reports an agentset that contains all the patches in a model.

Read more
globals

Defines variables that can be accessed throughout the whole model and has the same value for all the agents.

Read more
neighbors

Reports an agentset containing the eight neighboring patches.

Read more
 
Learn another primitive: