Skip to main content

aci-tallies

Read MCNP tally files, however large, into NumPy arrays: meshtal files (FMESH mesh tallies), MCTAL files (F tallies) and D1SUNED's cell-under-voxel files (cuvmsh, meshinfo), in Rust, from Python or Rust.

Install as aci-tallies, import as aci_tallies.

import aci_tallies

f = aci_tallies.open("meshtal", input="model.i")   # or an MCTAL file; input optional
f.ids                          # tally numbers; f.tallies describes each, no values read
t = f[14]                      # read one tally
t.result, t.rel_error          # read-only NumPy views, no copy
f.read(14, energy="total")     # read only MCNP's Total energy bin of it

Opening a file indexes it in one parallel pass; values are read when asked for, a tally or part of one at a time, straight from disk into the arrays returned. A 50 GB file opens in well under a second, and only what you read is ever in memory.

  • crates/tallies (aci-tallies): the readers. common (file sources, the parallel scan, Fortran number parsing, bins, error propagation), meshtal, mctal, cuv.
  • crates/geom (aci-tallies-geom): mesh geometry (voxels, volumes, centres, point location, VTK, TR=), dependency-light, shared with other mesh tools.
  • crates/py and python/aci_tallies: the Python package. It needs only NumPy; to_polars, to_xarray and to_pyvista need their extras (pip install 'aci-tallies[polars,xarray,vtk]', or [all]).

The MCNP input (input=, a path or an aci_tallies.Input to reuse) is optional and read with migjorn: it gives what the files leave out (below).

meshtal files

aci_tallies.meshtal.open(path, input=None) → MeshtalFile, a mapping from tally number to MeshTally.

  • Every out= layout (col, cf, ij, ik, jk), rectangular and cylindrical meshes, energy and time bins and their Total bins.
  • result/rel_error always have five axes, (energy, time, i, j, k); a mesh without EMESH/TMESH has length 1 there. When an axis has more than one bin, MCNP's Total bin is one more index at its end (t.energy.total, t.energy.total_index), never dropped. t.volume (out=cf) is (i, j, k).
  • t.geometry is the mesh: kind, axis_names (x y z or r z theta), bounds, origin/axis/vec, transform (4x4, TR=), volumes(), centers(), locate(points).
  • f.read(id, energy=, time=) reads only those bins (an index or "total"); in the columnar layouts a bin's rows are consecutive, in the matrix ones a run of blocks, so nothing else is read.
  • Operations run in Rust, in parallel, without copying their inputs: `+ -
    • /(errors propagated as for independent quantities;t + tis not2 * t), isel(energy=, time=, i=, j=, k=)with ints, slices or"total", integrate_energy()/integrate_time()(MCNP's Total bin when printed: its error comes from the histories, which summing can't reproduce),integrate_space()`.
  • to_polars()/to_parquet() (one row per value; an axis with one bin gets no columns), to_xarray(), to_pyvista() (every field and bin attached), to_vtk(path) (written by Rust, no PyVista needed).

In Rust, aci_tallies_geom::mcnp_input reads the FMESH cards of an input exactly (read_fmeshes) and writes them (FmeshCard::to_input, with the TRn card of a TR=): a written card reads back the same, bounds to the bit, and MCNP scores it as the card it came from.

What a meshtal file can't tell you

Found by running MCNP 6.2 and 6.3 on purpose-built inputs (tests/fixtures/pencil_beam*.mcnp: one ray through void, so every voxel scores exactly chord / volume). The input fixes the first two and the third:

  • Bounds are rounded to 2 decimals (theta 3), origin and axes to 3 significant digits: geometry rebuilt from them is off by up to ~0.2% (~2% for an unround cylinder origin), and bins finer than 0.01 cm collapse (with a warning). Values are unaffected.
  • TR= leaves no trace. tally.geometry_from_input says which you got.
  • *FMESH looks like FMESH; only the input says (energy_weighted).
  • Bounds around ±1e5–1e6 cm overflow MCNP's fixed-width fields: such a section is listed in f.failed.
  • MCNP5 prints no VEC for a cylinder: MCNP's default, 1 0 0 made perpendicular to the axis, is assumed, with a warning (input= gives the one the run used). MCNP 6.2 and 6.3 use that default when the card has no VEC, and stop when the axis is along x (the two are parallel): such a header's VEC is unknown (NaN) without the input.

