# How to use new features "filed base source" on OpenMC 0.12.1

**URL:** <https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090>\
**Category:** User Support\
**Created:** [March 27, 2021, 1:46pm UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090 "2021-03-27T13:46:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![billytnp](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@billytnp](https://openmc.discourse.group/u/billytnp)\
**Post date:** [March 27, 2021, 1:46pm UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090/1 "2021-03-27T13:46:33Z")

</div>

Hi all,

I have seen the OpenMC update with the new features " Using a file-based source for fixed source simulations" on version 0.12.1 and seem like in OpenMC document didn’t update the info yet. So I want to know how to use this feature? and about the source file, what’s the present format of source.h5 file?

I have attached my .h5 file below here (created by python to convert the data from FLUKA output to .h5). Is this format still available?

[my .h5 file (it’s too large to attached)](https://drive.google.com/file/d/1z6HB8avW1dx9qkjKzh0GL3bf-nGdLjAZ/view?usp=sharing)

If anyone has an example of using this new feature or any suggestions, please let me know.

Thank you,  
thanapong

---

<div class="post-metadata">

**Author:** ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)\
**Post date:** [March 30, 2021, 2:34pm UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090/2 "2021-03-30T14:34:49Z")

</div>

Hi @billytnp,

To use a file-based source you can set the `file` attribute of an `openmc.Source` object

```python
settings.source = openmc.Source(filename='source.10.h5')
settings.export_to_xml()

```

Where `source.10.h5` should be replaced with the name of your own source file.

[openmc.Source — OpenMC Documentation](https://docs.openmc.org/en/stable/pythonapi/generated/openmc.Source.html?highlight=source#openmc-source)

Hope this helps!

-Patrick

---

<div class="post-metadata">

**Author:** ![billytnp](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@billytnp](https://openmc.discourse.group/u/billytnp)\
**Post date:** [April 4, 2021, 9:36am UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090/3 "2021-04-04T09:36:05Z")

</div>

Dear @pshriwise,

I’ve tried to fix my script and executed it, but this error appeared

 ![|377px;x267px;](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/0/0c6c869bb7a51a672fa9f15221792abea624d8a1.png)  
In fact, my source file is not surface source type. It made from FLUKA which all of neutrons are coming from spallation process which have different direction and position, so it’s not rely on a surface (new source file format said need to define the surf\_id).  
Could this be the problem of this error? and Is it necessary to define surf\_id on my problem, if not what should I define it?

---

<div class="post-metadata">

**Author:** ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)\
**Post date:** [April 4, 2021, 9:00pm UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090/4 "2021-04-04T21:00:57Z")

</div>

Unset surface IDs shouldn’t be a problem. They don’t affect the source file read at this point in time. (The contributor for that feature intends to add capabilities for reading source particles from specific surfaces in the future.)

To make sure I understand correctly, you have a set of initial positions, directions, energies, etc. for neutrons generated by spallation from FLUKA that you’ve converted into the `source.h5` format for OpenMC?

I’d first check to make sure that the source locations from the FLUKA model are also valid for the OpenMC model and make sure that the OpenMC model doesn’t have an error. I’m not sure about the reaction sampling error for `Pb204` though. Not sure what your charged particle energies are for the spallation simulation, but do any of your source particle energies exceed the maximum energy supported by the data (20 MeV)?

---

<div class="post-metadata">

**Author:** ![billytnp](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@billytnp](https://openmc.discourse.group/u/billytnp)\
**Post date:** [April 5, 2021, 5:23pm UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090/5 "2021-04-05T17:23:52Z")

</div>

Dear @pshriwise,

Thank you for your help after I changed the energy to below 20 MeV the error mentioned before has been solved, another error has occurred.

 ![|633px;x401px;](https://global.discourse-cdn.com/free1/uploads/openmc/original/2X/1/1efaceb9003dcca70261ee2609614fcb4b053902.png)

Maybe I should recheck my geometry again. Thank you.

---

<div class="post-metadata">

**Author:** ![pshriwise](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/pshriwise/32/3863_2.png) [@pshriwise](https://openmc.discourse.group/u/pshriwise)\
**Post date:** [April 5, 2021, 7:10pm UTC](https://openmc.discourse.group/t/how-to-use-new-features-filed-base-source-on-openmc-0-12-1/1090/6 "2021-04-05T19:10:43Z")

</div>

Glad it got you one step closer!

We have a plotting tool that’s pretty useful for debugging geometry issues if you’d like to give it a try: [https://github.com/openmc-dev/plotter](https://github.com/openmc-dev/plotter)
