Menu

farfield_inputmain matlab

Anonymous

Paramters to go in input_main.m

Experimental setup

edit?]#Beam_energy_and_flux?

Beam energy and flux

Energy = 24.344                         % Energy in keV
I0 = 1e14                               % Beam flux (Ph/s/mm2)

edit?]#Detector_specification_e.g._Frelon2K_non-binned_specs_below?

Detector specification e.g. Frelon2K non-binned specs below

dety0 = 1023.5                          % beamcenter, y in pixel coordinatees
detz0 = 1023.5                          % beamcenter, z in pixel coordinatees
pixelysize = 0.04677648                 % Pixel size y (mm)
pixelzsize = 0.04808150                 % Pixel size z (mm)
detysize = 2048.0                       % detector y size (pixels)
detzsize = 2048.0                       % detector z size (pixels)
Lsam2det = 55.00                        % sample-detector distance (mm)
tilt_x   = 0.0                          % detector tilt counterclockwise around laboratory x axis (beam direction) in radians
tilt_y   = 0.01                         % detector tilt counterclockwise around laboratory y axis in radians
tilt_z   = 0.0                          % detector tilt counterclockwise around laboratory z axis (same as omega axis) in radians

OBS: If diffraction images are to be formed it is also possible to simulate detector point spread, background and noise. See below.
edit?]#Omega_scan_range.2C_step_size_and_speed?

Omega scan range, step size and speed

wmin = -45.0                            % Minimum Omega in range of interest (in deg)
wmax = 45.0                             % Maximum Omega in range of interest (in deg)
wstep = 2.0                             % Omega step size (in deg)
wspeed = 1                              % Collection speed (seconds/deg), just a scalar of
                                        % the intensities

edit?]#Grain_input?

Grain input

There is three possibilities for the grain orientations used in the simulation

  1. Orientations input by the user as U matrix.
  2. Orientations input by the user as Euler angles
  3. Random orientations

edit?]#Orientations_input_by_the_user?

Orientations input by the user

For 1 a variable U_grains should be defined having the structure

U_grains = [U11(1) U12(1) U13(1) U21(1) U22(1) U23(1) U31(1) U32(1) U33(1);
            U11(2) U12(2) U13(2) U21(2) U22(2) U23(2) U31(2) U32(2) U33(2);
            ...
            ...
            U11(n) U12(n) U13(n) U21(n) U22(n) U23(n) U31(n) U32(n) U33(n)]

For 2 a variable euler_grains should be defined having the structure

euler_grains = [phi1(1) Phi(1) phi2(1);
            phi1(2) Phi(2) phi2(2);
            ...
            ...
            phi1(n) Phi(n) phi2(n)]

n being the n_th_ and last grain.
edit?]#Random_orientations?

Random orientations

For having random orientations the number of grains to simulate is input

grains = 10

edit?]#Sample_orientation? Sample orientation
If the orientations given above is with respect to a special sample orientation a tranformation matrix S can be input. By default S is the indentity matrix.

S = [1 0 0; 0 1 0; 0 0 1];

edit?]#Grain_sizes?

Grain sizes

Again two possiblies are presently available, either one common grain size choosen by the user or the grain sizes can be simulated to follow a log normal distribution.

mediangrainsize = 50.0         % Median grain size (diameter in microns): Default is 75 microns
                               % If a negative value is given this will be the grain size of all grains

In a log distribution is chosen it is possible to limit the range of the distribution, by setting a maximum and minimum grain size.

grainsizemin = 5
grainsizemax = 120

edit?]#Reflection_input?

Reflection input

edit?]#Generation_of_reflections?

Generation of reflections

Should reflections be generated by simul_farfield

readhkl = 0

or read from a previously saved Matlab file

readhkl = 1
hklfile = 'Ahkl_theta27.mat'

or a ascii file given that the input file is structured such that columns are separated by at least one space character. The first four columns are h k l F^2. The parameters set on the input file is then

readhkl = 1
hklfile = 'insulin.hkl'

By default reflections will be generated to cover the detector according to the distance given. But it is possible the limit the number of reflections by specifying a maximum θ value.

thetamax = 16.0

edit?]#Reflection_intensities?

Reflection intensities

The intensities can be choosen to be proportional to a constant independent on the structure factor or be proportional to the reflections structure factor. If structure factors are to be calculated structural input can to be input.

structfact = 0 % don't calculate structure factors
structfact = 1 % do
structfact = 2 % read hkl list and squared structure factors from file hklfile (see above)

Lorentz and Polarisation effects can be taken into account.

Lorentz = 0                 % Do not apply Lorentz factor
Lorentz = 1                 % Apply Lorentz factor
polfactor = 0               % Do not apply polarisation factor
polfactor = 1               % Apply polarisation factor

If the polarisation effect is choosen to be included a factor for the polarisation of the beam

beampol = 1.0               % Beam polarisation (1 = totally horizontally polarised)
                            %                   (0 = nonpolarised beam)

edit?]#Diffraction_images?

Diffraction images

simul_farfield can be used without simulating the diffraction images, in this case

makeframes = 0

else

makeframes = 1

edit?]#Peak_shape?

Peak shape

Currently only two different peak shapes/profiles are available
A square 3x3 spike

peakshape = 0

or a Gaussian spot with one FWHM in the y and z detector directions (in pixels) and another in ω

peakshape = 1           % Make the Gaussian peak
peakfwhm  = 2           % FWHM in pixels
peakwsig  = 0.2           % FWHM in omega (in deg)

or use the 'real' orientation spread of the crystal (mosaicity). OBS - This will not smear intensity in the 2theta direction.

peakshape = 2          % Make peak spread from orientation distribution function

There is two possibilities of providing/defining an orientation distribution function (ODF) The simplest one is to give to ODF as a isotropic Gaussian mosaic spread

odf_type = 1
mosaicity = 0.2        % The mosaic spread in degrees

if no odf_type or mosaicity these values will by default be used. The other is to give the ODF in as voxelated grid defined in Rodrigues space.

odf_type = 2
odf_scale = 0.04 % scale of the grid in degrees
odf = [ ]        % x by y by z matrix

edit?]#Noise_and_background?

Noise and background

The peaks can be added upon a constant background

bgint = 10             % Background level in counts

Poissonian noise can added to the diffraction images

addnoise = 1

otherwise set

addnoise = 0

if noise will be added DIPimage matlab toolbox and DIPlib have to be installed.
edit?]#Detector_point_spread_function_.28PSF.29?

Detector point spread function (PSF)

If an ODF (look above) is used calculate the mosaic spread of the peaks, it is possible convolute the detector image by a point spread function.

psf = 0             % No PSF applied (default)
psf = 1             % PSF is a Gaussian function, input also psf_y, psf_y_size, psf_z, and psf_z_size
psf = 2             % User supplies PSF as a matrix (psf_map)

if psf = 1, the following parameters can be supplied

psf_y              % sigma (pixels) of Gaussian in y detector direction (default 0.7)
psf_z              % sigma (pixels) of Gaussian in z detector direction (default 0.7)
psf_y_size         % number of pixels in PSF map in the y direction (default 3 pixels)
psf_z_size         % number of pixels in PSF map in the z direction (default 3 pixels)

if psf =2, the following variable is required

psf_map = [0.0422    0.1171    0.0422;
           0.1171    0.3248    0.1171;
           0.0422    0.1171    0.0422]; % the PSF

Related

Wiki: farfield simulation matlab

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.