Generating a magnetic field is a simple matter of running current through a wire. Since these wires will be bound to the outer hull of the starship, and are significantly smaller than it, it will be reasonable for us to approximate the current as a surface current. The magnetic field resulting from a current is given by the Biot-Savart law, for a surface current K experienced at a point a:
We'll use cylindrical coordinates, since the starship is a cylinder. Since we've already said that the field producing wires are on the ship exterior they can only practically be wound either along it's primary axis, in the z direction, or around the ship angularly. So, rather than solving the above integral, we can use Ampere's circuital law:
And, by the same derivation, in the z direction:
So we have a magnetic field. For an angular current it is directed along the axis, for an axial current it is angular. Note that the magnetic field depends only on the radial distance from the center of the ship, r, not on its axial distance. This is because Ampere's circuital law assumed an infinitely long current carrying body, so that we could ignore fringing effects at the ends. This is a simplification and will result in errors for particles moving solely in the axial direction or those moving very near the fore and aft sections of the starship. For most purposes, though, the approximation is reasonable.
Now we can consider what happens when a proton comes near the starship. When a charged particle moves through a magnetic field it experiences a force:
Solving through the cross product for the acceleration:
So, no matter which of our two possible currents we pick we'll see some radial effect. We'll also observe that the field accelerates the particle either in the angular or axial direction, deflecting the particle away as it slows its approach. Combining the two sets of equations for an angular current:
Notice that the two cross products ensure that the particle is deflected in the same direction as the current flow. Which makes sense, the positively charged proton is pulled along by the negatively charged electron current. While the same thing is true for the z directed current, we'll carry forwards with the angular current.
Because both components of acceleration are dependent on both the velocity (a function of acceleration) and position (a function of both velocity and acceleration) there is no closed form solution of this problem. Therefore it is necessary to iteratively solve the problem, beginning with a certain velocity and then solving for acceleration, finding the position, then solving again for acceleration, and so on.
So far we've discussed the motion of a cosmic ray in terms of its kinetic energy. However at these small sizes and high velocities the normal Newtonian relation between kinetic energy and velocity no longer holds, instead special relativity shows that energy depends on the Lorentz factor:
solving for velocity:
Now we have our starting condition. We'll place particle moving in the r direction towards the starship. It'll appear a distance away so that the galactic background magnetic field is about equal to the shield's magnetic field, the edge of the ship's sphere of influence.
For the simulation we'll do an iterative time step until the particle either strikes the starship surface (r
As a sanity check we can recalculate the energy of the particle after it has been deflected. It's total energy should be unchanged, only its direction of motion should be affected. So if the particle's final energy is equal to its initial energy our forces and fields should have been calculated correctly.
A code to do this was written in Scilab, and is available here. The code suggests that a value of current somewhere in the 9.6 MA range is adequate.
In order to produce a uniform current over the entire outer shell of the ship a sizeable voltage, and therefore power supply, will be needed. Once we can add that into consideration, along with the mass of the coils needed, we can finally compare the magnetic shield to the simple bulk shield previously derived. There should be some ideal, minimum mass, combination of the two that can adequately protect our crew from cosmic radiation.