NetLogo banner

NetLogo Publications
Contact Us

Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Farsi / Persian


NetLogo Models Library:
Sample Models/Chemistry & Physics/Materials Science

(back to the library)

Molecular Dynamics Lennard-Jones

[screen shot]

If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web


This is a model of atoms interacting. Atoms are modelled as Newtonian objects (i.e., point masses with position and velocity) which apply forces on one another and move according to Newton's laws. This is known as a "molecular dynamics model."

Many properties of matter can be modelled using this technique, such as phase changes, thermal expansion, crystal structure, which can all be seen in this model. Other emergent properties of matter can be modelled using molecular dynamics with more complicated interatomic potential functions that take into account the properties of different types of atoms.

This model is similar to the Monte Carlo Lennard-Jones model in the models library, in that they both model matter using the Lennard-Jones potential. However, the computational techniques are different. Molecular dynamics computes the actual trajectories of atoms. This allows you to model how the system evolves over time, but it takes longer to model a given amount of time in the real world. In contrast, Monte Carlo uses statistically weighted random jumps to update the model state. This allows for computing the equilibrium state of the system more quickly, but the path that the system takes to get there is not necessarily realistic.


Atoms in this model interact according to the Lennard-Jones interatomic potential. In reality, the protons and electrons in each atom interact with the electrons and protons in other atoms. The opposite charge particles (protons in one atom and electrons in the other) attract and the same-charged particles repel. At close distances, the repulsion is stronger than the attraction and atoms exert a net repulsive force on each other. At long distances the attraction is stronger than the repulsion and the atoms exert a net attractive force on each other. At a specific distance the two forces balance and the net force they exert on each other is zero. To summarize, atoms (approximately) do not interact at long distances, attract at relatively short distances, and repel if they are squeezed too close together.

At each tick in the model, atoms calculate the forces they feel from all the atoms around them and sum these forces into a single net-force vector. Based on this force, they are accelerated according to F=ma (a=F/m). They then move a small distance at their current velocity.

The exact algorithm used in this model to update velocity based on forces and to move based on velocity is known as the Velocity Verlet algorithm, named after the French physicist Loup Verlet. The Velocity Verlet algorithm was chosen because it conserves energy (potential + kinetic energy will stay constant in the model) and it is easier to use than the other algorithms with this property. It is important for a physical model such as this one to not violate conservation of energy.


When you press the SETUP button, a number of atoms are created according to the NUM-ATOMS slider. If INITIAL-ARRANGEMENT is set to "random" then the atoms will be positioned randomly. If it is set to "Hexagonal Close Packed" the atoms will start in a hexagonally close-packed structure. The initial velocities are set so that the temperature of the system equals the TEMP slider. Remember, that temperature is actually a measure of the average kinetic energy of the atoms in the system. The BOND-STRENGTH slider determines the strength of bonds (how much energy it takes to break them).

If CONSTANT-TEMPERATURE? is on, then the velocities of the particles are scaled each tick to keep the average temperate equal to the TEMP slider. You can think of this as the system being in thermal equilibrium with some outside body that is at that temperature. If CONSTANT-TEMP? is off, then the temperature is allowed to change away the initial temperature. You can think of this as the system being thermally insulated, and the interactions within the system can change the temperature. Note that temperature is on an arbitrary scale.


Notice how the atoms move at different temperatures. Notice what configuration the atoms solidify in. What is the maximum number of neighbors an atom can have?

If CONSTANT-TEMP? is off and the INITIAL-ARRANGEMENT is random, what happens to the temperature? Why is this?


Try running the simulation at different temperatures and bond-strengths. At what temperatures do phase changes happen? Does it depend on the bond strength?

Try starting the atoms in random vs Hexagonal Close Packed configurations. What are differences between what happens at different temperatures from these two starting conditions?


Try adding plots to graph the distribution of x and y velocities. What do the graphs look like?

Try coloring the atoms based on their velocity or kinetic energy to see what the distribution looks like.

Try adding a second type of atom of a different size. You will need to decide how to combine their two sigmas (which models atomic radius) in the calc-force procedure.


  • Monte Carlo - Lennard-Jones
  • The GasLab models
  • Electrostatics
  • Dislocation Motion and Deformation


This model uses the dx and dy primitives to get the x and y components of the force atoms exert on one another. This is a way of decomposing the force vector into its x and y components.


This model uses the integration method known as Velocity Verlet. See the wikipedia entry for more information


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 2022 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

(back to the NetLogo Models Library)