McStas - A neutron ray-trace simulation package

McStas is a general tool for simulating neutron scattering instruments and experiments. It is actively supported by DTU Physics, NBI KU, ESS, PSI and ILL

Simulated scattering from a hollow-cylinder vanadium sample.

The plot shows the intensity of scattered neutrons (red is highest intensity). The sample is at the center of the sphere with the neutron beam coming from the left. Clearly seen is the shadowing effect of the sample causing a lower intensity opposite the beam. Also seen is the effect of the non-symmetric geometry of the sample, causing lower intensity directly above and to the side of the sample.



Recent news


December 20th, 2020: Experimental Docker image with McStas 3.0 and NVIDIA HPC SDK

Dear all,

Fitting McStas and the NVIDIA HPC SDK in a live-dvd has proven very challenging.

Instead, an experimental docker solution has been made available at https://github.com/McStasMcXtrace/McCode/tree/mcstas-3.0/Docker/mcstas/3.0-fat-with-nvhpc

Minimal usage instructions are available at https://github.com/McStasMcXtrace/McCode/blob/mcstas-3.0/Docker/README.md

More detailed instructions will arrive in 2021.


December 17th, 2020: Ubuntu 20.4 live-dvd with 2.7 and 3.0 releases.

Dear all,

At http://livedvds.mcstas.org a Ubuntu 20.04 live system, pre-loaded with McStas 2.7 and 3.0 has been uploaded.

Here are some tips:

An alternative version including McStas 3.0 only, and loaded with the NVIDIA HPC-SDK is in preparation.


December 15th, 2020: McStas 3.0 release!

Dear all,

McStas, v. 3.0, our next-generation code generator and support for NVIDIA GPU's via OpenACC has been built and is ready for download!

Download and installation instructions are available via our GitHub download pages.

Selected highligts from the release are listed below. The full list of changes is also available at http://mcstas.org/CHANGES_McStas.

