<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Exercise 1
Step1:  Positions
Step2:  Optional
Step3:  $\sigma=\frac{\text{FWHM}}{2\sqrt{2\log 2}}$
Step4:  Finally, beam divergency settings will look as follows
The distribution widget should show the following plot
Optional
Step5:  Finally, the resolution function is defined as
In this exercise we have defined the same resolution width in both directions. However, for some instruments the resolution in $X$ and $Y$ directions may be different.
Exercise 2
Step6:  Click Fourier button on the top panel. The Fourier transform should look as shown below.
Step7:  Switch to Projections view in the top right corner.
Choose the horizontal line on the right panel to create a horizontal projection. Position it at $Q_z=0.4$. Click to the floppy disk to save projection to a text file. The result should look as shown below.
Step8:  Choose the vertical line on the right panel to create a vertical projection. Position it at $Q_y=0$. Click to the floppy disk to save projection to a text file. The result should look as shown below.
<ASSISTANT_TASK:>
Python Code:
width = 981 * 0.172
print("Width = ", width, " mm")
height = 1043 * 0.172
print("Height = ", height, " mm")
Explanation: Exercise 1: Set up GALAXI instrument
Beam parameters
Pay attention, that Wavelength must be given in nm. Thus, $\lambda = 0.134$ nm.
Detector parameters
Considering pixel size 0.172 mm, calculate the detector size:
End of explanation
u0 = 600 * 0.172
print ("u0 = ", round(u0, 2), " mm")
v0 = 350 * 0.172
print("v0 = ", round(v0, 2), " mm")
Explanation: Positions
End of explanation
import numpy as np
angle_fwhm = np.degrees(0.3e-3)
print("Angular divergency = ", round(angle_fwhm, 3), " degrees")
Explanation: Optional: beam divergency
Beam divergency should be specified in degrees. Thus, first we need to convert units:
End of explanation
divider = 2*np.sqrt(2*np.log(2))  # approximately equal to 2.355
sigma = angle_fwhm/divider
print("sigma = ", round(sigma,3))
Explanation: $\sigma=\frac{\text{FWHM}}{2\sqrt{2\log 2}}$
End of explanation
sigma = 0.172/2.355
print("SigmaX = SigmaY = ", round(sigma, 3))
Explanation: Finally, beam divergency settings will look as follows
The distribution widget should show the following plot
Optional: detector resolution
GALAXI detector pixel has size 0.172 mm. Thus for FWHM equal to the pixel size,
End of explanation
from IPython.display import Image
imgfile = "img/sim1.png"
Image(url=imgfile)
Explanation: Finally, the resolution function is defined as
In this exercise we have defined the same resolution width in both directions. However, for some instruments the resolution in $X$ and $Y$ directions may be different.
Exercise 2: Si Nano dots on Si substrate
Construct the sample
Drag on the left side and drop in the sample design area  the Multi layer object.
Drag 2 layers and drop them on the Multilayer.
Drag and drop the Basic particle layout object. Connect it to the upper layer.
Drag and drop Box particle. Connect it to the Particle layout.
Set the materials
Click on the bottom layer to select it. On the right panel click on the Material to start the Material editor widget.
Create new material Si with $\delta=5.78\cdot 10^{-6}$ and $\beta=1.02\cdot 10^{-7}$. For this exercise we use Refractive index based material. More about material kinds in BornAgain in later tutorials.
After you've selected substrate material to be Si, click on the Particle ans set it's material to Si too.
Finally, set the particle length to 30 nm, width to 20 nm and height to 10 nm.
Exercise 3
Click Run Simulation button in Simulation view. After the simulation has finished, BornAgain should automaticaly switch to Job view screen. Click Properties on the top panel. Change Axes Units from mm to q-space. Change the Min value of the y-axis to 0. Click Save button on the top panel to save the plot as .png file. The result should look like shown below.
End of explanation
fftfile = "img/sim1_fft.png"
Image(url=fftfile)
Explanation: Click Fourier button on the top panel. The Fourier transform should look as shown below.
End of explanation
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
projfile = "data/proj2.txt"
data = np.loadtxt(projfile)
plt.semilogy(data[:,0], data[:,1], color='k')
plt.xlabel(r'$Q_y$ (nm$^{-1}$)')
plt.ylabel('Intensity (a. u.)')
plt.title(r"Horizontal slice at $Q_z=0.4$ nm$^{-1}$");
Explanation: Switch to Projections view in the top right corner.
Choose the horizontal line on the right panel to create a horizontal projection. Position it at $Q_z=0.4$. Click to the floppy disk to save projection to a text file. The result should look as shown below.
End of explanation
projfile = "data/proj1.txt"
data = np.loadtxt(projfile)
plt.semilogy(data[:,0], data[:,1], color='r')
plt.xlabel(r'$Q_z$ (nm$^{-1}$)')
plt.ylabel('Intensity (a. u.)')
plt.title(r"Vertical slice at $Q_y=0$ nm$^{-1}$")
plt.xlim(0.0, 2.3);
Explanation: Choose the vertical line on the right panel to create a vertical projection. Position it at $Q_y=0$. Click to the floppy disk to save projection to a text file. The result should look as shown below.
End of explanation
<END_TASK>