Skip to content
Snippets Groups Projects
Forked from RNSD / SAMMY
85 commits behind, 5 commits ahead of the upstream repository.
Chen Zhang's avatar
Zhang, Chen authored
441f1064
History

SAMMY R-Matrix Code

SAMMY is an R-matrix Bayesian fitting program used in the analysis of nuclear cross section data.


Documentation can be found in the SAMMY Manual pdf and here

Quick Installation instructions can be found here

Detailed Installation instructions are listed here after the quick install instructions.


Features include:

  • Multiple R-matrix formalisms (Reich-Moore, Single/Multiple Level Breit-Wigner, etc.)
  • Neutral and charged particle projectiles (neutron, proton, alpha...)
  • Experimental corrections (Doppler/resolution broadening, multiple scattering for reaction yields...)
  • Bayes' method for fitting
  • Resolved/Unresolved resonance region analysis
  • Pre/Post processing to connect with the ENDF/B format

The structure of the code is broadly described by the image below.

The flow of the SAMMY program

Quick Installation

In a terminal execute the following commands:

$ git clone https://code.ornl.gov/RNSD/SAMMY.git
$ cd sammy/sammy
$ mkdir myscript
$ cp script/configure_sammy_gcc.sh myscript/
$ mkdir build
$ cd build
$ ../myscript/configure_sammy_gcc.sh ../
$ make -j4
$ make install

Finally run the tests with:

$ ctest -j4

Build and Test

Please note: At this writing the master branch is the only fully open-source version of SAMMY, and is therefore what would be considered ''bleeding-edge'' until a tagged version greater than 8.2.0-beta2 is released.

The SAMMY build is based on CMake from KitWare, which supports a consistent experience on LINUX, Mac, and Windows. OS specific instructions are given below for MacOS, Linux, and Windows. Guidance for common CMake errors can be found here.

SAMMY build requires:

Program Version
GNU gcc/g++/gfortan 9 or higher
CMake 3.12...3.22
Qt 5
Lapack/Blas 3.0 or higher
HDF5 1.12
git-lfs 3 or higher

Instead of GNU compilers it is also possible to use Intel Fortran/C++ 13.1 or higher.

There are four main steps to create an SAMMY installation:

  1. CMake configuration creates a native build tree
  2. Compilation compiles all executables and libraries
  3. Installation deploys all executables into a configuration ready for running
  4. Run test cases

CMakeLists.txt files are found throughout SAMMY. From the SAMMY root directory, these CMakeLists.txt files create a tree of included directories called the SOURCE TREE.

To configure a build, cmake is called on the root CMakeLists.txt file, namely <sammy_dir>/sammy/CMakeLists.txt. CMake takes the SOURCE TREE and creates a BUILD TREE.

The BUILD TREE contains or will contain the build configuration, Make files, and all compilation output (i.e., object files, archive libraries and binary executables).

Then make install in the build directory will install the packages, and an optional ctest command will run several tests to ensure that SAMMY built correctly.

SAMMY requires Qt, LAPACK and BLAS routines. If these libraries reside in a known location (i.e., installed by apt, yum, macports, or brew see below), the installation procedure may automatically find the libraries. Otherwise the location can be given at configuration time in configure_sammy_gcc.sh.

Recommended instructions for building is as follows. To clone the directory, if you have account credentials from ORNL (external users can start here), in a terminal type:

$ git clone git@code.ornl.gov:rnsd/sammy.git

if you want to clone without any credentials (without credentials you have limited user functionality in GitLab), type the following in the terminal:

$ git clone https://code.ornl.gov/RNSD/SAMMY.git

In the example above the main cloned directory is sammy, but it is possible to specify a different cloned directory name with the following command:

$ git clone git@code.ornl.gov:rnsd/sammy.git different_cloned_directory

In this guide, however, the main cloned directory will be referred to as sammy or the "top sammy directory" since we want to simply use the default configuration.

After cloning run the following in the terminal:

$ cd sammy/sammy
$ mkdir myscript
$ cp script/configure_sammy_gcc.sh myscript/
$ mkdir build
$ cd build

In the editor of your choice, set up your configuration options in the file configure_sammy_gcc.sh that you've copied into the myscript directory. It's best to copy the file to myscript as the myscript directory is not tracked by git and the file will not be overwritten every time you pull the latest version of sammy from the remote server. There are several paths that can be defined in the script for the build environment, such as the path/to/scale.

