  In this paper we present the development of a simulation code capable of
optimizing the geometry of a spiral inflector designed for axial injection into
a cyclotron. To do this, an electric field map of the device is generated by
utilizing a boundary elements method and then used to track one or more
particles. The information from the trajectories is then used to shorten the
electrodes of the spiral inflector to adjust for fringing electric fields such
that the particles end up on the mid-plane of the cyclotron. This method was
also used to analyze the effects of a modified electrode geometry that can
focus the beam as it travels through the device. Compared against commercial
multiphysics software, the developed code produced similar results within a
negligible margin of error attributed to differences in meshing and particle
tracking algorithms.
