# Premature optimization & modeling: The root of scientific evil

As a spectator in the sport, I feel it’s worth saying that most scientists, and most engineers, are misguided. Misguided in that many spend their time trying to make new discoveries mathematically -a fools’ errand in my mind, given that models are not the nonlinear, stochastic world we live in.

Premature optimization; that is, spending all of your time analytically modeling and/or simulating systems before they’re built, is bad. It takes far too much time and mental labor, and, without any experimental link to reality to keep models on track, that is very well (and often is), time just wasted!

For example, the hours you spend modeling an IGBT in SPICE, or a transformer in COMSOL, perhaps with data pulled from spec-sheets, is time gambled. I’ve found that in almost every case, it takes far less effort, and far less time, to just build a test rig for the device and see for example, what waveforms, or what flux-densities can be achieved. Often it is the case that such measurements are far different from what your models expect, and further often, one finds that there are many further variables that weren’t accounted for in your model!

If you have an idea in mind, use your ingenuity and available tools to “just build it”. With practice one soon finds that often your guesses will work! Perhaps your design is not optimized, but, once your system is stable, it becomes a far, far easier task to optimize it thereafter than it would have been initially (mathematically). Sometimes, you’ll even find that what was initially “proven” impossible by theoretical modeling is in fact, entirely feasible, and maybe even the right way to go.

I shall now provide a case study:

Some time ago, perhaps one year to date, I set out to design a 100kHz, 30kV transformer for flyback converter purposes. The system goals were simple:

1) Take 72VDC
2) Turn it into 20kV, at 100kHz, with a power throughput of 5kW.

Initially, I did what I could to model, and simulate some designs. In doing so, I eventually found after 5 days’ work that something to this effect should be physically possible, given ideal conditions:

I then built such a transformer, and lo and behold, it sucked something fierce. This was concerning, as there were several parasitic elements taken into account; flux leakage, nonlinear core losses, stray capacitances, etc, yet still, the thing just sucked. And so, it was thrown out, and I adopted a new philosophy.

Instead of returning to my model, I proceeded to go about it the way I’m most familiar: the intuitive way. I considered instead of differential equations, the physical relationships between wire spacing, flux density, core size among other parameters, and picked values I felt were best.

When choosing a core, instead of taking into account permeabilies and fields modeling, I looked instead, at published BH curves. That is, data collected by the manufacturer of cores in experiment. Graphs of core loss vs temperature, saturation flux density vs frequency, replaced my mathematica equations and scaling constants, and the “proper” physical core size was determined simply by ripping apart a switch-mode welder, and seeing what has thus far worked.

Once a suitable core was obtained, my flux density setpoint was determined not by maxwells’ equations in $$\mathbb{R}^3$$, but rather, by a few turns of wire on the core, a car audio amplifier, and an oscilloscope. It took all of 5 minutes to determine that my chosen core saturates (ie, distorts my sinusoidal test signal) at about 40V per turn. Mathematically, that should have been 18-ish.

In an effort to keep stray capacitance low, guided of course, by the simple concept of “a capacitor is two parallel plates”, the secondary winding was redesigned to be physically large and of few turns. Considering of course, that every flux line passing through the solenoid would contribute to induced emf, making the coil physically large wasn’t as much of a problem as some texts made it out to be.

Leakage inductance was kept low by replacing primary turns of wire, with primary turns made from copper sheet. I decided this was OK after considering that most of the current in a high frequency conductor would be flowing on the surface, anyway, so there’s little advantage to using wire. (spice model that, I dare you!)

Several more “educated guesses” eventually led to, a transformer. One that worked much better than my simulated transformer, but probably wasn’t optimized. Making notes of some errata I then followed up the

design with another revision*

*Eg, I noticed some very high density flux escaping the cores’ mating surfaces via experiments with iron filings, so I cut my primary in two to leave space for these to escape unhindered. This prevent magnetically induced, circulating currents in my primary.

…which, when all was done, worked, with only 2 days of patience and effort. Hot damn!

That my reader, is how science & engineering is done: by seeing what works. Doing so experimentally is fast, time efficient, and fun! Most others unfortunately don’t see benefit to such activity; they are too caught up in the beauty and false-reassurance of mathematics to understand that, models are only models. They are not reality, and they take time to build. Time that’s often better spent,inventing.

This applies elsewhere. If for example, you wish to design a protein, don’t waste months simulating Schrodinger’s equation in Matlab. Instead, look at NMR data of proteins similar to the ones you wish to design, understand how they function, and tinker with them. Add new groups, see what happens. When designing an airplane, CAD some interesting designs and toss them in a wind tunnel. When designing a nuclear reactor, consider not intense mathematics, but rather, your alloys, their characteristics, and the tools you have to measure and machine them. I dare you to build a model that perfectly predicts metal creep under extreme neutron bombardment!

Science is not as concrete as many imagine it to be. When going about it, don’t get lost in your head –instead, follow in the footsteps of Faraday, Tesla, Edison, Hedy Lamarr, Curie, Rontgen, Jack Kilby, Compton and countless others who’ve changed the way we see the world.

Just do it!

Plan your experiments with a pen and paper, make them work, and if you stumble on something of value, model it afterwards. Often it’s not as expensive to do so as you might think, and it gets work done faster too.

## One thought on “Premature optimization & modeling: The root of scientific evil”

1. Computer Science rules on optimization.
1.Don’t
2.Don’t
3.Don’t yet