Skip to content

Commit 29d8810

Browse files
committed
added filetype attribute as 'wmp' and included a nuclide name
1 parent e86192e commit 29d8810

4 files changed

Lines changed: 40 additions & 56 deletions

File tree

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,21 @@ Detailed specifications can be found in
6767

6868
## Download
6969

70-
[Git LFS] is used to store the binary HDF5 files.
71-
To download the real WMP library, you need to firstly install [Git LFS] and then
72-
clone this repository.
70+
- download the compressed library from the latest releases: https://github.com/mit-crpg/WMP_Library/releases
7371

74-
``` bash
75-
$ git clone https://github.com/mit-crpg/WMP_Library.git
76-
```
72+
``` bash
73+
$ wget https://github.com/mit-crpg/WMP_Library/releases/download/v1.0.1/WMP_Library_v1.0.1.tar.gz
74+
```
75+
76+
- clone from git repository
77+
78+
[Git LFS] is used to store the binary HDF5 files.
79+
To download the real WMP library, you need to firstly install [Git LFS] and
80+
then clone this repository.
81+
82+
``` bash
83+
$ git clone https://github.com/mit-crpg/WMP_Library.git
84+
```
7785

7886
## Usage
7987

@@ -84,7 +92,7 @@ absorption, and fission.
8492

8593
An excellent reference is [OpenMC], which implements WMP in both the transport
8694
solver and the [OpenMC Python API]. You can also check the scripts `scripts/WMP.py`
87-
for an Python implementation, which illustrates how to read, evaluate and export
95+
for a Python implementation, which illustrates how to read, evaluate and export
8896
an windowed multipole format library.
8997
For example, the following script demonstrates how to utilize WMP library using
9098
the nuclear data interface [WindowedMultipole].

scripts/WMP.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,6 @@
2424
_FIT_A = 1 # Absorption
2525
_FIT_F = 2 # Fission
2626

27-
ATOMIC_SYMBOL = {0: 'n', 1: 'H', 2: 'He', 3: 'Li', 4: 'Be', 5: 'B', 6: 'C',
28-
7: 'N', 8: 'O', 9: 'F', 10: 'Ne', 11: 'Na', 12: 'Mg', 13: 'Al',
29-
14: 'Si', 15: 'P', 16: 'S', 17: 'Cl', 18: 'Ar', 19: 'K',
30-
20: 'Ca', 21: 'Sc', 22: 'Ti', 23: 'V', 24: 'Cr', 25: 'Mn',
31-
26: 'Fe', 27: 'Co', 28: 'Ni', 29: 'Cu', 30: 'Zn', 31: 'Ga',
32-
32: 'Ge', 33: 'As', 34: 'Se', 35: 'Br', 36: 'Kr', 37: 'Rb',
33-
38: 'Sr', 39: 'Y', 40: 'Zr', 41: 'Nb', 42: 'Mo', 43: 'Tc',
34-
44: 'Ru', 45: 'Rh', 46: 'Pd', 47: 'Ag', 48: 'Cd', 49: 'In',
35-
50: 'Sn', 51: 'Sb', 52: 'Te', 53: 'I', 54: 'Xe', 55: 'Cs',
36-
56: 'Ba', 57: 'La', 58: 'Ce', 59: 'Pr', 60: 'Nd', 61: 'Pm',
37-
62: 'Sm', 63: 'Eu', 64: 'Gd', 65: 'Tb', 66: 'Dy', 67: 'Ho',
38-
68: 'Er', 69: 'Tm', 70: 'Yb', 71: 'Lu', 72: 'Hf', 73: 'Ta',
39-
74: 'W', 75: 'Re', 76: 'Os', 77: 'Ir', 78: 'Pt', 79: 'Au',
40-
80: 'Hg', 81: 'Tl', 82: 'Pb', 83: 'Bi', 84: 'Po', 85: 'At',
41-
86: 'Rn', 87: 'Fr', 88: 'Ra', 89: 'Ac', 90: 'Th', 91: 'Pa',
42-
92: 'U', 93: 'Np', 94: 'Pu', 95: 'Am', 96: 'Cm', 97: 'Bk',
43-
98: 'Cf', 99: 'Es', 100: 'Fm', 101: 'Md', 102: 'No',
44-
103: 'Lr', 104: 'Rf', 105: 'Db', 106: 'Sg', 107: 'Bh',
45-
108: 'Hs', 109: 'Mt', 110: 'Ds', 111: 'Rg', 112: 'Cn',
46-
113: 'Nh', 114: 'Fl', 115: 'Mc', 116: 'Lv', 117: 'Ts',
47-
118: 'Og'}
48-
ATOMIC_NUMBER = {value: key for key, value in ATOMIC_SYMBOL.items()}
49-
5027
def check_type(name, value, expected_type):
5128
r"""Ensure that an object is of an expected type.
5229
@@ -263,7 +240,8 @@ class WindowedMultipole(object):
263240
a/E + b/sqrt(E) + c + d sqrt(E) + ...
264241
265242
"""
266-
def __init__(self):
243+
def __init__(self, name):
244+
self.name = name
267245
self.spacing = None
268246
self.sqrtAWR = None
269247
self.E_min = None
@@ -273,6 +251,10 @@ def __init__(self):
273251
self.broaden_poly = None
274252
self.curvefit = None
275253

