anaklasis is a set of open-source Python3 scripts (with FORTRAN 90 extensions) that facilitate a range of specular neutron and x-ray reflectivity calculations, involving the generation of theoretical curves and the comparison/fit of interfacial model reflectivity against experimental datasets. The ref module, contains three callable functions, ref.calculate for generating theoretical reflectivity curves, ref.compare for comparison of experimental data with theoretical curves and ref.fit for refinement of experimental data against a defined model. Execution takes place by defining the interfacial model and instrumental parameters as lists in a simple Python script and by passing them as arguments to the desired function.
In the examples folder many scripts with calculations and refinements performed by the program can be found. Addiitonaly some Jupyter notebooks explaining the input and output are included.
Full description of used methods is reported in an open-access article at the Journal of Applied Crystallography.
It is adviced to install a FORTRAN compiler on your system before proceeding with installation, so that the extensions for reflectivity calculations can be compiled. If you perform the installation without a FORTRAN compiler, a Python calculation engine will be used by the package. The engine can be considerably accelerated by installing the Numba package after installing anaklasis.
Note that calculations with Numba are 30-40% slower than with the FORTRAN extensions, while Python calculation engine without Numba installed can be more than 20-30 times slower than the FORTRAN extensions.
Linux
- Install Python >= 3.7 and optionally gfortran
- Install NumPy
- then download the latest anaklasis release, unzip the archive and install throught the terminal
python3 setup.py install --user- If gfortran was not present, install Numba package.
macOS
- Install python >= 3.7 from python.org
- Optionally install gfortran compiler. An easy way is to use the installers provided by fxcoudert at github
- Install NumPy
python3 -m pip install numpy- then download anaklasis, navigate to the proper folder and install throught the terminal
python3 setup.py install- If gfortran was not present, install Numba package.
python3 -m pip install numbaNote that if you prefer you may use MacPorts or Homebrew for the installation of gfortran compiler.
Windows 10 (Numba)
- Install python >= 3.7 from python.org and do not forget to include python in the systen path.
- Install NumPy and upgrade setuptools
py -m pip install --upgrade pip setuptools
py -m pip install numpy- Download the latest anaklasis release, navigate to the proper folder and install thought the command prompt
py setup.py install- Install Numba
py -m pip install numbaWindows 10 (Python 3.9 only with provided wheel )
For convenience a wheel with a pre-compiled fortran extension is provided (folder \win_wheel) for Python version 3.9. For installing it follow the steps below:
- Install python 3.9 from python.org and do not forget to include python in the systen path.
- Install NumPy and upgrade setuptools
py -m pip install --upgrade pip setuptools
py -m pip install numpythen navigate in the \win_wheel folder and install through the command prompt
py -m pip install anaklasis-1.6.0-cp39-cp39m-win_amd64.whlIn case you prefer Anaconda on Windows just make sure you have setuptools and NumPy on the system and just install the wheel.
Windows (with gfortran installation)
- Install python >= 3.7 from python.org and do not forget to include python in the systen path.
- Install NumPy and upgrade setuptools
py -m pip install --upgrade pip setuptools
py -m pip install numpy- Install MSYS2 following these instructions. Make sure that you include c:\msys64\mingw64\bin in the system PATH (edit environement variables in control panel) and that you get the latest packages by using the appropriate commands (pacman -Syuu) in the MSYS2 console.
- After MSYS2 is installed and all packages updated, install gfortran from the MSYS2 console
pacman -S mingw64/mingw-w64-x86_64-gcc-fortran- Finally download anaklasis, navigate to the proper folder and install thought the command prompt
py setup.py install build_ext --compiler=mingw32In case you prefer Anaconda on Windows here are instructions for setting up the fortran compiler.
Windows 10 (using WSL)
An additional option for Windows 10 users is to use the Windows Subsystem for Linux (WSL), install a Linux distribution (like Ubuntu) and follow the installation instructions presented above for Linux.
You may use the following Binder link in order to perform anaklasis calculations inside jupyter notebooks that run on the cloud .
You may find templates for calculations and refinements in the form of jupyter notebooks that you can modify according to your needs. You may also upload data files in order to use them in your refinements. Resources on Binder are a bit limited but you are able to experiment with anaklasis without performing a local installation on your machine.
In the /docs folder you may find the program's API in various formats.
Also after installing anaklasis, you may install pdoc and from the console run
pdoc anaklasisthat will open a html version of the API in your browser.
In this YouTube link you may also find a video tutorial for fitting the ORSO example data with anaklasis.
In the directory /script_templates you may find commented scripts that may guide you for writing anaklasis analysis scripts.
In the folder /tests you will find a Python script tests.py that runs tests of the core calculations used by all three anaklasis functions and reports if the results are the same as those obtained by version 1.5.2 of the package. You may run the tests using
python3 tests.pyIf the run is succesful you will receive a All anaklasis tests passed! message at the end.
Also a script that runs only the ORSO validation tests ORSO_tests.py can be found in /tests.
On macOS and Linux before performing a bootstrap analysis you might need to increase the user resource limit using the command
ulimit -n 2048Jupyter notebook examples of model calculations
- XRR of supported lipid membrane at the water/Si interface
- X-ray reflectivity calculations (2 layers)
- Data/Theory compasion for NR of supported lipid membrane
Jupyter notebook examples of data refinements