OpenMC Guide
Settings Parameters in OpenMC
Understanding Settings
Now that we understand materials and geometry, let's learn how to control our simulations using OpenMC's Settings class.
What Settings Control
- Number of particles
- Type of calculation
- Source definition
- Physics options
Common Uses
- Reactor criticality
- Shielding analysis
- Dose calculations
- Source problems
Basic Settings
Let's start with the most common settings you'll need:
Essential Settings
python
# Create settings
settings = openmc.Settings()
# Basic parameters
settings.batches = 100 # Total batches
settings.inactive = 20 # Initial batches to skip
settings.particles = 10000 # Particles per batch
# Set calculation type
settings.run_mode = 'eigenvalue' # For reactors
# settings.run_mode = 'fixed source' # For shieldingTip: Start with fewer particles/batches for testing, then increase for production runs. More particles = better statistics but longer runtime.
Source Definition
Next, let's define where particles start in our model:
Reactor Source
python
# Source in fuel regions
lower_left = (-10, -10, -10)
upper_right = (10, 10, 10)
source = openmc.Source(
space=openmc.stats.Box(lower_left, upper_right)
)
settings.source = sourceExternal Source
python
# Point source for shielding
source = openmc.Source(
space=openmc.stats.Point((0,0,-50)),
energy=openmc.stats.Discrete([14e6], [1.0])
)
settings.source = sourceAdvanced Options
Physics Options
python
# Energy settings
settings.cutoff = {
'energy': 1.0e-11 # 0.01 eV cutoff
}
# Temperature handling
settings.temperature = {
'method': 'nearest'
}Convergence
python
# Run until error < 0.1%
trigger = openmc.Trigger('std_dev', 0.001)
settings.trigger_active = True
settings.trigger_max_batches = 500Best Practices
Tips for Good Results
- Use enough inactive batches (20-50) for source convergence
- Check convergence with more particles before production
- Save settings to XML with settings.export_to_xml()
- Use triggers for precise error control
- Match source to your problem type