The Simulation Object¶
How can I configure and control a simulation?
How do I choose which processor to use?
Explain the parts of the Simulation object and how they relate.
Explain how the device object influences how the simulation executes.
Demonstrate the creation of these objects.
HOOMD-blue is an object-oriented Python package. First, import the package:
The Simulation object combines all the elements of a simulation together and provides an interface to run the simulation. It consists of the simulation state and operations which act on that state. The simulation state includes the current box, bonds, particle positions, velocities, orientations, and other particle properties. Operations examine or modify the state. A simulation has one state, and any number of operations.
Selecting a device¶
You must specify a device when constructing a Simulation. The device tells the simulation where to store the state and what processor to use when executing operations. HOOMD-blue can execute on the CPU:
cpu = hoomd.device.CPU()
Or the GPU:
gpu = hoomd.device.GPU()
GPUs are highly parallel processors best suited for larger workloads. In typical systems with more than 4,000 particles a single GPU performs an order of magnitude faster than an entire CPU (all cores). Try your simulation on both to see what hardware can run the same number of time steps in less time.
Creating a Simulation¶
Now, you can instantiate a Simulation with the chosen device.
sim = hoomd.Simulation(device=gpu)
A newly constructed Simulation has no state:
And no integrator, updaters, or writers, which are types of operations:
The remaining sections in this tutorial will show you how to populate a Simulation with operations, initialize the state, and run the simulation.