This is SRW for Python
Project description
Synchrotron Radiation Workshop (SRW)
SRW is a physical optics computer code for calculation of detailed characteristics of Synchrotron Radiation (SR) generated by relativistic electrons in magnetic fields of arbitrary configuration and for simulation of the radiation wavefront propagation through optical systems of beamlines.
Frequency-domain near-field methods are used for the SR calculation, and the Fourier-optics based approach is generally used for the wavefront propagation simulation. The code enables both fully- and partially-coherent radiation propagation simulations in steady-state and in frequency-/time-dependent regimes. With these features, the code has already proven its utility for a large number of applications in infrared, UV, soft and hard X-ray spectral range, in such important areas as analysis of spectral performances of new synchrotron radiation sources, optimization of user beamlines, development of new optical elements, source and beamline diagnostics, and even complete simulation of SR based experiments. Besides the SR applications, the code can be efficiently used for various simulations involving conventional lasers and other sources. SRW versions interfaced to Python and to IGOR Pro (WaveMetrics), as well as cross-platform library with C API, are available.
In the following writing, it is assumed that SRW_Dev
is absolute path to the full SRW directory (obtained e.g. after downloading from repository).
I. Using pre-compiled SRW libraries and clients / bindings:
The last ~"clean" release of SRW for IGOR Pro and for Python can be found in SRW_Dev/env/release
, in particular:
- installers (of compressed packages) can be found in
SRW_Dev/env/release/install
; - unpacked folder of SRW for IGOR Pro (for Windows only) is:
SRW_Dev/env/release/srw_igor
;
This folder contains ReadMe.txt file with general "start-up" notes; detailed documentation for IGOR Pro version can be found in:SRW_Dev/env/release/srw_igor/SRW Help/SRW Help.ifn
file (in IGOR formatted notebook format); - unpacked folder of SRW for Python (for Windows and Linux) is:
SRW_Dev/env/release/srw_python
; this folder contains ReadMe.txt file with general "start-up" notes.
The most recent pre-releases and current work versions of SRW for Python and for IGOR Pro can be found in: SRW_Dev/env/work
.
Testing of the pre-compiled SRW libraries and clients / bindings can be done using examples included both to Python and IGOR Pro versions of SRW (see "Checking the examples" sections below for different platforms).
II. Compiling and testing SRW Library and its Python and IGOR Pro bindings on Windows
II.1. Compiling SRW library and Python binding using MS Visual C++
II.1.1
Microsoft Visual C++ 2015 (or later version) solution file (SRW.sln
), which includes 4 projects:
- SRW Library (file
SRWLIB.vcxproj
), - SRW Python client / binding (file
SRWLClientPython.vcxproj
), - SRW IGOR Pro client / binding (file
SRWLClientIgor.vcxproj
), - SRW C demo client (file
SRWLClientC.vcxproj
), can be found inSRW_Dev/cpp/vc
.
The SRWLClientPython project file allows for compiling srwlpy.pyd
shared library, i.e. SRW for Python 2.7 or/and 3.x (64-bit or 32-bit); SRWLClientIgor allows for compiling SRW.xop
shared library, i.e. SRW for IGOR Pro (32-bit only). Free Microsoft Visual Studio Community 2015 (or later versions) can be used.
To compile SRW library supporting OpenMP based parallel calculations (e.g. for XFEL applications):
- In the Visual C++ Configuration Manager, select "Release_omp" version of the SRWLIB project, then re-compile SRWLIB and SRWLClientPython under the "x64" Solution Platform to produce a 64-bit version of SRW for Python supporting OpenMP based parallel calculations.
- Note that the "Release_omp" version of the SRWLIB project has only a few differences with respect to the standard version: the "_WITH_OMP" preprocessor definition is added to Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions, the "Open MP Support" option is set to "Yes (/openmp)" in Configuration Properties -> C/C++ -> Language -> Open MP Support, and the linking is made with older versions of the FFTW library (FFTW 2.5), whereas the "normal" compilation / linking is with the FFTW 3.8.
II.2. Checking the examples
II.2.1
The SRW for Python examples can be tested using e.g. "IDLE" (Python native GUI). To do so, start this application (e.g. from Windows Start menu), open an example file in it, e.g. SRW_Dev\env\work\srw_python\SRWLIB_Example01.py
, and run it from the IDLE.
Alternatively, the example scripts can be executed from the Windows Command Prompt, e.g. from within the SRW_Dev\env\work\srw_python
directory. For convenience, correct path to python.exe file may need to be specified in the Windows system PATH variable prior to these tests.
II.2.2
The SRW for IGOR Pro examples can be tested from "SRWE" and "SRWP" menus, "Help" sub-menus, of the IGOR Pro.
III. Compiling and testing SRW Library and its Python binding on Linux
III.1. Compiling SRW library and Python binding
This can be done either using Python "setuptools" module (see section III.1.1 below) or without it (see section III.1.2).
III.1.1. Compiling using Python "setuptools" module
Make sure the "setuptools" module of the Python version you would like to use is properly installed and configured. If this is done, the compilation and installation is simple:
cd SRW_Dev
make all
To compile SRW library supporting OpenMP based parallel calculations (e.g. for XFEL applications) add "MODE=omp" after "make all":
make all MODE=omp
This should compile libsrw.a
and srwlpy.so
, and copy srwlpy.so
to SRW_Dev/env/work/srw_python/
III.1.2. Compiling without "setuptools"
III.1.2.1. Download and compile fftw-2.1.5 or/and fftw-3.3.8 library as required for SRW
Make sure files fftw-3.3.8.tar.gz
and fftw-2.1.5.tar.gz
are located in SRW_Dev/ext_lib
directory (if necessary, download these files from FFTW site, probably http://www.fftw.org/download.html).
Do the following to compile fftw-3.3.8 for using single-precision numbers as required for most FFT-based operations in SRW:
cd SRW_Dev/ext_lib
tar -zxvf fftw-3.3.8.tar.gz
cd fftw-3.3.8
./configure --enable-float --with-pic
Manually (using editor) add -fPIC option to CFLAGS in Makefile
make -j8 && cp .libs/libfftw3f.a ../
Do the following to compile fftw-3.3.8 for using double-precision numbers required for some FFT-based operations in SRW:
cd SRW_Dev/ext_lib
tar -zxvf fftw-3.3.8.tar.gz
cd fftw-3.3.8
./configure --with-pic
Manually (using editor) add -fPIC option to CFLAGS in Makefile
make -j8 && cp .libs/libfftw3.a ../
Do the following to compile fftw-2.1.5 for using single-precision numbers required for supporting OpenMP based parallel calculations in SRW:
cd SRW_Dev/ext_lib
tar -zxvf fftw-2.1.5.tar.gz
cd fftw-2.1.5
./configure --enable-float --with-pic
Manually (using editor) add -fPIC option to CFLAGS in Makefile
make -j8 && cp fftw/.libs/libfftw.a ../
III.1.2.2. Compiling the SRW library and Python binding
cd SRW_Dev/cpp/gcc
Make sure Python 3.3 or higher (or Python 2.7) is installed.
In the SRW_Dev/cpp/gcc/Makefile
, modify/correct PYPATH and PYFLAGS variables, i.e. specify path to Python header and library files. Depending on Linux environment, it may also be necessary to modify the name of compiler to be used, e.g.:
CC = gcc
CXX = g++
#CC = cc
#CXX = c++
After this, execute the following:
rm libsrw.a
make all
To compile SRW library in the mode supporting OpenMP based parallel calculations (e.g. for XFEL applications) add "MODE=omp" after "make all":
make all MODE=omp
Then copy srwlpy.so to SRW_Dev/env/work/srw_python/
:
cp srwlpy.so ../../env/work/srw_python/
III.2. Checking the examples
Make sure the path to Python 3.x (or 2.7) is added to the PATH variable and "srw_python" to PYTHONPATH variable:
export PATH="$PATH:<absolute path to Python 3.x>" # this is not necessary if you install python using the distro's package manager
export PYTHONPAH="$PYTHONPATH:SRW_Dev/env/work/srw_python/" #temporary solution
or
echo "export PYTHONPATH=$PYTHONPATH:SRW_Dev/env/work/srw_python/" >> ~/.bashrc #permanent solution for a single user
Setting up PYTHONPATH allows to import srwlpy module from any directory. Testing of the examples would preferably done in the srw_python
directory:
cd SRW_Dev/env/work/srw_python
python SRWLIB_ExampleXX.py
IV. Compiling and testing SRW Library and its Python binding on Mac OSX
Try to follow the steps described in section III (describing options for compiling and testing SRW on Linux).
We were informed that the actions described in III.1.1 lead to successful compilation on OSX 10.14.5 after the following modifications in SRW_Dev/cpp/gcc/Makefile
:
Change CXX variable as follows:
#CXX = c++
CXX = g++ -stdlib=libc++ -mmacosx-version-min=10.9
Make sure to explicitly use the C++ compiler (CXX) for compiling all *.cpp files, e.g.:
%.o: $(SH_SRC_PARSE_DIR)/%.cpp
$(CXX) $(CFLAGS) -c $<
It may be necessary also to set also the CC variable to came value as CXX (?):
#CC = cc
CC = g++ -stdlib=libc++ -mmacosx-version-min=10.9
Previously, we were informed that the actions described in III.1.2.2 lead to successful compilation with gcc/g++ provided by Xcode 10.1, after the following modifications in SRW_Dev/cpp/gcc/Makefile:
CC = gcc
CXX = g++
#CC = cc
#CXX = c++
...
PYPATH=/Library/Frameworks/Python.framework/Versions/3.6
PYFLAGS=-I$(PYPATH)/include/python3.6m -I$(PYPATH)/include/python3.6m -L$(PYPATH)/lib/python3.6/config-3.6m-darwin -lpython3.6m -ldl
The correct path and flags can be obtained e.g. by executing from command line:
python3-config --includes --ldflags
and removing the option "-framework"
With earlier versions of Xcode, the following manipulations, consisting in installation of "macports" and obtaining the whole gcc toolchain, were reported to be successful:
sudo port install gcc47
Modify the SRW_Dev/cpp/gcc/Makefile
so that CC=<path to macports>/gcc
and CXX=<path to macports>/g++
, and proceed to the compilation as described in III.1.2.2.
V. Compiling and testing SRW Library and its Python binding on Windows and Linux (via CMake/Pip)
Run the following in a Visual Studio Developer Command Line/Linux Terminal:
cmake -B build
cmake --build build -j
The pip installable version of the package can be obtained by running the following in a Visual Studio Developer Command Line/Linux Terminal:
cd env/python
pip install -e .
VI. GPU Acceleration of SRW
SRW has basic support for GPU acceleration of some routines through CUDA. Compilation of SRW with GPU acceleration requires the CUDA HPC SDK to be installed and, on Linux can be performed with:
MODE=cuda make
To compile on Windows, open the SRW solution in Visual Studio, set the target to the _cuda
variants and update the library and include paths for the SRWLIB project. You may also have to copy the following DLLs from the HPC SDK install into the env/python/srwpy directory:
- cudart64_110.dll
- cufft64_10.dll
Authors and Contributors to SRW project
O. Chubar (ESRF - SOLEIL - BNL)
P. Elleaume (ESRF)
J. Chavanne (ESRF)
R. Celestre (ESRF)
P. Dumas (SOLEIL)
O. Marcouille (SOLEIL)
L. Samoylova (E-XFEL)
A. Buzmakov (E-XFEL)
G. Geloni (E-XFEL)
I. Agapov (E-XFEL)
J. Sutter (DIAMOND)
D. Laundy (DIAMOND)
A. He (BNL)
R. Coles (BNL)
R. Li (BNL)
M. Rakitin (BNL)
H. Goel (SBU - BNL)
N. Canestrari (ESRF - BNL)
A. Suvorov (BNL)
R. Reininger (ANL)
X. Shi (ANL)
R. Lindberg (ANL)
L. Rebuffi (ELETTRA - ANL)
D. Bruhwiler (RadiaSoft LLC)
R. Nagler (RadiaSoft LLC)
P. Moeller (RadiaSoft LLC)
B. Nash (RadiaSoft LLC)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for srwpy-4.0.0b1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c74ca7258e6e63e1368a656ceebdcaa55a84239a2ded0febc909ad7ad1d2b82b |
|
MD5 | 50182bd1efcd7343b203573289e23a26 |
|
BLAKE2b-256 | b90819ea71b9043946d38a7decbd6ec965a6e58d05191f6f1a82f8961f5d7f5b |
Hashes for srwpy-4.0.0b1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33cf25e90889851c51022970c69bc2da3131d1c8a388835ecd1441226adf40b1 |
|
MD5 | 28a09c38e65a3af4457274c18d2be45b |
|
BLAKE2b-256 | 0bda8a5edce0f203627b41d2d589b2391374bcd9bfa955ba408b1d8b86c593d6 |
Hashes for srwpy-4.0.0b1-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bdc90a3cc64e511d41ae0e932eb47f217f83a215a1cab8cb675266ce34565eb |
|
MD5 | 3e272c3281b76047b1f286e36c1740bf |
|
BLAKE2b-256 | fe1f626a539ae48d606ff7c0ebfd03c9f3a781b86634f6d13be5b87c7db485ad |
Hashes for srwpy-4.0.0b1-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3d291c02de05e32aa0ac7ab43d793d0b95bd2f0005c9f11431210db9f9848e2 |
|
MD5 | c7dc7824fb7b628bf302288d81c76250 |
|
BLAKE2b-256 | 4fca7259e65b184c7e770dd62b462e56266a7f6ab2e5cff23bc0be992c485f4b |
Hashes for srwpy-4.0.0b1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e08b971e475de4b3ef05b05a1fce9030ace56db99607eb043fec17b14e685a05 |
|
MD5 | bc2b4f8ba84b584d83b5f9a62f1bf8fb |
|
BLAKE2b-256 | 7e6ee9023060cc30f936aa2369b3b6b807662a6b49334f2ca6a93753780aff35 |
Hashes for srwpy-4.0.0b1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf6a99b5941f35862275db4ab72dce04df8939e55b6c5be49e94e46955945af3 |
|
MD5 | 7e4821b6671dd642cad06ef5720075cc |
|
BLAKE2b-256 | cd686c530aa4a5ece53fef5e514e494d20b0c0cba2045d87907b7585c22dd11c |
Hashes for srwpy-4.0.0b1-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94e7d73133559eed3f9647cfa30051b531fd92794dab10356e39f8f94e525b89 |
|
MD5 | 6e3e8c2b928135d900d5e00ca07f587a |
|
BLAKE2b-256 | dcfb4c7c21bd9ec8d80826e8ad8c32689fa93f05fe5e7fd934d4e5285732a96b |
Hashes for srwpy-4.0.0b1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6f808ecec0ad58af1a4001ba95bd6070c7d3832a84e6b8166f83cb8786a75b8 |
|
MD5 | 48e69d3236fa67000745a250dce6b742 |
|
BLAKE2b-256 | 10f607d0200c46a0d1eadd426c2ffa8a7c36af93dc7bd24e6dc04518063704d0 |
Hashes for srwpy-4.0.0b1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cf02ef576055d70da2295b8b498add3d4aa8a3cdc42677deab6a41be2e96790 |
|
MD5 | 76d4d4664cd2f4248cec839934c5f0ed |
|
BLAKE2b-256 | 7d425370ded4c8902db69ef45da5da4256599fa467135a3de1b67c2afa16c86c |
Hashes for srwpy-4.0.0b1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97db7912901b93624c31c3a8addaf0826cd311b41a59de985cdf7e379ef45db6 |
|
MD5 | 5bbfb3b748760f2b951f2ef35cffb718 |
|
BLAKE2b-256 | 135a690ece1e52ad22c18d2011cafaeb9a3a29f528b9a78c13bc2c0a73d0b999 |
Hashes for srwpy-4.0.0b1-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e4d58bd04b0e39e99dc47bc5b2346cfce19649c44cc06b634c8354cd8846a8e |
|
MD5 | 9f4131fb67bcf89f9ecc3d690dc22090 |
|
BLAKE2b-256 | ac9afac62bd567d474b7a42f6b09c688419afc4581343021091a8eabed5a64b1 |
Hashes for srwpy-4.0.0b1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0615c591669c415d54cfcb89c2021b4cb0cd2fbe10f044bb9a124a71dbc630d4 |
|
MD5 | f20d4646b72d81cd283f2058718d5fa1 |
|
BLAKE2b-256 | 43b4ad641b285f4cf741edfb5c6f3c2afb1526d1e70687554d9eab30ffb77a42 |
Hashes for srwpy-4.0.0b1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed6408e5468b8d218937bea67d479d960b878c2c129ef2e17d4bfe4fa04d6f91 |
|
MD5 | 61ec5198aedc7a353d0b0d26838bd515 |
|
BLAKE2b-256 | 908c0c85a406235ece449e4dce0c2ed129d367694f532b9d35f8a2b9c26f4d5d |
Hashes for srwpy-4.0.0b1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b48de84feb95e6b3a1d1fc4d2aade370cac5e878196ee6d8dd598c70ac8b3da8 |
|
MD5 | df3fc5f9fc54882c40c54948d3049007 |
|
BLAKE2b-256 | 7b26749263e19dbf758f3ee9e43009d59f93ddf8d9dd1b784b22c5b2076fd290 |
Hashes for srwpy-4.0.0b1-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dff5e25a4f8d2c7711f3b1ac7d966744d792902007bf3ff29401c68036afd89b |
|
MD5 | f3b59ae975c94c08f93784c626047a7e |
|
BLAKE2b-256 | 6cf9d85f6e73470b1334cc9c3c5c9e5d0521a7b4119c4fb7c3a7130d4bef3d15 |
Hashes for srwpy-4.0.0b1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0af58ee81ecf6bf597da46703ac744987055ffa64b4f108801ca580b07c7e61b |
|
MD5 | e2a57d0cb162db8a4222ba1a85084084 |
|
BLAKE2b-256 | 4a4c64405ee83ffd52d2e4ab686f0dd3b559bf69ed0418e4f6b4bb9db12a497e |