# ALARA Input and Output Interfaces – pyne.alara¶

This is a module for reading and writing ALARA input to and from PyNE Mesh objects. The functionality of the module can be obtained by importing as such:

from pyne import alara


## ALARA API¶

This module contains functions relevant to the ALARA activation code and the Chebyshev Rational Approximation Method

pyne.alara.cram(N, t, n_0, order)[source]

This function returns matrix exponential solution n using CRAM14 or CRAM16

Parameters
Nlist or array

Array of nuclides under consideration

tfloat

Time step

n_0list or array

Nuclide concentration vector

orderint

Order of method. Only 14 and 16 are supported.

pyne.alara.get_alara_lib(alara_params)[source]

This function is used to get the alara_library from alara_params.

Parameters
alara_params: string

ALARA parameters.

Returns
alara_lib: string

Path to ALARA library.

pyne.alara.irradiation_blocks(material_lib, element_lib, data_library, cooling, flux_file, irr_time, output='number_density', truncation=1e-12, impurity=5e-06, 0.001, dump_file='dump_file')[source]

This function returns a string of the irradation-related input blocks. This function is meant to be used with files created by the mesh_to_geom function, in order to append the remaining input blocks to form a complete ALARA input file. Only the simplest irradiation schedule is supported: a single pulse of time <irr_time>. The notation in this function is consistent with the ALARA users’ guide, found at:

http://svalinn.github.io/ALARA/usersguide/index.html

Parameters
material_libstr

Path to material library.

element_libstr

Path to element library.

data_librarystr

The data_library card (see ALARA user’s guide).

coolingstr or iterable of str

Cooling times for which output is requested. Given in ALARA form (e.g. “1 h”, “0.5 y”). Note that “shutdown” is always implicitly included.

flux_filestr

Path to the “fluxin” file.

irr_timestr

The duration of the single pulse irradiation. Given in the ALARA form (e.g. “1 h”, “0.5 y”).

outputstr or iterable of str, optional.

The requested output blocks (see ALARA users’ guide).

truncationfloat, optional

The chain truncation value (see ALARA users’ guide).

impuritytuple of two floats, optional

The impurity parameters (see ALARA users’ guide).

dump_file: str, optional

Path to the dump file.

Returns
sstr

pyne.alara.mesh_to_fluxin(flux_mesh, flux_tag, fluxin='fluxin.out', reverse=False, sub_voxel=False, cell_fracs=None, cell_mats=None)[source]

This function creates an ALARA fluxin file from fluxes tagged on a PyNE Mesh object. Fluxes are printed in the order of the flux_mesh.__iter__().

Parameters
flux_meshPyNE Mesh object

Contains the mesh with fluxes tagged on each volume element.

flux_tagstring

The name of the tag of the flux mesh. Flux values for different energy groups are assumed to be represented as vector tags.

fluxinstring

The name of the ALARA fluxin file to be output.

reversebool

If true, fluxes will be printed in the reverse order as they appear in the flux vector tagged on the mesh.

sub_voxel: bool, optional

If true, sub-voxel r2s work flow will be sued. Flux of a voxel will be duplicated c times. Where c is the cell numbers of that voxel.

cell_fracsstructured array, optional

The output from dagmc.discretize_geom(). A sorted, one dimensional array, each entry containing the following fields:

idx

int The volume element index.

cell

int The geometry cell number.

vol_frac

float The volume fraction of the cell withing the mesh ve.

rel_error

float The relative error associated with the volume fraction.

The array must be sorted with respect to both idx and cell, with cell changing fastest.

cell_matsdict, optional

Maps geometry cell numbers to PyNE Material objects.

The cell_fracs and cell_mats are used only when sub_voxel=True. If sub_voxel=False, neither cell_fracs nor cell_mats will be used.

pyne.alara.mesh_to_geom(mesh, geom_file, matlib_file)[source]

This function reads the materials of a PyNE mesh object and prints the geometry and materials portion of an ALARA input file, as well as a corresponding matlib file. If the mesh is structured, xyz ordering is used (z changing fastest). If the mesh is unstructured the mesh_iterate order is used.

