Skip to content

Releases: mctools/ncrystal

NCrystal release 4.0.0

10 Feb 15:17
Compare
Choose a tag to compare
  • This milestone release primarily brings new supported user platforms and a huge restructuring of the environment in which NCrystal is developed and tested. In addition, it also brings many minor fixes, and an updated and improved infrastructure for NCrystal plugins.
  • As the perhaps biggest user-visible feature, NCrystal now also supports usage on Windows! This support is NOT considered experimental, and Windows users can now install the "ncrystal" package via tools like pip and conda and expect the same features on both the command-line and in the Python/C/C++ APIs as Unix users have had in the past. Of course, there might be bugs or issues to iron out, so please help us test out the new release on Windows and file issues at https://github.com/mctools/ncrystal/issues as appropriate!
  • As another user-visible feature, it is now possible to install optional NCrystal plugins via a simple "pip install", and have NCrystal automatically and seamlessly pick up and load the plugin. We are currently putting together a curated list of known plugins, and in the near future we will provide an overview of these on the Wiki. As a quick preview teaser, try to do "pip install ncrystal-plugin-WaterData" and notice how "nctool --browse" suddenly shows a large list of NCMAT data files for light and heavy water at different temperatures. These files were in the past deemed too large for the NCrystal standard data library, but can now be easily made, without the need for manual download.
  • In addition to Windows support, the NCrystal code-base has also been updated to support a variety of other compilers and other dependencies. This notably includes support for the Intel OneAPI compilers, but also latest gcc and clang, C++20, Python 3.13, Numpy 2, and of course Microsoft VisualStudio. Drop support for Python 3.6 and 3.7.
  • As part of the efforts to make NCrystal command-line tools easily work on Windows, the various commandline tools of NCrystal (nctool, ncrystal_cif2ncmat, ncrystal_hfg2ncmat, etc.), are now better integrated into the NCrystal Python API. As a result they can be invoked directly in the Python API (i.e. without the need for subprocess calls invoking a shell command), via the new NCrystal.cli Python module. For instance, NCrystal.cli.run('nctool','--dump','Al_sg225.ncmat') will have the same effect as invoking "nctool --dump Al_sg225.ncmat" at the command line. One notable difference is that the code will run in the same process, meaning that any virtual files registed in memory will also be available to these tools.
  • NCrystal packaging was updated. Users should still simply install a package from PyPI or conda-forge named "ncrystal", but behind the scenes, the formerly monolithic package named "ncrystal" has been split into three packages: "ncrystal-core", "ncrystal-python", and a metapackage called "ncrystal". The ncrystal-core package contains everything needed for those only needing C/C++ APIs: The binary file library (named libNCrystal.so, libNCrystal.dylib, or NCrystal.dll+NCrystal.lib depending on your platform), the NCrystal C++/C header files, the ncrystal-config command, and the CMake configuration files. Included in ncrystal-core (actually embedded in the binary library) is also the standard data library of NCMAT files. The "ncrystal-python" package contains the NCrystal python module, and all the many command-line tools (except for ncrystal-config). Finally, the package named "ncrystal" is simply a meta-package which depends on both "ncrystal-core" and "ncrystal-python", and ensures that they will be installed in compatible versions.
  • The ncrystal repository at https://github.com/mctools/ncrystal is now finally maintained like any other open source project, with good CI and testing coverage, ready to accept PRs, and so on. This actually marks a VERY large change in the NCrystal project since the code has until now, and for historical reasons, actually been developed and tested in an in-house repository at the European Spallation Source's DMSC, nested in a Unix-only build and testing framework (https://mctools.github.io/simplebuild/). The code was then exported to the ncrystal repository at github when ready for a new release, through the usage automated scripting which reformatted the code as appropriate. Although this was a useful mode of development in the early days of the project, it is needless to say that this has long been a burdensome way of working, precluding meaningful usage of pull requests and other open source workflows at GitHub. From now on, the ncrystal repo at GitHub is the true upstream source of NCrystal code, and it also includes a large number of tests which can be invoked via CTest or the simple-build-system.
  • The Python and cmdline API should be mostly unchanged by this release, and likewise the C++ and C APIs are mostly the same, although a few container classes were modified to support Microsoft and Intel compilers. Notably, many header file locations were modified, but code sticking to including "NCrystal/NCrystal.hh" and "NCrystal/ncrystal.h" should be safe (it is henceforth recommended to only include those files, since the location of other files might change. The C++ interface of NCrystal4 is NOT ABI compatible with earlier versions of NCrystal, and will require recompilation of downstream code. Code only using the C-API in "NCrystal/ncrystal.h" would on the other hand be ABI compatible.
  • The new "ncrystal" PyPI package now comes with optional dependencies listed. At the time of writing this is: "plot" which installs dependencies required by various plotting functions in the NCrystal cmdline tools or Python API (currently this is just matplotlib), "composer" which installs dependencies required for usage of the NCMATComposer (currently this is just spglib), "cif" which installs dependencies required for reading and processing CIF files (currently this is gemmi, spglib and ase), Finally, the "all" dependencies combines all of the above, so doing pip install "ncrystal[all]" should ensure that users will not encounter missing dependencies when using the NCrystal Python or cmdline APIs. Another category, "devel", is intended for NCrystal developers and CI pipelines, and adds additional packages needed for such work.
  • Keeping in line with general trends at github, the default branch of the ncrystal repository is named main rather than master, from this point on. For a little while we will try to keep the master branch alive, in case of any hardwired usage of the branch name "master" somewhere, but this will not be the case for long. This change does not, however, change the fact that we will in general try to keep default branch (now: main), synchronised with the main release (apart possibly from minor documentation and CI fixes), and keep the "develop" branch as the main branch to target with pull requests between releases. NOTE: Any local clones of the ncrystal code repository should be updated to reflect this change. If there is no local interesting content in the clone, one option is to remove the local clone and get a fresh one from github. Otherwise, GitHub advices the following four commands to "repair" your local clones (experts only):
    git branch -m master main
    git fetch origin
    git branch -u origin/main main
    git remote set-head origin -a
  • Added a new ncrystal_mcstasunion command-line script which is to be used instead of calling 'python -mNCrystal.mcstasutils --union'.
  • The NCrystal-Geant4 bindings are moved out of the NCrystal repository and into https://github.com/mctools/ncrystal-geant4 . Note that at the time of this release, this migration is still work in progress and not complete yet. Anyone needing NCrystal and Geant4 are recommended to use NCrystal release 3.9.7 as a short term workaround.
  • For more details, refer to the CHANGELOG.

NCrystal release 3.9.7

24 Sep 12:12
Compare
Choose a tag to compare

Fix bug in LoadedMaterial.xsect/.macroscopic_xsect methods.

NCrystal release 3.9.6

30 Aug 11:47
Compare
Choose a tag to compare

This releases adds several new convenience methods to MiniMC results and histograms and fixes a bug in MiniMC histogram error propagation.

Additionally, the NCMATComposer gets new expert-only methods for adding @CUSTOM_ sections or raw text to NCMAT data.

NCrystal release 3.9.5

30 Aug 11:46
Compare
Choose a tag to compare

Make ncrystal_hfg2ncmat functionality available in Python API as well in the new NCrystal.hfg2ncmat module. Also add NCMATComposer.from_hfg(..) factory function to access the functionality.

NCrystal release 3.9.4

30 Aug 11:45
Compare
Choose a tag to compare

A few fixes for the PhononDOSAnalyser (github issue #187).

NCrystal release 3.9.3

30 Aug 11:45
Compare
Choose a tag to compare

Minor fixes for NCrystal.cifutils and MiniMC plotting.

NCrystal release 3.9.2

19 Aug 11:15
Compare
Choose a tag to compare

Minor tweaks and fixes for the new MiniMC code.

NCrystal release 3.9.1

16 Aug 15:38
Compare
Choose a tag to compare

This is a minor release fixing the newly introduced info.hklObjects() method in the Python API (see #164).

NCrystal release 3.9.0

14 Aug 12:12
Compare
Choose a tag to compare

After half a year of dedicated work, NCrystal 3.9.0 is finally available! This release brings both general improvements and new features, as well as a slew of maintenance updates and bug fixes. For those wishing all the gory details refer to the CHANGELOG, but in short the highlights are:

  • General speedup in a lot of the code. In particular the Fast Fourier Transform code, used when expanding phonon density of states to full scattering kernels for inelastic modelling, was improved by as much as 40%. This will make a noticeable difference when initialising many materials, and is an improvement independent from the multi-threading option mentioned in the next item.

  • If requested, NCrystal can now initialise materials even faster, by performing the initialisation calculations in multiple threads. This can for instance be enabled by setting the environment variable NCRYSTAL_FACTORY_THREADS to the number of threads you wish to use (e.g. 8 if you have 8 CPU cores available, or 9999 to have NCrystal pick a number suitable for your machine). Alternatively, you can call functions in the Python, C, or C++ APIs to enable this:

    NC.enableFactoryThreads() # Python
    NC::FactoryThreadPool::enable(); //C++
    ncrystal_enable_factory_threadpool(9999); // C
    export NCRYSTAL_FACTORY_THREADS=9999 # BASH
    
  • NCrystal now includes the first iteration of a "Mini Monte Carlo" framework (for lack of a better word), which makes it possible to insert an NCrystal material into a simple geometric "sample" shape, subject it to a source of neutrons, and obtain a spectrum or pattern of the outgoing neutrons. Thus, one can easily produce a simplistic diffraction pattern, including effects of multiple scattering and both elastic and inelastic physics. For now, the focus has been on developing the framework itself, rather than preparing a library of interesting shapes, sources, and tallies. Thus, the only readily available setup in this release is that of a monochromatic pencil beam impinging on a sphere, tallying the outgoing angle of the neutrons as they leave that sphere. Nonetheless, the results provides a very convenient view of how NCrystal modelling translates into a particular pattern -- without the need for an additional software package like McStas, Geant4, or OpenMC. Here is an example showing such a result:

    nctool --mc '2Aa' '5mm' 'AgBr_sg225_SilverBromide.ncmat;temp=350K'
    
    nctool MiniMC plot

    It works for single crystal materials as well:

    nctool --mc '3.8Aa' '5mm' 'C_sg194_pyrolytic_graphite.ncmat;mos=1deg;dir1=@crys_hkl:0,0,2@lab:0,3,1;dir2=@crys_hkl:1,0,0@lab:0,1,0;dirtol=180deg'
    
    nctool MiniMC plot

    The scope of this "Mini Monte Carlo" framework is of course not to try to rival existing applications in terms of ability to simulate complicated geometries or beamlines, but rather to provide another convenient way to quickly investigate NCrystal materials, as well as potentially serve as a way for NCrystal to be used in a regression-loop while analysing actual neutron scattering data. For that reason, speed has been a major concern, and both multithreading and vectorisation has been utilised to bring the time it takes to go from defined NCMAT data to having a high-statistics diffraction pattern available, down to the sub-second scale.

  • Internally NCrystal code no longer uses raw std::cout or printf statements. Rather, all messages are now emitted via a centralised infrastructure. This most importantly fixes an issue where output from the Python and C++ layers could occasionally be emitted in incorrect order - now, when using the NCrystal Python API, all output will be emitted through Python's own print buffer. Secondly, several NCrystal objects now gets a .dump_str() method, meaning for instance that material dumps can be captured in strings rather than emitted on std-output. Finally, this new feature could in principle be used for various output redirection purposes (e.g. a GUI application might wish to show all output from NCrystal in some dedicated text box).

  • NCrystal has been updated to work with latest versions of Numpy, Clang, GCC, Python, Gemmi, and Spglib. Additionally work has started to support Intel OneAPI compilers and Microsoft VisualStudio, although more work is needed to finalise this for the case of VisualStudio. As part of these efforts, the ABI had to be broken in some places, since for instance VisualStudio did not support all the data structures used previously (for instance, its std::vector does not accept move-only objects like std::unique_ptr).

  • Info objects gets a new .hklObjects() method which returns HKL list information in a more object oriented and convenient format than the existing .hklList(). See issue #164 for more details.

NCrystal release 3.8.0

03 Dec 13:30
Compare
Choose a tag to compare

Release 3.8.0 brings several changes of a technical nature, and mostly to how one builds and configures NCrystal. People using NCrystal installed via conda or pip will most likely only notice that the command previously available under the two names ncrystal_inspectfile and nctool, no longer is available as ncrystal_inspectfile. From this point on, the command is only available via the name nctool.

We also would like to point out that in addition to conda-forge and PyPI, NCrystal packages are now also available in Debian stable (thanks to the team lead by Emmanuel Farhi from the Synchrotron SOLEIL) and FreeBSD (thanks to efforts by Yuri Victorovich).

For people manually building NCrystal or downstream C++/C code, the primary changes to be aware of are (as usual, the CHANGELOG has more details):

  • NCrystal libraries now are installed with SOVERSION, and optionally with a custom namespace for both library symbols and library name. Thus, compiling downstream projects (without CMake) with -L/some/where -lNCrystal is no longer recommended (see the CHANGELOG for the recommended alternative).
  • Files like /setup.sh are no longer installed by default. If you need them, please set -DNCRYSTAL_ENABLE_SETUPSH=ON and note that the files are additionally renamed like <PREFIX>/ncrystal_setup.sh.
  • NCrystal-related McStas (mcstas.org) components and instruments are no longer provided as part of NCrystal. Rather, they are now provided as part of the McStas project.