D1SUNED meshtal sections

D1SUNED's FMESH can score nuclides, parent nuclides or cells (ETAG/TTAG) and decay times in place of energy or time bins: their axis has labels (26059.002 for Fe59, the 2nd bin; 0.001 is every other nuclide) instead of bounds, and a kind ("nuclide", "parent", "cell", "decay_time"; decay times have no Total). A nuclide that overflows its 10-character field (**********, as 41092900 does) is read from the FMESH card when input= is given; without it the section is in f.failed. D1SUNED 3.1.4's lone Total Energy Bin block is the one bin it is, and a negative value run into its coordinate (112.500-1.57688E-11) is split. Source-importance meshes (GEOMETRY IMESH, target tallies) are not read (they are in f.failed).

MCTAL files

aci_tallies.mctal.open(path, input=None) → MctalFile, a mapping from tally number to Tally.

  • result/rel_error always have MCNP's eight axes, in the order the file lists values: f d u s m c e t (cells or surfaces, direct, user, segments, multipliers, cosines, energies, times). t.axes["e"] has an axis's bins: MCTAL gives upper bounds only (Axis.upper), and flags a Total bin (total, last index) or cumulative bins (cumulative).
  • f.read(id, f=slice(...)) reads only those cells: f varies slowest, so their values are a run of lines. f.read(id, perturbation=n) reads a PERT card's values; f.kcode has a KCODE run's estimates per cycle (a named column each); t.tfc the fluctuation chart.
  • Detectors (point, ring, radiography grids), *F/+F, user bins, legacy TMESH mesh tallies (their cells are the f bins, first axis fastest).
  • isel(f=, e=, ...), integrate("e", "t"), + - * /, to_polars(), to_xarray().

What an MCTAL file can't tell you

