Welcome to simS2E’s documentation!


Contents:

Getting started

_images/pmi_rsz.png

simS2E is an implementation-agnostic framework that defines the data interfaces between the modules, i.e. Module A must output an hdf5 file that adheres to the simS2E interface which Module B is expecting to read in. Actual implementation of Modules A and B is up to the user. If you understand this concept, then you are ready to use simS2E. You will need to set up the environment for simS2E and if you have a module that you want to plug in, find out what data formats the input and output should be here:

http://sims2e.readthedocs.org/en/latest/docs/fel_source_simulation.html

If you would like to try running an example simS2E pipeline, then you need Docker installed on your machine.

System requirements

You will need at least 8GB RAM and 20GB of disk space.

Installing Docker for example simS2E pipeline

You do NOT need Docker for simS2E. You only need it for running the example simS2E pipeline that we provide. Docker is a new container technology (Think of it as a light-weight virtualbox) that can be run on your choice of OS. Instructions for installation can be found here:

https://docs.docker.com/installation/

Setting up the environment for simS2E

You need to clone the simS2E repository from GitHub into your local directory (I will refer to this directory as /host/path):

cd /host/path
git clone https://github.com/chuckie82/simS2E.git

You now have a copy of all the files/scripts in the sub-directories needed for simS2E:

/host/path/simS2E/workflow: Directory for run scripts
/host/path/simS2E/config: Directory for configuration files
/host/path/simS2E/data: Directory for reading/saving data
/host/path/simS2E/packages: Directory for installing software packages
/host/path/simS2E/modules: Directory for module specific scripts
/host/path/simS2E/tmp: Directory for storing temporary files
/host/path/simS2E/docs: Directory for online documentation

Go to the packages directory and run setup.sh. This will build all the packages as Docker containers; 1) FAST for FEL source, 2) WPG for optics, 3) pmi_demo for radiation damage to the sample, 4) SingFEL for diffraction patterns, 5) EMC for orientation recovery, and 6) DM for phase retrieval:

cd /host/path/simS2E/packages
./setup.sh

Now you are ready to run the simulation!!!

1 ) Let’s run the FEL source simulation using FAST:

docker run -it -v /host/path/simS2E:/simS2E fast:v0.1 /bin/bash

You are now inside the Docker container running bash on Ubuntu v14.04. The FAST package is installed under /home/packages and the simS2E directory is located under /simS2E.

Go to the workflow directory and run the example. This will generate a single FEL pulse:

cd /simS2E/workflow
./runFAST

This script runs master.sh which in turn runs master_fast.sh. All the simulation configuration is defined in /simS2E/config/config_sim_example. Let’s examine the configuration file:

nano /simS2E/config/config_sim_example

NUM_FELsource_OUT=1 means output 1 instance of the FEL pulse. FELsource=ppFAST means use the FAST package. FAST simulation parameters are defined under ###### ppFAST ######.

When the simulation is complete. Exit the docker container by typing “exit” or Contrl+D. FELsource output hdf5 file will be in /host/path/simS2E/data/sim_example/FELsource. You can examine the hdf5 file by running:

h5ls -r /host/path/simS2E/data/sim_example/FELsource/FELsource_out_0000001.h5

Note that the output hdf5 names and fields conform to the specifications of the simS2E framework.

2 ) Let’s run the optics simulation using WPG:

docker run -it -v /host/path/simS2E:/simS2E wpg:v0.1 /bin/bash

You are now inside the Docker container running bash on Ubuntu v14.04. The WPG package is installed under /home/packages and the simS2E directory is located under /simS2E.

Go to the workflow directory and run the example. This will generate the FEL pulse that will hit the sample after propagating through the SPB/SFX beamline optics:

cd /simS2E/workflow
./runWPG

When the simulation is complete. Exit the docker container by typing “exit” or Contrl+D. WPG output hdf5 file will be in /host/path/simS2E/data/sim_example/prop.

3 ) Let’s run the photon matter interaction simulation using PMI_DEMO:

docker run -it -v /host/path/simS2E:/simS2E pmi_demo:v0.1 /bin/bash

You are now inside the Docker container running bash on Ubuntu v14.04. The PMI_DEMO package is installed under /home/packages and the simS2E directory is located under /simS2E. Due to the license agreement, the PMI package is not available in this example simulation and demo version is used instead.

