McXtrace logo

McXtrace - An X-ray ray-trace simulation package

Synchrotron SOLEIL DTU Physics


About McXtrace
 Project Partners
 Project People


 Wiki (GitHub)

Mailing list



Code-repository (GitHub)

Report bugs (GitHub)

Old News items

McXtrace 1.5 is released

[25/10/2019] Dear all - The McXtrace team is proud to announce the release of McXtrace version 1.5. The release contains many improvements to computations, model improvements, new components and example instruments, as well as general stability improvements. Head on over to and get yours while it is still hot!

Packages have been built on Debian Stable (10), Centos 7, Mac OS Catalina, and for windows 64 bit. Fedora 29 rpms are also available. Debian and Centos packages are available through our repositories (using apt-get and yum). Mac users should simply be able to download the bundle and drag it to /Applications, following the instructions in the README.

As always - if you experience _any_ problems please don't hesitate to contact the McXtrace team. Either through the mailing list or indeed submit a ticket on the McCode issue tracker on github

CHANGES in 1.5

  1. Standardized reflectivity library, making it much simpler to deal with reflectivity files
  2. The shipped MCPL-library has been updated
  3. Updated and streamlines the installation procedure - such that windows and Mac installs are now (almost completely sandboxed).
  4. New components:
    1. Bragg_crystal (replacing Perfect_crystal)
    2. Bragg_crystal_BC
    3. Laue_crystal_BC
    4. Reflective grating
    5. SAXS_samples series
    6. Attenuating_mask
    7. Phi_monitor: Phase monitor.
  5. Updates to components:
    1. Mirror comp - can now be either in the xz or yz-plane
    2. Virtual option to Mask-component - used to artifically add a 2D-pattern to a subsequent component.
    3. Mirrors now use the reflectivity library
    4. Source_lab: Add Ag as an anode material
    5. Source_lab: Default is now to use lorentzian line-shapes
    6. Undulator: Easier to compile with GSL on windows
    7. PowderN Major improvement in the way incoherent scattering is handled
    8. Monitors: Monitors now have a nowritefile option to dynamically disable monitor (useful if an instrument has a lot of monitors)
    9. PSD_monitor: pixel count can now be set by a variable
    10. PSD_monitor_coh: optionally rays are now treated as if they hit a pixel center. This avoids convoluting the pixel shape in the interference pattern
    11. MCPL: can now encode polarization vector
  6. several new example and updated instruments:
    1. MAXIV_Bloch
    2. MAXIV_DanMax
    3. DBD_IBM_Si_analyzer
    4. PDB_BT
    5. Template_Johann_spectrometer
    6. Updated Test instruments (many of these can be used as examples)
  7. Updates to the GUI - including autoplot options and improved stability of the plotting and display subsystems
  8. Performance improvement to MPI
  9. Better performance on reading datafiles (especially on windows)
  10. Updated manual
... and more

McXtrace 1.4 on Mac OS 10.14 Mojave

It appears that McXtrace can fail to compile the generated c-code on Mac OS 10.14, with an error that math.h cannot be found. A cause for this may be that with the newest release of XCode 10 there is no longer a /usr/include directory by default. See the release notes for more info: X Code 10 Release notes. For now, a package is distributed with XCode 10 that will create /usr/include and its contents:

The release notes state that this package will not be packaged in future releases of XCode. We are working on a long term solution.

McXtrace 1.4: workaround for a python issue on windows 10

[27/11/2017] A reported issue with McXtrace 1.4 and numpy has found a workaround. The procedure below has been reported to work, if when starting an McXtrace simiulation for the GUI, you happen to see error messages complaing about missing dlls and at the end of them (there can be a lot) find something like the following:

File "C:\mcxtrace-1.4\miniconda3\lib\site-packages\numpy\core\", line 14, in 
from . import multiarray ImportError: DLL load failed ...
If this applies to you then you may try this, which has been reported to work:
  1. Move the numpy folder in the miniconda3 folder c:/mcxtrace-1.4/minoconda3/Lib/site-packages/numpy out of the way.
  2. Start a mcxtrace shell session
  3. In the shell, issue the command: pip install numpy

