f4enix.input.materials.MatCardsList#

class f4enix.input.materials.MatCardsList(materials: list[Material])#

Bases: Sequence

Object representing the list of materials included in an MCNP input. This class is a child of the Sequence base class.

Parameters:

materials (list[Material]) – list of materials.

Return type:

None.

Variables:
  • materials (list[Material]) – list of the material objects that compose the material section

  • matdic (dict[str, Material]) – dictionary of the material objects that compose the material section. This attribute is used mostly as internal object, the recommended way to access materials is to use directly the “dictionary” capabilities of the MatCardsList object.

Examples

>>> from f4enix.input.inputAPI import MatCardsList
... # initialize from file
... materials = MatCardsList.from_input('inputfile.i')
... # get a specific material
... mat1 = materials['m1']

Methods

__init__(materials)

Object representing the list of materials included in an MCNP input.

append(material)

count(value)

extend(materials)

fractions_to_atom_densities(lib_manager, density)

Given a specific mass density of the material, replace the atom fractions in the material with un-normalized atom fractions which correspond to the zaid atom densitiy in the material.

from_input(inputfile)

This method use the numjuggler parser to help identify the mcards in the input.

generate_material(materials, percentages, ...)

Starting from an MCNP input, materials contained in its material list can be used to generate a new material combining them.

get_info(lib_manager[, zaids])

Get the material informations in terms of fraction and composition of the material card

index(value, [start, [stop]])

Raises ValueError if the value is not present.

remove(item)

to_text()

return text of the material cards in order

to_xml(libmanager)

Generate an XML representation of materials and return it as a string.

translate(newlib, lib_manager[, code])

This method allows to translate the material cards to another library.

update_info(lib_manager)

This methods allows to update the in-line comments for every zaids containing additional information

count(value) integer -- return number of occurrences of value#
fractions_to_atom_densities(lib_manager: LibManager, density: float) None#

Given a specific mass density of the material, replace the atom fractions in the material with un-normalized atom fractions which correspond to the zaid atom densitiy in the material.

This is obtained multiplying the normalized atom fraction of each zaid by the total atomic density of the material.

Parameters:
  • lib_manager (LibManager) – Library manager for the conversion.

  • density (float) – mass density of the material in g/cm^3.

classmethod from_input(inputfile: PathLike) MatCardsList#

This method use the numjuggler parser to help identify the mcards in the input. Then the mcards are parsed using the classes defined in this module

Parameters:

inputfile (os.PathLike) – MCNP input file containing the material section.

Returns:

new material card list generated.

Return type:

MatCardsList

generate_material(materials: list[str], percentages: list[float], newlib: str, libmanager: LibManager, fractiontype='atom', mat_name='M1') Material#

Starting from an MCNP input, materials contained in its material list can be used to generate a new material combining them.

Parameters:
  • materials (list[str]) – list of materials to mix (e.g. [‘m1’, ‘M2’]).

  • percentages (list[float]) – percentages associated to the source materials in the new materials (e.g. [0.1, 0.9)]. Their are intended as atom or mass fraction depending on the fractiontype that is specified.

  • newlib (str) – library for the new material.

  • fractiontype (str, optional) – type of fraction to use in the new material (either ‘atom’ or ‘mass’. The default is ‘atom’.

  • mat_name (str, optional) – Material card name of the new generated material. the default is ‘M1’

Returns:

Newly created material

Return type:

Material

get_info(lib_manager: LibManager, zaids: bool = False) tuple[DataFrame, DataFrame]#

Get the material informations in terms of fraction and composition of the material card

Parameters:
  • lib_manager (libmanager.LibManager) – To handle element name recovering.

  • zaids (bool, optional) – Consider or not the zaid level. The default is False.

Returns:

  • df (pd.DataFrame) – Raw infos on the fractions.

  • df_elem (pd.DataFrame) – processed info for the element: normalized fraction added both for material and submaterial.

index(value[, start[, stop]]) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

to_text() str#

return text of the material cards in order

Returns:

material card list MCNP formatted text.

Return type:

str

to_xml(libmanager: LibManager) str#

Generate an XML representation of materials and return it as a string.

Parameters:

libmanager – libmanager

Returns:

The XML representation of materials as a string.

Return type:

str

translate(newlib: str | dict, lib_manager: LibManager, code: str = 'mcnp') None#

This method allows to translate the material cards to another library. The zaid are collapsed again to get the new elements

Parameters:
  • newlib (dict or str) –

    There are a few ways that newlib can be provided:

    1) str (e.g. 31c), the new library to translate to will be the one indicated;

    2) dic (e.g. {‘98c’ : ‘99c’, ‘31c: 32c’}), the new library is determined based on the old library of the zaid

    3) dic (e.g. {‘98c’: [list of zaids], ‘31c’: [list of zaids]}), the new library to be used is explicitly stated depending on the zaidnum.

  • lib_manager (libmanager.LibManager) – Library manager for the conversion.

Return type:

None.

update_info(lib_manager: LibManager) None#

This methods allows to update the in-line comments for every zaids containing additional information

Parameters:

lib_manager (libmanager.Libmanager) – Library manager for the conversion.

Return type:

None.