# Convert ACE ENDF format

**URL:** <https://openmc.discourse.group/t/convert-ace-endf-format/2144>\
**Category:** User Support\
**Created:** [June 27, 2022, 12:53pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144 "2022-06-27T12:53:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilyavitte](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ilyavitte](https://openmc.discourse.group/u/Ilyavitte)\
**Post date:** [June 27, 2022, 12:53pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/1 "2022-06-27T12:53:57Z")

</div>

Hello! I try to convert to hdf ACE and ENDF formats from this library:

> **[NJOY-NCrystal-Library/mixed\_elastic/MgH2-064 at master ·...](https://github.com/highness-eu/NJOY-NCrystal-Library/tree/master/mixed_elastic/MgH2-064)**
>
> master/mixed\_elastic/MgH2-064

But it doesn’t work. Maybe I do something wrong.

 ![2022-06-27_15-48-05](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/c/ca8d37401880da8e67177bcfc24ce693e7ed76ad.png)  
 ![2022-06-27_15-47-17](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/e/e91d5f39b1665b8a2b9d9170da96b588bc83e3a8.png)

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 11, 2022, 7:30pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/2 "2022-07-11T19:30:05Z")

</div>

@Ilyavitte When OpenMC does not recognize a specific thermal scattering material, you need to supply the table name, list of ZAIDs, and “nmix” parameter (see documentation for NJOY/ACER card 9). This can be done as:

```nohighlight
openmc.data.ThermalScattering.from_njoy(
    neutron_endf_file, thermal_endf_file,
    table_name='c_H_in_MgH2',
    zaids=[1001],
    nmix=1
)

```

The above is just an example, and you should confirm the appropriate parameters for your case.

As for the error you’re seeing when you try `from_ace`, I believe this is related to the fact that this is a new evaluation that uses mixed elastic scattering (incoherent+coherent). With the arguments above passed to `from_njoy`, I actually get the same error too. I have a branch I’m working on to support mixed elastic scattering in OpenMC, so stay posted and hopefully I’ll have a fix soon!

---

<div class="post-metadata">

**Author:** ![Ilyavitte](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ilyavitte](https://openmc.discourse.group/u/Ilyavitte)\
**Post date:** [July 26, 2022, 2:10pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/3 "2022-07-26T14:10:54Z")

</div>

Hello, Paul! I try to use it in my jupyter notebook, but it gives me the same mistake as when i’m calling command ‘from\_ace’

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 26, 2022, 2:54pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/4 "2022-07-26T14:54:12Z")

</div>

Ah yes, I forgot that even trying to read the ACE file from the current version won’t work. I’ve recently implemented support for thermal scattering evaluations for mixed coherent/incoherent elastic, which you can find in this [pull request](https://github.com/openmc-dev/openmc/pull/2134). With that branch, you should be able to run either `from_njoy` or `from_ace` on these new evaluations.

---

<div class="post-metadata">

**Author:** ![Ilyavitte](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ilyavitte](https://openmc.discourse.group/u/Ilyavitte)\
**Post date:** [July 26, 2022, 3:26pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/5 "2022-07-26T15:26:32Z")

</div>

Okay… I see, that in article: “ NJOY+NCrystal: An open-source tool for creating thermal neutron scattering  
libraries with mixed elastic support” authors use OpenMC for their calculations. Maybe you know something about this and can give some examples, how they use specific data for their calculations?

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 26, 2022, 6:37pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/6 "2022-07-26T18:37:41Z")

</div>

I believe they may have had their own branch of OpenMC that implemented support for mixed elastic (separate from the one that I submitted a pull request).

---

<div class="post-metadata">

**Author:** ![Ilyavitte](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ilyavitte](https://openmc.discourse.group/u/Ilyavitte)\
**Post date:** [July 29, 2022, 11:01am UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/7 "2022-07-29T11:01:58Z")

</div>

## So, I try to use your pull request. And it works! It makes hdf file, but when i try to use recompiling cross-section file with this data i have error: HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5D.c line 285 in H5Dopen2(): unable to open dataset major: Dataset minor: Can’t open object #001: H5VLcallback.c line 1910 in H5VL\_dataset\_open(): dataset open failed major: Virtual Object Layer minor: Can’t open object #002: H5VLcallback.c line 1877 in H5VL\_\_dataset\_open(): dataset open failed major: Virtual Object Layer minor: Can’t open object #003: H5VLnative\_dataset.c line 123 in H5VL\_\_native\_dataset\_open(): unable to open dataset major: Dataset minor: Can’t open object #004: H5Dint.c line 1490 in H5D\_\_open\_name(): not a dataset major: Dataset minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5A.c line 449 in H5Aopen(): invalid location identifier major: Invalid arguments to routine minor: Inappropriate type #001: H5VLint.c line 1749 in H5VL\_vol\_object(): invalid identifier type to function major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5A.c line 777 in H5Aget\_type(): not an attribute major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5T.c line 2328 in H5Tget\_size(): not a datatype major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5T.c line 1977 in H5Tclose(): not a datatype major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5A.c line 1624 in H5Aclose(): not an attribute major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5T.c line 2376 in H5Tset\_size(): size must be positive major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5A.c line 449 in H5Aopen(): invalid location identifier major: Invalid arguments to routine minor: Inappropriate type #001: H5VLint.c line 1749 in H5VL\_vol\_object(): invalid identifier type to function major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5A.c line 698 in H5Aread(): not an attribute major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5A.c line 1624 in H5Aclose(): not an attribute major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5I.c line 902 in H5Iget\_name(): invalid identifier major: Object atom minor: Inappropriate type #001: H5VLint.c line 1749 in H5VL\_vol\_object(): invalid identifier type to function major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0: #000: H5I.c line 902 in H5Iget\_name(): invalid identifier major: Object atom minor: Inappropriate type #001: H5VLint.c line 1749 in H5VL\_vol\_object(): invalid identifier type to function major: Invalid arguments to routine minor: Inappropriate type terminate called after throwing an instance of ‘std::runtime\_error’

UnicodeDecodeError Traceback (most recent call last)  
Input In [1], in \<cell line: 156\>()  
152 tallies.append(tally)  
153 tallies.export\_to\_xml()  
 → 156 openmc.run()

File ~/anaconda3/lib/python3.9/site-packages/openmc/executor.py:276, in run(particles, threads, geometry\_debug, restart\_file, tracks, output, cwd, openmc\_exec, mpi\_args, event\_based)  
232 “”“Run an OpenMC simulation.  
233  
234 Parameters  
(…)  
268  
269 “””  
271 args = \_process\_CLI\_arguments(  
272 volume=False, geometry\_debug=geometry\_debug, particles=particles,  
273 restart\_file=restart\_file, threads=threads, tracks=tracks,  
274 event\_based=event\_based, openmc\_exec=openmc\_exec, mpi\_args=mpi\_args)  
 → 276 \_run(args, output, cwd)

File ~/anaconda3/lib/python3.9/site-packages/openmc/executor.py:95, in \_run(args, output, cwd)  
92 lines =   
93 while True:  
94 # If OpenMC is finished, break loop  
—\> 95 line = p.stdout.readline()  
96 if not line and p.poll() is not None:  
97 break

File ~/anaconda3/lib/python3.9/codecs.py:322, in BufferedIncrementalDecoder.decode(self, input, final)  
319 def decode(self, input, final=False):  
320 # decode input (taking the buffer into account)  
321 data = self.buffer + input  
 → 322 (result, consumed) = self.\_buffer\_decode(data, self.errors, final)  
323 # keep undecoded input until the next call  
324 self.buffer = data[consumed:]

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x80 in position 46: invalid start byte

I try to use my script on another computer and have the same problem, but DecodeError was with 0x84.

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [July 30, 2022, 1:40pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/8 "2022-07-30T13:40:59Z")

</div>

@Ilyavitte did you recompile the OpenMC executable before trying to run?

---

<div class="post-metadata">

**Author:** ![Ilyavitte](https://avatars.discourse-cdn.com/v4/letter/i/db5fbb/32.png) [@Ilyavitte](https://openmc.discourse.group/u/Ilyavitte)\
**Post date:** [August 1, 2022, 5:42pm UTC](https://openmc.discourse.group/t/convert-ace-endf-format/2144/9 "2022-08-01T17:42:19Z")

</div>

> [@paulromano](#):
>
> did you recompile the OpenMC executable before trying to run?

I make two environments. One of them with your’s pull request and one with stable version of openmc. I make cross section hdf5 in pull request and try to use this cross sections in both versions. But it doesn’t work with same error. I check version when i make calculation, they’re different
