Running Condor simulations¶
There are generally two ways of configuring and running simulations with Condor:
A) Configuration files
Write a configuration file based on the examples below, name the file ‘condor.conf’ and run the Condor executable in the same folder:
$ condor -n [number_of_patterns]Condor will create an HDF5 file named ‘condor.cxi’, which contains the simulated pattern(s) and additional output (Reading CXI files).
For help and more options run:
$ condor -h
B) Python scripts
Create a
condor.experiment.Experiment
instance and callcondor.experiment.Experiment.propagate()
to obtaining the simulation result:E = condor.Experiment(source, sample, detector) res = E.propagate() intensity_pattern = res["entry_1"]["data_1"]["data"] fourier_pattern = res["entry_1"]["data_1"]["data_fourier"]The simulation result is provided as Python dictionary that contains besides the simulated pattern a lot of additional output.
A) Configuration files¶
A Condor configuration file is composed of at least three sections:
1) Source [source]
2) Particle - at least one particle section:
a) Uniform sphere
[particle_sphere]
b) Uniform spheroid
[partice_spheroid]
c) Refractive index map
[particle_map]
d) Atom positions
[particle_atoms]
3) Detector [detector]
Note
All section titles have to be unique in a configuration file. If you want to specify more than one particle sections of the same particle model make the section title unique by appending an underscore and a number to the standard title (e.g. [particle_sphere_2]
).
1) Source¶
This section configures the condor.source.Source
class instance.
Example:
[source]
# Wavelength [m]
wavelength = 1.E-09
# Focal spot size (FWHM of profile) [m]
focus_diameter = 5.E-06
# Pulse profile can be set to 'None', 'top_hat', 'gaussian' or 'pseudo_lorentzian'
profile_model = None
# Pulse energy [J]
pulse_energy = 1E-03
# Pulse energy variation can be set to 'None', 'normal' or 'uniform'
# (if 'normal' or 'uniform' the additional argument 'pulse_energt_spread' is required)
pulse_energy_variation = None
2) Particle¶
a) Uniform sphere¶
This section configures a condor.particle.particle_sphere.ParticleSphere
class instance.
Example:
[particle_sphere]
# Number density in units of the interaction volume
number = 1.
# Arrival of particles at the interaction volume can be either 'random' or 'synchronised'. If sync at every event the number of particles in the interaction volume equals the rounded value of the number_density. If 'random' the number of particles is Poissonian and the number_density is the expectation value.
arrival = synchronised
# Position of particle relative to focus point
position = [0.,0.,0.]
# Position variation can be set to 'None', 'normal', 'uniform'
# (if not 'None', additional argument position_spread is required)
position_variation = None
# Material type can be set to 'None', 'protein', 'virus', 'cell', 'latexball', 'water' or 'custom' ('custom' requires additional arguments relative concentrations of elements (cH, cHe, ...) and massdensity)
material_type = cell
# Sample size [m]
diameter = 450.0E-09
# Diameter variation can be set to 'None', 'normal', 'uniform'
# (if not 'None' additional argument diameter_spread has to be specified)
diameter_variation = None
b) Uniform spheroid¶
This section configures a condor.particle.particle_spheroid.ParticleSpheroid
class instance.
Example:
[particle_spheroid]
# Number density in units of the interaction volume
number = 1.
# Arrival of particles at the interaction volume can be either 'random' or 'synchronised'. If sync at every event the number of particles in the interaction volume equals the rounded value of the number_density. If 'random' the number of particles is Poissonian and the number_density is the expectation value.
arrival = synchronised
# Position of particle relative to focus point
position = [0.,0.,0.]
# Position variation can be set to 'None', 'normal', 'uniform'
# (if not 'None', additional argument position_spread is required)
position_variation = None
# Material type can be set to 'None', 'protein', 'virus', 'cell', 'latexball', 'water' or 'custom' ('custom' requires additional arguments relative concentrations of elements (cH, cHe, ...) and massdensity)
material_type = cell
# Sample size [m]
diameter = 450.0E-09
# Diameter variation can be set to 'None', 'normal', 'uniform'
# (if not 'None' additional argument diameter_spread has to be specified)
diameter_variation = None
# Rotation values
#rotation_formalism = quaternion
#rotation_values = [[0.,1.,0.,0.]]
rotation_mode = extrinsic
# Flattening (flattening = semi-diameter a / semi-diameter c; a is the equatorial radius of the spheroid, and c is the distance from centre to pole along the symmetry axis)
flattening = 0.8
# Flattening variation
flattening_variation = None
c) Refractive index map¶
This section configures a condor.particle.particle_map.ParticleMap
class instance.
Example:
[particle_map]
# Number density in units of the interaction volume
number = 1.
# Arrival of particles at the interaction volume can be either 'random' or 'synchronised'. If sync at every event the number of particles in the interaction volume equals the rounded value of the number_density. If 'random' the number of particles is Poissonian and the number_density is the expectation value.
arrival = synchronised
# Position of particle relative to focus point
position = [0.,0.,0.]
# Position variation can be set to 'None', 'normal', 'uniform'
# (if not 'None', additional argument position_spread is required)
position_variation = None
# Material type can be set to 'None', 'protein', 'virus', 'cell', 'latexball', 'water' or 'custom' ('custom' requires additional arguments relative concentrations of elements (cH, cHe, ...) and massdensity)
material_type = cell
# Sample size [m]
diameter = 450.0E-09
# Diameter variation can be set to 'None', 'normal', 'uniform'
# (if not 'None' additional argument diameter_spread has to be specified)
diameter_variation = None
# Rotation values
#rotation_formalism = quaternion
#rotation_values = [[1.,0.,0.,0.]]
rotation_mode = extrinsic
# Available geometry types are: 'icosahedron', 'cube', 'sphere', 'spheroid' or 'custom'
# ('custom' requires additional argument filename to specify the location of the H5-file that contains the density map; use dataset name "data")
# ('spheroid' requires additional arguments flattening and flattening_variation)
geometry = icosahedron
d) Atom positions¶
This section configures a condor.particle.particle_atoms.ParticleAtoms
class instance.
Example:
[particle_atoms]
# Number density in units of the interaction volume
number = 1.
# Arrival of particles at the interaction volume can be either 'random' or 'synchronised'. If sync at every event the number of particles in the interaction volume equals the rounded value of the number_density. If 'random' the number of particles is Poissonian and the number_density is the expectation value.
arrival = synchronised
# Position of particle relative to focus point
position = [0.,0.,0.]
# Position variation can be set to 'None', 'normal', 'uniform'
# (if not 'None', additional argument position_spread is required)
position_variation = None
# PDB file
pdb_filename = ../../DNA.pdb
# Rotation values
#rotation_formalism = quaternion
#rotation_values = [[1.,0.,0.,0.]]
rotation_mode = extrinsic
3) Detector¶
This section configures a condor.detector.Detector
class instance.
Example:
[detector]
# sample-detector distance [m]
distance = 0.73
# pixel width and height [m]
pixel_size = 75E-06
# absolute number of pixels in x/y direction
nx = 1024
ny = 1024
# binning (additional output of binned pattern if binning is not None)
binning = None
# Central gap between detector halves in pixel
x_gap_size_in_pixel = 0
y_gap_size_in_pixel = 0
# Central hole in detector
hole_diameter_in_pixel = 0
# Center position [0,nx-1] and [0,ny-1], can be set to either floating point value or 'middle', which stands for (n-1)/2.
cx = middle
cy = middle
# Center variation can be set to 'normal', 'uniform', 'None'
# (if 'normal' or 'uniform' additional arguments 'center_spread_x' and 'center_spread_y' have to be specified)
# (if 'normal' additional argument 'center_variation_n' has to specified)
center_variation = None
# Noise statistics can be set to 'None', 'poisson', 'normal' or 'normal_poisson'
# (if 'normal' or 'normal_poisson' additional argument noise_spread is required)
noise = poisson
# saturation level [ph/pixel] can be set to a floating point value or 'None'
saturation_level = None
B) Python scripts¶
Simulations are carried out from an instance of the condor.experiment.Experiment
class. Its constructor requires three arguments
- A Source instance
condor.source.Source
- A dictionary with at least one Particle instance:
- Uniform sphere -
condor.particle.particle_sphere.ParticleSphere
(the key has to start with'particle_sphere'
)- Uniform spheroid -
condor.particle.particle_spheroid.ParticleSpheroid
(the key has to start with'particle_spheroid'
)- Refractive index map -
condor.particle.particle_map.ParticleMap
(the key has to start with'particle_map'
)- Atom positions -
condor.particle.particle_atoms.ParticleAtoms
(the key has to start with'particle_atoms'
)- A Detector instance -
condor.detector.Detector
Calling the method condor.experiment.propagate()
starts the simulation of a single diffraction pattern. The method returns a dictionary that contains the diffraction pattern(s) and a lot of additional output.
Examples¶
Simple example:
import numpy
import condor
# Construct Source instance
src = condor.Source(wavelength=0.1E-9, pulse_energy=1E-3, focus_diameter=1E-6)
# Construct Detector instance
det = condor.Detector(distance=0.05, pixel_size=110E-6, nx=1000, ny=1000)
# Construct ParticleSphere instance
par = condor.ParticleSphere(diameter=1E-9, material_type="water")
# Combine source, detector, and particle by constructing Experiment instance
E = condor.Experiment(src, {"particle_sphere" : par}, det)
# Calculate diffraction pattern and obtain results in a dict
res = E.propagate()
# Arrays for Fourier and real space
data_fourier = res["entry_1"]["data_1"]["data_fourier"]
real_space = numpy.fft.fftshift(numpy.fft.ifftn(data_fourier))
Many more examples for condor scripts can be found here.