McXtrace 1.4: known bugs

[16/08/2017] A list of known bugs in the McXtrace 1.4 dsitribution. These will be fixed in an upcoming 1.4.1.
  • Lens_parab & Lens_parab_Cyl: A missing 'I' in the header (line 11) trips the intersection algorithm. Fixed in the development tree
  • mxplot-pyqtgraph on windows: An error in a post-install script causes the file c:\mcxtrace-1.4\bin\mxplot-pyqtgraph to have a typo where it says instead of as it should. The mxplot-pyqtgraph script is generated install time - the install procedure has been altered to fix this. For existing systems the simple workaround is to either edit that file in place or to replace it with one from this
  • On windows, if you want to use the Undulator component, you must also install The GNU scientific Library (GSL). It is available from This also implies that you probably need to edit the mcxtrace compiler flags. Go to File->Configure and add something along the lines "-Lc:\mcxtrace\Program Files (x86)\GnuWin32\lib -Ic:\mcxtrace\Program Files (x86)\GnuWin32\include" to the C flags box for mcxxtrace to be find the libraries compile time.

McXtrace 1.4 is released!

[23/06/2017] The McXtrace team is proud to announce that McXtrace 1.4 has finally been released. In the first step packages are made available for debian systems, while the testing trolls do their work on the rpms and windows file to make sure the installation procedure runs as smooth as possible. Fortunately testing trolls do not celebrate Swedish midsummers' eve. New features of 1.4 (pasted from the CHANGES file):
  1. Source_pt, Source_flat, Source_gaussian, and Source_div now behave in the same manner wrt. phase. The relevant parameters are randomphase and phase. If randomphase is !=0 the phase is completely random, if ==0 the value of phase is used.
  2. EPSD_monitor: Has a parameter nE which denotes a number of energy bins. if >1 the monitor will output a number of files. each corresponding to an energy bin.
  3. Lens_parab, Lens_parab_Cyl The functionality of the _rough versions of these components have been merged into the main components and the _rough versions themselves retired.
  4. Support for binary file dump of photons in the mcpl-format is added.
  5. On debian class systems, McXtrace now installs to /usr/share to be more standards compliant.
  6. New Components:
    • sources/Undulator.comp: Undulator model based on Kim, 1989, "Characteristics of synchrotron radiation"
    • samples/Incoherent.comp: Model sample of an incoherent scatterer
    • samples/Polycrystal.comp: Polycrystal sample based on Single_crystal formalism
    • samples/SasView_model.comp: All samples included in the SasModels module of SasView. Currently does not take in absorption into account
    • misc/Air.comp: A "box" full of Air that may scatter.
    • misc/Focus.comp: Adds resampling to any component. I.e. causes the preceding object to become a secondary source.
    • misc/MCPL_input.comp: Interface components to read/write MCPL-format files.
    • misc/MCPL_output.comp
    • monitors/DivE_monitor.comp
    • monitors/DivPos_monitor.comp
    • monitors/Divergence_monitor.comp
    • optics/Bragg_crystal.comp: Superseeds Perfect_Crystal
    • optics/Bragg_crystal_bent.comp: Bent crystal model
    • optics/Capillary.comp: Capillary tube with reflecting walls.
    • optics/Collimator_linear.comp: Ideal collimator models
    • optics/Collimator_radial.comp
    • optics/Mirror.comp: Simple flat mirror component
    • optics/Mirror_toroid.comp: Toroidal mirror
    • contrib/Detector_pn.comp: Detector model with quantum efficiency.
    • contrib/SAXS/SAXSCurve.comp: A set of SAXS-sample models
    • contrib/SAXS/SAXSCylinders.comp
    • contrib/SAXS/SAXSEllipticCylinders.comp
    • contrib/SAXS/SAXSLiposomes.comp
    • contrib/SAXS/SAXSNanodiscsFast.comp
    • contrib/SAXS/SAXSNanodiscsWithTagsFast.comp
    • contrib/SAXS/SAXSNanodiscsWithTags.comp
    • contrib/SAXS/SAXSNanodiscs.comp
    • contrib/SAXS/SAXSPDBFast.comp
    • contrib/SAXS/SAXSPDB.comp
    • contrib/SAXS/SAXSQMonitor.comp
    • contrib/SAXS/SAXSShells.comp
    • contrib/SAXS/SAXSSpheres.comp
  7. Example Instrument simulations:
    • Full model of proposed DanMAX beamline.
    • Pump_probe_solvent: Example of disordered scattering in solution.
    • SAXS_saxlab: Laboratory SAXS setup with Montel optic.
    • template_1Slit_Diff & template_2Slit_Diff: examples of raytracing with coherent interference effects.
    • ESRF_ID01: Microdiffraction beamline with polycrystal sample
    • templateSasView: Example of using the (experimental) SasView interface.
    • ... and various Unit test/Example instruments
  8. New python/Qt based GUI/plotting tool
  9. PowderN: incoherent scattering (computed from tables)
  10. Curved Bragg monochromator crystal, Major improvements to the flat Bragg monochromator crystal
  11. Output in the NeXus-format.
  12. Data files (such as photoelectric absorption spectra) can be read once and reused by other components without further disk IO overhead.

