MCNP Guide
Basic Optimization
What you'll learn
- Decide whether a problem is worth optimizing before optimizing it, using the figure of merit.
- Step cell importances up through a shield by factors of two to four, reserving
imp:n=0for the graveyard cell. - Aim a source with
VECandDIR, and say why editingSPalone changes the physics rather than biasing the sampling. - Apply
CUTwhere it saves time, and say where a neutron energy cutoff would destroy the answer instead.
Before you start
What optimization is for
Every technique on this page does the same thing: it moves computational effort toward the histories that contribute to the tally and away from the ones that do not. None of them makes MCNP faster in any general sense, and none of them changes the answer — a correct variance reduction scheme leaves the expected value untouched and only shrinks the spread around it.
That last property is also the trap. A scheme that is subtly wrong will still produce a number with a small error bar, and the error bar will not tell you. This is why the figure of merit is the measuring instrument here: it is 1/(R²T), so it already accounts for the time you spent, and comparing the FOM before and after a change tells you whether the change helped. A change that improves the error only because the run took longer will not move the FOM at all. Judge every technique below by the FOM, and confirm the mean did not shift by more than its own uncertainty.
The problems that need this are the ones with a large attenuation between the source and the tally: a thick shield, a small detector far away, a deep penetration through a duct. In such a problem the fraction of unbiased histories that ever reach the tally can be 10⁻⁶ or smaller, which no amount of running will fix. A well-converged reactor pin cell, by contrast, needs none of this. If an analog run already gives you a stable FOM and the error you need, adding variance reduction is a way to introduce a bug for no gain.
Cell importances
Geometry splitting with cell importances is the oldest variance-reduction method in MCNP and still the first one to reach for, because it needs no new cards — only an imp:n entry on cells you already have.
When a particle crosses from a cell of importance 1 into a cell of importance 2, MCNP splits it into two particles of half the weight each. Crossing the other way, it plays Russian roulette: the particle survives with probability 1/2 and its weight doubles if it does. The total weight is conserved in both directions, which is why the tally mean is unaffected. What changes is the population — more particles, each carrying less weight, in the region you declared important.
c Concrete shield in four layers, importance doubling outward
1 1 -2.35 -1 imp:n=1 $ Source region
2 1 -2.35 1 -2 imp:n=2 $ First layer
3 1 -2.35 2 -3 imp:n=4 $ Second layer
4 1 -2.35 3 -4 imp:n=8 $ Third layer
5 0 4 -5 imp:n=8 $ Detector region — same as the layer
6 0 5 imp:n=0 $ Graveyard
c Surfaces
1 so 10 $ Inner sphere
2 so 20
3 so 30
4 so 40
5 so 50 $ Outer boundaryThe step size is the whole art, and the rule is to compensate for attenuation rather than to pick round numbers. Aim for roughly one doubling per factor-of-two loss in flux, which in practice means one step every mean free path or two. Factors of two to four per cell are safe; a jump of ten or more produces a swarm of very low-weight particles that consume time without adding information, and the tell is a figure of merit that falls when you increase the splitting.
Two conventions matter more than they look. Importance zero means the particle is killed, so it belongs on the graveyard cell that covers the complement of the geometry and nowhere else — an imp:n=0 on an interior cell is a hole that silently swallows particles. And the cell holding the tally should carry the same importance as its neighbors, since splitting a particle on the way into the detector adds correlated scores rather than independent ones.
Setting importances by hand stops scaling somewhere around a factor of 10⁴ in total attenuation. Past that, use the weight-window generator to derive them from the problem instead of guessing, which variance reduction covers.
Aiming the source, and biasing it
If the tally is in one direction and the source emits in all of them, most histories are wasted before their first collision. MCNP separates two different remedies here, and confusing them is the most common source-card mistake in the language.
The first is to describe a source that really is directional. VEC gives a reference axis and DIR gives the distribution of the cosine about it, so a narrow DIR distribution is a beam. This is a statement about the physical source, and it changes the problem.
c A source that physically emits mostly toward +x
SDEF PAR=n POS=0 0 0 ERG=14
VEC=1 0 0 $ Reference axis
DIR=D1 $ Cosine about that axis, from distribution 1
SI1 -1 0.9 1 $ Two cosine bins: -1 to 0.9, and 0.9 to 1
SP1 0 0.1 0.9 $ 10% of particles in the wide bin, 90% in the narrow oneThe second is to sample a source non-uniformly while keeping it physically unchanged, by compensating with particle weight. That is what SB is for. SP states the true probabilities; SB states the probabilities MCNP should actually sample from, and each source particle's weight is adjusted by the ratio of the two so that the sampled population still represents the true source. The answer is unchanged and the variance is lower.
c An isotropic source, sampled preferentially toward +x
SDEF PAR=n POS=0 0 0 ERG=14 VEC=1 0 0 DIR=D1
SI1 -1 0.9 1
SP1 0 0.95 0.05 $ The truth: isotropic, so 5% of solid angle
SB1 0 0.1 0.9 $ Sample it 90% of the time, and weight accordinglyThe distinction is easy to state and easy to get wrong: editing SP models a different source, while adding SB models the same source more cleverly. If you meant an isotropic source and you sharpened SP, you have quietly answered a different question, and every tally in the deck will be wrong by the ratio of the solid angles.
Cutoffs, and the reactor problem they ruin
A particle that can no longer affect the tally still costs time to track. The CUT card discards them below a chosen energy or after a chosen time. Its entries are time, then energy, then two weight-cutoff values, and J jumps an entry to leave it at its default.
c 14 MeV shielding problem: photon transport below 1 keV is not worth tracking
MODE n p
CUT:n J 0.01 $ time default; kill neutrons below 10 keV
CUT:p J 0.001 $ time default; kill photons below 1 keVA photon cutoff around a keV is nearly always safe, because a photon that low deposits its energy essentially where it is and travels no distance worth resolving. A neutron cutoff is a different matter entirely.
The 10 keV neutron cutoff above is defensible in a fast-neutron shielding problem where the tally responds to MeV neutrons. Put it in a thermal reactor deck and the calculation is destroyed: fission in U-235 is driven by neutrons near 0.025 eV, which is six orders of magnitude below that cutoff. Every neutron would be killed during slowing down, before it could cause the fission that the eigenvalue is made of.
A neutron energy cutoff is only ever appropriate when you can state what response function you are protecting and show it is negligible below the cutoff. In a thermal system, there is no such energy.
The same caution applies in weaker form to the weight cutoffs, which kill low-weight particles by roulette. They interact with the importances above — a particle split down to a tiny weight can be rouletted away immediately, wasting the split. MCNP's defaults are tuned to work with cell importances; changing both at once is how a scheme becomes hard to debug.
Working order
Optimize in the order that keeps the answer verifiable. Get an analog run to complete first, however poor its statistics, and record its mean, error, and FOM — that is the reference against which everything else is judged, and it is the only run in the sequence you know to be unbiased.
Then add one technique at a time, starting with cell importances since they are the easiest to reason about. After each change, check that the FOM improved and that the mean has not moved by more than its uncertainty. A mean that shifts is not a better estimate — it is evidence that the scheme is biased, or that the original run had never sampled the paths the new one is finding. Either way it is a result to investigate rather than to accept.
Card semantics on this page follow MCNP6.3.1 Theory & User Manual (LA-UR-24-24602 Rev. 1), §5.12.1 IMP: Cell Importance, §5.8.4 SB: Source Bias and §5.7.4 Physics Cutoffs (CUT, ELPT).
Full reference list on the attribution page.
Check yourself
- Use the figure of merit to decide whether a variance-reduction change helped?
- Step importances up through a shield, and say why
imp:n=0belongs only on the graveyard? - State the difference between editing
SPand addingSB? - Say why a 10 keV neutron cutoff is reasonable in a shielding deck and fatal in a reactor deck?