Go to the workflow directory and run the example. This will generate the scattering factors of the sample under going radiation damage over time:

cd /simS2E/workflow
./runPMI

The pdb file that specifies the initial atom positions and scattering factors is stored under /simS2E/data/sim_example/sample/sample.h5. When the simulation is complete, exit the docker container by typing “exit” or Contrl+D. PMI_DEMO output hdf5 file will be in /host/path/simS2E/data/sim_example/pmi.

4 ) Let’s run the diffraction simulation using SingFEL:

docker run -it -v /host/path/simS2E:/simS2E singfel:v0.1 /bin/bash

You are now inside the Docker container running bash on Ubuntu v14.04. The SingFEL package is installed under /home/packages and the simS2E directory is located under /simS2E.

Go to the workflow directory and run the example. This will generate the diffraction patterns of the sample under going radiation damage over time:

cd /simS2E/workflow
./runSingFEL

Let’s open the simulation configuration file again in /simS2E/config/config_sim_example. NUM_DIFFR_OUT=100 means generate 100 time evolution diffraction patterns. In order to run a meaningful simulation, try increasing this number to 50,000. DIFFR=singfel means use the SingFEL package. SingFEL parameters are defined under ###### SingFEL ######. When the simulation is complete, exit the docker container by typing “exit” or Contrl+D. SingFEL output hdf5 file will be in /host/path/simS2E/data/sim_example/pmi.

You can examine the hdf5 file by running:

cd /host/path/s2eDocs/modules/diffr
python diagnostic_singfel.py /host/path/simS2E/data/sim_example

You should observe two matplotlib plots: 1) photon field and 2) photon count. You may need to install h5py, matplotlib and numpy to run this script.

5 ) Let’s run the orientation recovery simulation using EMC:

docker run -it -v /host/path/simS2E:/simS2E emc:v0.1 /bin/bash

You are now inside the Docker container running bash on Ubuntu v14.04. The EMC package is installed under /home/packages and the simS2E directory is located under /simS2E.

Go to the workflow directory and run the example. This will generate the 3D diffraction volume after orientation recovery. Note that EMC may take many hours to converge to a solution. On my Linux box, it takes about a day:

cd /simS2E/workflow
./runEMC

Let’s open the simulation configuration file again in /simS2E/config/config_sim_example. ORIENT=EMC specifies the EMC algorithm for orientation recovery. The EMC parameters are defined under ###### EMC ######. When the simulation is complete, exit the docker container by typing “exit” or Contrl+D. EMC output hdf5 file will be in /host/path/simS2E/data/sim_example/orient.

6 ) Let’s run the phase retrieval simulation using DM:

docker run -it -v /host/path/simS2E:/simS2E dm:v0.1 /bin/bash

###### DM ###### You are now inside the Docker container running bash on Ubuntu v14.04. The DM package is installed under /home/packages and the simS2E directory is located under /simS2E.

Go to the workflow directory and run the example. This will generate the 3D electron density.:

cd /simS2E/workflow
./runDM

Let’s open the simulation configuration file again in /simS2E/config/config_sim_example. PHASE=DM specifies the Difference Map algorithm for phase retrieval. The DM parameters are defined under ###### DM ######. When the simulation is complete. Exit the docker container by typing “exit” or Contrl+D. DM output hdf5 file will be in /host/path/simS2E/data/sim_example/phase.

Setting up Sphinx for documenting simS2E simulation

You need clone the simS2E repository from GitHub:

git clone https://github.com/chuckie82/start-to-end.git

The index.rst is the master ReST for your project.

You may already have sphinx installed – you can check by doing:

python -c 'import sphinx'

If that fails install the latest version with:

> sudo easy_install -U Sphinx

Let’s see if we can build our html:

make html

If you now open your favorite internet browser and type _build/html/index.html, you should see the documentation website.

To update the document on the web, just push your changes:

git add *.rst
git commit -m "Update all documents"
git push -u origin master

That’s it! Now you are ready to

_images/undulator_rsz.png
_images/undulator_rsz.png

FEL source simulation

Introduction

Documentation for FEL source simulation can be found on this page.

Data access

Data in archive can be exported using web browser. Initial FEL source can be downloaded from here:

FEL source web site

with authentication (xfel/desy account)

FEL source web site

If you use this dataset, please acknowledge [SALDIN99].