Bug in PowderN.comp

A bug has been found in PowderN shipped with McXtrace 1.2. It results in underestimating absorption substantially. A patch has been commited to the devlopment tree which may be downloaded from PowderN.comp. Thanks to the groups at University College London and Cranfield University for reporting this.

McXtrace Manual

A manual is "under construction". A rough draft version is available here. From now on, we will upload nightly builds of the manuals here: nightlies.

A printed, bound version is planned using a Print-On-Demand scheme.

This is work in progress and may contain significant omissions and inaccuracies but for the interested it may be downloaded here:

The User manual documents the use of the McXtrace system whereas the Component manual details the inner workings of the models employed in the components, in other words the interaction physics between devices and beam.

Art Gallery

We've established a gallery of plots which are beautiful/funnny or otherwise interesting at McXtraceArt. Please take a look and be inspired!

McXtrace 1.2 is released!

Finally McXtrace 1.2 is out. This release focuses on solidifying the models that exists and has greatly improved installation procedure. Packages are now bundled for easy installation. As of day one - packages are built for:
  • Debian class GNU/Linux systems
  • Rpm-based (e.g. RedHat) GNU/Linux systems
  • Windows systems (including 7, 8, and 8.1)
  • Mac OSX 10.10 Yosemite and 10.9 Maverics
Packages for further platforms can be built upon request - forthcoming is also a FreeBSD port. Please report any problems that you may experience to the maintainer. We will deal with all inconveniences ASAP.

Other new features in 1.2 include

  • Interface source components to SPECTRA, Simplex, and GENESIS 1.3.
  • Experimental Bending magnet and Wiggler components
  • Absorption feature added to Molecule_2state sample
  • Several more examples and test instruments

McCode goes github

The McCode-team is happy to announce that we have now moved to using git for version control and consequently also moved the code repository to GitHub. Effective immediately McXtrace (and McStas) code will live on To get a snapshot of the code you may issue the command: git clone, provided you have a github account.

Perl related installation problem on windows

We have lately found that in a few rare cases, there is a problem with the perl tools installation process on Windows 7. If the extra ppds cannot be gathered by the installation script it might be caused by a permission issue in the perl site directory. If you encounter some problem along these lines please make sure that actually have Full control-permissions over the perl directory and its subdirectories. If that didnø't help pleasde donø't hesitate to use the mailing list (or indeed the facebook page)

bugfix patch

