Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0e0cd0a
Added hooks for NCrystal
marquezj Sep 13, 2021
0f33e0b
Add temporary requirement of natural elements in NCrystal materials
tkittel Sep 13, 2022
9c54ac0
Fix access to private attributes
marquezj Sep 13, 2022
70d5c76
Fixed material.h
marquezj Sep 13, 2022
29a10ea
Removed MacroNCrystalXS
marquezj Sep 16, 2022
2e19260
Implement recommended changes
marquezj Sep 26, 2022
5afcc9e
Apply clang-format
marquezj Sep 26, 2022
fdf763e
Couple of fixes
marquezj Sep 26, 2022
52ee2c3
Print where NCrystal was found as suggested by @paulromano
tkittel Oct 20, 2022
a5b811e
Use new NCrystal getFlattenedComposition method to better support mor…
tkittel Oct 20, 2022
f2e807e
Move NCrystalRNGWrapper data member into explicit private section as …
tkittel Oct 20, 2022
aca4fcb
NCrystal cfgstr printout now mentions material ID
tkittel Oct 21, 2022
a3dd55d
first stab at gha-install-ncrystal.sh
tkittel Oct 21, 2022
e64bf6a
Add installation instructions for NCrystal
marquezj Nov 10, 2022
1f3c5ed
Add use instructions and examples for NCrystal
marquezj Nov 10, 2022
cf96ddf
Basic introduction to NCrystal
marquezj Nov 17, 2022
24572a7
Added simple NCrystal test
marquezj Nov 17, 2022
54745f5
Changed example NCrystal cfg strings
marquezj Nov 18, 2022
91f939a
Add flag for NCrystal
marquezj Nov 18, 2022
5f8e64b
Add NCrystal vairables to ci.yml
marquezj Nov 18, 2022
87ed26b
Add option to install NCrystal
marquezj Nov 18, 2022
8cf9dbe
Fixed in NCrystal docs
marquezj Nov 18, 2022
b9e8f13
Attempt to fix NCrystal installation script
marquezj Nov 18, 2022
b9a1fd5
Merge branch 'mixed_ncrystal' of https://github.com/highness-eu/openm…
marquezj Nov 18, 2022
d7ab491
Try fix of NCrystal install
marquezj Nov 19, 2022
b199db9
Update gha-install-ncrystal.sh
marquezj Nov 19, 2022
39d0c5c
Try to initialize with setup.sh
marquezj Nov 19, 2022
9e1abb3
Update gha-install-ncrystal.sh
marquezj Nov 19, 2022
3e6bb9d
Upgrade installation script to NCrystal 3.5.0
marquezj Nov 28, 2022
be330a1
Update gha-install-ncrystal.sh
marquezj Nov 28, 2022
fff545a
Update gha-install-ncrystal.sh
marquezj Nov 28, 2022
8598ff7
Pass CMAKE_PREFIX_PATH from NCrystall installation
marquezj Nov 28, 2022
c98a121
Update gha-install.py
marquezj Nov 28, 2022
19bf624
Add NCrystal installation test
marquezj Nov 28, 2022
4391d60
find NCrystal
marquezj Nov 28, 2022
e626447
Update gha-script.sh
marquezj Nov 28, 2022
e7b4285
Cleanup
marquezj Nov 29, 2022
f2c2870
Apply suggestions from code review
tkittel Dec 7, 2022
a86e74f
Rename compute_angular_distribution to pencil_beam_model
tkittel Dec 7, 2022
b6d6bdf
Merge branch 'develop' into mixed_ncrystal_pr
paulromano Jan 9, 2023
7dae457
Merge pull request #1 from paulromano/ncrystal_mixed
tkittel Jan 10, 2023
62af773
Refactor NCrystal interface code to ncrystal_interface.h/cpp
paulromano Jan 9, 2023
4eda693
Style and spacing changes
paulromano Jan 10, 2023
c4227f7
Change Material.from_ncrystal to accept kwargs
paulromano Jan 10, 2023
fe4a1de
Merge pull request #2 from paulromano/mixed_ncrystal_pr
tkittel Jan 10, 2023
e83ced8
Change ncrystal_max_energy to be a global constant
paulromano Jan 10, 2023
93aaa32
Merge pull request #3 from paulromano/mixed_ncrystal_const
tkittel Jan 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Style and spacing changes
  • Loading branch information
