You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue while trying to generate ACE files from the ENDF/B-VIII.0 library using NJOY2016 (version 2016.78). The process fails specifically when the RECONR module is processing U-235 (n-092_U_235.endf).
Problem Summary:
The NJOY run stops abruptly after the RECONR module starts. The output file shows that RECONR begins processing, prints resonance range information, and reports some threshold changes, but then the log simply ends without any ***error*** message. The output file for the next module (tape22) is created but remains at 0 bytes.
This behavior strongly suggests a segmentation fault or a hard crash within the RECONR module, likely due to an incompatibility between the older NJOY2016 and the modern ENDF/B-VIII.0 data format for U-235.
What I've tried so far:
Checked the NJOY input script: The data flow is correct (MODER: 20 -> -21, RECONR: -21 -> -22, etc.). The tape21 from MODER is generated successfully.
Added tolerance to RECONR: I tried adding a resonance integral error tolerance (errint = 1.0e-5) to the RECONR input card, but this did not solve the crash.
This issue is reproducible: It happens consistently every time I run the script.
#!/usr/bin/env python3
import os
import subprocess
import tempfile
import shutil
# ==============================================================================
# --- CONFIGURATION SECTION (Please edit) ---
# ==============================================================================
# Path to the NJOY executable (use absolute path)
NJOY_EXE_PATH = '/home/hzn/projects/NJOY2016-main/build/njoy'
# Directory containing the original ENDF data files (use absolute path)
ENDF_DIR = '/home/hzn/projects/NJOY2016-main/endf_files'
# Directory to store the generated ACE files (use absolute path)
ACE_DIR = '/home/hzn/projects/NJOY2016-main/ACE_libraries'
# Define the nuclides and temperatures to process
# Format: 'ENDF_filename': (Official MAT number, 'Nuclide_Name', [List_of_Temperatures])
NUCLIDES_TO_PROCESS = {
'n-092_U_235.endf': (9228, 'U235', [950, 1000, 1050, 1100, 1150]),
'n-092_U_238.endf': (9237, 'U238', [950, 1000, 1050, 1100, 1150]),
'n-007_N_015.endf': (728, 'N15', [950, 1000, 1050, 1100, 1150]),
'n-082_Pb_204.endf': (8225, 'Pb204', [700, 750, 800, 850, 950, 1000]),
'n-082_Pb_206.endf': (8231, 'Pb206', [700, 750, 800, 850, 950, 1000]),
'n-082_Pb_207.endf': (8234, 'Pb207', [700, 750, 800, 850, 950, 1000]),
'n-082_Pb_208.endf': (8237, 'Pb208', [700, 750, 800, 850, 950, 1000]),
}
# ==============================================================================
# --- NJOY INPUT TEMPLATE (Corrected) ---
# ==============================================================================
# NOTE: This template has the corrected data flow (reconr reads from -21)
# and includes a tolerance for the resonance integral check in RECONR.
# Data flow: tape20 -> MODER -> tape21 -> RECONR -> tape22 -> BROADR -> tape23 -> ACER -> tape27
NJOY_TEMPLATE = """moder
20 -21 0 /
reconr
-21 -22 /
{nuclide_name} from ENDF/B-VIII.0 /
{zaid} 1 1 /
0 0 0 1 /
0.001 /
0. /
1.0e-5 /
broadr
-22 -23 /
{nuclide_name} at {temp}K /
{zaid} 1 0 0 /
0.001 /
{temp} /
0.0 /
acer
-23 -27 0 0 /
1 0.0 /
{ace_id} /
{zaid} {temp} /
{comment} /
stop
"""
# ==============================================================================
# --- MAIN SCRIPT (No modification needed below) ---
# ==============================================================================
def main():
"""
Main function to loop through and process all defined nuclides and temperatures.
"""
# Check basic configuration
if not os.path.exists(NJOY_EXE_PATH):
print(f"!!! FATAL ERROR: NJOY executable not found at '{NJOY_EXE_PATH}'")
return
if not os.path.exists(ENDF_DIR):
print(f"!!! FATAL ERROR: ENDF directory not found at '{ENDF_DIR}'")
return
# Create output directory
os.makedirs(ACE_DIR, exist_ok=True)
print(f"--- ACE libraries will be saved to: {ACE_DIR} ---")
# Loop through each nuclide
for endf_file, (zaid, name, temps) in NUCLIDES_TO_PROCESS.items():
endf_path = os.path.join(ENDF_DIR, endf_file)
if not os.path.exists(endf_path):
print(f"!!! WARNING: ENDF file not found: {endf_path}. Skipping this nuclide.")
continue
# Loop through each temperature for this nuclide
for temp in temps:
print(f"\n--- Processing {name} at {temp}K ---")
# MCNP/Serpent ACE naming convention: zaid.##c (where ## = temp / 100)
# e.g., 950K -> 09c, 1000K -> 10c
lib_id_temp = int(temp / 100)
ace_id = f"{zaid}.{lib_id_temp:02d}c"
njoy_input_str = NJOY_TEMPLATE.format(
nuclide_name=name,
zaid=zaid,
temp=float(temp),
ace_id=ace_id,
comment=f"Generated by script from {endf_file} at {temp}K"
)
# Use a temporary directory to run NJOY, avoiding file conflicts and leftovers
with tempfile.TemporaryDirectory(prefix=f"njoy_{name}_{temp}K_") as temp_dir:
try:
# 1. Prepare NJOY input files in the temporary directory
# - Create a symbolic link 'tape20' to the ENDF file
os.symlink(endf_path, os.path.join(temp_dir, 'tape20'))
# - Create the NJOY control input file
temp_input_path = os.path.join(temp_dir, 'njoy.inp')
with open(temp_input_path, 'w') as f:
f.write(njoy_input_str)
# 2. Build and execute the NJOY command
command = [NJOY_EXE_PATH]
with open(temp_input_path, 'r') as stdin_file:
result = subprocess.run(
command,
stdin=stdin_file, # Pass the content of njoy.inp as standard input
check=True, # Raise an exception if NJOY returns a non-zero exit code
capture_output=True, # Capture stdout and stderr
text=True, # Process output as text
cwd=temp_dir # Ensure NJOY runs in the temporary directory
)
# 3. If successful, move the generated ACE file to the final directory
output_ace_name = f"{name}-{temp}K.ace" # Use a more readable filename
final_ace_path = os.path.join(ACE_DIR, output_ace_name)
# NJOY's ACER module outputs to tape27 by default
shutil.move(os.path.join(temp_dir, 'tape27'), final_ace_path)
print(f"+++ Successfully generated: {final_ace_path}")
except FileNotFoundError as e:
# Catch file operation errors, e.g., if 'tape27' is not created
print(f"!!! File operation failed: {e}")
print(f"--- Failed on: {name} at {temp}K ---")
except subprocess.CalledProcessError as e:
# If NJOY execution fails, print detailed error information
print(f"!!! NJOY execution failed: {name} at {temp}K")
print("--- NJOY Standard Output (stdout): ---")
print(e.stdout)
print("\n--- NJOY Standard Error (stderr): ---")
print(e.stderr)
# Save the failed input file for debugging
failed_input_filename = f"failed_{name}_{temp}K.inp"
with open(failed_input_filename, "w") as f_err:
f_err.write(njoy_input_str)
print(f"--- Failed NJOY input content has been saved to '{failed_input_filename}' ---")
if __name__ == '__main__':
main()
print("\n--- All tasks completed ---")
And here is the tail end of the output file, showing where it stops:
... (log from MODER is successful) ...
reconr...reconstruct pointwise cross sections in pendf format 0.7s
unit for endf tape ................... -21
unit for pendf tape .................. -22
... (reconr input cards are read correctly) ...
processing mat 9228 in endf-6 format
92-U -235 IAEA EVAL-FEB23 LANL/INDEN Collaboration
resonance range information
ier energy-range lru lrf method
1 1.000E-05 2.250E+03 1 3 normal
2 2.250E+03 2.500E+04 2 2 normal
---message from rdf2bw---calculation of angular distribution not installed.
samm max legendre order: 0
changed threshold from 5.320736E+06 to 5.320737E+06 for mt 16.
... (many similar "changed threshold" messages) ...
changed threshold from 3.588333E+05 to 3.588334E+05 for mt 69.
<-- The log file ends here. No further output. -->
My Question:
Is this a known incompatibility issue? I suspect the solution is to upgrade to a newer version like NJOY21. I'm currently in the process of downloading and compiling it, but I wanted to post this here to confirm if this is the correct path forward and to document the issue for others who might encounter it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm encountering an issue while trying to generate ACE files from the ENDF/B-VIII.0 library using NJOY2016 (version 2016.78). The process fails specifically when the
RECONR
module is processing U-235 (n-092_U_235.endf
).Problem Summary:
The NJOY run stops abruptly after the
RECONR
module starts. Theoutput
file shows thatRECONR
begins processing, prints resonance range information, and reports some threshold changes, but then the log simply ends without any***error***
message. The output file for the next module (tape22
) is created but remains at 0bytes.
This behavior strongly suggests a segmentation fault or a hard crash within the
RECONR
module, likely due to an incompatibility between the older NJOY2016 and the modern ENDF/B-VIII.0 data format for U-235.What I've tried so far:
MODER: 20 -> -21
,RECONR: -21 -> -22
, etc.). Thetape21
fromMODER
is generated successfully.errint = 1.0e-5
) to theRECONR
input card, but this did not solve the crash.Here is the NJOY input I'm using:
Here is the python script I'm using:
And here is the tail end of the
output
file, showing where it stops:My Question:
Is this a known incompatibility issue? I suspect the solution is to upgrade to a newer version like NJOY21. I'm currently in the process of downloading and compiling it, but I wanted to post this here to confirm if this is the correct path forward and to document the issue for others who might encounter it.
Thanks for any insights or confirmation!
Beta Was this translation helpful? Give feedback.
All reactions