NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
3D/Sample Models

(back to the library)

[screen shot]

Note: If you download the NetLogo application, every model in the Models Library is included.


This model simulates hydrogen diffusion through a lattice, in particular, hydrogen desorption from solid state hydrides. These hydrides are hydrogen storage materials that absorb hydrogen at high pressures, and release hydrogen at high temperatures.

This research tool allows us to better understand the kinetics of hydrogen desorption from a lattice, which can aid in the development of candidate hydrogen storage materials for hydrogen fuel cell powered vehicles. These vehicles have the potential to be extremely efficient, zero-emission vehicles and may serve to be a central component in the battle against global warming.

Diffusion and desorption are complex material behaviors, and these kinetics are not well understood. There are several fundamental parameters involved in these processes:

Bond breaking

Hydrogen atoms are stored on molecular units like BH<sub>4</sub> and AlH<sub>4</sub>, where they are bonded to some central atom like boron or aluminum. In order for hydrogen to diffuse, it must break the bond formed with this central atom. An important factor affecting this process is the strength of the bond, controlled in the model by the hydrogen desorption probabilities sliders.

Diffusion through different phases

As hydrogen desorbs, the underlying crystal structure of the material will change. This in turn affects the movement speed of hydrogen atoms through the material. It is important to model the relative probability of a hydrogen atom moving into a cell depleted of hydrogen, versus a completely full cell.


There is a probability that if a hydrogen atom travels to a non-full cell, it will form bonds with the central atom in that cell. This reabsorption property is probabilistic and can dramatically affect the desorption rate from the materials.

This model explores the contribution of each of these properties on the desorption and diffusion behavior of candidate hydrogen storage materials. Different materials can be modeled through setting the absorption and desorption probabilities to match the behavior of the material under investigation.


The model begins with a fully saturated lattice with all available hydrogen in compound form. Hydrogen will diffuse freely through the lattice until they reach the surface of the material, where they must pair off in order to leave the lattice as a H<sub>2</sub> gas molecule. The simulation terminates when the available hydrogen in the model reaches the user-set termination percent.

The SETUP button initializes the model with a fully saturated lattice of hydrogen atoms.

The GO button begins the diffusion process. The lattice is represented by a series of small cubes marking the center of each lattice molecule. At each tick, hydrogen atoms have the opportunity to break their bonds to the lattice molecule. This behavior is controlled by the HYDROGEN DESORPTION PROBABILITIES sliders which define the probability of a hydrogen atom desorbing based on the number of hydrogen atoms currently bonded with the central atom. Free hydrogen within the lattice will move to one of its six neighboring patches with equal probability, unless one of them is a depleted (red) patch, where the probability is altered by a factor of RED-DIFFUSE. The hydrogen will continue to desorb/absorb over the course of the model run until it pairs up and leaves the system.

When a free hydrogen atom reach the surface of the lattice, it will still move once per tick, but can only move to other patches on the surface of the material. When it pairs up with another hydrogen, it flashes yellow then is removed from the model.

The color of the cube indicates the amount of available desorbable hydrogen. White:&nbsp;&nbsp;XH<sub>4</sub>: fully saturated with 3 potential available hydrogen atoms Blue:&nbsp;&nbsp;&nbsp;&nbsp;XH<sub>3</sub>: 2 potential hydrogen to be desorbed Green:&nbsp;&nbsp;XH<sub>2</sub>: 1 potential hydrogen to be desorbed Red:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XH&nbsp;&nbsp;: fully depleted with no available hydrogen to lose

*This is modeled after LiBH<sub>4</sub>, which follows the reaction LiBH<sub>4</sub> -> LiH+B+3/2H<sub>2</sub>. LiH is a stable compound and does not desorb more hydrogen.

When an atom has desorbed all available hydrogen, it becomes red and "stable". At this stage, it undergoes a "phase change". It is unknown if hydrogen will diffuse through these phases at different speeds, but it is very likely to have a different diffusing speed. Because the XH compound has less hydrogen, it ought to be less dense, and we anticipate the diffusion rate to be slower. In the model, this rate can be controlled by the RED-DIFFUSE slider.

The desorbed hydrogen follow a similar color scheme: Blue - first free hydrogen Green - second free hydrogen Red - third free hydrogen


