McStas (web) is a general tool for simulating neutron scattering instruments. It is based on a compiler that reads a high-level specification language defining the instrument to be simulated and produces C code that performs the Monte Carlo Simulation. This makes it very fast, typical figures are 500000 neutron histories per second on a fast PC.
It is common to test calculations in more than one software to check their validity; an alternative to McStas is Vitess.
McStas shares codebase with its X-Ray analogous, McXtrace, with a similar syntax.
It is recommended to install McStas with miniforge. Once miniforge is installed, create a conda environment and install McStas:
conda create --name mcstas
conda activate mcstas
mamba install mcstas
To use McStas in HPC clusters like Hyperion, it should be installed in the /scratch folder.
Replacing gila
by your own username,
module load Python
conda create --prefix /scratch/gila/.conda/envs/mcstas
conda activate /scratch/gila/.conda/envs/mcstas
conda install mamba --channel conda-forge
mamba install mcstas
Once installed, it can be accessed anytime as
module load Python
conda activate /scratch/gila/.conda/envs/mcstas
McStas comes with a comprehensive library of well-tested components that include most standard elements of neutron scattering instruments. New components are constantly created by the community.
- McStas components documentation
- Shared useful files for McStas used to simulate ISIS or ESS instruments
The ESS workflow using McStas is presented in the ESS DMSM Summer School. Neutron sources can be imported as MCPL files from other MC codes, such as PHITS. Then we can use the McStasScript Python API to create the instruments easily.
- McStasScript Python API to make things easier
- MCPL file format to transfer data between different Monte Carlo applications
- ESS DMSM Summer School. Great tutorial with the ESS workflow, from McStas calculations to data analysis with Scipp
- McStas and McXtrace schools. Repo with learning material from past schools
- McStasScript-notebooks. Tutorial with McStasScript quizzes
- Neutron scattering and McStas learning exercises. Following Kim Leffman's notes