[SALDIN99]
    1. Saldin, E. A. Schneidmiller, and M. V. Yurkov. Nucl. Instrum. and Methods, A(429):233, 1999.

Output data description

The output data is expected in hdf5 format, and the glossary can be found below. FEL source module is responsible for writing out in the format specified below.

FELsource_out_<7 digit ID>.h5 (Output HDF glossary)

Field name Description Data type Units
data/      
data/arrEhor Complex EM field written in 4D array, horizontal polarization Float  
data/arrEver Complex EM field written in 4D array, vertical polarization Float  
params/ Parameters for wavefront propagation    
params/Mesh/nSlices Numbers of points vs photon energy/time for the pulse Int  
params/Mesh/nx Numbers of points, horizontal Int  
params/Mesh/ny Numbers of points, vertical Int  
params/Mesh/sliceMax Max value of time [s] or energy [ev] for pulse (fragment) Float s or ev
params/Mesh/sliceMin Min value of time [s] or energy [ev] for pulse (fragment) Float s or ev
params/Mesh/xMax Maximum of horizontal range Float m
params/Mesh/xMin Minimum of horizontal range Float m
params/Mesh/yMax Maximum of vertical range Float m
params/Mesh/yMin Minimum of vertical range Float m
params/Mesh/zCoord Longitudinal position, for FEL output data - length of active undulator   m
params/Rx Instantaneous horizontal wavefront radius Float m
params/Ry Instantaneous vertical wavefront radius Float m
params/dRx Error of wavefront horizontal radius Float m
params/dRy Error of wavefront vertical radius Float m
params/nval complex electric field nval==2 Int  
params/photonEnergy Average photon energy Float ev
params/wDomain Wavefront in time or frequency (photon energy) domain String  
params/wEFieldUnit Electric field units, {sqrt(W/mm^2) (time domain), arbitrary} String  
params/wFloatType Electric field numerical type String  
params/wSpace R-space or Q-space wavefront presentation String  
params/xCentre Horizontal transverse coordinates of wavefront instant ‘source center’ Float m
params/yCentre Vertical transverse coordinates of wavefront instant ‘source center’ Float m
history/parent/info/ Information about input data    
history/parent/info/ contact Contact Information String  
history/parent/info/ data_description Description of FEL data String  
history/parent/info/ method_description Method description String  
history/parent/info/ package_version Package version String  
misc/ Complimentary information    
history/parent/misc/ FAST2XY.DAT FELsource_params_FAST2XY.txt used for post-processing FAST output String  
history/parent/misc/ angular_distribution radial distribution of far field divergence Float  
history/parent/misc/ spot_size near field transverse FEL beam size (FWHM) Float  
history/parent/misc/ gain_curve gain curve, dependence of FEL pulse energy (column 2) from number of working point (column 0) and active undulator length z[cm] (column 1) Float  
history/parent/misc/nzc number of working point defines active undulator length Int  
history/parent/misc/ temporal_struct FEL pulse temporal structure, instantaneous power P(tau) Float  
version hdf5 format version Float 0.1

Diagnostic (diagnostic_felsrc.py)

Fig.1. Pulse irradiance XY map (number of photons per pixel), the title contains size of the pixel;

Fig.2. Pulse time structure, the title contains the pulse energy value.

_images/optics.png

Propagation, including optics

Input data description

The input data is expected in hdf5 format, and the glossary can be found in the link below.

prop_out_<7 digit ID>.h5 (Output HDF glossary)

