The 100-year-storm abates, and good progress is made on removing large amounts of code.

The storm abates

Wow, it is now being published that the storm we’ve been having here in Christchurch is the largest we’ve had since 1975, but is also a 1-in-100-year storm. Quite how they come to such a statistic I do not know though. I bet that some people are hoping that we don’t have another storm as bad anytime before the year 2100.

Last night’s jury-rigged solution of taping tongs to a large pan so that water can drip down the tongs in to the pan was largely successful.

Outside many of the roads are flooded, but fortunately my scooter can travel on the footpath when required. Sadly for the food co-op though the truck wasn’t able to make it today due to the weather, so things have been postponed there until tomorrow.

Removing Air performance code

Through a series of gradual improvements, more and more code has been removed from the calculations, until eventually virtually no code will be needed at all.

It started with having the calculations directly in the code, for example:

data.wing_area_ft = data.wing_load_lb_ft / data.w;
data.aspect_ratio = data.b * data.b / data.wing_area_ft;

Then the formulas were moved out to a separate aircraftFormulas area:

data.wing_area_ft = aircraftFormulas[7].s(data.wing_load_lb_ft, data.w);
data.aspect_ratio = aircraftFormulas[14].ar(data.b, data.wing_area_ft);

Then separate relations were used to refer to those aircraftFormulas:

data.wing_area_ft = relation[2][0].s(data.wing_load_lb_ft, data.w);
data.aspect_ratio = relation[2][1].ar(data.b, data.wing_area_ft);

And then the formulas were able to solve themself based on given information:

data.wing_area_ft = relation[2][0].solve({ws: data.wing_load_lb_ft, w: data.w).s;
data.aspect_ratio = relation[2][1].solve({b: data.b, s: data.wing_area_ft}).ar;

The change that’s happening now is to rename the variables so that they are consistent throughout, using standard aircraft notation. s for wing area or spread, w for weight, ws for wing loading, ar for aspect ratio, b for wing span or breadth.

data.s = relation[2][0].solve({ws: data.ws, w: data.w}).s;
data.ar = relation[2][1].solve({b: data.b, s: data.s}).ar;

After the above was done I can remove the variables completely, resulting in just passing data and picking out the newly solved value.

data.s = relation[2][0].solve(data).s;
data.ar = relation[2][1].solve(data).ar;

and the above code is now no longer in the code. It’s just information in an array:

function solveForFields(fields, form) {
    fields.forEach(function (relationInfo) {
        var field = relationInfo.field,
            section = relationInfo.relation,
            part = relationInfo.part;
        data[field] = relation[section][part].solve(data)[field];
    });
}
solveForFields(
    {field: 's', relation: 2, part: 0},
    {field: 'ar', relation: 2, part: 1},
    ...
], form);

Once all of these formulas are information in the array, I can make the solver more generic, so that it doesn’t need to be told which particular formulas are to be used to solve things, and I’ll be able to achieve my ultimate aim of returning back to aircraftFormulas, and reducing things down to a final form of the code:

aircraftFormulas.solveAll(data);
Advertisements