Hi Draven and the others!
The full answer is: an FEM program. But then, the only ones I know cost 1000s of Usd [if somebody knows a free or cheap one, I'm interested!]
Cheaper answer? This depends on what you hope to do, maybe you could tell a bit more? Computing torques and forces when distances are bigger than dimensions of permanent magnets or ironless coils doesn't even need a computer. But at short distances, or with ferromagnetic materials added, solving is indeed difficult, and needs precise geometric models of your parts. Such a program is best integrated with a 3D-CAD.