Trajectory of a Charged Particle in a Magnetic Field: ODE Formulation and Python-Based Numerical Simulation
Abstract-- Moving particles that have charge in a field is a basic idea in the study of electricity and magnetism. It also helps test how well computer programs can simulate situations. This paper looks at how a proton moves in a field that is the same everywhere. The way the proton moves is found using the Lorentz force law. The equations of motion are derived using the Lorentz force law and solved analytically. The proton moves in a circle when it is not moving in the direction of the magnetic field. At the same time, it moves straight in the direction of the field. The path it takes is like a spiral in three dimensions. A computer program made in Python is used to do the simulation. The program uses NumPy, Matplotlib and SciPy’s solve_ivp function with a method called DOP853. The proton starts with a velocity of 2.0×10⁵ m/s perpendicular to the field and 1.0×10⁵ m/s parallel to it. The magnetic field is 0.5 Tesla. The simulation runs five times the time it takes for the proton to go around in a circle. The program checks for errors by comparing the results with the math solution. The error is measured by how far the proton's position is from where it should be. Also, the difference in the energy the proton has is measured. The time it takes for the proton to go around in a circle is 1.31189-7 seconds. The radius of the circle the proton makes is 4.17587 -3 meters. The maximum position error is 1.89331 -12 meters, and the relative kinetic-energy deviation is 5.59434 -10. These numbers show that the computer simulation and the math solution match closely the choices made in the simulation
Authors
- Shaurya Singh (ORCID: https://orcid.org/0009-0000-9392-9684)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-10-24
- DOI
- https://doi.org/10.5281/zenodo.23620496
- Primary Topic
- Numerical methods for differential equations
- Type
- preprint