Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion openmc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.metadata
from openmc.arithmetic import *
from openmc.bounding_box import *
from openmc.cell import *
Expand Down Expand Up @@ -39,4 +40,5 @@
from openmc.model import Model


__version__ = '0.14.1-dev'

__version__ = importlib.metadata.version("openmc")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would recommend using dynamic metadata instead to keep this more consistent with what people expect: dynamic metadata.

73 changes: 73 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
[build-system]
requires = ["setuptools", "wheel", "numpy", "cython"]

[project]
name = "openmc"
authors = [
{name = "The OpenMC Development Team", email = "openmc@anl.gov"},
]
description = "OpenMC"
version = "0.14.1-dev"
requires-python = ">=3.8"
license = {file = "LICENSE"}
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Topic :: Scientific/Engineering",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"numpy>=1.9",
"h5py",
"scipy",
"ipython",
"matplotlib",
"pandas",
"lxml",
"uncertainties",
]

[project.optional-dependencies]
depletion-mpi = ["mpi4py"]
docs = [
"sphinx",
"sphinxcontrib-katex",
"sphinx-numfig",
"jupyter",
"sphinxcontrib-svg2pdfconverter",
"sphinx-rtd-theme"
]
test = ["pytest", "pytest-cov", "colorama"]
vtk = ["vtk"]

[project.urls]
Homepage = "https://openmc.org"
Documentation = "https://docs.openmc.org"
Repository = "https://github.com/openmc-dev/openmc"
Issues = "https://github.com/openmc-dev/openmc/issues"

[tool.setuptools.packages.find]
include = ['openmc*', 'scripts*']
exclude = ['tests*']

[tool.setuptools.package-data]
"openmc.data.effective_dose" = ["*.csv"]
"openmc.data" = ["*.txt", "*.DAT", "*.json", "*.h5"]

[project.scripts]
openmc-ace-to-hdf5 = "scripts.openmc_ace_to_hdf5:main"
openmc-plot-mesh-tally = "scripts.openmc_plot_mesh_tally:main"
openmc-track-combine = "scripts.openmc_track_combine:main"
openmc-track-to-vtk = "scripts.openmc_track_to_vtk:main"
openmc-update-inputs = "scripts.openmc_update_inputs:main"
openmc-update-mgxs = "scripts.openmc_update_mgxs:main"
openmc-voxel-to-vtk = "scripts.openmc_voxel_to_vtk:main"
93 changes: 47 additions & 46 deletions scripts/openmc-ace-to-hdf5 → scripts/openmc_ace_to_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,52 @@
from openmc.data.ace import TableType


def ace_to_hdf5(destination, xsdir, xsdata, libraries, metastable, libver):
class CustomFormatter(
argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
):
pass

parser = argparse.ArgumentParser(
description=__doc__, formatter_class=CustomFormatter
)
parser.add_argument("libraries", nargs="*", help="ACE libraries to convert to HDF5")
parser.add_argument(
"-d",
"--destination",
type=Path,
default=Path.cwd(),
help="Directory to create new library in",
)
parser.add_argument(
"-m",
"--metastable",
choices=["mcnp", "nndc"],
default="nndc",
help="How to interpret ZAIDs for metastable nuclides",
)
parser.add_argument("--xsdir", help="MCNP xsdir file that lists " "ACE libraries")
parser.add_argument(
"--xsdata", help="Serpent xsdata file that lists " "ACE libraries"
)
parser.add_argument(
"--libver",
choices=["earliest", "latest"],
default="earliest",
help="Output HDF5 versioning. Use "
"'earliest' for backwards compatibility or 'latest' "
"for performance",
)
args = parser.parse_args()


def main():

destination=args.destination
xsdir=args.xsdir
xsdata=args.xsdata
libraries=args.libraries
metastable=args.metastable
libver=args.libver

if not destination.is_dir():
destination.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -109,48 +154,4 @@ def ace_to_hdf5(destination, xsdir, xsdata, libraries, metastable, libver):

if __name__ == "__main__":

class CustomFormatter(
argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
):
pass

