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

Density response #126

Merged

Conversation

valeriaRaffuzzi
Copy link
Member

Adding a response that returns the inverse of the particle velocity to calculate the neutron density. Valid for neutrons and photons.

@valeriaRaffuzzi valeriaRaffuzzi added enhancement New feature or request Tallies labels May 9, 2024
Copy link
Collaborator

@Mikolaj-A-Kowalski Mikolaj-A-Kowalski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect! Thanks for the development.

! Test neutron density with different particle energies
p % type = P_NEUTRON
p % E = ONE
res = ONE/1.3831592645e+09_defReal
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bit annoying and I don't think there is reason to change it how it is.
It would be just clearer for the future people to either calculate reference from the formula for velocity or to include the one you used. along the lines of:

Suggested change
res = ONE/1.3831592645e+09_defReal
res = ONE / (sqrt(TWO * p % E)/ neutronMass)

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a test using the same formula almost seems like cheating!
I could write the formula in a comment? Unless we might update the constants in the future, but I don't see why?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I had exactly the same pause. But really what the test checks is that right parameters are used for the right particle. There just isn't enough ways to calculate the velocity 😅

Formula in the comment is good!
As for the parameters we should really change them... at the moment they are taken from thin air. We should use the NIST CODATA values or the recommendations from the ENDF manual (the most recent version 2023, a lot of details do change silently between different editions I found out recently). And provide the source of the data in a comment.

!!
!! The function returns the inverse of the velocity (response to score particle density)
!! if the particle type is neutron or photon, and zero otherwise
!!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!!
!!
!! NOTE:
!! The velocities are computed from non-relativistic formula for massive particles.
!! The small error might appear in MeV range (e.g. for fusion applications)
!!

The difference is very small in this range, but could lead to bias with respect to other codes so worth to emphasise the approximation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I might suggest is moving the speed calculation to the particle since we want it anyway (e.g., for alpha, dynamic), but this may not be necessary for the moment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! A method in the particle may be the best place for the velocity indeed!
But I second that it is not necessary at the moment. We can marge this PR as it is and open an Issue about it. It would be a good 'first issue' for new contributors do deal with ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, I don't think that's necessary right now. It might clutter the particle and it won't be used for a long time. But it's a small change so I'll respect democracy.

Copy link
Member Author

@valeriaRaffuzzi valeriaRaffuzzi May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end I went for it, it was a very fast change. I believe I also addressed all the comments, so @ChasingNeutrons @Mikolaj-A-Kowalski let me know if I can go ahead and merge.

Copy link
Collaborator

@ChasingNeutrons ChasingNeutrons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest all looks good!

@valeriaRaffuzzi valeriaRaffuzzi merged commit 3dd3132 into CambridgeNuclear:main May 26, 2024
5 checks passed
@valeriaRaffuzzi valeriaRaffuzzi deleted the densityResponse branch May 26, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Tallies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants