The recommended way to install SANDY both on Windows and Linux is on an Anaconda virtual environment that already includes several python packages. Click here for more details on Anaconda.
We advise to install the SANDY dependences in a python environment that was not previously altered. You can do so from a terminal/Anaconda Prompt using the package/environment management system conda
included in Anaconda, as
conda update --name base conda
conda create -y --name sandy-devel -c conda-forge python numpy scipy pandas pyyaml pytables
This environment covers all hard dependencies of SANDY, but i usually like to add a few more packages (such as ipython
) depending on my goal:
- data analysis and visualization:
matplotlib
,seaborn
,scikit-learn
- testing:
pytest
,numpydoc
,nbval
,codecov
,coveralls
,pytest-cov
- packaging projects:
build
,twine
- jupyter notebooks:
jupyterlab
,jupyter_nbextensions_configurator
,jupyter_contrib_nbextensions
From now on, every time you want to use SANDY in your python distribution you need to activate the correct environemt.
conda activate sandy-devel
... and the following to deactivate it.
conda deactivate
To manage your python environments read the conda cheatsheet.
Once the virtual environment is set up and active, you can install SANDY with pip
.
pip install sandy
- Open a terminal/Anaconda Prompt.
- Switch to the correct python environment (if any).
- Type
python
oripython
to open up a python/ipython session. - Then type
import sandy
Now, if sandy
is available and if you have a running version of NJOY2016 you are ready to roll!
The source code of SANDY is available as a git repository. The recommended way to get SANDY is by cloning the source package using your local git distribution (click here to download it!).
git clone https://github.com/luca-fiorito-11/sandy.git
cd sandy
If a SSL Certificate problem
appears when pushing or pulling with git, one can tell git to not perform the validation of the certificate using the global option:
git config --global http.sslVerify false
Move to the folder sandy
that you cloned with git and run the installation command,
cd sandy
python setup.py install --user
Don't forget to activate the virtual environment if you are using one.
SANDY is installed! Now go back to run it in a python shell.
SANDY also works as a wrapper to the NJOY code to process nuclear data files into PENDF and ACE formats. The installation of NJOY is not mandatory (it is if you want to produce random samples), but recommended.
We suggest using NJOY2016 (we haven't tried NJOY2021 yet!). You can find the source on its github repository.
To install NJOY you can do the following
Clone NJOY2016 with git
and follow the installation instructions provided on the NJOY website.
Then, add the NJOY executable to the environment variables, as
export NJOY=/path/to/njoy
or make this permanent by adding it to your .bashrc
.
You can see that sandy
recongnizes the NJOY executable if you open a python terminal and type
import sandy
sandy.get_njoy()
- Download Cygwin64.
- Follow the instructions of the installation wizard.
- You will be asked to select a 'Root Install Directory', that is, the directory where you want to install cygwin. In my case it is
C:\cygwin64
. From now on we'll call the 'Root Install Directory'C:\path\to\cygwin64
. - Make sure you select the following packages to ensure that NJOY be succesfully installed:
cmake 3.20.0-1
make 4.3-1
gcc-fortran 10.2.0-1
gcc-g++ 10.2.0-1
- Open a
git
terminal and download NJOY2016.
cd C:\path\to\cygwin64\home\your_username
git clone https://github.com/njoy/NJOY2016.git
- Open a
cygwin64
terminal and install NJOY2016:
cd C:\path\to\cygwin64\home\username\NJOY2016
mkdir bin
cd bin
cmake ..
make
make test
Make sure cmake finds an available python3 interpreter, if not you might have to use the cmake option
-DPython3_EXECUTABLE
.
- Open an Anaconda Prompt terminal and set up the NJOY executable in the environment variable
NJOY
. This way SANDY will automatically find it.
conda activate sandy-devel
conda env config vars set NJOY=C:\path\to\cygwin64\home\username\NJOY2016\bin\njoy.exe
conda activate sandy-devel
If you run the following you should see NJOY
in your list of environment variables (inside the python virtual environment),
conda env config vars list
To succesfully run NJOY Windows must be able to find some DLL files such as cygwin1.dll
.
This file is part of cygwin, so most likely it's located in C:\path\to\cygwin64\bin
.
Then, you have to add C:\path\to\cygwin64\bin
(or the location where cygwin1.dll
can be found) to your PATH
typing the following on an Anaconda Prompt terminal
set PATH=%PATH%;C:\path\to\cygwin64\bin
Again, the environment variable editor in the control panel can also be used.
To verify that NJOY is correctly found by SANDY open a python terminal, import sandy and run get_njoy()
.
import sandy
sandy.get_njoy()
If you want to succesfully run NJOY2016 through SANDY, cygwin must be allowed to access different directories outside the cygwin home directory.
From a cygwin terminal this can be done specifing /cygdrive/
before the directory absolute path.
Example: you can access the root of your C: drive from cygwin by specifying the directory
cd /cygdrive/c
To consistently be able to write in your user account on the C: drive (C:\Users\your_username
), for example, we recommend creating a symbolic link in a cygwin terminal, as
ln -sv /cygdrive/c/Users/your_username ~/your_username
To check if NJOY works you can:
- open a Anaconda Prompt terminal;
- move to a directory where cygwin has writing permission;
- make sure
C:\path\to\cygwin64\bin
is in your list of environemnt variables (juste typeset
and look atPath
); - run
C:\path\to\cygwin64\home\your_username\NJOY2016\bin\njoy.exe
.
NJOY should now be running in your terminal!
If you installed SANDY from source you can test if it works correctly by runnning a number of unit tests. First, make sure you istalled the following packages
conda install -y --name sandy-devel -c conda-forge pytest numpydoc nbval
Then, you can run the tests from a terminal/Anaconda Prompt from the sandy
folder with
conda activate sandy-devel
mkdir tests
cd tests
pytest ../sandy
Hopefully they are all green!
For combatibility issues we recommend installing a python kernel specific for the sandy-devel
environment.
For that, you can run the following after making sure that ipykernel
is installed in the virtual environment.
conda activate sandy-devel
python -m ipykernel install --user --name sandy-devel --display-name "Python3 (sandy-devel)"