killah-t-cell / Plasma.jl

An interface for accelerated simulation of high-dimensional collisionless and electrostatic plasmas.
MIT License
34 stars 4 forks source link

Plot recipes #27

Open SebastianM-C opened 3 years ago

SebastianM-C commented 3 years ago

Hi! Thanks for writing this package. I was looking over the code and I noticed that for plotting the GLMakie backend is hardcoded. I think that if would be better to define (Makie) plot recipes for PlasmaSolution types and thus depend on Makie / MakieCore and not on a specific backend. This will mean that WGLMakie will work "for free" and in the case of 2D plots, CairoMakie too.

I'd like to help with a PR that implements this if you want.

killah-t-cell commented 3 years ago

That's a great idea! The current version is pretty hacky 😄

Feel free to open a PR. I can help if you have any questions as well.

SebastianM-C commented 3 years ago

Do you have an estimate for how long a simulation should take? I tried running examples from the README and from the tests, but they did not complete (I left them to run for couple of hours).

killah-t-cell commented 3 years ago

They are very heavy. I'm working on making them faster right now – they currently take a few hours. My tip is to test changes with as low a dimension as possible (so 1D1V).

10x speed improvements are my current focus (basically integration is really inefficient right now, and that can be sped up).

SebastianM-C commented 3 years ago

Do you have a MWE for that? I tried using the example in runtests.jl but I saw that the loss decreased for some time and then started increasing.

With regards to performance, I saw some things that might cause type instabilities, but I'm not sure if those are optimized by MTK when constructing the equations symbolically.

killah-t-cell commented 3 years ago

I'll push some pre-trained weights and an MWE asap :)

What do you see that would cause type instabilities?

SebastianM-C commented 3 years ago

What do you see that would cause type instabilities?

I did not look too close at the code, but https://github.com/killah-t-cell/Plasma.jl/blob/41476321f30f2ac3f8c33e0f8442ad1b23d77720/src/solve.jl#L68-L72

might lead to some Anys because qs and ms are initialized as Vector{Any}. I'm not sure if this will create any notable performance problems though (I didn't benchmark or profile the code yet).

I'll try to take a close look at the code and open an issue if I find something else.

killah-t-cell commented 3 years ago

Oh nice catch. I don't think this will cause problems, but I think normalisation would matter more here. Setting m to 1 instead of to the electron mass, for example.