Here is a compact settling model you can run locally — nothing outside the standard library is needed.
The script does five things:
- We set up the basin and seed one grain with the plotter.
- The grain enters near the top of the basin with a random lateral velocity.
- We apply drift so the grain sinks.
- We test for contact with the basin walls and the bed, reversing direction or settling as needed.
- The model advances in a continuous loop.
To run this simulation:
- Make sure Python 3.11 or newer is installed on your machine.
- Copy the code into a new file and save it with a .py extension (e.g., "grain_settle.py").
- Run the script from your terminal.
You should see a window open with an amber grain drifting down toward the basin floor.
Would you like me to walk through any part of the code in more detail, or suggest ways to extend the model?
Norite can be wrong. Check anything that matters before you ship it.
Move to Studio for 5× more usage with Norite Scree 1.5.
Reply to Norite…
Norite Scree 1.5
1
Grain Settling Simulation using Canvas
vx = 1.4 vy = 0.0 drift = -0.24 settle_rate = 0.86 # Simulation loop while True: # Advance the grain grain.move(grain.x() + vx, grain.y() + vy) # Apply drift vy += drift # Check for basin walls if grain.x() > 384 or grain.x() < -384: vx *= -1 # Check for the bed surface if grain.y() < -288: grain.settle(-288) vy *= -settle_rate # Redraw the layer canvas.update() # Hold the window open canvas.mainloop()
Last edited just now