Found by running MCNP 6.2 and 6.3 on tests/fixtures/mctal/*.mcnp:

  • The f line names a bin only by its first level, and only when that is one cell or surface: (8 < 7[2 0 0] < 3) is listed as 8, a group (1 2) as 0, and the T bin as 0 unless every bin starts with the same cell. t.numbers has these.
  • With the input, t.bins has what each bin is: every level, groups, lattice elements, the T bin, expanded the way MCNP expands the F card (str(bin) is the name MCNP's output gives it, "(8<7[1 0 0]<3)"). They are checked against the file, and left out with a warning if they don't match. In a chain a level of several cells or a lattice range makes one bin each, innermost level fastest, first lattice index fastest; a parenthesized level is one union.
  • Values below 1e-99 are printed without the E (2.50000-113), in MCTAL and meshtal files alike: read exactly here (some other readers take them for 0).

CDGS files (D1SUNED)

A Common Decay Gamma Source file holds decay gamma sources on meshes, as D1SUNED (and F4Enix) write them.

from aci_tallies import cdgs

f = cdgs.open("cdgs")                      # aci_tallies.open works too
f.info(1).cooling_time, f.info(1).strength # s, photons/s
src = f[1]                                 # MeshTally: source per voxel and energy bin
src.result.shape                           # (energy, 1, i, j, k), Total energy bin last
  • Read by parts like the other formats: opening indexes the file and reads the headers; a read parses the mesh's voxels in parallel.
  • A voxel's source is the sum of its cells' (each cell's part of the voxel's source, as D1SUNED writes them); voxels the file leaves out have none. The Total bin is the sum of the bins, its error that of the sum; a voxel whose printed source (or its cells' sum) differs from it by more than 1e-4 is counted in a warning, as are voxels listed twice.
  • Energy bins (energy_type bins), or gamma lines (lines: an axis of labels, kind == "line"). A bound too large for its field (******) is NaN, with a warning.
  • Rectangular and cylindrical meshes. A cylinder's bounds and voxels are printed r, theta, z: they are put in (r, z, theta) order. A rectangular mesh placed by a TR card has its frame (origin, x and y axes) as geometry.transform, with a warning: no file has confirmed that reading yet.

CuV files (D1SUNED)

An FMESH with out=cuv (D1SUNED's cell-under-voxel mesh) is not written to the meshtal file but to two files holding every CuV mesh of the run: the meshinfo gives each (voxel, cell) pair's material, density and share of the voxel's volume, the cuvmsh the same pairs with their flux spectra.

from aci_tallies import cuv

f = cuv.open("cuvmsh", input="model.i")    # or a meshinfo; aci_tallies.open works too
p = f[14]                                  # CuvPairs: every (voxel, cell) pair of mesh 14
p.voxel, p.cell, p.fraction, p.flux        # flux: (pair, energy), per cm² and source particle
f.read(14, voxels=slice(0, 10_000))        # only those voxels' part of the file
both = cuv.open_mesh("cuvmsh", "meshinfo") # + material and density, pairs checked equal
f.to_mesh(14)                              # MeshTally of voxel fluxes: to_vtk, isel, ...
f.to_mesh(14, cells=[3, 4], norm="celf")   # only those cells, over the share they fill
  • Pairs come voxel by voxel in the mesh's flat order (voxel, as Geometry.locate numbers them); each voxel's printed centre is checked against the geometry, so a file in another order is refused.
  • to_polars() (a row per pair; spectra=True: per pair and energy bin), to_xarray() (dimensions pair, energy). to_mesh sums each voxel's cells, flux × volume share: what the same FMESH without out=cuv scores (to its 6 printed digits, tests/fixtures/d1suned). Its errors are combined as if the cells were independent: they aren't, and the estimate ran 2–18% low there. cells= keeps only those cells' pairs (a voxel with none of them is 0); norm="ctot" multiplies by the voxel volume, norm="celf" divides by the share of the voxel the cells kept fill.
  • The headers round the geometry like a meshtal header (and the energy bounds to 3 digits) and leave out TR=; input= gives the FMESH card's exact ones. D1SUNED's own keywords (sppts, spmode, ...) are known.
  • D1SUNED 3.x meshinfo files of cylinders (theta in radians, volumes 2π too large) are corrected (legacy_cylindrical).
  • D1SUNED 4.1.3.2 crashed writing a cylindrical CuV mesh with 2 energy bins ("output statement overflows record"); 20 bins ran.

Reliability

A damaged part of a file never stops the rest from being read: a bad row or line leaves its values NaN with a ReadWarning (with its line number), an unreadable section or tally is listed in f.failed, and every value is where it belongs whatever is missing around it. A file changed since it was opened is reported, never misread. Checked against MCNP 6.2 and 6.3 output with exact expected values, property tests of the chunked parsing, and, for MCTAL, F4Enix's reader (identical wherever it reads right).

Performance

On 96 cores, files in the OS cache:

file open read all peak memory
meshtal, 6.6 GB, 14 tallies 0.06 s 0.33 s 1.6 GB (the arrays)
MCTAL, 2 GB, 104M values 0.11 s 0.22 s 1.7 GB (the arrays)

One bin of a 2.5M-voxel mesh tally: 0.01 s; ten cells of a 4M-cell MCTAL tally: 1 ms. One core reads about 0.6–0.9 GB/s. The previous version read the meshtal file in 3.3 s with 5.1 GB of memory (it held a section's text). cargo run --release --example meshtal -- <file> --all (or mctal) times a file and prints a checksum per tally.

Rust

use aci_tallies::{common::Input, mctal, meshtal};

let input = Input::read("model.i")?;
let mesh = meshtal::Reader::open_with_input("meshtal", &input)?;
let bin = mesh.read_bin(14, 0, 0)?;            // one energy and time bin
let cells = mctal::Reader::open_with_input("mctal", &input)?;
let part = cells.read_f(4, 0..10)?;            // ten cells of tally 4

aci_tallies::detect(head) tells the formats apart from a file's first bytes.

Development

cargo test --workspace
python -m venv .venv && . .venv/bin/activate
pip install maturin && maturin develop --release   # the extension, into the venv
pip install -e ".[dev]"
pytest tests/python && mypy python/aci_tallies tests/python && ruff check python tests

maturin develop without --release builds a debug extension, 10–30x slower at parsing. The fixtures under tests/fixtures are MCNP output; each .mcnp says how to regenerate it (tests/fixtures/d1suned: its README).

Releases: raise version and the aci-tallies-geom pin under it in Cargo.toml (or tools/release.sh X.Y.Z); pushing that to master publishes to PyPI and crates.io and tags vX.Y.Z (AGENTS.md, "Versions and releases").

License

EUPL-1.2.

Metadata

Release files for aci-tallies 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aci-tallies 0.1.3
File Size Uploaded Provenance Actions
aci_tallies-0.1.3.tar.gz 185.3 kB With provenance Details for aci_tallies-0.1.3.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for aci-tallies 0.1.3
File Actions
aci_tallies-0.1.3-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for aci_tallies-0.1.3-cp310-abi3-win_amd64.whl
aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_x86_64.whl
aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details for aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_aarch64.whl
aci_tallies-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for aci_tallies-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
aci_tallies-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for aci_tallies-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
aci_tallies-0.1.3-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for aci_tallies-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
aci_tallies-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for aci_tallies-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 8.1 MB

Release files / aci_tallies-0.1.3.tar.gz

Download URL aci_tallies-0.1.3.tar.gz
Size 185.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9cefe8d124700f936afc645b0894ca8349454d26b1f06936959487a5bebbc8f5
BLAKE2b-256 checksum
How to use checksums
281a34facbbf60640fc98e69d03f29dd623941c79f6ae8afaf7689307239bef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-win_amd64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-win_amd64.whl
Size 1.0 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3f41146e4c3bfd9a50fb39730696b6f176ff931557d95ba67939798c3f3c9ab3
BLAKE2b-256 checksum
How to use checksums
444c5e04fd601cacd1c589700483d560953b3b7b09d78c447c66ffec93c78f50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
967a8e6e65be53fcc717386b228abc8f986498eb3060f8effc607c71a485d7ae
BLAKE2b-256 checksum
How to use checksums
fa2fed7b626f94e8a0152c8fe6ec93fc461e51b265a1c39a0faf419a6a52f8c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-musllinux_1_2_aarch64.whl
Size 1.3 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
add24965ceb8bf1563cf983acf4020786124392ac0c72b04ca40248ddafee0fb
BLAKE2b-256 checksum
How to use checksums
429b71b57c1465fe33625b96123a4d82592e0f2bc72d858ad40b70aacc5e4e2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
581716d96bdc131c446399458a1cd11d961e75b0190fc821989fc8a9fe49d37a
BLAKE2b-256 checksum
How to use checksums
28208b25c14c470b1fa0ae506ae731e7103b2cdf791995b8da5af705ab6a8623
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3036ff7710fb0207bff146184c5fecc4bc9ca07dbfbbfa9776a2395b71ffc419
BLAKE2b-256 checksum
How to use checksums
86c4cbb3c721ca775dc462e1bf52085b74bb5254e3a2c92ead341bc922f7aa41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-macosx_11_0_arm64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0978ea98864530e7c0df7216ef4fd4992ca9d9113403a5be864d1855599ca98a
BLAKE2b-256 checksum
How to use checksums
5026ec066613d37e39eaec37fc50d6f655ad093326cae74f2a3d3f1b0552d2e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / aci_tallies-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl

Download URL aci_tallies-0.1.3-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
08a168ef90a8858784172bc85beaf2725725d9641d532549e70efc116e021873
BLAKE2b-256 checksum
How to use checksums
8ba3cf38c3fc51fbb9039f2476d89ed6f07103bec8327cdbc81cade2c80faa5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for aci-tallies 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for aci_tallies-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page