paulromano committed Jan 10, 2023
commit 4eda693133a3a0f6c55eea084ca7ddeb3ab0769d
29 changes: 16 additions & 13 deletions docs/source/methods/cross_sections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,22 @@ been selected. There are three methods available:
NCrystal materials
------------------

As an alternative of the standard thermal scattering treatment using :math:`S(\alpha,\beta)`
tables, OpenMC allows to create materials using NCrystal_. In addition to the regular thermal elastic,
and thermal inelastic processes, NCrystal allows the generation of models for materials that
cannot currently included in ACE files such as oriented single crystals (see the `NCrystal paper`_),
and further extend the physics `using plugins`_. Thermal scattering kernels are generated on
the fly from dynamic and structural data, or loaded from :math:`S(\alpha,\beta)` tables converted
from ENDF6 evaluations. These kernels are sampled in a direct way using a fast `rejection algorithm`_
that does not require previous processing. A `large library`_ of materials is already included in
the NCrystal distribution, and new materials can be easily defined from scratch in the `NCMAT format`_
or `combining existing files`_.

The compositions of the materials defined in NCrystal are passed on to OpenMC all other reactions
except for thermal neutron scattering are handled by continuous energy ACE libraries.
As an alternative of the standard thermal scattering treatment using
:math:`S(\alpha,\beta)` tables, OpenMC allows to create materials using
NCrystal_. In addition to the regular thermal elastic, and thermal inelastic
processes, NCrystal allows the generation of models for materials that cannot
currently included in ACE files such as oriented single crystals (see the
`NCrystal paper`_), and further extend the physics `using plugins`_. Thermal
scattering kernels are generated on the fly from dynamic and structural data, or
loaded from :math:`S(\alpha,\beta)` tables converted from ENDF6 evaluations.
These kernels are sampled in a direct way using a fast `rejection algorithm`_
that does not require previous processing. A `large library`_ of materials is
already included in the NCrystal distribution, and new materials can be easily
defined from scratch in the `NCMAT format`_ or `combining existing files`_.

The compositions of the materials defined in NCrystal are passed on to OpenMC
all other reactions except for thermal neutron scattering are handled by
continuous energy ACE libraries.

----------------
Multi-Group Data
Expand Down
11 changes: 6 additions & 5 deletions docs/source/usersguide/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@ Prerequisites
* NCrystal_ library for defining materials with enhanced thermal neutron transport

Adding this option allows the creation of materials from NCrystal, which
replaces the scattering kernel treatment of ACE files with a modular, on-the-fly approach.
To use it `install <https://github.com/mctools/ncrystal/wiki/Get-NCrystal>`_ and
`initialize <https://github.com/mctools/ncrystal/wiki/Using-NCrystal#setting-up>`_
replaces the scattering kernel treatment of ACE files with a modular,
on-the-fly approach. To use it `install
<https://github.com/mctools/ncrystal/wiki/Get-NCrystal>`_ and `initialize
<https://github.com/mctools/ncrystal/wiki/Using-NCrystal#setting-up>`_
NCrystal and turn on the option in the CMake configuration step:

cmake -DOPENMC_USE_NCRYSTAL=on ..
Expand Down Expand Up @@ -374,8 +375,8 @@ OPENMC_USE_DAGMC
(Default: off)

OPENMC_USE_NCRYSTAL
Turns on support for NCrystal materials. NCrystal must be
`installed <https://github.com/mctools/ncrystal/wiki/Get-NCrystal>`_ and
Turns on support for NCrystal materials. NCrystal must be
`installed <https://github.com/mctools/ncrystal/wiki/Get-NCrystal>`_ and
`initialized <https://github.com/mctools/ncrystal/wiki/Using-NCrystal#setting-up>`_.
(Default: off)

Expand Down
20 changes: 11 additions & 9 deletions docs/source/usersguide/materials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ you would need to add hydrogen and oxygen to a material and then assign the
Adding NCrystal materials
-------------------------