Parameters
meshPyNE Mesh object

The Mesh object containing the materials to be printed.

geom_filestr

The name of the file to print the geometry and material blocks.

matlib_filestr

The name of the file to print the matlib.

pyne.alara.num_density_to_mesh(lines, time, m)[source]
This function reads ALARA output containing number density information and

creates material objects which are then added to a supplied PyNE Mesh object. The volumes within ALARA are assummed to appear in the same order as the idx on the Mesh object. All the strings in this function is text (unicode).

Parameters
lineslist or str

ALARA output from ALARA run with ‘number_density’ in the ‘output’ block of the input file. Lines can either be a filename or the equivalent to calling readlines() on an ALARA output file. If reading in ALARA output from stdout, call split(‘

‘) before passing it in as the lines parameter.
timestr

The decay time for which number densities are requested (e.g. ‘1 h’, ‘shutdown’, etc.)

mPyNE Mesh

Mesh object for which mats will be applied to.

pyne.alara.photon_source_hdf5_to_mesh(mesh, filename, tags, sub_voxel=False, cell_mats=None)[source]

This function reads in an hdf5 file produced by photon_source_to_hdf5 and tags the requested data to the mesh of a PyNE Mesh object. Any combinations of nuclides and decay times are allowed. The photon source file is assumed to be in mesh.__iter__() order

Parameters
meshPyNE Mesh

The object containing the PyMOAB instance to be tagged.

filenamestr

The path of the hdf5 version of the photon source file.

tags: dict

A dictionary were the keys are tuples with two values. The first is a string denoting an nuclide in any form that is understood by pyne.nucname (e.g. ‘1001’, ‘U-235’, ‘242Am’) or ‘TOTAL’ for all nuclides. The second is a string denoting the decay time as it appears in the file (e.g. ‘shutdown’, ‘1 h’ ‘3 d’). The values of the dictionary are the requested tag names for the combination of nuclide and decay time. For example if one wanted tags for the photon source densities from U235 at shutdown and from all nuclides at 1 hour, the dictionary could be:

tags = {(‘U-235’, ‘shutdown’) : ‘tag1’, (‘TOTAL’, ‘1 h’) : ‘tag2’}

sub_voxel: bool, optional

If the sub_voxel is True, then the sub-voxel r2s will be used. Then the photon_source will be interpreted as sub-voxel photon source.

cell_matsdict, optional

cell_mats is required when sub_voxel is True. Maps geometry cell numbers to PyNE Material objects.

pyne.alara.photon_source_to_hdf5(filename, nucs='all', chunkshape=10000)[source]

Converts a plaintext photon source file to an HDF5 version for quick later use.

This function produces a single HDF5 file named <filename>.h5 containing the table headings:

idxint

The volume element index assuming the volume elements appear in xyz order (z changing fastest) within the photon source file in the case of a structured mesh or mesh.mesh_iterate() order for an unstructured mesh.

nucstr

The nuclide name as it appears in the photon source file.

timestr

The decay time as it appears in the photon source file.

phtn_src1D array of floats

Contains the photon source density for each energy group.

Parameters
filenamestr

The path to the file for read

nucsstr
Nuclides need to write into h5 file. For example:
• ‘all’: default value. Write the information of all nuclides to h5.

• ‘total’: used for r2s. Only write TOTAL value to h5.

chunkshapetuple of int

A 1D tuple of the HDF5 chunkshape.

pyne.alara.phtn_src_energy_bounds(input_file)[source]

Reads an ALARA input file and extracts the energy bounds from the photon_source block.

Parameters
input_filestr

The ALARA input file name, which must contain a photon_source block.

Returns
e_boundslist of floats
The lower and upper energy bounds for the photon_source discretization. Unit: eV.
pyne.alara.read_decay_times(line)[source]

This function reads a line contian decay times information from alara output file and return the decay times list.

Parameters
linestring

A line from ALARA output.txt

Returns
decay_timesarray of string

Array of decay times.