In the file configure_sammy_gcc.sh, it is often necessary to point SAMMY to the Qt installation, this can be done by including in the configure_sammy_gcc.sh the following line (assuming brew installed Qt binaries to "/usr/local/opt/qt@5/bin"):

export PATH="/usr/local/opt/qt@5/bin:$PATH"

From the build directory in the terminal:

$ ./configure_sammy_gcc.sh ../
$ make -j4
$ make install

Finally run the tests with:

$ ctest -j4

Note that both make and ctest take -j option (e.g. -j8) to run in parallel on several cores (e.g. 8), where the number 8 would be exchanged for however many processors you have available.

Other CMake flags, e.g. CMAKE_Fortran_COMPILER, CMAKE_Fortran_FLAGS, CMAKE_C_COMPILER, CMAKE_C_FLAGS, CMAKE_CXX_COMPILER, and CMAKE_CXX_FLAGS may be modified in the cmake command invocation line to update the compilers or compiler flags to the desired settings.


Windows 10 (not updated for versions > 8.2.0-beta2)

Modern versions of SAMMY have not been fully tested on Windows OS's, but have been successfully built and tested on Windows Subsytem for Linux WSL. WSL can be used to run a Linux operating system as an application inside the Windows OS directly interacting with files in the Windows OS. SAMMY has been built and tested in Ubuntu for WSL. To set up the Ubuntu application in Windows you may follow the Microsoft documentation on their website, but the basics are repeated here.

WSL instructions are detailed here.

Open a Windows PowerShell as an administrator and execute the following command:

$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

You will likely need to restart your computer after executing this command in the PowerShell. Once your computer has restarted, open the Microsoft Store and search for "Ubuntu". Windows should lead you through a user-friendly installation procedure. Once you have the Ubuntu application installed you should be able to open a Ubuntu shell and begin setting up your environment for SAMMY. In the Ubuntu terminal:

$ sudo apt-get update
$ sudo apt-get upgrade

