Thursday, March 22, 2012

First Code

It's just a sketch of the geometry analysis portion, really, but I've demonstrated that I've got my programming tools reestablished and github working.
Per Racket practice, the ugly code goes in the "Private" directory, and the pretty public face, including contracts enforcing usage and hiding some implementation, will be in the root directory.
Here's a sample interaction, demonstrating the syntax for newcomers to things Lispish:

Welcome to DrRacket, version 5.2.1 [3m].
Language: racket/base; memory limit: 128 MB.
Warning: (test-make-geometry) is not yet implemented!
> (define my-geometry(make-geometry #(1 0.5+0.05i 0+0.1i 0.5+0.05i 1)))
Warning: (j-1 n a) is not yet implemented!
Warning: (optimize-c0 c0 n a) is not yet implemented!
Warning: (dt/dc ? ? ?) is not yet implemented!
> (geometry? my-geometry)
#t
> (geometry-chord my-geometry)
1.004987562112089
> (geometry-N my-geometry)
'#(0.4925434091539446-0.09950371902099892i 0.0+0.0i -0.4925434091539446+0.09950371902099892i 0.0+0.0i 0.4925434091539446-0.09950371902099892i)
> 
We feed make-geometry a vector describing a flat plate set at an angle to the x-axis. We get expected warnings because this is a work in progress. We explore the returned structure. We discover our first bug! geometry-N is supposed to return a vector rotated so as to be parallel to the x axis. I apparently rotated the wrong way.

The Long and Winding Road

The little project I intend to document in this blog has been moving along in fits and starts since my undergraduate days, some (shudder) thirty years ago. At that time I was introduced to panel methods as a means of analyzing airfoils. Modeling an elegantly curved surface as a series of straight lines, and then modelling smooth airflow as a series of tiny tornadoes just struck me as ugly!
On the other hand, I was enchanted with the use of complex numbers to transform simple shapes, easy to analyze, into complex ones. Complex transforms have long been used in the design of airfoils (mapping a cylinder to a shape to achieve a certain velocity distribution), but not in the analysis of airfoils (mapping an airfoil to a circle in order to determine the velocity distribution).
I have gone down many blind alleys over the years, but started making real progress about 3 years ago. My math was solid, my code was solid, and then my laptop crashed.
I had intended to reorganize, anyway. Since I've given up becoming a rich aviation entrepreneur, I've decided to do my coding (https://github.com/SlowThought/SlowFlight) and thinking (here) in public, in the hope that somebody might find my musings useful.