AngelFP / VisualPIC

Data Visualization for Particle-in-Cell Codes.
GNU General Public License v3.0
47 stars 13 forks source link

Quasi-3D support in OSIRIS #11

Closed tsung1029 closed 5 years ago

tsung1029 commented 5 years ago

Hi:

Someone pointed out your tool to me and I just installed it. I really loved it so far. However, quasi-3D data (from OSIRIS) seems to have caused some confusion for your package. Have you tried it? Can you tell me what we have to do to make the Quasi-3D data work with your tool? Thank you!

RemiLehe commented 5 years ago

I agree! It would be great to have support for quasi-3D (both for Osiris data and openPMD data).

@AngelFP We talked about this a while ago, and I suggested I could help on the openPMD side, but then I never got the time. But maybe I could bump up the priority of this task.

What I am thinking is that I could modify ts.get_field so that, if the argument theta is None, then openPMD-viewer returns a full 3D array (reconstructed from quasi-3D data). Would that help? Also, by looking at the implementation, maybe this could allow you to do the same for the native Osiris data.

AngelFP commented 5 years ago

Hi all!

Thanks for reporting this issue and I'm glad you are finding VisualPIC useful. I am aware of the problems when dealing with data which is not purely 3D cartesian. This is something I tried to address when I stating adding support for FBPIC data. There is a separate branch badly named "cyl_coord_cupport" in which I tried to make it work and, to some extent it does, but it introduced many other bugs in the code.

The problem is that VisualPIC was initially designed only with Osiris and 3d cartesian data in mind, and that has its limitations. Therefore, at some point I started a whole rewrite of the code which could make it much more versatile (see the branch 'general_redesign') but due to lack of time (I have to finish my PhD at some point...) it has been on hold for a few months.

So, to summarize, this data can in principle be supported, but in the current versions of VisualPIC this would require quite some deep changes. I hope to be able to work on this again (so I appreciate your offer a lot Remi!) but right now it sadly has to wait.

Cheers, Ángel.

tsung1029 commented 5 years ago

Hi Angel:

Thank you. I just want to say that I really like this tool for what it is doing already. -- Frank

RemiLehe commented 5 years ago

Thanks for the quick reply @AngelFP. I might give it a quick try in the next few days (i.e. updating openPMD-viewer as mentioned above, and doing a corresponding quick pull request in VisualPIC - which would probably only involve very minimalistic changes, i.e. for all purposes VisualPIC would see the quasi-3D data as a 3D Cartesian dataset, since openPMD-viewer would be responsible for the underlying conversion). Should I start from the dev branch in this case, or it is currently considered deprecated (and to replaced with general_redesign)?

AngelFP commented 5 years ago

Hi Frank,

No worries, I appreciate a lot that someone other than me is also using it :) I will keep the quasi-3d in mind and I will let you know if I have any progress on it.

AngelFP commented 5 years ago

And thanks for the effort @RemiLehe, I'll be looking forward to it, even if it's just on openPMD-viewer. If you want to add this to VisualPIC I would actually choose the branch with support for cylindrical coordinates. The general_redesign branch has some quite drastic changes and it's still far from being usable.

RemiLehe commented 5 years ago

Thanks for the info!

I have a branch of openPMD-viewer that has the conversion from quasi-3D to full Cartesian 3D (i.e. ts.get_field returns a full 3D array if the user passes theta=None). The implementation can certainly be improved, but the basic capability is there. I will try to couple it with the cyl_coord_support branch. The above-mentioned feature should take care of this https://github.com/AngelFP/VisualPIC/blob/cyl_coord_cupport/VisualPIC/DataReading/fieldReaders.py#L412 (which I assume is used for the 3D visualization)

Do you remember other issues/bugs with cyl_coord_support branch?

AngelFP commented 5 years ago

Hi @RemiLehe!

Sorry for the late reply, I had forgotten to check this. Thanks for looking into it and implementing the 3D field conversion in openPMD-viewer, I will certainly check it out. And yes, I think that's the method used by the 3D visualizer.

Regarding the bugs, I remember that after adding support for cylindrical coordinates some things stopped working properly with 3d cartesian data. It also introduced some bugs when plotting data in the main VisualPIC window (not the 3D stuff), but I would have to look into it again. In general, the code got a bit messy, and that's when I decided it might be a better option to do a general rewrite of the core of VisualPIC 😅

RemiLehe commented 5 years ago

Sorry for the late reply.

I think I have a rudimentary working version of VisualPIC with quasi-3D support: https://github.com/AngelFP/VisualPIC/pull/12

In fact, I tried to implement this both in the dev branch and the cyl_coord_support branch ; I got some issues in the latter case, while things worked OK in the first case. Therefore, the above PR is from/to the dev branch.

@AngelFP Would you have time to quickly test the above PR and make sure that everything is working as expected? (e.g. using an FBPIC dataset). Note that, for the moment, you will have to use the branch circ2cartesian from my fork of openPMD-viewer, at least until this PR is merged. (which can be done for instance with:

pip uninstall openPMD-viewer
git clone https://github.com/RemiLehe/openPMD-viewer.git
cd openPMD-viewer
git checkout circ2cartesian
python setup.py develop

)