The probability for desorption, diffusion, and absorption of free hydrogen can be changed using corresponding sliders. By varying the desorption sliders, one can control the probability for hydrogen atoms to free themselves from the compound at each of the three stages (4->3, 3->2, 2-1). Similarly, the absorption sliders control the probability for hydrogen atoms to be re-absorbed back into molecular form (causing the lattice cube to change color accordingly).

Visualization Options

The GRID-DRAW switch enables the user to turn on or off the grid markings for each patch. By default this is set to off and is generally not recommended for world sizes of larger than 5x5x5.

The four H-On switches enable the user to change the color of the desired hydrogen to dark gray. This allows the user to focus their attention on one particular stage of diffusion. For example, turning off the H4,H3,H2 switches will color everything dark gray except for the red depleted lattice patches as well as the final desorbed hydrogen.


Fraction of Surface H Remaining: Displays the fraction of desorbable hydrogen (vs. initial) remaining in the surface layer of the lattice.

Percent of Hydrogen Remaining: Displays fraction of desorbable hydrogen (vs. initial) remaining in the entire lattice.

Total Hydrogen Count: Displays total of both attached and free hydrogens remaining in the system over time.

Patch Distribution: Shows the distribution of patches based on how many desorbable hydrogen it are present


One interesting thing to notice about the model is that the Total Hydrogen Count plot will have two distinct slopes. First, there will be a steep decrease near the beginning of the simulation, due to the fact that the desorbed hydrogen atoms near the surface will quickly pair up and leave the system. This will be followed by a linear region of diffusion as the particles regularly leave the system. Given that the user has allowed for absorption and reabsorption at all stages, as the particles leave the system and desorption and reabsorption continues, the outer region of the lattice may decay to XH1(red) more quickly than the inner region. This is due to the fact that free desorbed hydrogen atoms exit through the surface of the material, while the hydrogen atoms in the central part of the lattice must diffuse more before being able to exit the system. Effectively, the inner lattice patches have greater opportunity to absorb free hydrogen. Changing the sliders can modify the degree to which this effect occurs.


Setting all hydrogen control parameters to 0.10 will induce a "shell effect," where outer hydrogen atoms leave quickly, and free hydrogen atoms will become trapped in the central region of the lattice. This is due to a re-absorption probability in combination with a slower relative diffusion rate through depleted cells.

When the RED-DIFFUSE is increased, the desorption rate decreases dramatically, with nearly linear dependence on this slider. With zero RED-DIFFUSE (0% chance to move to a red patch when there are other patches to move to), we observe many desorbed hydrogen atoms tightly grouped around a small area of non-depleted patches sustained by abnormally high re-absorption rates. Eventually these patches will become depleted, causing an 'explosion' of each of these clusters of free hydrogen atoms. While this phenomenon is rather unrealistic, 0% RED-DIFFUSE is unrealistic as well.

Absorption also plays a huge role on the rate of hydrogen leaving the system. With the absorption sliders set to 0, the simulation runs extremely quickly. But with a slight increase of p3to4 and p2to3 to 0.02, the simulation time nearly doubles.


There are many interesting techniques that are used to accelerate kinetics of desorption that could eventually be modeled by this simulation.

The properties that are being investigated (bond breaking, diffusion speed, etc.) are calculable using first-principles Density Functional Theory methods. Having a built in converter that changed binding energy directly to a bond-breaking probability would allow the model to be greatly extended to model a great number of realistic systems.

Additionally, there are several catalytic means that could be implemented into this model. There is a 'magic dust' concept, where the inclusion of a very small amount of catalyst can dramatically reduce desorption time. There is alloy seeding, where the existence of depleted patches nearby promote the formation of similar patches nearby, depleting hydrogen. There is finally a size-effect - it is known that nanoparticles desorb hydrogen at much lower temperatures than bulk materials, but it is not known why - sophisticated size effect models could also be examined.


This project was programmed by Daniel Kim, a graduating senior from the computer science department at Northwestern University as part of Professor Wilensky's Agent-Based Modeling class. It was advised by Wenhao Sun, a graduating senior in the Department of Materials Science and Engineering at Northwestern University.


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:


Copyright 2015 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at

This is a 3D version of the 2D model Hydrogen Diffusion.

(back to the NetLogo Models Library)