Thanks:

  • Thanks to all members of the joint McStas-McXtrace team, you guys ROCK!
  • A special thanks to Jakob Garde who has continued to contribute (unpaid!) to the 3.0 efforts even after leaving DTU.
  • Thanks to Guido Juckeland (HZDR,DE) and Sebastian Alfthan (CSC,FI) who were behind the GPU Hackathons we participated in
  • Thanks to our NVIDIA mentors Vishal Metha, Christian Hundt and Alexey Romanenko

    Main new features and changes:

    1. New code-generation scheme based on functions instead of #defines, which brings
      • Much improved compilation-times, the code is better suited for modern compilers
      • In most cases a speed-up of order 20%
      • The neutron _particle is now represented by a struct
      • The component types and instances are also represented by structs
      • In the generic TRACE function of a given component type, the _comp var is short-hand for "whatever the component instance is"
      • New instrument section of USERVARS %{ double example_flag; %} which enriches the _particle struct
      • In component DECLARE blocks, assignments can no longer be done and all declarations must be listed independently, i.e double a; is OK, double a,b; is not. Variables in this scope are automatically so-called "OUTPUT PARAMETERS" (we may deprecate that keyword completely for the official McStas 3.0 release)
      • Components no longer support DEFINITION PARAMETERS, instead the SETTING PARAMETERS must be used, which now includes a vector and string type supplementing the (default) double/MCNUM and int types.
      • Further, the new cogen implements support for Nvidia GPU's, for details see point 2 below.
    2. Support for OpenACC acceleration on NVIDIA GPU's on Linux systems
      • #pragma driven, inserted by the code-generation, but also implemented in libs and comps
      • Speedups measured using top-notch NVIDIA V100 datacenter cards are in the range of 10-600 with respect to a single-core of a modern CPU, see the figure in the below link. It was generated for an "ideally" parallel instrument.
      • Platform support / compiler configuration:
        • Required compiler for GPU/OpenACC: NVIDIA HPC SDK 20.x or newer. Community edition works fine
        • Required GPU hardware: NVIDIA Tesla card + configured driver
        • Windows: At this point UNSUPPORTED for GPU/OpenACC since NVIDIA does not yet ship a package for this platform. Support should come with WSL 2.0 or via native support from NVIDIA.
        • macOS: At this point UNSUPPORTED for OpenACC since NVIDIA does not ship a package for this platform.
        • Linux: Full acceleration support with GPU, and with CPU/multicore.
      • Install the compiler and put it on your system PATH. Install and configure Nvidia drivers for your card.
      • We hope that GCC will offer better support for OpenACC in the near future.
      • Tool support
        • On Linux and macOS mcrun is preconfigured so that mcrun -c --openacc compiles with:
        • Linux: nvc -ta:tesla,managed,deepcopy -DOPENACC
        • Linux: You may configure for use on CPU/multicore via: nvc -ta:multicore -DOPENACC
        • The --funnel option can be used to launch the FUNNEL simulation flow, see description below.
        • For both of the above, adding -Minfo:accel will output verbose information on parallelisation
        • In mcgui, the mcrun --openacc configuration can be selected via the preferences
        • Both mcgui and mcrun allow combining --openacc and --mpi if you have multiple GPU's available. The n'th mpi process will attempt to use the k'th GPU, where k = #available GPU's % #MPI nodes.
    3. Special McStas 3.0 grammar for mixed CPU/GPU mode:
      • A "FUNNEL" mode has been added, which allows
        • Mixed GPU/CPU mode, were sections of the instrument are executed on each device type, with copying of neutron-bunches back and forth.
        • When this instrument grammar is specified, it signifies that the component should be executed on CPU rather than GPU. CPU SPLIT 10 COMPONENT Sample = Something()
        • Sections before and after that are not marked CPU will be executed on GPU.
        • If a component includes the NOACC token in the component header, the CPU-mode is forced through the compilation, as it signifies that the component does NOT support GPU. This is for the time being the case for Union_master. (Support is expected to come with McStas 3.1)
    4. Interoperability with McStas 2.7
      • Support for MCPL event interchange has been added through MCPL_input and MCPL_output components, that work both on CPU and GPU for McStas 3.0. Note however that targeting GPU, MCPL_input reads ALL particle events durin INITIALIZE and MCPL_output writes ALL particle events during SAVE, whereas when using CPU in 3.0 or 2.7, reads and writes happen during the TRACE flow.
    5. Known limitations
      • The Union subsystem works on CPU only for now, but can be used in the mixed GPU/CPU funnnel mode as mentioned above. Union_master is a NOACC component.
      • The same solution is applied in use of the NCrystal_sample and will eventually come for Sample_nxs.
      • Not all features of all components correspond to those from McStas 2.7, but all essential components have beenfully ported from the 2.7 tree to the 3.0 tree. Hence, some parts distributed with McStas 2.7 will either not exist in the 3.0 release or may not function, due to either: (1) very specialised features (2) maintainability issues or (3) use ofcomplex algorithms.
      • Generally, most components/instruments are now ported to our OpenACC based GPU-technology, but you likely may find combinations of use that slipped through our not fully exhaustive test-suite. Missing support may come in the form of either
        • Code that does not compile
        • Instruments that segfaults during execution
        • Instruments or components that produce obscure results
      • At the time of release, the nightly tests show that
        • McStas 3.0 ships with 211 instruments that succesfully compiles
        • These instruments use 147 of our components
      • We don't ship an updated set of manuals for McStas 3.0, but essential documentation is available on the McCode GitHub wiki
    We hope you will enjoy this new release!!!


    December 12th, 2020: Scheduled downtime for McStas webserver on December 14th

    The McStas webserver will be down during Monday December 14th as it is being migrated to a new server.


    December 12th, 2020: Getting ready for McStas 3.0

    We are closing in on the McStas 3.0 release, with support for NVIDIA GPU's using the nvc compiler and OpenACC.

    To give you an idea of what to expect, here is a small demo video where an 1e9 run of ILL_IN5 is executed on 8 x NVIDIA GeForce 1080 and 8 x Intel(R) Xeon(R) CPU E5-2687W:

    Demo video (4:22 min, hosted at media.mcstas.org)


    December 4th, 2020: NCrystal-package available on CentOS

    Dear all,

    The mcstas repo has been updated with an NCrystal-package which was missing in the CentOS package set from last Friday. To install it, please run:

    yum install mcstas-ncrystal-2.7

    As a bonus, the RPM package contains the newly released NCrystal 2.2.1 relase.


    November 27th, 2020: McStas 2.7 release!

    Dear all,

    A new release of McStas, v. 2.7 has been built and is ready for download!

    Download and installation instructions are available via our GitHub download pages.

    Selected highligts from the release are listed below. The full list of changes is also available at http://mcstas.org/CHANGES_McStas.

    (A small PS: Our build for CentOS will lack NCrystal for the time being, there are some issues compiling. Talks have been initiated with the NCrystal authors and the missing RPM is expected during next week.)

    Changes in McStas v.2.7, November 27th, 2020

    We hope you will enjoy this new release!!! (And keep an eye out for 3.0, it is almost also there...)


    October 2nd, 2020: McStas presentation from the 2020 OpenACC summit now online

    Dear all,

    The McStas presentation from the OpenACC summit is now online on YouTube.

    OpenACC (see https://www.openacc.org) is a high-level, compiler-driven approach to GPU-acceleration, and in the video McStas team tech-lead Peter Willendrup gives an overview about neutron scattering, McStas and how the team is porting the code to Nvidia GPU's.

    Have a look at https://www.youtube.com/watch?v=HDU-WRJUZXs&feature=youtu.be


    September 10th, 2020: Multi-GPU support in McStas 3 code tree

    For Linux systems with multiple Nvidia GPU's the McStas team now has a solution, based on MPI and OpenACC. The images below show 8 NVIDIA GeForce 1080 running BNL_H8 in parallel and profiling-output in NVIDIA Nsight Systems:

    8 gpus shown running using nvidia-smi8-gpu profiling output

    The plan is to release either another beta or the first "real" McStas 3.0 before the end of 2020.


    August 24th, 2020: macOS 11.0 Big Sur beta, hold your horses...

    The McStas team has tested the current 2.6.1 release on the beta, and lots of stuff is broken on Big Sur...

    We are aware that getting the freshest or forthcoming version of macOS can be tempting, but please wait for an updated McStas release if you aim to do any work with McStas... :-)


    May 26th, 2020: Experimental McStas 2.6.1 and McXtrace 1.5 dockers

    The combined McStas and McXtrace team have started experimenting with using Docker's for deployment. The advantage is simplified installation and a uniform look and feel / functionality across platforms.

    If you feel like giving our experimental docker solutions a spin, have a look at https://github.com/McStasMcXtrace/McCode/blob/master/Docker/README.md


    May 4th, 2020: McStas 2.6.1 released

    Dear all,

    A new minor-release of McStas, v. 2.6.1 has been built and is ready for download!

    Download and installation instructions are available via our GitHub download pages.

    The release adresses a few bugs found in the 2.6 release, see the related issue list at GitHub, but is in terms of features and functionality almost identical to 2.6.

    Best
    Peter Willendrup


    April 28th, 2020: McStas 2.6 on Ubuntu 20.04

    Dear all,

    I have tried out the McStas 2.6 release on the fresh Ubuntu 20.04 release, and my findings are these:

    A new minor release 2.6.1 is on the way, implementing a few bugfixes, see our GitHub issue tracker for more information.

    Best regards,
    Peter Willendrup


    February 27th, 2020: McStas 3.0beta bugfixes etc


    February 25th, 2020: McStas 3.0beta technology preview available!

    Dear all,

    A technology preview for the forthcoming McStas 3.x series is now available for testing!

    Main highlights of the release are:

    For more details and instructions, please refer to this document on our Wiki

    Thanks to:


    January 24th, 2020: McStas 2.6 release!

    Dear all,

    A new release of McStas, v. 2.6 has been built and is ready for download!

    Download and installation instructions are available via our GitHub download pages.

    Selected highligts from the release are listed below. The full list of changes is also available at http://mcstas.org/CHANGES_McStas.

    Changes in McStas v.2.6, January 24th, 2020

    - Most other new datafiles are directly related to component- or instrument-additions and have been mentioned above.

    We hope you will enjoy this new release!!!


    Previous news items: 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998.