f4enix.input.materials.Material#
- class f4enix.input.materials.Material(zaids: list[Zaid], elem: list[Element], name: str, submaterials: list[SubMaterial] | None = None, mx_cards: list | None = None, header: str | None = None, density: float | None = None)#
Bases:
objectObject representing an MCNP material
- Parameters:
zaids (list[zaids]) – zaids composing the material.
elem (list[elem]) – elements composing the material.
name (str) – name of the material (e.g. m1).
submaterials (list[Submaterials], optional) – list of submaterials composing the material. The default is None.
mx_cards (list, optional) – list of mx_cards in the material if present. The default is None.
header (str, optional) – material header. The default is None.
density (float, optional) – material density, used for OpenMC materials. Default is None.
- Return type:
None.
- Variables:
attributes. (all __init__ parameters are stored as)
Methods
__init__(zaids, elem, name[, submaterials, ...])Object representing an MCNP material
add_mx(mx_cards)Add a list of mx_cards to the material
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_text(text)Create a material from MCNP formatted text
from_zaids(zaids, libman, lib[, name, mat_id])Generate a material giving a list of zaids or elements.
get_density(tad, lib_manager)Return the density of the material given the total atom density.
get_info(lib_manager[, zaids])Get information on the fraction of the different elements and zaids contained in the materials.
get_tad(density, lib_manager)Return the total atom density of the material given the mass density.
Returns the total material fraction
switch_fraction(ftype, lib_manager[, inplace])Switch between atom or mass fraction for the material card.
to_text()Write the material to MCNP formatted text
to_xml(libmanager, material_tree)Generate XML content for a material and its submaterials.
translate(newlib, lib_manager[, code, update])This method allows to translate all submaterials to another library
- add_mx(mx_cards: list) None#
Add a list of mx_cards to the material
- 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_text(text: list[str]) Material#
Create a material from MCNP formatted text
- Parameters:
text (list[str]) – Transport code formatted text representing the material.
- Returns:
material object created.
- Return type:
matreader.Material
- classmethod from_zaids(zaids: Sequence[tuple[str | int, float]], libman: LibManager, lib: str, name: str = '', mat_id: int = 1) Material#
Generate a material giving a list of zaids or elements.
- Parameters:
zaids (list[tuple[str | int, float]]) – list of (zaid, fraction) couples, e.g., (1001, -0.1). If negative, fractions are intended as mass fraction, if positive as atom fractions. To define a material using elements, one can use natural zaids notation, e.g., (1000, -1). The translation operation to the requested library will take care of expanding such zaids using natural abundances.
libman (LibManager) – The usual library manager needed for XS operations.
lib (str) – suffix of the library to apply to the material, e.g., 31c.
name (str, optional) – this will be put in the header of the material card as a comment, by default ‘’.
mat_id (int, optional) – material id, by default 1.
- Returns:
F4Enix material object
- Return type:
- get_density(tad: int | float, lib_manager: LibManager) float#
Return the density of the material given the total atom density.
- Parameters:
tad (int | float) – total atom density in barn^-1 cm^-1.
lib_manager (LibManager) – Library manager for the conversion.
- Returns:
mass density of the material in g/cm^3.
- Return type:
float
- get_info(lib_manager: LibManager, zaids: bool = False)#
Get information on the fraction of the different elements and zaids contained in the materials.
- Parameters:
lib_manager (LibManager) – library manager to handle lib operations
zaids (bool, optional) – If true the info is output also at zaid level, by default False
- Returns:
df_complete (pd.DataFrame) – detailed dataframe
df_elem (pd.DataFrame) – dataframe grouped at element level
- get_tad(density: int | float, lib_manager: LibManager) float#
Return the total atom density of the material given the mass density.
- Parameters:
density (int | float) – mass density in g/cm^3.
lib_manager (LibManager) – Library manager for the conversion.
- Returns:
atom density of the material in barn^-1 cm^-1.
- Return type:
float
- get_tot_fraction() float#
Returns the total material fraction
- switch_fraction(ftype: str, lib_manager: LibManager, inplace: bool = True) list[SubMaterial]#
Switch between atom or mass fraction for the material card. If the material is already switched the command is ignored.
- Parameters:
ftype (str) – Either ‘mass’ or ‘atom’ to chose the type of switch.
lib_manager (libmanager.LibManager) – Handles zaid data.
inplace (bool) – if True the densities of the isotopes are changed inplace, otherwise a copy of the material is provided. DEFAULT is True
- Raises:
KeyError – if ftype is not either ‘atom’ or ‘mass’.
- Returns:
submaterials – list of the submaterials where fraction have been switched
- Return type:
list[SubMaterial]
- to_text() str#
Write the material to MCNP formatted text
- Returns:
MCNP formatte text representing the material.
- Return type:
str
- to_xml(libmanager: LibManager, material_tree: Element) None#
Generate XML content for a material and its submaterials.
- Parameters:
libmanager – libmanager
material_tree – The XML element for the material where content will be added.
- translate(newlib: dict | str, lib_manager: LibManager, code: str = 'mcnp', update: bool | None = None) None#
This method allows to translate all submaterials to another library
- 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) – object handling all libraries operations.
code (str, optional) – Monte Carlo code for material format. The default is ‘mcnp’.
update (bool, optional) – if True, material infos are updated. The default is True.
- Return type:
None.