The Riga dynamo experiment is a laboratory model of the natural process that is responsible for all environmental magnetic-fields which are generated without human interference. This applies to the field of the Earth, the Sun, stars, and even galaxies which are produced by intense motions of large volumes of good electro-conducting fluids. For our experiment, we use molten sodium – the best liquid electro-conductor available in the laboratory. Approximately 2 m3 of molten sodium are filled into a prolonged cylinder, at the top of which rotates a propeller powered by 200 kW from two motors. The cylinder is divided by thin coaxial inner walls into three parts: in the inner tube the propeller moves the sodium flow helically downward; in the middle one the sodium flows vertically upward; and the outer part contains liquid sodium at rest. When the propeller speed exceeds a critical value (depending on temperature: around 1800 rpm, corresponding to a sodium flow of 0.6 m3 s−1) then a magnetic-field is spontaneously excited. The field pattern slowly rotates around the vertical axis. To enable self-excitation, the sodium flow had been carefully optimized. This article gives an historical overview about the steps in the mathematical description of the Riga dynamo and the optimization of the sodium flow structure. Our analytical model builds on the Ponomarenko configuration, which we modify in four analytical steps. Firstly, the Ponomarenko model was adopted for finite Rm. Then, instead of real generation, we find convective amplification. Secondly, when the outer conductor was replaced with a return tube an absolute instability was attained but at high Rm. Thirdly, to lower Rm a third, immobile conductor was inserted outside and all sizes optimized to achieve global generation at minimum Rm. Adopting these sizes, an experiment was designed and made. Fourthly and finally, the velocity profile was replaced by a trial polynomial to identify the direction in which the flow structure should be corrected.