joheinze / PriNCe-examples

Examples for the PriNCe propagation code
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Proton adiabatic only propagation #1

Open afedynitch opened 4 years ago

afedynitch commented 4 years ago

Sorry I commited by fault to master! This was unintetionally. Gomennasai

What I wanted to discuss in the PR was that in the adiabatic only proton example the propagated spectrum doesn 't match the expectation. It did a couple of trivial checks, but it didn't really solve the issue. BDF and EULER give different results as well. I'm not sure if this is due to the issue where the last injection was or so, but I wanted to let you know that the results are different. I remember you've spent plenty of time on it, so you may know better what's going on if you see it.

joheinze commented 4 years ago

Yes, I saw this as well when converting the proton example. I know I checked this over two years ago and they matched exactly. So it is some bug, that we reintroduced.

My best guess is that this is due to how the partial differential equation is solved, i.e. now by finite differences. I probably checked this only for the SemiLagrangian method that we used earlier. There I checked, that particle number and enery are conserved. Probably the finite differences defined in the DifferentialOperator class are not exactly accurate for the given step width. This would also explain the difference between EULER and BDF, due to forward vs backward steps in z.

To check this, we can go back to the SemiLagrangian for EULER. Unfortunately this will not work together with BDF, since the interface to scipy does not allow to apply SemiLagrangian in between steps.