ChristopherMayes / lume-astra

Python wrapper for Astra (A Space Charge Tracking Algorithm, DESY) for eventual use in LUME https://christophermayes.github.io/lume-astra/
https://christophermayes.github.io/lume-astra/
Apache License 2.0
14 stars 9 forks source link

Astra and LUME-ASTRA producing different envelopes #15

Closed kathryn-baker closed 2 years ago

kathryn-baker commented 2 years ago

Hi there,

I've been using lume-astra for a number of simulations, but I've noticed that even when using the same input file, I get different results between lume-astra and the native Astra installation on my laptop. The main difference is that it seems like the x and y beam envelopes are swapped.

I've attached a picture here to illustrate the difference. A zip folder containing the notebook (github issue.ipynb) and files used to generate the plots has also been attached. lume_astra_envelope astra_envelope removed zip

The native astra simulation is the orientation and shape that I am expecting.

From looking at your code it seems like Astra is run using a subprocess, but is there anything different with how the results are interpreted between lume-astra and the native application that could be causing the difference? Or is there anything I need to change in the settings between the two to account for any differences?

It may also be useful for you to know that we are simulating an H- beam. We have tried flipping the signs of the q_grad settings, which corrects the orientation of the x and y envelope, but the shape still doesn't quite match.

I am running the lume-astra notebook in a docker container with python 3.9.5 and lume-astra version 0.4.5. I am running the native Astra on Ubuntu 20.04.2 LTS (GNU/Linux 5.10.60.1-microsoft-standard-WSL2 x86_64).

Thank you for your help!

ChristopherMayes commented 2 years ago

@kathryn-baker good catch! The problem had to do with handling the particle species (it was previously assuming electrons at the cathode from the generator). I've generalized it. This involved changes to openPMD-beamphysics as well.

image

I will make new conda-forge releases soon - otherwise you'll need to clone and update openPMD-beamphysics as well as this.

kathryn-baker commented 2 years ago

Thank you for such a quick response! Having cloned the repositories I now get the right shape as well :)

I'm happy using the cloned repo's, but would it be possible to let me know when you've made the new conda forge releases please?

Thanks again