to get the latest and greatest tools for Ubuntu. Next get the package manager brew to install the necessary compilers and other supporting programs (link to brew's website):

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

Add brew to your PATH in the file ~/.bashrc with the following line at the end of the file:

export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH

Then execute the following in the shell to install the latest GNU compilers (keep in mind that SAMMY must be built with the same compilers/compiler-options as SCALE/AMPX), Qt-5, LAPACK/BLAS libraries, Java Development Kit, and HDF5 libraries:

$ sudo apt-get update
$ sudo apt-get install build-essential
$ brew install gcc
$ brew install cmake
$ sudo apt install qt5
$ sudo apt install liblapack-dev libblas-dev
$ sudo apt install default-jdk
$ brew install hdf5

After successfully installing these programs, you should be able to follow the instructions starting with quick installation. If you have not previously installed SCALE, you should first follow the instructions for compiling a minimal SCALE build that SAMMY requires.

Based on SAMMY regression tests WSL was seen to run ~3-4x slower than the test suite executed on a MacBook Pro 2018. This is most likely due to slower I/O speed, and may change with an upcoming release of WSL 2.


Mac OSX

XCode is needed to compile SAMMY on a Mac OS X computer. It is available free from the App Store. In addition, the command line options from XCode must be installed. This can typically be accomplished by running the following in the command line:

xcode-select --install

and following any prompts given by the MacOS.

The latest version of macports, download-able from http://www.macports.org, can be used to download required programs as well as Homebrew (Homebrew works with both OS's), but this package manager is no longer being tested by the authors.

Homebrew instructions are detailed here.

Homebrew for MacOS (Linux will be different) can be downloaded from the Hombrew website using the command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The Homebrew website is a good resource for finding out more about how to install and use Homebrew on a Mac or Linux machine (it can also be installed on Windows Subsytem for Linux: WSL).

Once homebrew has been built and installed (and is found in the PATH) use the following commands to install required software.

$ brew install gcc
$ brew install cmake
$ brew install qt@5
$ brew install hdf5

If brew successfully installs software it typically is stored in a Homebrew-specific folder such as /usr/local/ on MacOS. Current MacOS distributions come with LAPACK and BLAS in the Veclib Framework but can also be installed with brew with command:

$ brew install openblas

PLEASE note: we have recently seen issues with compiling HDF5 APIs using the GNU compilers for C/C++. We would strongly recommend using the native MacOS clang/clang++ and telling cmake that you want to use these compilers by setting variables in your configure script with the following:

$ export CC=${CC:-clang}
$ export CXX=${CXX:-clang++}
$ export F90=${F90:-gfortran}

where I've left the F90 variable set to gfortran to reinforce the fact that we are using native MacOS C-compilers and the GNU compiler for Fortran.

Linux-Ubuntu

When installing the required software for SAMMY for a Linux OS (tested on Ubuntu) you should start with a general update:

$ sudo apt-get update
$ sudo apt-get upgrade

to get the latest and greatest tools for Ubuntu.

Homebrew instructions are detailed here.

Next get the package manager brew to install the necessary compilers and other supporting programs (link to brew's website):

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

Add brew to your PATH in the file ~/.bashrc with the following line at the end of the file:

export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH

The Homebrew website is a good resource for finding out more about how to install and use Homebrew on a Mac or Linux machine (it can also be installed on Windows Subsytem for Linux: WSL).

Once Homebrew has been built and installed (and is found in the PATH) use the following commands to install required software.

$ brew install gcc
$ brew install cmake
$ brew install qt@5
$ brew install hdf5

If brew successfully installs software it typically is stored in a Homebrew-specific folder such as /home/linuxbrew/ on Linux distros. On Linux distributions it is suggested to install LAPACK and BLAS with apt:

$ apt install liblapack-dev libblas-dev


Common CMake Errors

Details

When users configure SAMMY, they often find that the CMake build process will not find a required package or third-party software. As an example, let's walk through the process for fixing a SCALE TPL error in a general fashion (see the bottom for the best SCALE not found fix). Typically an error message such as this will be printed at configure:

--   Searching for lib 'ScaleUtilsEndfLib' ...
-- NOTE: Did not find a lib in the lib set "ScaleUtilsEndfLib" for the TPL 'SCALE'!
-- ERROR: Could not find the libraries for the TPL 'SCALE'!
-- TIP: If the TPL 'SCALE' is on your system then you can set:
     -DSCALE_LIBRARY_DIRS='<dir0>;<dir1>;...'
   to point to the directories where these libraries may be found.
   Or, just set:
     -DTPL_SCALE_LIBRARIES='<path-to-libs0>;<path-to-libs1>;...'
   to point to the full paths for the libraries which will
   bypass any search for libraries and these libraries will be used without
   question in the build.  (But this will result in a build-time error
   if not all of the necessary symbols are found.)
-- ERROR: Failed finding all of the parts of TPL 'SCALE' (see above), Aborting!

This error message is boilerplate text filled in with the missing package name ScaleUtilsEndfLib from the TPL SCALE. To fix the error, the message tells you the option name to specify (-D SCALE_LIBRARY_DIRS) in your configure script. So, in general, if you got this error message while compiling SAMMY, you would open the file configure_sammy_gcc.sh and add the following option to the cmake command:

-D SCALE_LIBRARY_DIRS='<dir>'

where '<dir>' is the directory where the SCALE library ScaleUtilsEndfLib can be found. For me it would be -D SCALE_LIBRARY_DIRS='/Users/<username>/sammy/scale/install'. This is the general process for most libraries.

It should be noted however that this is simply an example. The error message in the case of SCALE libraries not being found points to the fact that we never specified where the SCALE install path was. We can fix this with one line in the configure script:

-D ${SCALE_INSTALL_PATH}='/Users/<username>/sammy/scale/install'

Changing the Array Size (Legacy versions only)

Details

Dynamic dimensioning is achieved in legacy portions of SAMMY by assigning and de-assigning space in a large container array, designated as A(-N:N). The default value for N is 100,000,000. To use a different value, modify the line in your configure file shown below, substituting a desired value for your computer system (current maximum is about 2,000,000,000):

current default value:

-D SAMMY_ARRAY_SIZE:INT=100000000 \

The following value is near the current maximum for the Intel ifort compiler and it would require 30 GB of RAM:

-D SAMMY_ARRAY_SIZE:INT=2000000000 \

Other compilers may have a smaller maximum SAMMY_ARRAY_SIZE that could be determined empirically. This behavior is currently being stripped away however, and changing the array size in SAMMY will eventually become obsolete.


Compiler Options, etc. (Legacy versions only)

Details

If you want to use a different FORTRAN compiler, for example f90, then set the environment variable F77=f90 in bash:

$ export F77=f90

in csh:

$ setenv F77 f90

and then do the above install sequence. If you want to set compiler flags, for example -Wall, then use in bash:

$ export FFLAGS=-Wall

in csh:

$ setenv FFLAGS -Wall

and then do the above install sequence.

Other Useful Commands

Details
$ make clean      <- removes all generated object and source files