Additional support for thermal scattering can be added by using NCrystal_.
The :meth:`Material.from_ncrystal` class method generates a :class:`openmc.Material` object from
an `NCrystal configuration string <https://github.com/mctools/ncrystal/wiki/Using-NCrystal#uniform-material-configuration-syntax>`_.
Temperature, material composition, and density are passed from the configuration string
and the `NCMAT file <https://github.com/mctools/ncrystal/wiki/NCMAT-format>`_
that define the material, e.g.::
Additional support for thermal scattering can be added by using NCrystal_. The
:meth:`Material.from_ncrystal` class method generates a :class:`openmc.Material`
object from an `NCrystal configuration string
<https://github.com/mctools/ncrystal/wiki/Using-NCrystal#uniform-material-configuration-syntax>`_.
Temperature, material composition, and density are passed from the configuration
string and the `NCMAT file
<https://github.com/mctools/ncrystal/wiki/NCMAT-format>`_ that define the
material, e.g.::

mat = openmc.Material.from_ncrystal('Al_sg225.ncmat;temp=300K')

Expand All @@ -125,12 +127,12 @@ defines a material containing polycrystalline alumnium,
defines an oriented germanium single crystal with 40 arcsec mosaicity.

NCrystal only handles low energy neutron interactions. Other interactions are
provided by standard ACE files. NCrystal_ comes with a `predefined library
provided by standard ACE files. NCrystal_ comes with a `predefined library
<https://github.com/mctools/ncrystal/wiki/Data-library>`_ but more materials can
be added by creating NCMAT files or on-the-fly in the configuration string.

.. warning:: Currently, NCrystal_ materials cannot be modified after they are created.
Density, temperature and composition should be defined in the
.. warning:: Currently, NCrystal_ materials cannot be modified after they are created.
Density, temperature and composition should be defined in the
configuration string or the NCMAT file.

.. _NCrystal: https://github.com/mctools/ncrystal
Expand Down
5 changes: 3 additions & 2 deletions include/openmc/physics.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ void inelastic_scatter(const Nuclide& nuc, const Reaction& rx, Particle& p);

void sample_secondary_photons(Particle& p, int i_nuclide);

// !Split or Roulette particles based their weight and the lower weight window
// bound.
//! Split or Roulette particles based their weight and the lower weight window
//! bound.
//
//! \param[in] p, particle to be split or rouletted with the weight window.
void split_particle(Particle& p);

Expand Down
16 changes: 10 additions & 6 deletions tests/regression_tests/ncrystal/test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from math import pi

import numpy as np
import openmc
import openmc.lib
Expand All @@ -9,6 +11,7 @@
not openmc.lib._ncrystal_enabled(),
reason="NCrystal materials are not enabled.")


def pencil_beam_model(cfg, E0, N):
"""Return an openmc.Model() object for a monoenergetic pencil
beam hitting a 1 mm sphere filled with the material defined by
Expand All @@ -24,7 +27,7 @@ def pencil_beam_model(cfg, E0, N):
sample_sphere = openmc.Sphere(r=0.1)
outer_sphere = openmc.Sphere(r=100, boundary_type="vacuum")
cell1 = openmc.Cell(region=-sample_sphere, fill=m1)
cell2_region= +sample_sphere & -outer_sphere
cell2_region = +sample_sphere & -outer_sphere
cell2 = openmc.Cell(region=cell2_region, fill=None)
geometry = openmc.Geometry([cell1, cell2])

Expand All @@ -48,7 +51,7 @@ def pencil_beam_model(cfg, E0, N):
tally1 = openmc.Tally(name="angular distribution")
tally1.scores = ["current"]
filter1 = openmc.SurfaceFilter(sample_sphere)
filter2 = openmc.PolarFilter(np.linspace(0, np.pi, 180+1))
filter2 = openmc.PolarFilter(np.linspace(0, pi, 180+1))
filter3 = openmc.CellFromFilter(cell1)
tally1.filters = [filter1, filter2, filter3]
tallies = openmc.Tallies([tally1])
Expand All @@ -66,11 +69,12 @@ def _get_results(self):
df = tal.get_pandas_dataframe()
return df.to_string()


def test_ncrystal():
NParticles = 100000
T = 293.6 # K
E0 = 0.012 # eV
n_particles = 100000
T = 293.6 # K
E0 = 0.012 # eV
cfg = 'Al_sg225.ncmat'
test = pencil_beam_model(cfg, E0, NParticles)
test = pencil_beam_model(cfg, E0, n_particles)
harness = NCrystalTest('statepoint.10.h5', model=test)
harness.main()