Hello,
I am using OpenMC version 0.15.0 with Docker in a Ubuntu environment.
I am trying to run a simulation with the following input script:
import openmc
import os
import sys
# --- Configure log file ---
log_file_path = "/home/dexcs/openmc_simulation/openmc.log"
sys.stdout = open(log_file_path, 'w')
sys.stderr = sys.stdout # Redirect stderr to the same log file
print("[INFO] Logging enabled, writing output to 'openmc.log'")
# --- Set environment variable ---
cross_section_path = "/root/nndc_hdf5/cross_sections.xml"
print(f"[INFO] Setting OPENMC_CROSS_SECTIONS to {cross_section_path}")
if not os.path.exists(cross_section_path):
print(f"[ERROR] Cross sections XML file '{cross_section_path}' does not exist.")
sys.exit(1)
os.environ["OPENMC_CROSS_SECTIONS"] = cross_section_path
print("[INFO] OPENMC_CROSS_SECTIONS set successfully.")
# --- Geometry ---
print("[INFO] Defining geometry...")
surface_1 = openmc.XPlane(x0=-150.0, boundary_type='vacuum')
surface_2 = openmc.XPlane(x0=150.0, boundary_type='vacuum')
surface_3 = openmc.YPlane(y0=-150.0, boundary_type='vacuum')
surface_4 = openmc.YPlane(y0=150.0, boundary_type='vacuum')
surface_5 = openmc.ZPlane(z0=-150.0, boundary_type='vacuum')
surface_6 = openmc.ZPlane(z0=150.0, boundary_type='vacuum')
region = -surface_1 & +surface_2 & -surface_3 & +surface_4 & -surface_5 & +surface_6
cell = openmc.Cell(region=region)
# --- Materials ---
print("[INFO] Defining materials...")
material = openmc.Material()
material.set_density('g/cm3', 1.0)
material.add_nuclide('H1', 2.0, 'ao') # Hydrogen
cell.fill = material
geometry = openmc.Geometry([cell])
materials = openmc.Materials([material])
# --- Settings ---
print("[INFO] Configuring settings...")
settings = openmc.Settings()
settings.run_mode = 'fixed source'
settings.batches = 20 # Reduced number of batches for debugging
settings.inactive = 5 # Inactive batches for initial convergence
settings.particles = 100000 # Increased number of particles
# --- Source Configuration ---
print("[INFO] Configuring source...")
source = openmc.IndependentSource()
source.space = openmc.stats.Box(lower_left=(-50.0, -50.0, -50.0), upper_right=(50.0, 50.0, 50.0))
source.energy = openmc.stats.Uniform(a=1e-3, b=20.0e6) # 0.001 eV to 20 MeV
source.angle = openmc.stats.Isotropic()
settings.source = source
# --- Export to XML ---
print("[INFO] Exporting XML files...")
try:
geometry.export_to_xml()
print("[INFO] geometry.xml exported successfully.")
materials.export_to_xml()
print("[INFO] materials.xml exported successfully.")
settings.export_to_xml()
print("[INFO] settings.xml exported successfully.")
except Exception as e:
print("[ERROR] Failed to export XML files:", str(e))
sys.exit(1)
# --- Run OpenMC Simulation ---
print("[INFO] Running OpenMC simulation...")
try:
openmc.run()
print("[INFO] OpenMC simulation completed successfully.")
except Exception as e:
print("[ERROR] OpenMC simulation failed:", str(e))
sys.exit(1)
# --- Close log file ---
sys.stdout.close()
However, no matter how I adjust the geometry, I always encounter the following error:
Simulating batch 1
ERROR: More than 95% of external source sites sampled were rejected. Please check your external source's spatial definition.
...
Abort(-1) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -1) - process 0
I initially suspected inappropriate nuclear data, so I manually downloaded a separate dataset and mounted it. However, even after mounting, the new dataset is not reflected in the simulation.
(For now, I am fine with using the default nuclear data as long as the simulation runs correctly.)
Could anyone help me resolve this issue?
Thank you in advance for your support!