Thursday, October 25, 2012

Fun with FEniCS

Today's entry is also inspired by another talk. We had Anders Logg of Simula Research and one of the developers at The FEniCS Project come by, all the way from Norway. FEniCS is one of the main pieces of software I am learning to use. Now, I started the day not thinking I would really encounter nested tori (and don't think, of course, every post is going to be about them!). But believe it or not, they made completely unexpected side entrance. I was testing out its capabilities for time evolution (simply solving the heat equation on a square with zero Dirichlet boundary conditions) and got it running with some trivial initial data. But as another interesting test run, I figured I should try some nontrivial initial data. My basic goal was to see if I could recreate this (from Wikipedia, LOL):

Now, where was I gonna get that horseshoe?

From nested tori, of course. If you slice a torus at an angle (this can easily be tested out with a good chef's knife and a bagel), you may get completely different-looking slices depending on the angle. In the plane of the bagel slice, of course, you get an annulus... the one that you spread cream cheese on. Completely perpendicular, you will get either two circle-like curves (if the knife cuts through the hole), a figure 8 (if the knife just grazes the hole), or a single oval like curve (if the knife cuts the side). Changing the angle will make any of these configurations into an annulus. For example, the two circles will "reach out to touch each other" as the angle changes, and then the other ends start wrapping around the hole. Just before those ends join, it becomes something like a letter "C" or a horseshoe (pause the movie about halfway in and look at the red):

Anyway, supplying the initial data as 1 inside the horseshoe and 0 outside (the interpolating part of the software actually enforces continuity, albeit with some very steep slopes), we get this:

Now just how exactly did I determine what was "inside" the horseshoe and "outside" it? I used level sets. That's where the nested tori come in. But I will have to leave my dear readers in suspense, and tell you about it in another entry. But this has been quite an adventure!

No comments:

Post a Comment