GithubHelp home page GithubHelp logo

pile-of-sand's Introduction

Pile-of-Sand

The project

I've watched Science étonnante's last video yesterday. This great video is about the modelisation of daily fluctations in the stock market. In the video he uses a python modelisation to explain the "Self-organised Criticality" principle. I found interresting to code it by myself with python. So here is a small modelisation of a pile of sand on which some grains of sand would be dropped regularly. When you launch the simulation, you can see some avalanches sometimes, result of the dropped grains and of the "Self-organised Criticality" phenomenom.

The "Self-organised Criticality" principle (applied to a sand pile) is the way the grains make avalanches when they're too unstable but that always stay near an unstable balance when the avalanche stops. The goal with my program is to simulate the evolution of the organisation of the grains when some new grains are dropped on the pile. I wanted to see these avalanches created by my own program and not just in somebody's video.

This simulation is lead by 2 simple rules, that remembers those of Conway's life game :

  • 1 : A new grain of sand is dropped on the pile at each round
  • 2 : If there're more than 4 grains on the same cell, they're pushed to the 4 cells around (top, bottom, right, left) *(Note : I used a variable in my program to be able to change this "critical threshold")

Here is a run of my simulation :

This is how my program works :

  • A ndArray is created with the wanted shape. It's filled with zeros
  • A for loop is used to create the rounds. A randome cell is incremented.
  • Then all cells are scanned and if the number of grains on it is over the critical threshold, I put a 0 on the cell, and increment the four cells around.
  • A for loop is used to create all the steps of the animation
  • The function matplotlib.animation.ArtistAnimation is used to animate the steps

Some ways of improvement :

  • I could add a color scale;
  • When I run the script, a second empty matplotlib window opens. I don't know why but I think it's possible to solve it;

Some informations

  • Written with python 3.6;
  • Uses numpy arrays to simulate the grid, and matplotlib.animation to display and animate the simulation;

Here are some documentation parts and examples that helped me throught this mini project :

pile-of-sand's People

Contributors

sylvain-brocas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.