pyne.alara.record_to_geom(mesh, cell_fracs, cell_mats, geom_file, matlib_file, sig_figs=6, sub_voxel=False)[source]

This function preforms the same task as alara.mesh_to_geom, except the geometry is on the basis of the stuctured array output of dagmc.discretize_geom rather than a PyNE material object with materials. This allows for more efficient ALARA runs by minimizing the number of materials in the ALARA matlib. This is done by treating mixtures that are equal up to <sig_figs> digits to be the same mixture within ALARA.

Parameters
meshPyNE Mesh object

The Mesh object for which the geometry is discretized.

cell_fracsstructured array

The output from dagmc.discretize_geom(). A sorted, one dimensional array, each entry containing the following fields:

idx

int The volume element index.

cell

int The geometry cell number.

vol_frac

float The volume fraction of the cell withing the mesh ve.

rel_error

float The relative error associated with the volume fraction.

cell_matsdict

Maps geometry cell numbers to PyNE Material objects. Each PyNE material object must have ‘name’ specified in Material.metadata.

geom_filestr

The name of the file to print the geometry and material blocks.

matlib_filestr

The name of the file to print the matlib.

sig_figsint

The number of significant figures that two mixtures must have in common to be treated as the same mixture within ALARA.

sub_voxelbool

If sub_voxel is True, the sub-voxel r2s will be used.

pyne.alara.response_hdf5_to_mesh(mesh, filename, tags, response)[source]

This function reads in an hdf5 file produced by response_to_hdf5 and tags the requested data to the mesh of a PyNE Mesh object. Any combinations of nuclides and decay times are allowed. The photon source file is assumed to be in mesh.__iter__() order

Parameters
meshPyNE Mesh

The object containing the PyMOAB instance to be tagged.

filenamestr

The path of the hdf5 version of the response file.

tags: dict

A dictionary were the keys are tuples with two values. The first is a string denoting an nuclide in any form that is understood by pyne.nucname (e.g. ‘1001’, ‘U-235’, ‘242Am’) or ‘TOTAL’ for all nuclides. The second is a string denoting the decay time as it appears in the file (e.g. ‘shutdown’, ‘1 h’ ‘3 d’). The values of the dictionary are the requested tag names for the combination of nuclide and decay time. For example if one wanted tags for the photon source densities from U235 at shutdown and from all nuclides at 1 hour, the dictionary could be:

tags = {(‘U-235’, ‘shutdown’) : ‘tag1’, (‘TOTAL’, ‘1 h’) : ‘tag2’}

responsestr
The keyword of the response. Supported responses:
• decay_heat

• specific_activity

• alpha_heat

• beta_heat

• gamma_heat

• wdr

• photon_source

pyne.alara.response_to_hdf5(filename, response, chunkshape=10000)[source]

Converts a plaintext output.txt file to an HDF5 version for quick later use.

This function produces a single HDF5 file named <filename>.h5 containing the table headings:

idxint

The volume element index assuming the volume elements appear in xyz order (z changing fastest) within the photon source file in the case of a structured mesh or mesh.mesh_iterate() order for an unstructured mesh.

nucstr

The nuclide name as it appears in the output file.

timestr

The decay time as it appears in the output file.

responsefloat
Supported response:
• decay_heat [W/cm3]

• specific_activity [Bq/cm3]

• alpha_heat [W/cm3]

• beta_heat [W/cm3]

• gamma_heat [W/cm3]

• wdr

• photon_source

Parameters
filenamestr

The path to the file output.txt

responsestr

Key word of the response

chunkshapetuple of int

A 1D tuple of the HDF5 chunkshape.

pyne.alara.responses_output_zone(responses=None, wdr_file=None, alara_params=None)[source]

This function returns a string that is an output block for an alara input file, configured for zone resolution.

Parameters
responseslist of string

A keyword represent the alara output zone. The following responses are supported:

• decay_heat

• specific_activity

• alpha_heat

• beta_heat

• gamma_heat

• wdr

• photon_source

wdr_filestring

File name of the standard used to calculate wdr.

alara_params: string

Alara parameters

Returns
String represent the output zone block corresponding to the response.