parser = argparse.ArgumentParser(
description=__doc__, formatter_class=CustomFormatter
)
parser.add_argument("libraries", nargs="*", help="ACE libraries to convert to HDF5")
parser.add_argument(
"-d",
"--destination",
type=Path,
default=Path.cwd(),
help="Directory to create new library in",
)
parser.add_argument(
"-m",
"--metastable",
choices=["mcnp", "nndc"],
default="nndc",
help="How to interpret ZAIDs for metastable nuclides",
)
parser.add_argument("--xsdir", help="MCNP xsdir file that lists " "ACE libraries")
parser.add_argument(
"--xsdata", help="Serpent xsdata file that lists " "ACE libraries"
)
parser.add_argument(
"--libver",
choices=["earliest", "latest"],
default="earliest",
help="Output HDF5 versioning. Use "
"'earliest' for backwards compatibility or 'latest' "
"for performance",
)
args = parser.parse_args()

ace_to_hdf5(
destination=args.destination,
xsdir=args.xsdir,
xsdata=args.xsdata,
libraries=args.libraries,
metastable=args.metastable,
libver=args.libver,
)
main()
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def get_file_data(self, filename):
sys.exit(1)


if __name__ == '__main__':
def main():
parser = argparse.ArgumentParser()
parser.add_argument('statepoint', nargs='?', help='Statepoint file')
args = parser.parse_args()
Expand All @@ -342,3 +342,6 @@ def get_file_data(self, filename):
app = MeshPlotter(root, filename)
root.deiconify()
root.mainloop()

if __name__ == '__main__':
main()
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ def update_materials(root):

return was_updated


if __name__ == '__main__':
def main():
args = parse_args()
for fname in args.input:
# Parse the XML data.
Expand All @@ -297,3 +296,6 @@ def update_materials(root):

# Write a new geometry file.
tree.write(fname, xml_declaration=True)

if __name__ == '__main__':
main()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import openmc


if __name__ == "__main__":
def main():
# Process command line arguments
parser = ArgumentParser('Converts a voxel HDF5 file to a VTK file')
parser.add_argument("voxel_file", help="Path to voxel h5 file")
Expand All @@ -20,3 +19,6 @@
print("Reading and translating data...")
openmc.voxel_to_vtk(args.voxel_file, args.output)
print(f"Written VTK file {args.output}...")

if __name__ == "__main__":
main()
63 changes: 4 additions & 59 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env python

import glob
import sys
import numpy as np

from setuptools import setup, find_packages
from setuptools import setup
from Cython.Build import cythonize


Expand All @@ -16,65 +15,11 @@

# Get version information from __init__.py. This is ugly, but more reliable than
# using an import.
with open('openmc/__init__.py', 'r') as f:
version = f.readlines()[-1].split()[-1].strip("'")
# with open('openmc/__init__.py', 'r') as f:
# version = f.readlines()[-1].split()[-1].strip("'")

kwargs = {
'name': 'openmc',
'version': version,
'packages': find_packages(exclude=['tests*']),
'scripts': glob.glob('scripts/openmc-*'),

# Data files and libraries
'package_data': {
'openmc.lib': ['libopenmc.{}'.format(suffix)],
'openmc.data': ['mass_1.mas20.txt', 'BREMX.DAT', 'half_life.json', '*.h5'],
'openmc.data.effective_dose': ['*.txt']
},

# Metadata
'author': 'The OpenMC Development Team',
'author_email': 'openmc@anl.gov',
'description': 'OpenMC',
'url': 'https://openmc.org',
'download_url': 'https://github.com/openmc-dev/openmc/releases',
'project_urls': {
'Issue Tracker': 'https://github.com/openmc-dev/openmc/issues',
'Documentation': 'https://docs.openmc.org',
'Source Code': 'https://github.com/openmc-dev/openmc',
},
'classifiers': [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Topic :: Scientific/Engineering'
'Programming Language :: C++',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],

# Dependencies
'python_requires': '>=3.7',
'install_requires': [
'numpy>=1.9', 'h5py', 'scipy', 'ipython', 'matplotlib',
'pandas', 'lxml', 'uncertainties'
],
'extras_require': {
'depletion-mpi': ['mpi4py'],
'docs': ['sphinx', 'sphinxcontrib-katex', 'sphinx-numfig', 'jupyter',
'sphinxcontrib-svg2pdfconverter', 'sphinx-rtd-theme'],
'test': ['pytest', 'pytest-cov', 'colorama'],
'vtk': ['vtk'],
},
# Cython is used to add resonance reconstruction and fast float_endf
# 'version': version,
'ext_modules': cythonize('openmc/data/*.pyx'),
'include_dirs': [np.get_include()]
}
Expand Down