openmc.data.DataLibrary

class openmc.data.DataLibrary[source]

Collection of cross section data libraries.

This class behaves like a list where each item is a dictionary summarizing cross section data from a single file. The dictionary has keys ‘path’, ‘type’, and ‘materials’.

Changed in version 0.14.0: This class now behaves like a list rather than requiring you to access the list of libraries through a special attribute.

export_to_xml(path='cross_sections.xml')[source]

Export cross section data library to an XML file.

Parameters

path (str) – Path to file to write. Defaults to ‘cross_sections.xml’.

classmethod from_xml(path=None)[source]

Read cross section data library from an XML file.

Parameters

path (str, optional) – Path to XML file to read. If not provided, openmc.config[‘cross_sections’] will be used.

Returns

data – Data library object initialized from the provided XML

Return type

openmc.data.DataLibrary

get_by_material(name, data_type='neutron')[source]

Return the library dictionary containing a given material.

Parameters
  • name (str) – Name of material, e.g. ‘Am241’

  • data_type (str) –

    Name of data type, e.g. ‘neutron’, ‘photon’, ‘wmp’, or ‘thermal’

    New in version 0.12.

Returns

library – Dictionary summarizing cross section data from a single file; the dictionary has keys ‘path’, ‘type’, and ‘materials’.

Return type

dict or None

register_file(filename)[source]

Register a file with the data library.

Parameters

filename (str or Path) – Path to the file to be registered. If an xml file, treat as the depletion chain file without materials.

remove_by_material(name: str, data_type='neutron')[source]

Remove the library dictionary containing a specific material

Parameters
  • name (str) – Name of material, e.g. ‘Am241’

  • data_type (str) – Name of data type, e.g. ‘neutron’, ‘photon’, ‘wmp’, or ‘thermal’