io0 / sim

Home Page:https://sage-arithmetic-1997b4.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Laplacian Occasion

Link to Video, and website

Laplace's equation is ubiquitous in physics. It turns out you can solve Laplace's equation and other partial differential equations by sampling random walks!

$$ \nabla^2 f = 0 $$

furniture_demo2_AdobeExpress (1)

Inspiration

image

Algorithm

Nov-06-2022 14-49-14

Nov-06-2022 14-47-32

If $\Omega \subset \mathbb R^n$ is a bounded domain with boundary $\partial \Omega$. We enforce dirichelet boundary conditions by specifying the value of $f$ on the boundary. You can draw the domain of the boundary and see resulting changes in the solution! You can also adjust the specific boundary function in the code.

Then we exploit Kakutani's principle: the solution to Laplace's equation at some point $x\in\Omega$ is the expected value of the values at the first intersection of a random walk starting at $x$ with the boundary $\partial \Omega$.

We can speed up the random walks by reccursively sampling random points on a sphere of radius $R=\inf {d(x,y):y\in\partial \Omega}$. Since each point on the sphere is equally likely to be crossed first by the random walker.

Once we reach a distance under $\epsilon$ of our boundary, we terminate the random walk, sample the boundary value function at the closest point, and use that value to update our expected value of $f(x)$.

We do this for each point in our domain.

Applications

Physicists use finite difference methods or finite element methods to solve many PDEs they encounter computationally. However, there are some problems that arise with these methods. First of all, they both require construcing grids. This has some down-sides

  • Working with meshes is hard. Meshes in the wild can come with a host of problems (singularities, self-intersecting faces, and all sorts of horible stuff)
  • The FEM/FDM solution does not always converge as fast as we would like it to. I.e. very fine meshes are required to obtain decent results.
  • Constructing meshes is computationally expensive and can take hours.

Enter Monte Carlo methods. (Monte Carlo is just a fancy name for statistical sampling. For instance, the way to measure the area of a circle with monte carlo is to drop many many tiny pins onto a square of known dimensions bounding the circle, and then count the ratio of pins that fall inside the circle vs the ones that fall in the square but outside the circle.)

The solver we are interested in is called the Walk-On-Spheres algorithm. It's a Monte Carlo algorithm that uses random walks and exploits the mean value property of the Laplace equation. It's been known about for some time, but recently researchers have been trying to generalise it to other problems.

Another type of solver inspired by ray-tracing algorithms, from the graphics industry, may be able to help scientists solve PDEs more efficiently. These are Monte Carlo methods.

Bloopers

Screen_Recording_2022-11-06_at_1 39 51_AM

Wishlist

Implement a Poisson solver too.

Getting started

Install http-server if you don't already have it.

npm install -g http-server

Run it!

http-server

Refs

Keenan Crane paper David Rioux & Toshiya Hachisuka paper

About

https://sage-arithmetic-1997b4.netlify.app/


Languages

Language:JavaScript 84.6%Language:HTML 13.2%Language:CSS 2.2%