armi.nuclearDataIO.cccc.isotxs module

This module reads and writes ISOTXS files.

ISOTXS is a binary file that contains multigroup microscopic cross sections. ISOTXS stands for Isotope Cross Sections.

ISOTXS files are often created by a lattice physics code such as MC2 or DRAGON and used as input to a global flux solver such as DIF3D.

This module implements reading and writing of the ISOTXS file format, consistent with [CCCC-IV].

Examples

>>> from armi.nuclearDataIO.cccc import isotxs
>>> myLib = isotxs.readBinary('ISOTXS-ref')
>>> nuc = myLib.getNuclide('U235','AA')
>>> fis5 = nuc.micros.fission[5]
>>> scat = nuc.micros.scatter[(0, 5, 6, 1)] # 1st order elastic scatter from group 5->6
>>> nuc.micros.fission[7] = fis5*1.01       # you can modify the isotxs too.
>>> captureEnergy = nuc.isotxsMetadata["ecapt"]
>>> isotxs.writeBinary(myLib, 'ISOTXS-modified')
armi.nuclearDataIO.cccc.isotxs.compareSet(fileNames, tolerance=0.0, verbose=False)[source]

takes a list of strings and reads all binaries with that name comparing them in all combinations

Notes

useful for finding mcc bugs when you want to compare a series of very similar isotxs outputs Verbose gets VERY long

armi.nuclearDataIO.cccc.isotxs.compare(lib1, lib2, tolerance=0.0, verbose=False)[source]

Compare two XSLibraries, and return True if equal, or False if not.

Notes

Tolerance allows the user to ignore small changes that may be caused by small library differences or floating point cacluations the closer to zero the more differences will be shown 10**-5 is a good tolerance to use if not using default. Verbose shows the XS matrixes that are not equal

armi.nuclearDataIO.cccc.isotxs.compareNuclideXS(nuc1, nuc2, tolerance=0.0, verbose=False)[source]
class armi.nuclearDataIO.cccc.isotxs._IsotxsIO(fileName, lib, fileMode, getNuclideFunc)[source]

Bases: armi.nuclearDataIO.cccc.cccc.Stream

A semi-abstract stream for reading and writing to a Isotxs.

Notes

This is a bit of a special case compared to most other CCCC files because of the special nuclide-level container in addition to the XSLibrary container.

The readWrite() defines the ISOTXS file structure as specified in http://t2.lanl.gov/codes/transx-hyper/isotxs.html.

Create an instance of a Stream.

Parameters
  • fileName (str) – name of the file to be read

  • fileMode (str) – the file mode, i.e. ‘w’ for writing ASCII, ‘r’ for reading ASCII, ‘wb’ for writing binary, and ‘rb’ for reading binary.

_FILE_LABEL = 'ISOTXS'
_getFileMetadata()[source]
_getNuclideIO()[source]
classmethod _read(fileName, fileMode)[source]
classmethod _write(lib, fileName, fileMode)[source]
classmethod _readWrite(lib, fileName, fileMode, getNuclideFunc)[source]
_rwMessage()[source]
_updateFileLabel()[source]

Update the file label when reading in the ISOTXS-like file if it differs from its expected value.

Notes

This occurs when MC2-3 is preparing GAMISO files. The merging of ISOTXS-like files fail if the labels are not unique (i.e. merging ISOTXS into GAMISO with each file having a file label of ISOTXS.

readWrite()[source]

This method should be implemented on any sub-classes to specify the order of records.

_fileID()[source]
_rw1DRecord(numNucs)[source]
_rw2DRecord(numNucs, nucNames)[source]

Read 2D ISOTXS record.

Notes

Contains isotope names, global chi distribution, energy group structure, and locations of each nuclide record in the file

_rwLibraryEnergies(record)[source]
_rw3DRecord()[source]

Read file-wide chi-distribution matrix.

_computeNuclideRecordOffset()[source]

Compute the record offset of each nuclide.

Notes

This is not used within ARMI, because it can compute it arbitrarily. Other codes use this to seek to a specific position within an ISOTXS file.

_computeNumIsotxsRecords(nuclide)[source]

Compute the number of ISOTXS records for a specific nuclide.

class armi.nuclearDataIO.cccc.isotxs._IsotxsNuclideIO(nuclide, isotxsIO, lib)[source]

Bases: object

A reader/writer class for ISOTXS nuclides.

Notes

This is to be used in conjunction with an _IsotxsIO object.

_getFileMetadata()[source]
_getNuclideMetadata()[source]
_getMicros()[source]
rwNuclide()[source]

Read nuclide name, other global stuff from the ISOTXS library.

_rw4DRecord()[source]

Read 4D ISOTXS record.

Notes

Read the following individual nuclide XS record. Load data into nuc. This record contains non-mg data like atomic mass, temperature, and some flags.

_rw5DRecord()[source]

Read principal microscopic MG XS data for a nuclide.

_rw6DRecord()[source]

reads nuclide-level chi dist

_rw7DRecord(blockNumIndex, subBlock)[source]

Read scatter matrix

Parameters
  • blockNumIndex (int) – Index of the scattering block (aka type of scattering) in this nuclide

  • subBlock (int) – Index-tracking integer. Since neutrons don’t scatter to and from all energies, there is a bandwidth defined to save on storage.

Notes

The data is stored as a giant array, and read in as a CSR matrix. The below matrix is lower triangular, where periods are non-zero.

. 0 0 0 0 0 . . 0 0 0 0 … 0 0 0 … . 0 0 … . . 0 … …

The data is read in rows starting at the top and going to the bottom. Per row, there are JBAND non-zero entries. Per row, there are JJ non-zero entries on or beyond the diagonal.

. 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Additionally, the data is reversed for whatever reason. So, let’s say we are reading the third row in our ficitious matrix. JBAND is 2, JJ is 1. We will read “1” first, and then “2” from the ISOTXS. Since they are backwards, we need to reverse the numbers before putting them into the matrix.

. 0 0 0 0 0 . . - - - - . 2 1 - - - - - - - - - - - - - - - - - - - - -

However, since we are reading a CSR, we can just add the indices in reverse (this is fast) and read the data in as is (which is a bit slower). Then we will allow the CSR matrix to fix the order later on, if necessary.

_getScatterBlockNum(scatterType)[source]

Determine which scattering block is elastic scattering.

This information is stored in the scatFlab libparam and is possibly different for each nuclide (e.g. C, B-10, etc.)

Parameters

scatterType (int) – ISOTXS-defined special int flag for a scatter type (100 for elastic, etc.)

Returns

blockNum – A index of the scatter matrix.

Return type

int

_getElasticScatterBlockNumIndex(legendreOrder=0)[source]
_getInelasticScatterBlockNumIndex()[source]
_getN2nScatterBlockNumIndex()[source]
_getTotalScatterBlockNumIndex()[source]
_setScatterMatrix(blockNumIndex, scatterMatrix)[source]

Sets scatter matrix data to the proper scatterMatrix for this blockNum

blockNumIndexint

Index of a scattering block.

_getScatterMatrix(blockNumIndex)[source]

Get the scatter matrix for a particular blockNum

Note: This is stupid and the logic should be combined with _setScatterMatrix. Please recommend a better way to do it during code review.