We have found a rather serious bug (thank's Carsten) in McXtrace which made the the
keyword generate rubbish photons. A patch file is available here mcxtrace-1.0_num_pars.patch. To apply it do something along the lines.
        cd /usr/local/lib/mcxtrace-1.0
        patch -p1 < /path/to/file/mcxtrace-1.0_num_pars.patch
if you have the patch utility available. N.b. this is fixed upstream.

McXtrace 1.1 Released

We are extremely happy to announce the release of McXtrace 1.1 Just in time for the 3-Codes workshop. This release is based on the well known perl tools while we are testing new solutions for python based plotting tools. Please head over to the download area to get your copy. Happy simulating!

Journal Article Published

A journal article on McXtrace has been published in the June issue of Journal of Applied Crystallography. Please follow this link: Journal of Applied Crystallography, 2013, Volume 46, pages 679-696, to get your copy.

Joint Tutorial Workshop

The McXtrace team are very happy to be a part of the Three-code joint tutorial workshop to be help at the ESRF in the beginning of June 2013. Jointly organized by the maintainers (Manuel Sanchez del Rio, Oleg Chubar and Erik Bergbäck Knudsen) of the simulation software packages SHADOW, SRW and McXtrace, it will give participants hand-on experience with simulation of X-ray instrumentation and experiments. Please see here for more details.

McXtrace 1.1 release candidate 1b

At long last the McXtrace team is proud to present the first public release candidate of McXtrace 1.1. Binary installation packages are available for debian and prm based Linux/Unix distributions, recent Windows (including 8, 7 and XP), and MacOSX (10.8, 10.7, and 10.6). Please download the appropriate version from download area. If you prefer, a source distribution is also available. Among the most major changes are

  • Separated packages for kernel, component libary and tools. This will allow the McXtrace team to repsond quicker to bugs as it allows us to make update release to the component library without packaging a new kernel.
  • A completely revamped build system: We have moved from autotools to CMake - so from source users will have to install CMake (>2.8) on their system. See installation for more details.
  • Several significant changes to the component library:
    1. Updated Source_lab
    2. Chopper_simple
    3. Lens_kinoform
    4. Mirror_parabolic
    5. Twin_KB_ML
    6. EPSD_monitor
    7. Monitor_nD
    8. PreMonitor_nD
    9. W_psd_monitor
    10. Molecule_2state
    11. Shadow_input
    12. Shadow_output

Head to the installation page for details on the various platforms.

As always: If you experience any problems (none are to small) please take a moment and report the problem to the development team either by:

  • reporting your issue in the bug-tracking system @ on the McXtrace/McStas code development site.
  • sending an email to the user mailing list
  • Leaving a note on the McXtrace facebook page McXtrace-facebook
  • By sending an email to

...or alternatively contact the development team People by any other means available to you. We don't mind reports about no problems as well.

Recent publications

At the recent SPIE conference SPIE Optics + Photonics 2011 in San Diego, CA, the following McXtrace related papers were presented and are now available in the coneference proceedings:

  • Advanced simulations of x-ray beam propagation through CRL transfocators using ray-tracing and wavefront propagation methods, Proceedings of SPIE, the International Society for Optical Engineering 2011, Volume 8141, Issue 1, 2011
  • A Monte Carlo approach for simulating the propagation of partially coherent x-ray beams, Proceedings of SPIE, the International Society for Optical Engineering 2011, Volume 8141, Issue 1, 2011
  • McXtrace: A modern ray-tracing package for X-ray instrumentation, Proceedings of SPIE, the International Society for Optical Engineering — 2011, Volume 8141, Issue 1, 2011

McXtrace 1.0

The McXtrace team is very happy to annouce the release of McXtrace version 1.0! It is currently available from the download area for unix-class systems and for Windows. More platforms will come up as soon as the testing team can process them.

Head to the installation page for details on the various platforms.

As always: If you experience any problems (none are to small) please take a moment and report the problem to the development team either:

  • By reporting your issue in the bug-tracking system @ on the McXtrace/McStas code development site.
  • By sending an email to

...or alternatively contact the development team People by any other means available to you. We don't mind reports about no problems as well.

Older releases

The McXtrace team are pleased to announce the availability of installation packages for Linux, MacOSX, and Windows (XP, Vista and 7). Please download the version which suits your needs from: Installation instructions are available on the installation page. If your setup is terminal driven, once installation is completed, you might want to take a look at the man pages for the command line tools available.

Last Modified: Thursday, 20-Jan-2022 13:49:01 CET
Search website mailinglist archive GitHub repos