Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a particle stepper for given external fields #40

Closed
3 of 4 tasks
StanczakDominik opened this issue May 28, 2017 · 5 comments
Closed
3 of 4 tasks

Add a particle stepper for given external fields #40

StanczakDominik opened this issue May 28, 2017 · 5 comments
Labels
simulations.PIC plasmapy.classes.Species and others
Milestone

Comments

@StanczakDominik
Copy link
Member

StanczakDominik commented May 28, 2017

As discussed on HipChat recently, I'd like to give adapting my particle stepper a try. The way I see this working would be:

  • Add a ParticleSpecies class containing their basic information such as position and velocity (as numpy ndarrays), charge and mass. This seems like a minimal necessary set of information. I would also like to save historical data on their positions and velocities every few timesteps into a larger ndarray to avoid frequent file IO (the iteration step between saving could be given by user, according to the resolution required).
  • Give them a push method that takes electric and magnetic fields (ndarrays) at particle locations (so they're the same shape) and updates their positions and velocities. I have two Boris pushers, one nonrelativistic and one relativistic - I can port both. Of course, we want velocities at half timesteps to help with energy conservation - adding another method init_push (without updating positions) to start that is trivial.
  • Add functionality for interpolating fields from - initially - Cartesian grids to particle positions. I've done this in 1D. Given that we want 3D, I'll try to find an algorithm that implements that - I have a few papers with those lying around.
  • I have to say that I have absolutely no idea on how to do this in non-cartesian geometries, so that's something I'd like to postpone until later. As far as I can tell our current idea for the Plasma class is to stay Cartesian for a bit, then branch out a little, so that seems reasonable to me.

I should be able to start working on this by about June 7th or so. Any help brainstorming before I get cracking on this would be much appreciated!

@namurphy
Copy link
Member

This sounds wonderful! With regards to interpolation, the method I'm most familiar with is trilinear interpolation (e.g., Haynes & Parnell, 2007). I suspect that some of the interpolation routines in SciPy would do pretty much what we need them to do (e.g., RegularGridInterpolator).

Another thought related to interpolation is that we should allow for flexibility in terms of the interpolation method which we'll eventually need. If we want to push test particles in a spectral or spectral element simulation, the most accurate way to interpolate would be to use the basis functions of the solution directly. However, we do not need to do this yet.

A simple test would be to match against analytical results for a particle orbit in a uniform magnetic field. Another possibility for a test would be to match particle drifts in simple configurations.

Thank you!

@namurphy namurphy modified the milestone: v0.1 May 30, 2017
@StanczakDominik
Copy link
Member Author

... so this was implemented in scipy all along?

Well.

I really do need to read the full docs of that, scipy keeps positively surprising me.

Thank you very much for the heads up, this will definitely come in handy!

I'll try to make the interpolation easy to swap out.

Uniform mag fields are definitely one of the tests I'm considering; another would be a harmonic potential. The drifts are a neat idea. Thanks!

@StanczakDominik
Copy link
Member Author

Okay, a minor point of confusion. I started doing some minor work on porting my code, and I'm noticing that we don't actually have an electric field defined in the plasma class. I know, quasineutrality, everything runs on magnetic in MHD scenarios, but in this case this means I'm kind of at a loss on how to proceed for now. I can't really interpolate a non-existant electric field.

I had the idea of interpolating not the fields, but the actual momentum - scale that to the particle mass and we get a velocity for the particle. But that seems like a hack, like something you would implement in a video game where you don't actually care about the physics involved.

@namurphy
Copy link
Member

namurphy commented Jun 6, 2017

Hm...some options would be to have the electric field either inputted directly, or calculated from an Ohm's law. @SolarDrew, do you have thoughts on how to address this?

@StanczakDominik
Copy link
Member Author

Hey, just wanted to give a heads up that I still intend to get this done, but other commitments are kind of getting in the way right now. I hope I can get back to this soon.

@StanczakDominik StanczakDominik added this to In progress in PIC simulation Aug 3, 2017
SolarDrew added a commit that referenced this issue Aug 21, 2017
@namurphy namurphy added the simulations.PIC plasmapy.classes.Species and others label Sep 12, 2017
@StanczakDominik StanczakDominik moved this from In progress to Done in PIC simulation Oct 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
simulations.PIC plasmapy.classes.Species and others
Projects
No open projects
Development

No branches or pull requests

2 participants