Field name Description Data type Units
data/      
data/arrEhor Complex EM field written in 4D array, horizontal polarization Float  
data/arrEver Complex EM field written in 4D array, vertical polarization Float  
params/ Parameters for wavefront propagation    
params/Mesh/nSlices Numbers of points vs photon energy/time for the pulse Int  
params/Mesh/nx Numbers of points, horizontal Int  
params/Mesh/ny Numbers of points, vertical Int  
params/Mesh/qxMax Maximum of horizontal frequency (If params/wSpace is Q-space)   1/m
params/Mesh/qxMin Minimum of horizontal frequency (If params/wSpace is Q-space)   1/m
params/Mesh/qyMax Maximum of vertical frequency (If params/wSpace is Q-space)   1/m
params/Mesh/qyMin Minimum of vertical frequency (If params/wSpace is Q-space)   1/m
params/Mesh/sliceMax Max value of time [s] or energy [ev] for pulse (fragment) Float s or ev
params/Mesh/sliceMin Min value of time [s] or energy [ev] for pulse (fragment) Float s or ev
params/Mesh/xMax Maximum of horizontal range (If params/wSpace is R-space) Float m
params/xMin Minimum of horizontal range (If params/wSpace is R-space) Float m
params/yMax Maximum of vertical range (If params/wSpace is R-space) Float m
params/yMin Minimum of vertical range (If params/wSpace is R-space) Float m
params/zCoord Longitudinal position, for FEL output data - length of active undulator Float m
params/beamline/printout (add description)    
params/Rx Instantaneous horizontal wavefront radius Float m
params/Ry Instantaneous vertical wavefront radius Float m
params/dRx Error of wavefront horizontal radius Float m
params/dRy Error of wavefront horizontal radius Float m
params/nval complex electric field nval==2 Int  
params/photonEnergy Average photon energy Float ev
params/wDomain Wavefront in time or frequency (photon energy) domain String  
params/wEFieldUnit Electric field units, sqrt(Phot/s/0.1%BW/mm^2), sqrt(W/mm^2) for time domain, sqrt(J/eV/mm^2) for frequency domain arbitrary String  
params/wFloatType Electric field numerical type String  
params/wSpace R-space or Q-space wavefront presentation String  
params/xCentre Horizontal transverse coordinates of wavefront instant ‘source center’ Float m
params/yCentre Vertical transverse coordinates of wavefront instant ‘source center’ Float m
info/      
info/package_version Package version    
info/contact Contact details of author    
info/data_description Short description of what the data is    
info/method_description Short description of what method was used to generate the data    
history Information about input data    
misc/ Complimentary information    
misc/xFWHM FWHM belong x-axis Float m
misc/yFWHM FWHM belong y-axis Float m
version hdf5 format version Float 0.1

Diagnostic (diagnostic.py)

Fig.1. Pulse irradiance XY map (number of photons per pixel), the title contains size of the pixel;

Fig.2. Plot of pulse time structure before and after propagating, the title contains the propagated pulse energy value.

About WPG

WPG, WaveProperGator is an interactive simulation framework for coherent X-ray wavefront propagation. WPG provides intuitive interface to the SRW library. The application examples oriented on European XFEL design parameters.

Online documentation page

_images/pmi_rsz.png

Photon Matter Interaction

Input/Output data description

The input/output data is expected in hdf5 format, and the glossary can be found below. Photon matter interaction module is responsible for reading in and writing out in the format specified below.

pmi_out_<7 digit ID>.h5 (Output HDF glossary)

Field name Description Data type Units
data/      
data/snp_<7 digit index>/ff Atomic form factor in 2D array (number of unique ions x length of atomFormFactorQ) Float  
data/snp_<7 digit index>/halfQ Reciprocal space spanned by the atomic form factor in 1D array (number of samples of reciprocal q) Float 1/Å
data/snp_<7 digit index>/Nph Numbers of photons in the beam Int ph
data/snp_<7 digit index>/r Atomic position in real space in 2D array (number of ions x 3D coordinates {x,y,z}) Float  
data/snp_<7 digit index>/T List of unique ID numbers given to each atomFormFactor in 1D array (number of unique ions) Int  
data/snp_<7 digit index>/Z List of atomType present at atomPosition in 1D array (number of ions x number of frames) Int  
data/snp_<7 digit index>/xyz List of indices of ff for each atom in Z Int  
data/snp_<7 digit index>/Sq_halfQ Reciprocal space spanned by the Compton scattering in 1D array (number of samples of reciprocal q) Float 1/Å
data/snp_<7 digit index>/Sq_bound Compton scattering by bound electrons in 1D array (length of Sq_Q) Float  
data/snp_<7 digit index>/Sq_free Compton scattering by free electrons in 1D array (length of Sq_Q) Float  
history Information about input data    
history/parent/detail Details of the parent inclusing /data, /info, /misc, /params    
history/parent/parent Iteratively list parent modules    
info/      
info/package_version Package version    
info/contact Contact details of author    
info/data_description Short description of what the data is    
info/method_description Short description of what method was used to generate the data    
misc/ Miscellaneous information    
params/ Parameters used to run the module    
version hdf5 format version Float 0.1

Python script for HDF

Script on bitbucket

