McStas logo McStas - A neutron ray-trace simulation package ILL; PSI; ESS Niels Bohr Institute DTU Physics

McStas

About McStas
 Conditions of use
 Authors/Contacts
 Project funding

Download
 Components
 Other Downloads (share)

Mailing list

Search web/mailinglist

Documentation
 Wiki (GitHub)
 McStas manual
 Publications

Links

Report bugs (GitHub)

Code-repository (GitHub)


McStas: Inhomogenous_incoherent_process

[ Identification | Description | Input parameters | Links ]

The Inhomogenous_incoherent_process Component

A sample component to separate geometry and phsysics

Identification

  • Site:
  • Author: Daniel Lomholt Christensen
  • Origin: University of Copenhagen
  • Date: 26/01/2026

Description

This Union_process is based on the Incoherent_process.comp component
originally written by Mads Bertelsen inspired by Kim Lefmann and
Kristian Nielsen

Part of the Union components, a set of components that work together and thus
sperates geometry and physics within McStas.
The use of this component requires other components to be used.

1) One specifies a number of processes using process components like this one
2) These are gathered into material definitions using Union_make_material
3) Geometries are placed using Union_box / Union_cylinder, assigned a material
4) A Union_master component placed after all of the above

Only in step 4 will any simulation happen, and per default all geometries
defined before the master, but after the previous will be simulated here.

There is a dedicated manual available for the Union components

Algorithm:
The general algorithm for the Union system is described elsewhere.

I here give a brief introduction as to what changes occur when using an
inhomogenous process in your Union make material. It is expected that you
understand the basic algorithm of the Union system before reading this.

In Union, the neutron moves through a network of objects in a 3 dimensional world.
When the neutron hits a material, the probability to scatter is calculated,
and a Monte Carlo choice is taken, as to whether that neutron should scatter,
or pass through. For a homogenous material (i.e constant attenuation coefficient $\mu$),
this probability is the Beer-Lambert law,

$P_s = 1 - e^{-\mu l}$
Where $P_s$ is the scattering probability, and $l$ is length of the neutron path throughout the object. For an inhomogenous material, this Beer-Lambert law must be modified, as $\mu$ is a function of the position. Therefore the Beer-Lambert law becomes,
$P_s = \int^l_0 1 - e^{-\mu(l')l'}dl'$
Calculating this $\mu$ in the inhomogenous case is often trivial, but not feasible, from a software development point of view (seeing as many different functions of $\mu$ might be wanted). Instead the inhomogenous processes performs an approximate integral, by evaluating $\mu$ at a number of points along the neutron path (This number is in fact number_of_sample_points). For this incoherent process, the linear attenuation coefficient is,
$\mu = pack/V_u * 100 * \sigma$
Where $pack$ is the packing factor of the material (defaults to 1), $V_u$ is the Unit cell volume, and $\sigma$ is the scattering cross section in barns. $\mu$ therefore has units of $m^{-1}$. For this component each factor in the attenuation coefficient can be a "tiny expression". This means that it can be a mathematical equation such as $\sigma_{expr} = "5.08 + 1000 * z * 2.35"$. When the attenuation coefficient is calculated, then the current value of $z$ is used to get $\sigma$. The parameters that the tiny expression can rely upon are currently: The positions, $x, y, z$ The velocities $vx, vy, vz$ and the time $t$ McStas uses a sligthly modified version of tiny expressions that evaluate exponentials from right to left instead of the standard left to right. Furthermore McStas has added two functions to tiny expressions. These are: A heavy side function hvs(variable, switch_point, large_val,small_val) which returns large val if variable > switch_point and small val otherwise. A gaussian distribution: gauss(A,sig,x), which evaluates to A*1/sqrt(2*PI)/sig*exp(-x^2/2/sig^2) An example using these can be found in the Test instrument for this component, called Test_inhomogenous_process.instr. Example #9 implements a gaussian and a heavyside function. For more information on tiny expressions, see the link below.

Input parameters

Parameters in boldface are required; the others are optional.
NameUnitDescriptionDefault
sigmabarnsIncoherent scattering cross section0
sigma_exprstringTiny expression to be calculated as replacement for sigma""
packing_factor1How dense is the material compared to optimal 0-11
packing_factor_exprstringTiny expression to be calculated as replacement for packing factor""
unit_cell_volumeAA^3Unit cell volume0
unit_cell_volume_exprstringTiny expression to be calculated as replacement for the unit cell volume""
gammameVLorentzian width of quasielastic broadening (HWHM) [1]0
gamma_exprmeVTiny expression to be calculated as replacement for the gamma value.""
f_QE1Fraction of quasielastic scattering (rest is elastic) [1]0
number_of_sample_points1Number of points that are sampled along the neutron path through a material20
interact_fraction1How large a part of the scattering events should use this process 0-1 (sum of all processes in material = 1)-1
verbose1Flag that prints out the values calculated in the cross section calculation0
initstringname of Union_init component (typically "init", default)"init"
AT ( , , ) RELATIVE
ROTATED ( , , ) RELATIVE

Links


[ Identification | Description | Input parameters | Links ]

Generated on mcstas 3.7.1


Last Modified: Friday, 22-May-2026 09:47:08 CEST
Search website mailinglist archive GitHub repos