kika.ace

The ace module provides functionality for parsing ACE (A Compact ENDF) format nuclear data files.

kika.ace.read_ace(filename, debug=False)[source]

Read and parse an ACE format file.

This implementation eagerly loads all data except energy distribution data which is still loaded on-demand when accessed.

Parameters:
  • filename (str) – Path to the ACE file

  • debug (bool, optional) – Whether to print debug information, defaults to False

Returns:

ace – An Ace object containing the parsed data

Return type:

Ace

Submodules

kika.ace.parsers.parse_ace

kika.ace.parsers.parse_ace.read_ace(filename, debug=False)[source]

Read and parse an ACE format file.

This implementation eagerly loads all data except energy distribution data which is still loaded on-demand when accessed.

Parameters:
  • filename (str) – Path to the ACE file

  • debug (bool, optional) – Whether to print debug information, defaults to False

Returns:

ace – An Ace object containing the parsed data

Return type:

Ace

kika.ace.parsers.parse_ace.read_xss(lines)[source]

Read the XSS array from an ACE file and convert it to a list of XssEntry.

The array uses 1-based indexing to match FORTRAN style indexing. Index 0 contains a placeholder value (0) to facilitate 1-based indexing.

Parameters:

lines (list) – List of lines from the file containing the XSS array

Returns:

The XSS array as a list of XssEntry objects starting at index 1

Return type:

list

kika.ace.xsdir

kika.ace.xsdir.build_xsdir_line(zaid_with_ext: str, awr: float, file_ref: str, xss_len: int, kT_MeV: float, *, dir_field: str | int = 0, file_type: int = 1, address: int = 1, record_len: int = 0, entries_per_record: int = 0, has_ptable: bool = False) → str[source]

Build one xsdir entry. Long entries are wrapped at field boundaries with a trailing “ +” continuation marker and 10-space indent on subsequent physical lines so that no physical line exceeds 80 columns.

zaid_with_extstr

Full table name as it must appear in xsdir, e.g. “22048.01c”.

awrfloat

Atomic weight ratio (AWR).

file_refstr

File reference in column 3. Can be a relative path or just a filename.

xss_lenint

Length of the XSS array (NXS(2)).

kT_MeVfloat

Temperature in MeV (kT).

dir_field : str | int, default 0 file_type : int, default 1

1 = text (sequential), 2 = binary (direct access).

address : int, default 1 record_len : int, default 0 entries_per_record : int, default 0 has_ptable : bool, default False

Whether to append the trailing “ptable” token.

str

The complete xsdir entry (may contain embedded “

“ for continuation).

kika.ace.xsdir.write_xsdir_line(xsdir_path: str, line: str, mode: str = 'w') → None[source]

Write a single xsdir entry (possibly multi-line) to file.

kika.ace.xsdir.create_xsdir_files_for_ace(ace_file_path: str, zaid: int, awr: float, xss_len: int, temperature_mev: float, sample_index: int, output_dir: str, master_xsdir_file: str = None, has_ptable: bool = False, per_sample_xsdir_path: str = None) → None[source]

Create xsdir files for a perturbed ACE file.

Creates both per-sample xsdir files and optionally updates a master xsdir file. Shared between ACE and ENDF perturbation workflows.

Parameters:

per_sample_xsdir_path (str, optional) – Full path to write the per-sample xsdir snippet. When None, the legacy layout sample_dir/{base}_{sample_str}.xsdir is used. Pass the new-layout path (e.g. output_dir/ace/<NNNN>/xsdir/<ZAID>.<ext>.xsdir) from pipelines that already provisioned a per-sample xsdir directory and want their xsdir to land there.