# How to simulate a stable pile of sand without grid patterns

This tutorial explains how to get a pile of sand to keep it’s original shape, while avoiding regular patterns in the particle distribution. Our goal is to let the particles keep the initial shape, while allowing them to react properly to additional collisions and forces.

The sand tools on the Grains shelf set up particle sources in a regular grid pattern. This ensures a stable simulation with nice stacking and fast settling, when you have a flat ground plane.

## Creating the pile of sand

1. Create a closed cone that you will eventually fill with sand. You can do this by clicking the Tube tool on the Create shelf and pressing Enter to place it at the origin. Set the following parameters on your tube geometry to make a cone.

• End Caps: `on`

• Radius: `0.0`, `0.8`

• Radius Scale:`1.0`

• Center: `0`, `0.25` or `0.5*ch("height")`, `0`

• Height: `0.5`

2. Go back up to the object level, select the tube object, and click the Dry Sand tool on the Grains shelf.

3. Create a flat Ground Plane for your base using the tool on the Rigid Bodies shelf.

4. On the Solver tab of the POP Grains node, turn on Drift Threshold. This is critical to getting a pile like this to rest perfectly.

5. Press on the playbar to run the simulation. The particles should stay very close to the original shape. If some particles are slighting off the sides, you can increase the Scale Kinetic parameter on `sand_update` node’s Behavior tab to `0.15` or `0.2`.

## Getting rid of the regular pattern

Getting rid of the regular pattern, makes it a bit harder for the particles to settle as well as before.

1. Go back to `/obj/tube_object1/grainsource1` and turn on the toggle to the left of Jitter Scale. This randomizes the particles positions, but created some overlap between particles, which would cause an initial explosion in the simulation. Which is why Relax Iterations is activated. This ensures that particles don’t overlap and stay inside the cone, at the cost of some additional cook time.

If you run the simulation now, you will see the pile flattening a lot. It also takes a long time to stop moving. This is mostly because particles aren’t packed quite as perfectly.

The best way to counter this is to again increase the kinetic friction scale (Scale Kinetic). We’ll need a much higher value though, which would lead to unnaturally sluggish behavior during the main part of the simulation. To get around this, we’ll use an expression to set a higher friction value while the particles settle.

2. Set the following expression in the Scale Kinetic parameter: `if(\$T<1, 0.8, 0.1)`. This will evaluate to a very high `0.8` during the first second, and to a more realistic value of `0.1` afterward.

3. Change the Drift Threshold value to `0.01` on the Solver tab, .

4. Press again. The particles should stay close to the original shape again and settle quickly.

# Grains

## Getting Started

• Grains uses Position Based Dynamics to simulate grains of sand and other granular matter.