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

Add neutron inelastic process #1187

Merged
merged 12 commits into from
Apr 23, 2024

Conversation

whokion
Copy link
Contributor

@whokion whokion commented Apr 15, 2024

Description

This MR includes

  • Add a initial skeleton of neutron inelastic process, model and interaction cross section (following up Add neutron inelastic process #1150)
  • Add a necleon-nucleon channel cross section below 320 MeV where the pion production is unlikely (For the first pass, it is decided to limit the Bertini nuclei model implementation below 320 MeV where pion production is unlikely, so that particle-nucleon channels are deduced to nucleon-nucleon channels. This is based on two important considerations: 1) the majority of neutrons from typical HEP applications is below the pion threshold - for example, more than 98% of neutrons are below 140 MeV in ttbar or Higgs event simulation with the CMS detector at the LHC collision, 2) computing performance should be enhanced significantly as only nucleons, photons and nuclei are produced at the end of inelastic neutron-nuclei interactions, which simplify the chain of inter-nucleus cascades.)
  • Add a nucleon-nucleon cross section calculator and a unit test to check cross sections.

@whokion whokion added enhancement New feature or request physics Particles, processes, and stepping algorithms labels Apr 15, 2024
@whokion
Copy link
Contributor Author

whokion commented Apr 15, 2024

@sethrj, @amandalund : this MR is just to pick up most of #1150 codes (sorry for losing all review comments with this new MR) - will add remaining codes later as they are not necessary pieces for initial code base at the moment. Only new addition to the earlier MR are for nucleon-nucloen cross sections in 1) NeutronInelasticModel.cc and 2) NucleonNucleonXsCalculator.hh. Thanks for your review.

Copy link
Contributor

@amandalund amandalund left a comment

Choose a reason for hiding this comment

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

Thanks @whokion, this looks great!

