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

solution from particle added by add_tracking_particle is not obtainable with get_solution() #52

Open
lpyras opened this issue Apr 21, 2023 · 7 comments

Comments

@lpyras
Copy link

lpyras commented Apr 21, 2023

I tried to calculate the contribution of D+ and D0 to the muon flux but adding the particle tracking did not work for me.
Here is the code snipped:
mceq_run.pman.add_tracking_particle([(411, 0), (421, 0)], (-13, 0), 'blabla', from_interactions=False) mceq_run.solve() blabla = mceq_run.get_solution('blabla', mag)

File "/Users/username/Software/MCEq/MCEq/core.py", line 244, in get_solution res = sum_lr(particle_name, prefix='') File "/Users/username/Software/MCEq/MCEq/core.py", line 203, in sum_lr result += sol[ref[prefix + ls].lidx:ref[prefix + ls].uidx] ValueError: operands could not be broadcast together with shapes (121,) (0,) (121,)

Can you tell me what I did wrong?

@afedynitch
Copy link
Collaborator

Hi! Which interaction model are you using? Any more details?

@afedynitch
Copy link
Collaborator

OK, I figure out what's not working. Since you're adding a new particle after everything has been reinitialized, the system size changed, so the dimensions need updating. After adding particles, you need to:

...add_tracking_particle...
mceq_run._resize_vectors_and_restore()
mceq_run.regenerate_matrices()

mceq_run.solve()
# etc...

How did you find the tracking_particle features? Was it documented somewhere?

@lpyras
Copy link
Author

lpyras commented Apr 22, 2023

Thanks for your fast response. It works for me now for Sybill 2.3c and GSF.

I think I found it when I searched for the obs_particle function, and found that it has been replaced by the add_tracking_particle function. I don't think it was documented, the doc string is a bit outdated.
I think it would be helpful to add something like this to the examples file Partial_hadron_contribution.ipynb.


mceq_run = MCEqRun(
interaction_model='SIBYLL2.3c',
primary_model = (pm.GlobalSplineFitBeta, None),
theta_deg=60.0,
**config)

mceq_run.pman.add_tracking_particle([(411, 0), (421, 0)], (13, 0), 'Dpm0_mu-', from_interactions=False)
mceq_run.pman.add_tracking_particle([(-411, 0), (-421, 0)], (-13, 0), 'Dpm0_mu+')
mceq_run.pman.add_tracking_particle([(431, 0), (-431, 0)], (-13, 0), 'Ds_mu+')
mceq_run.pman.add_tracking_particle([(-431, 0), (431, 0)], (13, 0), 'Ds_mu-')
mceq_run.pman.add_tracking_particle([(310, 0)], (-13, 0), 'K0s_mu+')
mceq_run.pman.add_tracking_particle([(130, 0)], (-13, 0), 'K0L_mu+')
mceq_run._resize_vectors_and_restore()
mceq_run.regenerate_matrices()
mceq_run.solve()

mu_conv = mceq_run.get_solution('conv_mu+', mag) + \
          mceq_run.get_solution('conv_mu-', mag)

mu_prompt = mceq_run.get_solution('pr_mu+', mag) + \
          mceq_run.get_solution('pr_mu-', mag)
....

@afedynitch
Copy link
Collaborator

Thanks. I’ll add it to the ToDO

@The-Ludwig
Copy link

@lpyras I played a little bit with this undocumented feature, but never got it to work. Really happy about this issue, this helps me a lot! :)

@The-Ludwig
Copy link

Ah, I rediscovered what didn't work for me earlier.
Is is possible that the tracking of e.g. a short-lifed omega meson is not supported anymore since 1.0? @afedynitch

@afedynitch
Copy link
Collaborator

It is technically possible but a different data file is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants