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
The proper way to specify a source and have it be exported in settings.xml is to instantiate a Source object and then assign it to the ‘source’ property of Settings. The Source object has ‘space’, ‘angle’, and ‘energy’ properties that expect distributions from the openmc.stats 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