Refactored array setups and added magnetic field.
Fixed divide-by-zero error and possible lack of float issue.