# How to specify the source in Openmc 0.8.0

**URL:** <https://openmc.discourse.group/t/how-to-specify-the-source-in-openmc-0-8-0/231>\
**Category:** User Support\
**Created:** [July 28, 2016, 2:11pm UTC](https://openmc.discourse.group/t/how-to-specify-the-source-in-openmc-0-8-0/231 "2016-07-28T14:11:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juan\_Kostelec](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@Juan\_Kostelec](https://openmc.discourse.group/u/Juan_Kostelec)\
**Post date:** [July 28, 2016, 2:11pm UTC](https://openmc.discourse.group/t/how-to-specify-the-source-in-openmc-0-8-0/231/1 "2016-07-28T14:11:59Z")

</div>

Would anyone mind writing a short example how to specify the source and export it to xml (how do you use the source.to\_xml() function to write to the settings.xml file?) in latest version of OpenMC?  
Thanks

---

<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 28, 2016, 2:27pm UTC](https://openmc.discourse.group/t/how-to-specify-the-source-in-openmc-0-8-0/231/2 "2016-07-28T14:27:25Z")

</div>

The proper way to specify a source and have it be exported in settings.xml is to instantiate a [Source](http://openmc.readthedocs.io/en/latest/pythonapi/generated/openmc.Settings.html#openmc.Settings) object and then assign it to the ‘source’ property of [Settings](http://openmc.readthedocs.io/en/latest/pythonapi/generated/openmc.Settings.html#openmc.Settings). The Source object has ‘space’, ‘angle’, and ‘energy’ properties that expect distributions from the [openmc.stats](http://openmc.readthedocs.io/en/latest/pythonapi/index.html#openmc-stats-statistics) package. So, for example, if you wanted a point source at (0,0,0), you’d have:

point\_dist = openmc.stats.Point()  
point\_source = openmc.Source(space=point\_dist)  
settings = openmc.Settings()  
settings.source = point\_source

settings.export\_to\_xml()

Note that the Settings.source property actually expects a **list** of Source objects – meaning you can have multiple source distributions each with a different source strength. However, if you assign a single scalar Source (a common case), it accepts it as well.

Best regards,

Paul