src/celeritas/neutron/data/NeutronInelasticData.hh Outdated Show resolved Hide resolved
src/celeritas/neutron/model/NeutronInelasticModel.cu Outdated Show resolved Hide resolved
src/celeritas/neutron/model/NeutronInelasticModel.cc Outdated Show resolved Hide resolved
auto NeutronInelasticModel::get_channel_xs(ChannelId ch_id)
-> ChannelXsData const&
{
CELER_EXPECT(ch_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe check that ch_id is less than the array size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to check ch_id < NeutronInelasticScalars::num_channels()?

src/celeritas/neutron/model/NeutronInelasticModel.cc Outdated Show resolved Hide resolved
src/celeritas/neutron/model/NeutronInelasticModel.cc Outdated Show resolved Hide resolved
/*!
* Calculate neutron inelastic cross sections from NeutronInelasticData
*/
class NeutronInelasticMicroXsCalculator
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we ever decide on the best way to reduce the duplicate code for the neutron micro xs calculators?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind of, but not yet. There is another one (capture process) which may look very similar, but may have some variations if isotope dependent xs are added. So, let's leave this duplication for now and then consolidate codes later (may need your help on that).

Copy link
Member

Choose a reason for hiding this comment

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

@whokion The data and implementation seem identical to NeutronElasticData (setting aside capture for now). Would it be OK to define:

template<Ownership W, MemSpace M>
struct NeutronXsData
{
    //! Microscopic (element) cross section data (G4PARTICLEXS/neutron/elZ)
    ElementItems<GenericGridData> micro_xs;

    // Backend data
    Items<real_type> reals;

    // (plus copy constructor, bool)
};

and then replace the micro_xs and (if needed) reals in both NeutronElasticData and NeutronInelasticData with an instance of that class? E.g.

template<Ownership W, MemSpace M>
struct NeutronElasticData
{
    // ...
    NeutronXsData<W, M> xs;
    // ...
};

Then NeutronElasticMicroXsCalculator could be renamed NeutronMicroXsCalculator and used for both elastic and inelastic. Is there anything I'm overlooking that would make this complicated?

@whokion
Copy link
Contributor Author

whokion commented Apr 17, 2024

@sethrj I resolved conflicts and updated codes reflecting @amandalund's review comments, then rebased the local neutron-inelastic with origin/develop (which was successful). Now, git push still fails with

To https://github.com/whokion/celeritas
 ! [rejected]            neutron-inelastic -> neutron-inelastic (non-fast-forward)
error: failed to push some refs to 'https://github.com/whokion/celeritas'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

I remember that you suggested to merge instead of push --force. After merging the branch to the local develop and pushed the develop to the remote develop, I tried to push the local neutron-inelastic to the remote neutron-inelastic, which still fails (i.e., error above). Probably I missed something here. Thank you for your help.

@sethrj
Copy link
Member

sethrj commented Apr 18, 2024

@whokion Please don't do any rebasing once reviews have started. You should instead git merge. If you can push your current branch to a new neutron-inelastic-temp I can try to fix it. Or you could try git rebase -i --onto aa5f3b7 upstream/develop to see if that puts your changes back on what's already pushed here. (And then follow up with git merge upstream/develop.)

As a reminder for why merging is preferred once a PR has left draft mode: rebasing destroys the CI logs and messes with the review history.

@whokion
Copy link
Contributor Author

whokion commented Apr 18, 2024

Thanks @sethrj! Good to know and to learn. I just to push a new neutron-inelastic-temp as the other suggested instruction seems not working for me. Sorry and thanks again for your help.

Copy link
Member

@sethrj sethrj left a comment

Choose a reason for hiding this comment

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

Looks great, @whokion ! Sorry for taking so long to review. If you think the consolidation of the XS calculators should wait, I accept that, but it looks like a pretty easy change to make now.

src/celeritas/io/NeutronXsReader.hh Show resolved Hide resolved
/*!
* Calculate neutron inelastic cross sections from NeutronInelasticData
*/
class NeutronInelasticMicroXsCalculator
Copy link
Member

Choose a reason for hiding this comment

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

@whokion The data and implementation seem identical to NeutronElasticData (setting aside capture for now). Would it be OK to define:

template<Ownership W, MemSpace M>
struct NeutronXsData
{
    //! Microscopic (element) cross section data (G4PARTICLEXS/neutron/elZ)
    ElementItems<GenericGridData> micro_xs;

    // Backend data
    Items<real_type> reals;

    // (plus copy constructor, bool)
};

and then replace the micro_xs and (if needed) reals in both NeutronElasticData and NeutronInelasticData with an instance of that class? E.g.

template<Ownership W, MemSpace M>
struct NeutronElasticData
{
    // ...
    NeutronXsData<W, M> xs;
    // ...
};

Then NeutronElasticMicroXsCalculator could be renamed NeutronMicroXsCalculator and used for both elastic and inelastic. Is there anything I'm overlooking that would make this complicated?

src/celeritas/neutron/xs/NucleonNucleonXsCalculator.hh Outdated Show resolved Hide resolved
src/celeritas/neutron/xs/NucleonNucleonXsCalculator.hh Outdated Show resolved Hide resolved
@whokion
Copy link
Contributor Author

whokion commented Apr 22, 2024

@sethrj Thanks for reviewing and extra comments. Regarding to the consolidation of the Xs calculators, your suggestion looks good. However, I still want to postpone it to later as there may be an extension for the inelastic interaction cross sections as there are several special elements which have isotope-dependent cross sections. Once the capture cross sections (which are mostly isotope-dependent and are different structure from elastic ones), I would reconsider which way is better to consolidate; elastic vs. inelastic (element-dependent) or inelastic vs. capture (isotope-dependent). Anyway, I pushed a branch name, neutron-inelastic-temp2 (and sorry again for the extra rebase/merging treatment).

src/celeritas/io/NeutronXsReader.hh Show resolved Hide resolved
@sethrj sethrj enabled auto-merge (squash) April 23, 2024 12:09
@amandalund
Copy link
Contributor

@sethrj did you incorporate the changes from the neutron-inelastic-temp2 branch?

@sethrj
Copy link
Member

sethrj commented Apr 23, 2024

God damn it, I pushed to my origin instead of Soon's. Thanks for the catch @amandalund .

@sethrj sethrj enabled auto-merge (squash) April 23, 2024 12:42
@sethrj sethrj merged commit 390ed0e into celeritas-project:develop Apr 23, 2024
25 of 26 checks passed
@whokion whokion deleted the neutron-inelastic branch April 25, 2024 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request physics Particles, processes, and stepping algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants