Skip to content

Commit b41e22f

Browse files
paulromanoGuyStenamandalund
authored
Refactor ParticleType to use PDG Monte Carlo numbering scheme (#3756)
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com> Co-authored-by: Amanda Lund <alund1187@gmail.com>
1 parent fc0d9ee commit b41e22f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1404
-561
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ list(APPEND libopenmc_SOURCES
372372
src/particle.cpp
373373
src/particle_data.cpp
374374
src/particle_restart.cpp
375+
src/particle_type.cpp
375376
src/photon.cpp
376377
src/physics.cpp
377378
src/physics_common.cpp

docs/source/io_formats/collision_track.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ may also be written after each batch when multiple files are requested
1010
(``collision_track.N.h5``) or when the run is performed in parallel. The file
1111
contains the information needed to reconstruct each recorded collision.
1212

13-
The current revision of the collision track file format is 1.0.
13+
The current revision of the collision track file format is 1.1.
1414

1515
**/**
1616

@@ -37,9 +37,9 @@ The current revision of the collision track file format is 1.0.
3737
- ``material_id`` (*int*) -- ID of the material containing the collision site.
3838
- ``universe_id`` (*int*) -- ID of the universe containing the collision site.
3939
- ``n_collision`` (*int*) -- Collision counter for the particle history.
40-
- ``particle`` (*int*) -- Particle type (0=neutron, 1=photon, 2=electron, 3=positron).
41-
- ``parent_id`` (*int64*) -- Unique ID of the parent particle.
42-
- ``progeny_id`` (*int64*) -- Progeny ID of the particle.
40+
- ``particle`` (*int32_t*) -- Particle type (PDG number).
41+
- ``parent_id`` (*int64_t*) -- Unique ID of the parent particle.
42+
- ``progeny_id`` (*int64_t*) -- Progeny ID of the particle.
4343

4444
In an MPI run, OpenMC writes the combined dataset by gathering collision-track
4545
entries from all ranks before flushing them to disk, so the final file appears

docs/source/io_formats/particle_restart.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Particle Restart File Format
55
============================
66

7-
The current version of the particle restart file format is 2.0.
7+
The current version of the particle restart file format is 2.1.
88

99
**/**
1010

@@ -26,8 +26,7 @@ The current version of the particle restart file format is 2.0.
2626
- **run_mode** (*char[]*) -- Run mode used, either 'fixed source',
2727
'eigenvalue', or 'particle restart'.
2828
- **id** (*int8_t*) -- Unique identifier of the particle.
29-
- **type** (*int*) -- Particle type (0=neutron, 1=photon, 2=electron,
30-
3=positron)
29+
- **type** (*int32_t*) -- Particle type (PDG number)
3130
- **weight** (*double*) -- Weight of the particle.
3231
- **energy** (*double*) -- Energy of the particle in eV for
3332
continuous-energy mode, or the energy group of the particle for

docs/source/io_formats/settings.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,10 @@ attributes/sub-elements:
721721
is present.
722722

723723
:particle:
724-
The source particle type, either ``neutron`` or ``photon``.
724+
The source particle type, specified as a PDG number or a string alias (e.g.,
725+
``neutron``/``n``, ``photon``/``gamma``, ``electron``, ``positron``,
726+
``proton``/``p``, ``deuteron``/``d``, ``triton``/``t``, ``alpha``, or GNDS
727+
nuclide names like ``Fe57``).
725728

726729
*Default*: neutron
727730

@@ -1537,7 +1540,8 @@ sub-elements/attributes:
15371540
*Default*: None
15381541

15391542
:particle_type:
1540-
The particle that the weight windows will apply to (e.g., 'neutron')
1543+
The particle that the weight windows will apply to, specified as a PDG
1544+
code or string (e.g., ``neutron``).
15411545

15421546
*Default*: 'neutron'
15431547

@@ -1597,7 +1601,8 @@ mesh-based weight windows.
15971601
*Default*: None
15981602

15991603
:particle_type:
1600-
The particle that the weight windows will apply to (e.g., 'neutron')
1604+
The particle that the weight windows will apply to, specified as a PDG
1605+
code or string (e.g., ``neutron``).
16011606

16021607
*Default*: neutron
16031608

docs/source/io_formats/source.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ following the same format.
1515
**/**
1616

1717
:Attributes: - **filetype** (*char[]*) -- String indicating the type of file.
18+
- **version** (*int[2]*) -- Major and minor version of the source
19+
file format.
1820

1921
:Datasets:
2022

2123
- **source_bank** (Compound type) -- Source bank information for each
2224
particle. The compound type has fields ``r``, ``u``, ``E``,
2325
``time``, ``wgt``, ``delayed_group``, ``surf_id`` and ``particle``,
2426
which represent the position, direction, energy, time, weight,
25-
delayed group, surface ID, and particle type (0=neutron, 1=photon,
26-
2=electron, 3=positron), respectively.
27+
delayed group, surface ID, and particle type (PDG number),
28+
respectively.

docs/source/io_formats/statepoint.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
State Point File Format
55
=======================
66

7-
The current version of the statepoint file format is 18.1.
7+
The current version of the statepoint file format is 18.2.
88

99
**/**
1010

@@ -56,8 +56,8 @@ The current version of the statepoint file format is 18.1.
5656
``time``, ``wgt``, ``delayed_group``, ``surf_id``, and
5757
``particle``, which represent the position, direction, energy,
5858
time, weight, delayed group, surface ID, and particle type
59-
(0=neutron, 1=photon, 2=electron, 3=positron), respectively. Only
60-
present when `run_mode` is 'eigenvalue'.
59+
(PDG number), respectively. Only present when `run_mode` is
60+
'eigenvalue'.
6161

6262
**/tallies/**
6363

docs/source/io_formats/tallies.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ should be set to:
318318
they use ``energy`` and ``y``.
319319

320320
:particle:
321-
A list of integers indicating the type of particles to tally ('neutron' = 1,
322-
'photon' = 2, 'electron' = 3, 'positron' = 4).
321+
A list of particle identifiers to tally, specified as strings (e.g.,
322+
``neutron``, ``photon``, ``He4``) or as integer PDG numbers.
323323

324324
------------------
325325
``<mesh>`` Element

docs/source/io_formats/track.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Track File Format
55
=================
66

7-
The current revision of the particle track file format is 3.0.
7+
The current revision of the particle track file format is 3.1.
88

99
**/**
1010

@@ -32,6 +32,5 @@ The current revision of the particle track file format is 3.0.
3232
the array for each primary/secondary particle. The
3333
last offset should match the total size of the
3434
array.
35-
- **particles** (*int[]*) -- Particle type for each
36-
primary/secondary particle (0=neutron, 1=photon,
37-
2=electron, 3=positron).
35+
- **particles** (*int32_t[]*) -- Particle type for
36+
each primary/secondary particle (PDG number).

docs/source/usersguide/settings.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ below.
400400
{
401401
openmc::SourceSite particle;
402402
// weight
403-
particle.particle = openmc::ParticleType::neutron;
403+
particle.particle = openmc::ParticleType::neutron();
404404
particle.wgt = 1.0;
405405
// position
406406
double angle = 2.0 * M_PI * openmc::prn(seed);
@@ -477,7 +477,7 @@ parameters to the source class when it is created:
477477
{
478478
openmc::SourceSite particle;
479479
// weight
480-
particle.particle = openmc::ParticleType::neutron;
480+
particle.particle = openmc::ParticleType::neutron();
481481
particle.wgt = 1.0;
482482
// position
483483
particle.r.x = 0.0;
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
#include <cmath> // for M_PI
1+
#include <cmath> // for M_PI
22
#include <memory> // for unique_ptr
33

4+
#include "openmc/particle.h"
45
#include "openmc/random_lcg.h"
56
#include "openmc/source.h"
6-
#include "openmc/particle.h"
77

8-
class RingSource : public openmc::Source
9-
{
8+
class RingSource : public openmc::Source {
109
openmc::SourceSite sample(uint64_t* seed) const
1110
{
1211
openmc::SourceSite particle;
1312
// particle type
14-
particle.particle = openmc::ParticleType::neutron;
13+
particle.particle = openmc::ParticleType::neutron();
1514
// position
1615
double angle = 2.0 * M_PI * openmc::prn(seed);
1716
double radius = 3.0;
@@ -25,10 +24,11 @@ class RingSource : public openmc::Source
2524
}
2625
};
2726

28-
// A function to create a unique pointer to an instance of this class when generated
29-
// via a plugin call using dlopen/dlsym.
30-
// You must have external C linkage here otherwise dlopen will not find the file
31-
extern "C" std::unique_ptr<RingSource> openmc_create_source(std::string parameters)
27+
// A function to create a unique pointer to an instance of this class when
28+
// generated via a plugin call using dlopen/dlsym. You must have external C
29+
// linkage here otherwise dlopen will not find the file
30+
extern "C" std::unique_ptr<RingSource> openmc_create_source(
31+
std::string parameters)
3232
{
3333
return std::make_unique<RingSource>();
3434
}

0 commit comments

Comments
 (0)