- #1
Appelros
- 20
- 0
- TL;DR Summary
- The magnetic field does no work but translating its force to velocity does, the solution is not elegant and inexact.
Hi! I am developing a fusion reactor simulator and when a proton spins in a perpendicular magnetic field the Lorentz force qv×B is applied at a right angle, however whenever you add a value to a vector in this way its magnitude increases, which contradicts that the velocity of the proton should remain constant since the magnetic field does no work. To solve this I simply scaled the vector back to its original size after adding the acceleration. All my units are set to 1 so the proton should spin in a circle with radius 1, which it does, but with two problems.
1. There are now two sets of acceleration vectors in my code, those that need scaling and those who don't. This feels very ad hoc.
2. While the proton spins in a circle of radius 1 it does so from 0.995 to -1.005 and 1.9999 to -1e-5. While the latter is a somewhat acceptable error rate the former is not (I'm assuming it should spin from 1 to -1). It continues to spin within these parameters for many rotations and under different calculation methods so it is not an error accumulation from my numerical algorithms.
Is there a more elegant solution that solves these problems?
1. There are now two sets of acceleration vectors in my code, those that need scaling and those who don't. This feels very ad hoc.
2. While the proton spins in a circle of radius 1 it does so from 0.995 to -1.005 and 1.9999 to -1e-5. While the latter is a somewhat acceptable error rate the former is not (I'm assuming it should spin from 1 to -1). It continues to spin within these parameters for many rotations and under different calculation methods so it is not an error accumulation from my numerical algorithms.
Is there a more elegant solution that solves these problems?