f4enix.input.ww_gvr.weight_window.WW#

class f4enix.input.ww_gvr.weight_window.WW(file_path: Path, geometry: Geometry, values: dict[ParticleType, dict[float, ndarray]])#

Bases: object

The representation of a WW.

It should be created using the class methods WW.load_from_ww_file or WW.create_gvr_from_meshtally_file.

Variables:
  • file_path (Path) – Path to the MCNP weight window file.

  • geometry (Geometry) – A Geometry object that contains the mesh and all geometrical information.

  • values (ValuesByParticle) – A dictionary with the values of the weight window for each combination of particle and energy.

Methods

__init__(file_path, geometry, values)

The representation of a WW.

add_particle([norm, soft])

Add a second particle to a weight window that only has one (neutrons).

create_gvr_from_meshtally_file(file_path[, ...])

Create a WW object (a GVR) from a MCNP meshtally file using the Van Vick / Andrew Davis / Magic algorithm.

export_as_vtk([file_path])

Export the weight window to a VTK file.

load_from_ww_file(file_path)

Create a WW object from a MCNP weight window file.

mitigate_long_histories([max_ratio])

The weigth window voxels with a ratio higher than max_ratio will be set to zero.

multiply(factor)

Multiply all values of the weight window by a factor.

plot()

Plot the weight window using the pyvista plotter.

remove_particle()

Remove a particle from a weight window that has two (neutrons and photons).

soften(softening_factor)

Soften the weight window values by raising them to a power.

write_to_ww_file([file_path])

Write the weight window to a file.

Attributes

energies

The energies of the weight window for each particle as a dictionary.

info

A string with the most important information of the weight window.

particles

List of ParticleType objects that are present in the weight window.

ratios

Same format as values, but showing the maximum ratio of every voxel with its neighbours.

values

The values of the weight window for each combination of particle and energy as a nested dictionary.

add_particle(norm: float = 1, soft: float = 1)#

Add a second particle to a weight window that only has one (neutrons).

The new particle will be photons, and its values will be the same as the neutron values but multiplied by a normalization factor and softened.

Parameters:
  • norm (float, optional) – The normalization factor, by default 1

  • soft (float, optional) – The softening factor, by default 1

Return type:

None

classmethod create_gvr_from_meshtally_file(file_path: str | Path, tally_num: int = 0, maximum_splitting_ratio: float = 5.0, softening_factor: float = 1.0)#

Create a WW object (a GVR) from a MCNP meshtally file using the Van Vick / Andrew Davis / Magic algorithm.

Parameters:
  • file_path (Pathlike) – Path to the MCNP meshtally file.

  • maximum_splitting_ratio (float, optional) – The maximum splitting ratio used in the formula, by default 5.0

Returns:

A WW object.

Return type:

WW

property energies: dict[ParticleType, list[float]]#

The energies of the weight window for each particle as a dictionary.

Has the following format: {ParticleType: List[float]}

export_as_vtk(file_path: str | Path | None = None) None#

Export the weight window to a VTK file.

Parameters:

file_path (Optional[Pathlike], optional) – The path to the file, by default None. If None, the file will be written with the same name as the original file but with “.vtk” extension.

Return type:

None

property info: str#

A string with the most important information of the weight window.

classmethod load_from_ww_file(file_path: str | Path)#

Create a WW object from a MCNP weight window file.

Parameters:

file_path (Pathlike) – Path to the MCNP weight window file.

Returns:

A WW object.

Return type:

WW

mitigate_long_histories(max_ratio: float = 10.0) None#

The weigth window voxels with a ratio higher than max_ratio will be set to zero. This stops the particle from over-splitting.

Parameters:

max_ratio (float, optional) – The maximum ratio allowed, by default 10.0

Return type:

None

multiply(factor: float) None#

Multiply all values of the weight window by a factor.

Parameters:

factor (float) – The factor to multiply the values.

Return type:

None

property particles: list[ParticleType]#

List of ParticleType objects that are present in the weight window.

It will be either [ParticleType.NEUTRON] or [ParticleType.NEUTRON, ParticleType.PHOTON].

plot() None#

Plot the weight window using the pyvista plotter.

The plot is interactive, so it will block the execution of the script until the plot is closed.

Parameters:

None

Return type:

None

property ratios: dict[ParticleType, dict[float, ndarray]]#

Same format as values, but showing the maximum ratio of every voxel with its neighbours.

remove_particle()#

Remove a particle from a weight window that has two (neutrons and photons).

Parameters:

None

Return type:

None

soften(softening_factor: float) None#

Soften the weight window values by raising them to a power.

This is useful to mitigate long histories and to reduce the aggressiveness of the weight window if the softening factor is lower than 1. Softening factors higher than 1 will have the opposite effect.

Parameters:

softening_factor (float) – The softening factor.

Return type:

None

property values: dict[ParticleType, dict[float, ndarray]]#

The values of the weight window for each combination of particle and energy as a nested dictionary.

Has the following format: {ParticleType: {energy(float): np.ndarray}}

write_to_ww_file(file_path: str | Path | None = None) None#

Write the weight window to a file.

Parameters:

file_path (Optional[Pathlike], optional) – The path to the file, by default None. If None, the file will be written with the same name as the original file but with “_written” added to the name.

Return type:

None