Proton in a magnetic field, numerical simulation

In summary, the study of a proton in a magnetic field involves the analysis of its behavior and dynamics under the influence of magnetic forces. Numerical simulations are employed to model and visualize the interactions, allowing for the examination of key parameters such as the proton's trajectory, spin precession, and energy levels. These simulations provide valuable insights into fundamental physics concepts and have applications in fields like nuclear magnetic resonance and particle physics.
  • #36
Appelros said:
Also double $ or # doesn't seem to work either... So I don't know how to input latex on this site, if anyone has a solution that would be great.
That's strange. I use double # and it has always worked just fine.

Test: ## Test * Test = Test^2##

Edit: Double # works for me. Remember to put the double # at the start and end of your latex.
 
Physics news on Phys.org
  • #37
Appelros said:
Also double $ or # doesn't seem to work either... So I don't know how to input latex on this site, if anyone has a solution that would be great.
There is a helpful "LaTeX Guide" link below the Edit window to get you started. Note that you put double-$ delimiters at the start and end of each stand-alone line of LaTeX, and double-# delimiters at the start and end of in-line LaTeX that does not need to be on its own line.

Example of in-line LaTeX: ##v(t) = L \frac{di(t)}{dt}##

Example of stand-alone LaTeX:
$$v(t) = L \frac{di(t)}{dt}$$
Also, if you right-click on a LaTeX equation in a post, you get a pop-up menu to let you view the LaTeX source or view it in other formats.

LaTeX isn't supported in thread titles, so you can use simple text math in titles if you want.

Note also that PF uses a feature called "lazy LaTeX rendering" that speeds up page loads. When you first post your LaTeX in a thread, you will not see it rendered that first time. Just refresh your browser page to force it to be rendered, and then it should render whenever you come back to that page/thread in the future.

If you have trouble using the Preview feature to check your LaTeX, you can use a website such as https://www.quicklatex.com/ or https://latexeditor.lagrida.com/ to preview your LaTeX before you post it.
 
  • Like
Likes Appelros and Drakkith
  • #38
Drakkith said:
I created a basic particles-in-magnetic-field simulation a little over a year ago using c-sharp and Unity. I believe I ended up using a symplectic integrator such as the Boris Method. See part 3 here: https://www.particleincell.com/2011/vxb-rotation/

This should fix your issue with the magnitude increasing with each time step, but note that there really isn't a way of simplifying things enough to directly simulate more than a few thousand to a few hundred thousand particles at the same time. At least not with personal computers you find at home. With a parallelized program running on my video card I was able to simulate about 100k particles at a time without my program falling below 30 fps, but that was purely a particle-mover without any way to store or analyze the data. It also wasn't computing particle-particle forces, just forces from an external field on each particle. And even at the rate it was running I'm not sure it was fast enough to do anything useful.
Yea the Boris method solves most problems, but I can't get it to bounce at the analytical bounce point in a magnetic bottle. I might start a thread about that after I extract a MWE.

Direct simulation is the most accurate, but by far the most resource intensive. You can go further up the scale to particle-in-cell, particle meshes, charged fluid, etc. Each step generally gets more abstract and less accurate while gaining the ability to simulation larger time frames and/or more particles.
Approximations can also be expensive, I found a plasma package that calculates the Vlasov equation but it would have taken weeks to get a solution. I simplified the equations and now it solves in seconds. Reminds me of an episode of Standupmaths where he ran a program for a month and viewers optimized it down to under a second.

Here's my thread asking for resources and posting some insights I gained working on my simulation: https://www.physicsforums.com/threads/resources-on-simulating-charges-in-magnetic-fields.1047935/
Great, I'll check out the resources posted in that thread. Are you still involved in plasma research?
 
  • #39
Drakkith said:
That's strange. I use double # and it has always worked just fine.

Test: ## Test * Test = Test^2##

Edit: Double # works for me. Remember to put the double # at the start and end of your latex.
Your latex switched from rendering to not rendering to rendering again while I posted my reply above, strange indeed.

##x^2##, now it works in preview. Sometimes it doesn't
 
  • #40
Appelros said:
Are you still involved in plasma research?
No, and I never really was. I learned just enough to make some charged particles move around in a magnetic field and that was about it.
 
  • #41
Appelros said:
Your latex switched from rendering to not rendering to rendering again while I posted my reply above, strange indeed.

, now it works in preview. Sometimes it doesn't
One extra note that I should have mentioned about the "lazy LaTeX rendering" is that each time after you edit your post with LaTeX in it, it will not render the first time you save your edits. Just make it a habit to refresh your browser page after you have done the edits, which will force the LaTeX engine to render the page. It's a bit annoying, but it is deterministic and you get used to it after a short while. :smile:
 
  • Like
Likes Appelros
  • #42
Drakkith said:
No, and I never really was. I learned just enough to make some charged particles move around in a magnetic field and that was about it.
Oh, okay, are you working on something else interesting?

I constructed the above mentioned MWE and fed the details to ChatGPT and it explained the solution, I thought AI would have huge problems with advanced physics but so far it has been very helpful.
 
  • #43
Appelros said:
Oh, okay, are you working on something else interesting?
Not at this time, no. With only some undergrad education in physics and programming, my capabilities in this area are very limited.
 
Back
Top