29 March 2014

Twelfth

A fun holdover from the days when I was last gainfully employed-- the 12th patent on which I'm part inventor was issued earlier this month: Converged call flow modeling and converged web service interface design.

28 March 2014

I {hate,heart} NaN

For two week's I've intermittently been tracking down an issue where suddenly a flow profile goes from turbulent/sane to a uniform flow profile in a single time step.

For awhile now I've been running with a custom banded solver that permits

  • mixed precision factorization
  • use of approximate factorizations, and
  • iterative refinement.
Relative to ZGBSVX this has been a net win. I get firm control over the quality of my linear system solutions and save a factor of 10 (yes, 10) over LAPACK's Cadillac banded solve.

It turns out that I didn't harden my one-off solver against NaNs. Ah, NaNs. Those lovely things that can make puzzling things like the following happen to a simulation:

The problem wasn't the NaN showing up in a computation, as I'd notice that. The problem was NaN showing up in a residual computation. Necessarily, that NaN failed a residual tolerance check. Because the tolerance check was false, I'd kick back a linear solution consisting of all zeros from an initial solution residual calculation that I'd performed.

What happened next was a comedy of my best intentions. I had a forcing constraint set so that if my solution failed to match my freestream, the state profile was forced to match. As my solution was all zeros, that NaN residual combined with the forcing caused my solution to become the freestream in a single time step. And suddenly my simulations went from sane to uniform instantaneously.

This came to me on the motorcycle while riding home after a rough day.

I simultaneously love and hate the beauty that is floating point.

17 March 2014

helm: a proportional-integral-derivative controller implementation

The class of homogenized boundary layer models I'm using in my thesis (developed by Spalart, made compressible by Guarini et al, and most recently extended by Topalian et al) has an adjustable knob called a "slow growth rate" that controls the thickness of the boundary layer. One can manually fiddle with it. One can use RANS simulations and hope that the value obtained produces something similar in a DNS. I aim to apply some basic control theory by bolting a PID controller onto my simulations.

It turns out everybody and their brother intuitively derive the equations governing a basic PID controller. Then they wave their hands a bit about how to solve windup woes, bumpless transition, and deal with incremental/velocity forms. Not that it doesn't work, but they drift away from the continuous equations to do so. Then they cough up O(10) lines of code assuming a constant, discrete sampling rate.

To permit variable sampling and understand where/how the fixes are made, I dug around until I found a nice treatment in Astrom & Murray (Available online), wrote up the variant of their PID derivation that I needed including the discretization, coded up the algorithm, and then put together a small test driver.

Aside from vanilla C99, the implementation has no dependencies. I hope someone else can put it to use.

16 March 2014

One bit

Despite coding being proverbially all zeros and ones, it's not often that a single, isolated bit is damning.

Today, however, I spent four hours tracking down where I wrote 0 when I should have written 1.

Subscribe Subscribe to The Return of Agent Zlerich