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

Improvemente of Directed Emission Module #438

Merged
merged 1 commit into from
Sep 29, 2023

Conversation

simonerossoni1996
Copy link

This PR introduces changes to the SourceDirectedEmission() module.

The SourceDirectedEmission() module samples a random vector from the von Mises-Fischer distribution defined by a mean direction and a concentration parameter. This vector is then used for the injection of the candidate. The sampling was done as in http://people.csail.mit.edu/jstraub/download/straub2017vonMisesFisherInference.pdf .

Given the presence of a function for random sampling from a von Mises-Fischer distribution (in Random.cpp), the sampling procedure was modified. Some functions in the module are no longer needed.

Thanks to @avvliet for help with the changes and with the PR.

@simonerossoni1996
Copy link
Author

simonerossoni1996 commented Sep 28, 2023

Here I describe a test of the new module implementation. A simulation is performed with the von Mises-Fischer injection module. The geometrical setting of the simulation can be found in the simulation script. The von Mises-Fischer parameters are kappa=10 and injection along the z-axis.

------ SIMULATION SCRIPT ------
from crpropa import *
import numpy as np

sim = ModuleList()

sim.add(SimplePropagation())
sim.add(MaximumTrajectoryLength(1.1 * Mpc))

obs = Observer()
obs.add(ObserverSurface(Sphere(Vector3d(0.0,0.0,0.0) * Mpc, 1.0 * Mpc)))
output = TextOutput("output.txt",Output.Event3D)
obs.onDetection(output)
sim.add(obs)

source = Source()
source.add(SourcePosition(Vector3d(0.0,0.0,0.0) * Mpc))
source.add(SourceDirectedEmission(Vector3d(0.0,0.0,1.0), 10.0))
source.add(SourceEnergy(1.0 * EeV))
source.add(SourceParticleType(nucleusId(1,1)))

sim.setShowProgress(True)
sim.run(source,100000)
output.close()
------------

The simulation output is used to compute the reduced probability distribution functions of the von Mises-Fischer function at the injection. In particular, the reduced probability distribution functions of the two injection angles are obtained and compared with the analytic expression, obtained by integrating the von Mises-Fischer distribution.


It can be seen that the new implementation continues to reproduce the required injection distribution.

@JulienDoerner
Copy link
Member

hey @simonerossoni1996,
I tested the PR with your script and I could not found any difference. Also the unit tests are still runing so everything seems to be okay from my point.

@JulienDoerner JulienDoerner merged commit f009258 into CRPropa:master Sep 29, 2023
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants