Tuesday, September 20, 2016

Coil Gun Simulation Program

For those who are not aware, undergraduate engineering students are required to complete a senior design project in their last year before they can receive their B.Sc. In undergraduate, my senior design project was to design and construct a single stage handheld electromagnetic launcher (coil gun) capable of accelerating a projectile to a muzzle velocity equivalent to that of a .22 caliber pellet gun (~13 [J] to 44 [J]). Normally, I wouldn't consider schoolwork to be interesting enough to warrant a post on this site, but one novel development resulted from the research and development process of designing the coil gun for my senior design project. Prior to beginning preliminary construction and benchtop testing of a specific coil gun design, I went in search of theoretical treatments of coil gun operation in the literature, so I could get a rough estimate of the geometric and component requirements that would be needed to meet our muzzle energy specification. After much digging, the best I could find were a few rules of thumb for coil gun design that were determined experimentally. Not having a very large budget, and having a hard deadline for the project, I felt that I probably wouldn't have the resources needed to iterate through several experimental designs in search of an acceptable solution.

Consequently, I set out to develop a simulator capable of rapidly approximating the electro-mechanical behavior of a coil gun with a reasonable degree of accuracy. As anyone who is familiar with coil guns is no doubt aware, this presents a broad set of challenges and complications that preclude a clean, purely analytic solution. In particular, transient changes in coil inductance brought on by the motion of the ferromagnetic core (projectile) through the coil during firing and the changing magnetization and relative magnetic permeability of the core material with the B field generated by the coil during firing are particularly difficult to predict. Moreover, the force between the coil and projectile that induces the launching of the projectile is governed by a set of elliptical integral calculations. In the process of developing an understanding of each physical effect at play, I developed six interconnecting physics modules to calculate the coil inductance, discharge current, induced coil B field, projectile magnetization, magnetic force, and projectile motion in the system at a given point in time (shown below in Figure 1).


Figure 1: Diagram of simulator physics modules      





Using these simulation blocks, it was possible to put together a fully integrated simulation program that could predict the overall system behavior of the coil gun during a discharge event by stepping the physics in small differential time intervals. Once the simulator was fully developed, I spent a good bit of my time trying to debug the physics modules by improving the approximations made by the simulator. For instance, the magnetic permeability of the space surrounding a coil gun during a discharge event is anything but uniform; this greatly complicates the calculation of inductance for the solenoid coil of the gun. After much tinkering with the simulator I found that the best way to approximate the permeability environment was to take a volumetric average of the permeability within the firing chamber. Similarly, to approximate the magnetic saturation of the projectile, the simulator requires the user to provide experimental B-H curve data for the material used.

All of the technical development of the simulation program aside, once I had tweaked the simulator enough, I found that the final muzzle energy it predicted for my senior design coil gun was seemingly very accurate. That said, I haven't seen any other simulators out there that are quite as comprehensive as mine. After letting the simulation code collect dust for a while now, I looked back over the code and decided that I should release the simulator program to the public so that perhaps someone else looking to build a coil gun might benefit from my work.

So, without further ado, here is a link where you can download the full MATLAB code for the simulator as well as a standalone executable version of the simulator.


Here are a few other notes regarding the simulator for those interested in using the simulator:
  • The simulator requires you to have B-H curve data for the magnetic material that the projectile is made of; however, the download link above includes example .csv files containing B-H curve data for several common ferromagnetic materials
  • The simulator is capable of estimating the inductance of the solenoid coil itself, but, if you happen to be lucky enough to have an RLC meter, you can input an override inductance parameter for the coil.
  • There are three modes of firing available in the simulator: thyristor, mosfet with freewheeling diode, and contactor. If you aren't sure what kind of component you plan to use for your coil gun, I would recommend just setting the simulator to contactor mode by unchecking the thyristor and mosfet radio buttons in the simulator parameters window.
  • The download link above includes MS Word documents with my original theoretical calculations used in the simulator development if you are interested in that sort of thing.
  • The download link also includes citations of all academic papers and websites that I got information/theory from that was used in making the simulator. 
  • You can actually use this program for multi-stage designs by using the initial conditions parameters.
  • Before anyone tells me that my simulator makes too many simplifications to be 100% accurate, I know. The whole point of the simulator is to be able to run very fast simulations to aid in coil gun optimization.

One final comment, if anyone has any questions/comments about the simulator or would like me to make a formal tutorial/documentation file for the simulator, feel free to contact me. For now, I'm just kinda throwing this thing out there and seeing if it sticks to anything.