254+
@property
255+
def name(self):
256+
return self._name
257+
276258
@property
277259
def fit_order(self):
278260
return self.curvefit.shape[1] - 1
@@ -313,6 +295,11 @@ def broaden_poly(self):
313295
def curvefit(self):
314296
return self._curvefit
315297

298+
@name.setter
299+
def name(self, name):
300+
check_type('name', name, str)
301+
self._name = name
302+
316303
@spacing.setter
317304
def spacing(self, spacing):
318305
if spacing is not None:
@@ -422,9 +409,10 @@ def from_hdf5(cls, group_or_filename):
422409
raise ValueError('The given WMP data uses version '
423410
+ version + ' whereas your installation of the OpenMC '
424411
'Python API expects version ' + WMP_VERSION)
425-
group = h5file['nuclide']
412+
group = list(h5file.values())[0]
426413

427-
out = cls()
414+
name = group.name[1:]
415+
out = cls(name)
428416

429417
# Read scalars.
430418

@@ -570,26 +558,29 @@ def __call__(self, E, T):
570558
fun = np.vectorize(lambda x: self._evaluate(x, T))
571559
return fun(E)
572560

573-
def export_to_hdf5(self, path, libver='earliest'):
561+
def export_to_hdf5(self, path, mode='a', libver='earliest'):
574562
"""Export windowed multipole data to an HDF5 file.
575563
576564
Parameters
577565
----------
578566
path : str
579567
Path to write HDF5 file to
568+
mode : {'r', r+', 'w', 'x', 'a'}
569+
Mode that is used to open the HDF5 file. This is the second argument
570+
to the :class:`h5py.File` constructor.
580571
libver : {'earliest', 'latest'}
581572
Compatibility mode for the HDF5 file. 'latest' will produce files
582573
that are less backwards compatible but have performance benefits.
583574
584575
"""
585576

586577
# Open file and write version.
587-
with h5py.File(path, 'w', libver=libver) as f:
578+
with h5py.File(path, mode, libver=libver) as f:
579+
f.attrs['filetype'] = np.string_('data_wmp')
588580
f.create_dataset('version', (1, ), dtype='S10')
589581
f['version'][:] = WMP_VERSION.encode('ASCII')
590582

591-
# Make a nuclide group.
592-
g = f.create_group('nuclide')
583+
g = f.create_group(self.name)
593584

594585
# Write scalars.
595586
g.create_dataset('spacing', data=np.array(self.spacing))

scripts/parse_wmp_info.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@
2323
for i, wmp_library in enumerate(wmp_files):
2424
result = []
2525
nuc_wmp = WMP.WindowedMultipole.from_hdf5(wmp_library)
26-
26+
nuc_name = nuc_wmp.name
2727
wmp_name = os.path.basename(wmp_library)
28-
atomic_number = int(wmp_name[0:3])
29-
mass_number = int(wmp_name[3:6])
30-
nuc_name = WMP.ATOMIC_SYMBOL[atomic_number] + str(mass_number)
31-
if wmp_name[6:-3] is not '':
32-
nuc_name += '_{}'.format(wmp_name[6:-3])
3328

3429
result.append(nuc_name)
3530
result.append(wmp_name)

scripts/validation.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,9 @@
5757

5858
print("Start validating {} nuclides - {}".format(len(wmp_files), time.ctime()))
5959
for i, wmp_library in enumerate(wmp_files):
60-
wmp_name = os.path.basename(wmp_library)
61-
nuc_Z = int(wmp_name[0:3])
62-
nuc_A = int(wmp_name[3:6])
63-
nuc_m = wmp_name[6:-3]
64-
nuc_name = WMP.ATOMIC_SYMBOL[nuc_Z]
65-
nuc_name += '{}'.format(nuc_A)
66-
if nuc_m is not '':
67-
nuc_name += '_{}'.format(nuc_m)
60+
# load wmp data
61+
nuc_wmp = WMP.WindowedMultipole.from_hdf5(wmp_library)
62+
nuc_name = nuc_wmp.name
6863

6964
print("{:>3}/{:<3} Processing {} {} - {} ".format(
7065
i+1, len(wmp_files), nuc_name, wmp_library, time.ctime()))
@@ -76,11 +71,6 @@
7671
logfile = os.path.join(out_dir, logfile_name);
7772
f = open(logfile, 'w');
7873

79-
# load wmp data
80-
nuc_wmp = WMP.WindowedMultipole.from_hdf5(wmp_library)
81-
f.write("Load wmp library: {}".format(wmp_library))
82-
f.write("\n")
83-
8474
# write info
8575
f.write("Energy range: {} {}".format(nuc_wmp.E_min, nuc_wmp.E_max))
8676
f.write("\n")

0 commit comments

Comments
 (0)