armi.utils.asciimaps module

ASCII maps are little grids of letters/numbers that represent some kind of a lattice.

These are commonly used in nuclear analysis to represent core maps, pin layouts, etc. in input files. This module reads various text and interprets them into meaningful data structures.

We make classes for different geometries to share code. This will eventually be expanded for various symmetries that are applicable to cores, assemblies, etc.

This is as attempted reimplementation of AsciiMaps aiming for simplicity, though inherently this work is complex.

Some vocabulary used here:

column, line

column and line numbers in the actual ascii text representation. What you would see in a text editor.

offset

The number of spaces needed at the beginning a line to properly orient the ascii representation.

i, j

Indices in the grid itself. For Cartesian, j is like the line number, but in other geometries (like hex), it is a totally different coordinate system.

See also

armi.reactor.grids

More powerful, nestable lattices with specific dimensions Most input lattices eventually end up as Grid objects.

armi.reactor.blueprints.latticeBlueprint

user input of generic lattices

armi.reactor.geometry

a specific usage of lattices, for core maps

class armi.utils.asciimaps.AsciiMap[source]

Bases: object

Base class for maps.

These should be able to read and write ASCII maps loaded either from text or programatically with i,j / specifiers.

asciiLines

A list of lines, each containing a list of ascii labels for each column. No blanks.

asciiOffsets

A list of offset integers for each line above that will be prepended before the contents of asciiLines

asciiLabelByIndices

A mapping from grid location objects to ascii labels

writeAscii(stream)[source]

Write out the ascii representation.

readAscii(text)[source]

Read ascii representation from a stream.

Update placeholder size according to largest thing read.

Parameters:

text (str) – Custom string that describes the ASCII map of the core.

static fromReactor(reactor)[source]

Populate mapping from a reactor in preparation of writing out to ascii.

gridContentsToAscii()[source]

Convert a prepared asciiLabelByIndices to ascii lines and offsets.

This is used when you have i,j/specifier data and want to create a ascii map from it as opposed to reading a ascii map from a stream.

As long as the map knows how to convert lineNum and colNums into ij indices, this is universal. In some implementations, this operation is in a different method for efficiency.

items()[source]
keys()[source]
class armi.utils.asciimaps.AsciiMapCartesian[source]

Bases: AsciiMap

Cartesian ascii map.

Conveniently simple because offsets are always 0

i and j are equal to column, row

class armi.utils.asciimaps.AsciiMapHexThirdFlatsUp[source]

Bases: AsciiMap

Hex ascii map for 1/3 core flats-up map.

  • Indices start with (0,0) in the bottom left (origin).

  • i increments on the 30-degree ray

  • j increments on the 90-degree ray

In all flats-up hex maps, i increments by 2*col for each col and j decrements by col from the base.

These are much more complex maps than the tips up ones because there are 2 ascii lines for every j index (jaggedly).

Lines are read from the bottom of the ascii map up in this case.

class armi.utils.asciimaps.AsciiMapHexFullFlatsUp[source]

Bases: AsciiMapHexThirdFlatsUp

Full core flats up ascii map.

Notes

Rather than making a consistent base, we switch base angles with this one because otherwise there would be a ridiculous number of placeholders on the left. This makes this one’s base computation more complex.

We also allow all corners to be cut off on these, further complicating things.

class armi.utils.asciimaps.AsciiMapHexFullTipsUp[source]

Bases: AsciiMap

Full hex with tips up of the smaller cells.

  • I axis is pure horizontal here

  • J axis is 60 degrees up. (upper right corner)

  • (0,0) is in the center of the hexagon.

Frequently used for pins inside hex assemblies.

This does not currently support omitted positions on the hexagonal corners.

In this geometry, the outline-defining _ijMax is equal to I at the far right of the hex. Thus, ijMax represents the number of positions from the center to the outer edge towards any of the 6 corners.

armi.utils.asciimaps.asciiMapFromGeomAndDomain(geomType: Union[str, GeomType], domain: Union[str, DomainType]) AsciiMap[source]

Get a ascii map class from a geometry and domain type.