Dec 12, 2021Create Your Own Finite Volume Fluid Simulation (With Python) Part 2: Boundary Conditions & Source TermsFor today’s recreational coding exercise, we will expand on the Finite Volume method for simulating the compressible fluid equations. We will add boundary conditions and source terms. For Part 1, please see the Python tutorial on the Kelvin-Helmholtz Instability, which we build on. Here in Part 2, we will simulate…Python5 min read
Mar 20, 2021Create Your Own Spring Network Simulation (With Python)For today’s recreational coding exercise, we will simulate a spring network: an array of nodes connected by springs that obey Hooke’s Law. The spring system will fall down due to gravity and bounce off the floor. We use a particle algorithm similar to our N-body simulation. You may find the…4 min read
Feb 5, 2021Create Your Own Direct Simulation Monte Carlo (With Python)For today’s recreational coding exercise, we learn how to simulate dilute gas with the Direct Simulation Monte Carlo (DSMC) method. This approach is useful when gas is weakly collisional. We will look at the Rayleigh Problem: the response of rarified gas between two plates after one suddenly starts moving. You…Phython7 min read
Published in The Startup·Jan 8, 2021Create Your Own Active Matter Simulation (With Python)For today’s recreational coding exercise, we simulate active matter, i.e., swarming. Such a system may describe a flock of birds or a school of fish. We will look at how very simple rules may lead to the emergence of self-ordered motions. You may find the accompanying Python code on github. …Python3 min read
Dec 21, 2020Create Your Own Lattice Boltzmann Simulation (With Python)For today’s recreational coding exercise, we simulate fluid flow past a cylinder using the Lattice Boltzmann method. This is a really cool and simple technique to simulate fluid flow: instead of evolving the fluid (Navier-Stokes) equations directly, microscopic particles on a lattice are simulated with streaming and collision processes. …Simulation5 min read
Nov 21, 2020Create Your Own Volume Rendering (With Python)For today’s recreational coding exercise, we look at a simple way to create volume renderings to visualize 3D simulation datacubes. This technique is incredibly useful when you have space-filling data you would like to visualize. …Visualization4 min read
Published in Level Up Coding·Oct 26, 2020Create Your Own Quantum Mechanics Simulation (With Python)For today’s recreational coding exercise, we will look at quantum mechanical systems, in particular, the Schrodinger-Poisson equations. We will create a simulation for the evolution of a wavefunction under its self-potential. Such a system may describe certain superfluids/Bose-Einstein condensate or exotic dark matter. You may find the accompanying Python code…Quantum Mechanics6 min read
Published in Level Up Coding·Oct 1, 2020Create Your Own Finite Volume Fluid Simulation (With Python)For today’s recreational coding exercise, we will simulate the Kelvin-Helmholtz Instability with the Finite Volume method. We will consider a compressible fluid with a high density stream moving in opposite direction of the background. …Simulation9 min read
Sep 19, 2020Create Your Own Smoothed-Particle Hydrodynamics Simulation (With Python)For today’s recreational coding exercise, we will simulate a star with smoothed-particle hydrodynamics (SPH). We will start with some initial condition and relax it into a stable stellar structure and measure the star’s density as a function of radius. …Simulation6 min read
Sep 17, 2020Create Your Own Plasma PIC Simulation (With Python)For today’s recreational coding exercise, we will investigate plasma physics with particle-in-cell (PIC) simulations. We will create a simulation of two electron beams passing through each other in opposite directions. An interesting phenomenon occurs, called the Two-Stream Instability. You may find the accompanying Python code on github. Before we begin…Python6 min read