Skip to content

Commit be61e8b

Browse files
authored
Merge pull request #125 from njoy/release
ENDFtk v0.2.0 Release
2 parents b6618b3 + a244968 commit be61e8b

File tree

810 files changed

+69272
-10444
lines changed

Some content is hidden

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

810 files changed

+69272
-10444
lines changed

.github/workflows/ContinuousIntegration.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
name: Continuous Integration
33

44
# This workflow is triggered on pushes and pull requests to the repository.
5-
on:
5+
on:
66
push:
77
branches: '**'
8-
pull_request:
8+
pull_request:
99
branches: 'master'
1010

1111
jobs:
@@ -14,23 +14,31 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ ubuntu-18.04, macos-10.15 ]
17-
cxx: [ g++-9, clang++ ]
17+
cxx: [ clang++ ]
1818
build_type: [ Debug, Release ]
1919

2020
steps:
2121
- name: which CXX
2222
run: |
23-
which ${{matrix.cxx}}
23+
which ${{matrix.cxx}}
2424
${{matrix.cxx}} --version
2525
- uses: actions/checkout@v2
2626
- name: mkdir bin
27-
run: mkdir bin
27+
run: mkdir bin
2828
- name: cmake
29-
run: cmake -D CMAKE_CXX_COMPILER=`which ${{matrix.cxx}}` -D CMAKE_BUILD_TYPE=${{matrix.build_type}} ..
29+
run: cmake -DPYTHON_EXECUTABLE=$(which python3) -D CMAKE_CXX_COMPILER=`which ${{matrix.cxx}}` -D CMAKE_BUILD_TYPE=${{matrix.build_type}} ..
3030
working-directory: ./bin
3131
- name: make
3232
run: make -j2
3333
working-directory: ./bin
3434
- name: ctest
3535
run: ctest -j2
3636
working-directory: ./bin
37+
- name: make ENDFtk.python
38+
run: make ENDFtk.python -j2
39+
working-directory: ./bin
40+
- name: python -m unittest
41+
run: |
42+
cp ../bin/*.so .
43+
python3 -m unittest discover -v -p "Test*"
44+
working-directory: ./python

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
*.app
3030

3131
bin
32+
build
3233
subprojects
34+
dependencies
3335

3436
# emacs
3537
*~

.gitmodules

Whitespace-only changes.

CMakeLists.txt

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ endif()
5252
# Project targets
5353
########################################################################
5454

55+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56+
# ENDFtk : library
57+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58+
59+
include_directories( src/ )
60+
5561
add_library( ENDFtk INTERFACE
5662
)
5763
target_include_directories( ENDFtk INTERFACE src/ )
@@ -64,6 +70,154 @@ target_link_libraries( ENDFtk
6470
INTERFACE range-v3-adapter
6571
)
6672

73+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74+
# ENDFtk : python bindings
75+
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76+
77+
include_directories( python/src/ )
78+
79+
pybind11_add_module( ENDFtk.python
80+
EXCLUDE_FROM_ALL
81+
python/src/ENDFtk.python.cpp
82+
python/src/record/DirectoryRecord.python.cpp
83+
python/src/record/TapeIdentification.python.cpp
84+
python/src/section/1/TabulatedMultiplicity.python.cpp
85+
python/src/section/1/PolynomialMultiplicity.python.cpp
86+
python/src/section/1/451.python.cpp
87+
python/src/section/1/452.python.cpp
88+
python/src/section/1/455.python.cpp
89+
python/src/section/1/455/DecayConstants.python.cpp
90+
python/src/section/1/455/EnergyIndependentConstants.python.cpp
91+
python/src/section/1/455/EnergyDependentConstants.python.cpp
92+
python/src/section/1/456.python.cpp
93+
python/src/section/1/458.python.cpp
94+
python/src/section/1/458/EnergyReleaseComponent.python.cpp
95+
python/src/section/1/458/ThermalPointComponents.python.cpp
96+
python/src/section/1/458/PolynomialComponents.python.cpp
97+
python/src/section/1/458/TabulatedComponents.python.cpp
98+
python/src/section/1/460.python.cpp
99+
python/src/section/1/460/DiscretePhotonMultiplicity.python.cpp
100+
python/src/section/1/460/DiscretePhotons.python.cpp
101+
python/src/section/1/460/ContinuousPhotons.python.cpp
102+
python/src/section/2/151.python.cpp
103+
python/src/section/2/151/Isotope.python.cpp
104+
python/src/section/2/151/ScatteringRadius.python.cpp
105+
python/src/section/2/151/ResonanceRange.python.cpp
106+
python/src/section/2/151/SpecialCase.python.cpp
107+
python/src/section/2/151/BreitWignerLValue.python.cpp
108+
python/src/section/2/151/ReichMooreLValue.python.cpp
109+
python/src/section/2/151/SingleLevelBreitWigner.python.cpp
110+
python/src/section/2/151/MultiLevelBreitWigner.python.cpp
111+
python/src/section/2/151/ReichMoore.python.cpp
112+
python/src/section/2/151/ParticlePairs.python.cpp
113+
python/src/section/2/151/ResonanceChannels.python.cpp
114+
python/src/section/2/151/ResonanceParameters.python.cpp
115+
python/src/section/2/151/NoBackgroundRMatrix.python.cpp
116+
python/src/section/2/151/SammyBackgroundRMatrix.python.cpp
117+
python/src/section/2/151/FrohnerBackgroundRMatrix.python.cpp
118+
python/src/section/2/151/TabulatedBackgroundRMatrix.python.cpp
119+
python/src/section/2/151/BackgroundChannels.python.cpp
120+
python/src/section/2/151/SpinGroup.python.cpp
121+
python/src/section/2/151/RMatrixLimited.python.cpp
122+
python/src/section/2/151/UnresolvedEnergyDependentFissionWidthsJValue.python.cpp
123+
python/src/section/2/151/UnresolvedEnergyDependentJValue.python.cpp
124+
python/src/section/2/151/UnresolvedEnergyIndependentLValue.python.cpp
125+
python/src/section/2/151/UnresolvedEnergyDependentFissionWidthsLValue.python.cpp
126+
python/src/section/2/151/UnresolvedEnergyDependentLValue.python.cpp
127+
python/src/section/2/151/UnresolvedEnergyDependent.python.cpp
128+
python/src/section/2/151/UnresolvedEnergyDependentFissionWidths.python.cpp
129+
python/src/section/2/151/UnresolvedEnergyIndependent.python.cpp
130+
python/src/section/2/152.python.cpp
131+
python/src/section/3.python.cpp
132+
python/src/section/4.python.cpp
133+
python/src/section/4/Isotropic.python.cpp
134+
python/src/section/4/LegendreCoefficients.python.cpp
135+
python/src/section/4/TabulatedDistribution.python.cpp
136+
python/src/section/4/LegendreDistributions.python.cpp
137+
python/src/section/4/TabulatedDistributions.python.cpp
138+
python/src/section/4/MixedDistributions.python.cpp
139+
python/src/section/5.python.cpp
140+
python/src/section/5/Parameter.python.cpp
141+
python/src/section/5/OutgoingEnergyDistribution.python.cpp
142+
python/src/section/5/TabulatedSpectrum.python.cpp
143+
python/src/section/5/DistributionFunction.python.cpp
144+
python/src/section/5/EffectiveTemperature.python.cpp
145+
python/src/section/5/GeneralEvaporationSpectrum.python.cpp
146+
python/src/section/5/EvaporationSpectrum.python.cpp
147+
python/src/section/5/MaxwellianFissionSpectrum.python.cpp
148+
python/src/section/5/WattSpectrum.python.cpp
149+
python/src/section/5/MadlandNixSpectrum.python.cpp
150+
python/src/section/5/Probability.python.cpp
151+
python/src/section/5/PartialDistribution.python.cpp
152+
python/src/section/6.python.cpp
153+
python/src/section/6/Multiplicity.python.cpp
154+
python/src/section/6/DefinedElsewhere.python.cpp
155+
python/src/section/6/Unknown.python.cpp
156+
python/src/section/6/LAW1/LegendreCoefficients.python.cpp
157+
python/src/section/6/LAW1/TabulatedDistribution.python.cpp
158+
python/src/section/6/LAW1/KalbachMann.python.cpp
159+
python/src/section/6/LAW1/ThermalScatteringData.python.cpp
160+
python/src/section/6/ContinuumEnergyAngle.python.cpp
161+
python/src/section/6/LAW2/LegendreCoefficients.python.cpp
162+
python/src/section/6/LAW2/TabulatedDistribution.python.cpp
163+
python/src/section/6/DiscreteTwoBodyScattering.python.cpp
164+
python/src/section/6/IsotropicDiscreteEmission.python.cpp
165+
python/src/section/6/DiscreteTwoBodyRecoils.python.cpp
166+
python/src/section/6/ChargedParticleElasticScattering.python.cpp
167+
python/src/section/6/LAW5/LegendreCoefficients.python.cpp
168+
python/src/section/6/LAW5/NuclearAmplitudeExpansion.python.cpp
169+
python/src/section/6/LAW5/NuclearPlusInterference.python.cpp
170+
python/src/section/6/NBodyPhaseSpace.python.cpp
171+
python/src/section/6/LAW7/EnergyDistribution.python.cpp
172+
python/src/section/6/LAW7/AngularDistribution.python.cpp
173+
python/src/section/6/LaboratoryAngleEnergy.python.cpp
174+
python/src/section/6/ReactionProduct.python.cpp
175+
python/src/section/7/2.python.cpp
176+
python/src/section/7/2/CoherentElastic.python.cpp
177+
python/src/section/7/2/IncoherentElastic.python.cpp
178+
python/src/section/7/2/MixedElastic.python.cpp
179+
python/src/section/7/4.python.cpp
180+
python/src/section/7/4/EffectiveTemperature.python.cpp
181+
python/src/section/7/4/ScatteringLawConstants.python.cpp
182+
python/src/section/7/4/AnalyticalFunctions.python.cpp
183+
python/src/section/7/4/TabulatedFunctions.python.cpp
184+
python/src/section/7/4/ScatteringFunction.python.cpp
185+
python/src/section/8/457.python.cpp
186+
python/src/section/8/457/AverageDecayEnergies.python.cpp
187+
python/src/section/8/457/DecayMode.python.cpp
188+
python/src/section/8/457/DecayModes.python.cpp
189+
python/src/section/8/457/DiscreteSpectrum.python.cpp
190+
python/src/section/8/457/ContinuousSpectrum.python.cpp
191+
python/src/section/8/457/DecaySpectrum.python.cpp
192+
python/src/section/12.python.cpp
193+
python/src/section/12/TotalMultiplicity.python.cpp
194+
python/src/section/12/PartialMultiplicity.python.cpp
195+
python/src/section/12/Multiplicities.python.cpp
196+
python/src/section/12/TransitionProbabilities.python.cpp
197+
python/src/section/13.python.cpp
198+
python/src/section/13/TotalCrossSection.python.cpp
199+
python/src/section/13/PartialCrossSection.python.cpp
200+
python/src/file/1.python.cpp
201+
python/src/file/2.python.cpp
202+
python/src/file/3.python.cpp
203+
python/src/file/4.python.cpp
204+
python/src/file/5.python.cpp
205+
python/src/file/6.python.cpp
206+
python/src/file/7.python.cpp
207+
python/src/file/8.python.cpp
208+
python/src/file/12.python.cpp
209+
python/src/file/13.python.cpp
210+
python/src/Material.python.cpp
211+
python/src/tree/Section.python.cpp
212+
python/src/tree/File.python.cpp
213+
python/src/tree/Material.python.cpp
214+
python/src/tree/Tape.python.cpp
215+
)
216+
target_link_libraries( ENDFtk.python PRIVATE ENDFtk )
217+
target_compile_options( ENDFtk.python PRIVATE "-fPIC" )
218+
target_compile_options( ENDFtk.python PRIVATE "-fvisibility=hidden" )
219+
set_target_properties( ENDFtk.python PROPERTIES OUTPUT_NAME ENDFtk )
220+
set_target_properties( ENDFtk.python PROPERTIES COMPILE_DEFINITIONS "PYBIND11" )
67221

68222
#######################################################################
69223
# Top-level Only

README.md

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,116 @@
11
![Continuous Integration](https://github.com/njoy/ENDFtk/workflows/Continuous%20Integration/badge.svg)
22

33
# ENDFtk
4-
Toolkit for reading and interacting with ENDF-6 formatted files
4+
Toolkit for reading and interacting with ENDF-6 formatted files. This toolkit provides a full C++ library along with python bindings.
5+
6+
## ENDFtk in python
7+
8+
The python bindings for ENDFtk are still work in progress and should be used accordingly. Please report any issues encountered while using the python bindings using the issue tracker on this repository.
9+
10+
### Installing ENDFtk for python
11+
12+
First of all, a user should clone the ENDFtk repository and build the python bindings:
13+
```
14+
git clone https://github.com/njoy/ENDFtk
15+
cd ENDFtk
16+
mkdir build
17+
cd build
18+
cmake -DCMAKE_BUILD_TYPE=Release ../
19+
make ENDFtk.python -j8
20+
```
21+
22+
ENDFtk in python requires python 3.x so you will need to have at least one python 3.x installed. When multiple python versions are installed, it may be beneficial to include ```-DPYTHON_EXECUTABLE=$(which python3)``` in the cmake configuration step so that the default python3 version will be picked. The compilation will produce a dynamic library linked to the python libraries on the user's computer (it'll be named something like `ENDFtk.cpython-37m-darwin.so`). This name will also indicate which version of the python libraries this library is linked to. This is important since you will need to use the associated python version with the ENDFtk python package.
23+
24+
In order to use the ENDFtk python package, the user should make sure that the library is within the python path. This can be done in multiple ways. You can set that up by adding the ENDFtk build path to the python path `$PYTHONPATH` environmental variable on your machine, or by using the following in your python code:
25+
```
26+
import sys
27+
sys.path.append( < ENDFtk-build-path > )
28+
```
29+
where `< ENDFtk-build-path >` is the path to the ENDFtk python dynamic library.
30+
31+
When running python in the build directory directly, none of these steps are required.
32+
33+
#### Troubleshooting ####
34+
35+
##### CMake doesn’t detect the right Python version #####
36+
37+
Taken from the pybind11 FAQ.
38+
39+
The CMake-based build system will try to automatically detect the installed version of Python and link against that. When this fails, or when there are multiple versions of Python and it finds the wrong one, delete CMakeCache.txt and then add -DPYTHON_EXECUTABLE=$(which python) to your CMake configure line. (Replace $(which python) with a path to python if your prefer.)
40+
41+
A version of python 3.x is preferred.
42+
43+
##### importError cannot import name <sysconfig> #####
44+
45+
This error sometimes comes up when running the cmake command. This appears to be related to an incomplete/corrupted python installation. It can be rectified by installing the distutils package for the python version that is being used. On a linux system, the following command should install the distutils package:
46+
```
47+
sudo apt install python3-distutils
48+
```
49+
50+
##### cannot find python.h #####
51+
52+
When compiling the python bindings, this error indicates that the python header files and static library we need to link to are not installed on your system. This appears to be related to an incomplete python installation. It can be rectified by installing the python3-dev package (when using python 3). On a linux system, the following command should install the header files:
53+
```
54+
sudo apt install python3-dev
55+
```
56+
57+
### A minimal user guide:
58+
59+
Opening up a tape:
60+
```
61+
import ENDFtk
62+
tape = ENDFtk.tree.Tape.from_file( 'n-001_H_001.endf' )
63+
```
64+
65+
An `ENDFtk.tree.Tape` effectively indexes the file into available materials, files and sections, which can be parsed at will by the user. The `ENDFtk.tree` submodule also provides an `ENDFtk.tree.Material`, `ENDFtk.tree.File` and `ENDFtk.tree.Section` that the user can look through before parsing the data that is contained in any of these. Parsing the data requires strict adherence to the ENDF6 format but loading the data into an `ENDFtk.tree.Tape` does not. As a result, the `ENDFtk.tree.Tape` is also capable of indexing older ENDF files that do not conform with the ENDF6 standard (tests have shown that we can index files as old as ENDF/B-II).
66+
67+
Once the data is indexed, a user can retrieve an/or parse components (entire materials, files or sections) as follows:
68+
```
69+
mat = tape.material(125).parse()
70+
file = tape.material(125).file(6).parse()
71+
section = tape.material(125).file(6).section(102).parse()
72+
```
73+
74+
Accessing the underlying files and sections from parsed materials and sections uses the same function names:
75+
```
76+
mat = tape.material(125).parse()
77+
file = mat.file(6)
78+
section = file.section(102)
79+
```
80+
but since they are already parsed, no need to use the `.parse()` at the end. There are also ENDF-speak equivalents to this for both the `ENDFtk.tree` components as well as the parsed components:
81+
```
82+
mat = tape.MAT(125).parse()
83+
file = mat.MF(6)
84+
section = file.MT(102)
85+
```
86+
87+
Every component in ENDFtk has python documentation associated to it that can be viewed using the `help(...)` function in python:
88+
```
89+
mat = tape.material(125).parse()
90+
file = tape.material(125).file(6).parse()
91+
section = tape.material(125).file(6).section(102).parse()
92+
help( section ) # this will display the help for an ENDF MF6 section
93+
```
94+
95+
A simple example for looking at the different secondary particles and the distribution types used for them:
96+
```
97+
pu = tape.material(9437).parse()
98+
for product in pu.file(6).section(102).reaction_products :
99+
100+
print( product.ZAP, product.LAW )
101+
```
102+
103+
ENDFtk uses a concept called ranges (aka sequences) so as a result, anything coming out as a range will be a custom type. These custom range types allow subscripting and iteration like any other sequence or list. To convert such a range into a proper list, you can use the `to_list()` method or slicing. This will do a deep copy of primitive types (int, doubles, etc.). It will not do a deep copy for custom types like sections or underlying components. To deep copy a range of custom types, a user can use the `copy()` method on the range.
104+
105+
For example:
106+
```
107+
file = tape.material(125).file(6).parse()
108+
sections = file.sections # this is the custom range type for MF6 sections
109+
sections = file.sections.to_list() # this is a list of MF6 sections, with the same memory address as those contained in the file object
110+
111+
sections = file.sections[:] # this is also a list of MF6 sections, with the same memory address as those contained in the file object
112+
sections = file.sections.copy() # this is a list of MF6 sections that have been copied, with a different memory address as those contained in the file object
113+
```
5114

6115
## LICENSE
7116
The software contained in this repository is covered under the associated [LICENSE](LICENSE) file.

cmake/develop_dependencies.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ FetchContent_Declare( range-v3-adapter
4141
GIT_SHALLOW TRUE
4242
)
4343

44+
FetchContent_Declare( pybind11
45+
GIT_REPOSITORY https://github.com/pybind/pybind11
46+
GIT_TAG v2.6.1
47+
GIT_SHALLOW TRUE
48+
)
49+
4450
#######################################################################
4551
# Load dependencies
4652
#######################################################################
@@ -52,4 +58,5 @@ FetchContent_MakeAvailable(
5258
hana-adapter
5359
header-utilities
5460
range-v3-adapter
61+
pybind11
5562
)

cmake/release_dependencies.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ FetchContent_Declare( Log
3030
GIT_TAG 52962b7796afe37ef1d8f7edb4bf9ecb1b868d15
3131
)
3232

33+
FetchContent_Declare( pybind11
34+
GIT_REPOSITORY https://github.com/pybind/pybind11
35+
GIT_TAG f1abf5d9159b805674197f6bc443592e631c9130 # tag: v2.6.1
36+
)
37+
3338
FetchContent_Declare( range-v3-adapter
3439
GIT_REPOSITORY https://github.com/njoy/range-v3-adapter
3540
GIT_TAG 252679d4737c8f755d87c0e1eed6c37394a2ec59
@@ -51,6 +56,7 @@ FetchContent_MakeAvailable(
5156
hana-adapter
5257
header-utilities
5358
Log
59+
pybind11
5460
range-v3-adapter
5561
spdlog
5662
)

0 commit comments

Comments
 (0)