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.