_images/detector_rsz.png

Coherent Diffraction

Input/Output data description

The input/output data is expected in hdf5 format, and the glossary can be found below. Coherent diffraction module is responsible for reading in and writing out in the format specified below.

diffr_params_SingFEL (Input Parameter glossary)

Field name Description DataType
–input_dir Input directory where pmi_out files are stored String
–output_dir Output directory where diffr_out files will be stored String
–config_file Full path and filename of this file String
-b Experimental beam file String
-g Experimental geometry file String
–uniformRotation Rotations are selected uniformly in given rotation space Int
–calculateCompton Calculate Compton scattering in diffraction pattern Int
–sliceInterval Interval to calculates diffraction Int
–numSlices Number of time slices to use for calculating diffraction Int
–pmiStartID Start ID of PMI trajectory Int
–pmiEndID End ID of PMI trajectory Int
–dpID Diffraction pattern index for current pmiID Int
–numDP Number of diffraction patterns to generate per pmiID Int
–USE_GPU Options to use GPU (1) or not (0) Int
version SingFEL version 0.1

diffr_out_<7 digit ID>.h5 (Output HDF glossary)

Field name Description Data type Units
data/      
data/data Diffraction pattern in 2D matrix Float  
data/diffr Diffracted intensity before Poisson noise (Optional) Float  
data/angle Additional rotation applied to the rotated pmi_out position. Initial rotation angle can be found in pmi_out/data/angle. Active right handed rotations applied in quaternion. Float  
history/ Information about input data    
history/parent/detail Details of the parent including /data, /info, /misc, /params /data should be soft-linked with a relative path    
history/parent/parent Iteratively list parent modules    
info/ Information    
info/package_version Package name and version String  
info/contact Contact details of author String  
info/data_description Short description of what the data is String  
info/method_description Short description of what method was used to generate the data String  
misc/ Miscellaneous information    
params/ Parameters used for coherent diffraction    
params/geom/detectorDist Detector distance from point of interaction Float m
params/geom/pixelWidth Pixel width Float m
params/geom/pixelHeight Pixel height Float m
params/geom/mask Mask of a diffraction pattern to indicate Int  
  pixel ON (1) or OFF (0) in 2D array    
params/beam/photonEnergy Photon energy Float eV
params/beam/photons Number of photons in the beam Int ph
params/beam/focusArea Beam focus area Float
params/info Input for Coherent diffraction program String  
version hdf5 format version Float 0.1

Diagnostic

Python script displays /data/data and /data/diffr at completion of the module execution.

Scaling behaviour of SingFEL

Calculation time using single processor vs number of atoms is non-linear, perhaps quadratic.

Detector number of pixels: 131x131

Benzoic acid: 15 atoms Chignolin: 2484 atoms 2YBE: 3240 atoms 2NIP: 4735 atoms 4AS4: 4963 atoms

_images/singfel_speed.png
_images/diffrVol_rsz.png

Orientation Determination

Input/Output data description

Test

The input/output data is expected in hdf5 format, and the glossary can be found below. Orientation determination module is responsible for reading in and writing out in the format specified below.

orient_out_<7 digit ID>.h5 (Output HDF glossary)

Field name Description Data type Units
data/      
data/data Diffraction volume in 3D array (dimX x dimY x dimZ) Float  
data/angle Most likely orientation Float  
data/center center of diffraction volume x,y,z Int pixels
params/ Parameters used for coherent diffraction    
params/info Input for orientation determination program and version String  
history/ Information about input data    
info/ Information    
misc/ Miscellaneous information    
version hdf5 format version Float 0.1

Diagnostics of reconstructed 3D diffraction volume

EMC reconstruction parameters..

_images/orient_2015_01_28_21_00_34.png
_images/protein_rsz.png

Phasing

Input/Output data description

The input/output data is expected in hdf5 format, and the glossary can be found below. Phasing module is responsible for reading in and writing out in the format specified below.

phase_out_<7 digit ID>.h5 (Output HDF glossary)

Field name Description Data type Units
data/      
data/electronDensity Recovered electron density volume in 3D array (dimX x dimY x dimZ) Float  
params/      
params/info Input for phasing program and version String  
history/ Information about input data    
info/ Information    
misc/ Miscellaneous information    
version hdf5 format version Float 0.1
_images/protein_rsz.png

Indices and tables