Python quickstart

Install DEME in an environment with a compatible NVIDIA driver and CUDA runtime, then verify the package and version:

python -c "import deme; print(deme.__version__)"

The following complete example creates a material, a bounded domain, and one spherical clump, then advances the simulation:

 1"""Run a minimal one-sphere DEME simulation and print its final position."""
 2
 3import deme
 4
 5
 6# A one-element device list places both DEME workers on logical CUDA device 0.
 7solver = deme.DEMSolver([0])
 8
 9material = solver.LoadMaterial(
10    {
11        "E": 1.0e7,
12        "nu": 0.3,
13        "CoR": 0.5,
14        "mu": 0.4,
15        "Crr": 0.0,
16    }
17)
18
19# Explicit spans make the global origin and floor location unambiguous.
20solver.InstructBoxDomainDimension(
21    (-0.5, 0.5),
22    (-0.5, 0.5),
23    (0.0, 1.0),
24)
25solver.InstructBoxDomainBoundingBC("top_open", material)
26
27sphere_type = solver.LoadSphereType(0.01, 0.025, material)
28sphere_batch = solver.AddClumps(sphere_type, [[0.0, 0.0, 0.5]])
29sphere_tracker = solver.Track(sphere_batch)
30
31solver.SetGravitationalAcceleration([0.0, 0.0, -9.81])
32solver.SetInitTimeStep(1.0e-5)
33solver.Initialize()
34
35# Synchronize before querying tracked state on the host.
36solver.DoDynamicsThenSync(0.01)
37print("Sphere position:", sphere_tracker.Pos())

Run it with:

python docs/python/examples/sphere_drop.py

The solver constructor initializes CUDA worker resources, so even importing successfully is not sufficient to run a simulation without a visible, supported NVIDIA GPU. See CUDA device selection when the process can see more than one GPU.

The example uses DoDynamicsThenSync because the position is read immediately afterward. For longer simulations, asynchronous DoDynamics calls can overlap host work; synchronize before reading results or exiting.

Where to go next