## Monday, December 10, 2012

### A non-cubical example!

Ahh, finally, an example with the appropriate symmetry... Learned how to create some interesting 3D meshes. This example is essentially the same as the previous, but with a different global mesh. I also changed the numerical method to something symplectic, and of higher order: Störmer-Verlet timestepping. The energy that is preserved here (or, only close to being preserved, actually—symplectic integrators do not exactly preserve energy, but do a lot better than more generic methods) is the field energy, 1/2(E, D) + 1/2 (B, H). Or, the energy that would be (close to) preserved, if it weren't for this oscillation being a driven one, caused by currents in the wire, rather than natural oscillations given by some initial, non-equilibrium configuration (as in the vibrating drum post). It's time for a different example, perhaps the analogue of a cavity resonator.

## Friday, December 7, 2012

### More Vector Finite Element Goodness

Would you like corn on the cob with that?

In case you weren't satisfied with steady-state behavior in the past couple of posts, I finally bring you some dynamics. This is a picture of the magnetic field caused by a central wire with a given alternating current, surrounded by air (although with boundary conditions tangent are to the surrounding cube, so the vector field becomes a bit squashed toward the outside as compared to an actually cylindrically symmetric problem). Current in the wire is modeled by simply taking a current density which is nonzero (and time-varying) within a small radius from the z-axis. The mesh is significantly more refined in the region, to better account for the discontinuity and that I intend the wire to actually be round. It takes a little while for it to reach steady state in terms of amplitude, so don't be disappointed if the vectors aren't very visible initially. If you look closely (and admittedly, you will have to either really look, or play the video in slower motion), you can see that there's a slight delay between what happens at the wire, and what happens some distance away from it. Here c = 3 (so today, E = 9m), that is, it takes 1/3 of a unit of time (about 2 seconds of the video) for the influence of the wave to traverse 1 cube length. The whole video itself is 4 units of time long. The original equations as presented in the paper of Bossavit is in fact more geared toward static situations, in which we can neglect the time derivative term for the electric displacement (the one that Maxwell added), but it turns out adding that term back makes the finite element formulation much more natural—in fact, when reducing it to mass and stiffness matrices and nodal vectors, the time-stepper we use is exactly the same as in the backward Euler discretization described a couple of posts ago. Without that term, I had to use  two different mass matrices. Here's a more interesting example:

And a donut too!

Here, we've modified the setup to include a conductor in the shape of, you guessed it, a torus. The significance of it being "conductive" is that an extra term, Ohm's law, is added in. It affects the dynamics because the field causes currents to flow inside the torus, which generates more field, in different directions. This is expressed in the program as a piecewise function which is zero outside the toroidal region and 1 inside it, and the stiffness matrix is modified to account for this extra term. For similar reasons as the wire above, the mesh is now also significantly more refined in the region of the torus (otherwise it kind of looks like a square block), and in any case, also better for handling the discontinuity, but this time for conductivity. Next up: seeing if there's a way to go about this using symplectic methods!