openmc.lib.Material

class openmc.lib.Material(uid=None, new=True, index=None)[source]

Material stored internally.

This class exposes a material that is stored internally in the OpenMC library. To obtain a view of a material with a given ID, use the openmc.lib.materials mapping.

Parameters
  • uid (int or None) – Unique ID of the material

  • new (bool) – When index is None, this argument controls whether a new object is created or a view to an existing object is returned.

  • index (int or None) – Index in the materials array.

Variables
  • id (int) – ID of the material

  • nuclides (list of str) – List of nuclides in the material

  • densities (numpy.ndarray) – Array of densities in atom/b-cm

  • name (str) – Name of the material

  • temperature (float) – Temperature of the material in [K]

  • volume (float) – Volume of the material in [cm^3]

add_nuclide(name, density)[source]

Add a nuclide to a material.

Parameters
  • name (str) – Name of nuclide, e.g. ‘U235’

  • density (float) – Density in atom/b-cm

get_density(units='atom/b-cm')[source]

Get density of a material.

Parameters

units ({'atom/b-cm', 'g/cm3'}) – Units for density

Returns

Density in requested units

Return type

float

set_densities(nuclides, densities)[source]

Set the densities of a list of nuclides in a material

Parameters
  • nuclides (iterable of str) – Nuclide names

  • densities (iterable of float) – Corresponding densities in atom/b-cm

set_density(density, units='atom/b-cm')[source]

Set density of a material.

Parameters
  • density (float) – Density

  • units ({'atom/b-cm', 'g/cm3'}) – Units for density