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

Moliere scattering generates non-normalized directional vectors for very large deflections #371

Open
Jean1995 opened this issue Jun 14, 2023 · 0 comments
Labels

Comments

@Jean1995
Copy link
Member

If one uses Moliere scattering with random numbers close to 1, it will create very large deflections.

However, is the random numbers becomes very close to 1, and the deflection becomes close to 90 degree, it actually creates unphysical directional changes (i.e. either tx or ty is larger 1). This generates directional vectors that are not normalized anymore.

This is a minimal working example

import proposal as pp
import numpy as np
import matplotlib.pyplot as plt

particle = pp.particle.EMinusDef()
medium = pp.medium.Air()

scattering = pp.make_multiple_scattering("moliere", particle, medium)

final_dir_list = []

rnd_list = [0.5, 0.999000, 0.999005, 0.999010, 0.999015, 0.9991]

color_list = iter(plt.cm.rainbow(np.linspace(0, 1, len(rnd_list))))

for rnd in rnd_list:
    deflection = scattering.scatter(0.97, 13.4, 13.2, [0.3, 0.6, 0.3, rnd]) 
    init_direction = pp.Cartesian3D(0, 0, 1)
    _, final_direction = pp.scattering.scatter_initial_direction(init_direction, deflection)
    print(final_direction.magnitude)
    final_dir_list.append(final_direction)


for final_dir, rnd, color in zip(final_dir_list, rnd_list, color_list):
    #print(final_dir)
    plt.arrow(0, 0, final_dir.y, final_dir.z, color=color, label=rnd)
plt.legend()
plt.xlabel('y')
plt.ylabel('z')

which generates the following plot:

image

The label shows the used random number. For random numbers going above 0.99901, the deflection angle becomes 90 degrees, but the directional vector becomes larger than 1.

@Jean1995 Jean1995 added the bug label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant