## Form factor
>[!Tip]
>Helpful websites for form factor analysis:
> [SASfit/doc/manual/sasfit.pdf at master · SASfit/SASfit · GitHub](https://github.com/SASfit/SASfit/blob/master/doc/manual/sasfit.pdf) Local file (240325): [[sasfit.pdf]] This is a doc still being updated. Check the website for latest version.
> [NCNR tools on the web (nist.gov)](https://www.ncnr.nist.gov/resources/)
> [SasView Model Functions — SasView 3.1.2 documentation](https://www.sasview.org/docs/old_docs/3.1.2/user/models/model_functions.html)
> [Form Factor - GISAXS](http://gisaxs.com/index.php/Form_Factor#Form_Factor_Equations_in_the_Literature) This page provides many links to form factors that have been published in the literature.
### Extracting form factor $P(q)$ from dilute sample
Recall in the last part of [[Introduction to SAS#Form and structure factor for identical particles]], we have the expression for differential cross-section as
$\frac{\mathrm{d}\Sigma}{\mathrm{d}\Omega}(\mathbf{q})= \phi V_p \langle\Delta\rho_p\rangle^2 P(\mathbf{q})S(\mathbf{q})$
For very dilute suspension of particles, $S(\mathbf{q})\approx1$, so we have the cross-section proportional to the form factor
$\frac{\mathrm{d}\Sigma}{\mathrm{d}\Omega}(\mathbf{q})= \phi V_p \langle\Delta\rho_p\rangle^2 P(\mathbf{q})$
And all other parameters are controllable. This enables one to extract the form factor.
### Form factors for simple geometries
The form factor, as the expression given as
$P(\mathbf{q}) =\frac{{\left| F(\mathbf{q}) \right|^2}}{\left| F(\mathbf{q} = \mathbf{0}) \right|^2} = \left| \frac{\int_{V_p} \mathrm{d}\mathbf{r} \Delta\rho_p(\mathbf{r}) e^{-i\mathbf{q} \cdot \mathbf{r}}}{\int_{V_p} \mathrm{d}\mathbf{r} \Delta\rho_p(\mathbf{r})} \right|^2$
is something that can be theoretically calculated. If one takes $\Delta \rho_{p}$ as a constant, then this term could be cancelled at both upper and lower side. An the denominator is just the volume of a particle. Therefore, $P(q)$ is just the numerator, who is an integral of the phase term inside entire volume, divided by volume.
#### Sphere
$\begin{aligned} P(q)&= \left( \frac{4\pi}{3} R^3 \right)^{-1} \left| \int_{S} \mathrm{d}^3r \, e^{-i\mathbf{q} \cdot \mathbf{r}} \right|^2 \\ &= \left\{ \frac{3[\sin(qR) - (qR) \cos(qR)]}{(qR)^3} \right\}^2 \end{aligned}$
$R$ is the sphere radius.
![[Drawing 2024-04-17 23.24.44.excalidraw.svg]]
The decay part has a $q^{-4}$ dependence. "Peaks" of spherical systems can also be used to determine the size of the particle.
#### Cylinder
Consider a cylinder with length $L$ and diameter $2R$. With its center placed at origin. Under cylindrical coordinate, $\mathbf{r} = \begin{pmatrix} r \cos \phi \\ r \sin \phi \\ z \end{pmatrix}$ and $\mathbf{q} = q \begin{pmatrix} \sin \theta \\ 0 \\ \cos \theta \end{pmatrix}$, $\theta$ is the angle between $\hat{\mathbf{z}}$ and $\mathbf{q}$. The from factor is
$P(q) = \frac{1}{(L\pi R^2)^2} f^2(q, \theta)$
where
$f(q) = \frac{4\pi R \sin\left(\frac{L}{2}q\cos\theta\right) J_1(Rq\sin\theta)}{q\cos\theta q\sin\theta}$
This $J_{1}$ is [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind of order one, or [cylindrical harmonics](https://en.wikipedia.org/wiki/Cylindrical_harmonics).
The trend of $P$ depends on $\theta$, i.e., how the particles are arranged. For $\theta=0$ one can notice a $q^{-4}$ dependence. For randomly oriented samples,
$P(q) = \frac{1}{(L\pi R^2)^2} \frac{1}{2} \int_{0}^{\pi} f^2(q, \theta) \sin(\theta) \mathrm{d}\theta$
![[Drawing 2024-04-17 23.46.48.excalidraw.svg]]
In the plot $L=11$ and $R=1$. One may notice $q^{-1}$ behavior at Guinier region (check [[Introduction to SAS#Know about SAS data and plot]]), and $q^{-4}$ for high $q$.
#### Cuboid
The cuboid with edges $a, b, c$ is defined as
$f(x, y, z) = \begin{cases} 1 & \text{if } -\frac{a}{2} \leq x \leq \frac{a}{2} \text{ and } -\frac{b}{2} \leq y \leq \frac{b}{2} \text{ and } -\frac{c}{2} \leq z \leq \frac{c}{2} \\ 0 & \text{otherwise} \end{cases}$
The form factor is
$P(q) = \left[ \frac{\sin \left(q_x \frac{a}{2}\right)}{q_x \frac{a}{2}} \cdot \frac{\sin \left(q_y \frac{b}{2}\right)}{q_y \frac{b}{2}} \cdot \frac{\sin \left(q_z \frac{c}{2}\right)}{q_z \frac{c}{2}} \right]^2$
This is also angle dependent.
![[Drawing 2024-04-18 00.12.28.excalidraw.svg]]
The plot is for $a=1, b=2, c=3$, and $q$ applied are $\textcolor{#FF8C00}{\mathbf{q} = q(1,0,0)}$, $\textcolor{#32CD32}{\mathbf{q} = {\frac{q}{\sqrt{2}}{(1,1,0)}}}$, $\textcolor{#00BFFF}{\mathbf{q} = \frac{q}{\sqrt{3}}{(1,1,1)}}$. The tendency also depends on orientation.
### Form factor for polymers
See [[Scattering from polymers]].
For Gaussian chain, $P(q)= \frac{2}{(q^2 \langle R_G^2 \rangle)^2} \left[ e^{-q^2 \langle R_G^2 \rangle} + q^2 \langle R_G^2 \rangle - 1 \right]$, where $\langle R_G^2 \rangle=\frac{1}{6} Nb^{2}$.
This model has the following limiting behavior:
- For $q^2 \langle R_G^2 \rangle \ll 1$, $P(q) \approx 1 - \frac{1}{3} q^2 \langle R_G^2 \rangle$
- For $q^2 \langle R_G^2 \rangle \gg 1$, $P(q) \approx \frac{2}{q^2 \langle R_G^2 \rangle}$
### Form factor for core-shell particles
![[Drawing 2024-05-20 18.05.07.excalidraw.svg]]
Write the $F$ of core and the whole sphere separately, then do the normalization. Notice this time we cannot cancel the $\Delta \rho$ and it gets into the expression.
Whole sphere:
$\begin{aligned} f(q) &= 4\pi \int_{0}^{R} \mathrm{d}r \, r^2 \frac{\sin(qR)}{qR} \\ &= \left( \frac{4\pi}{3} R^3 \right) \frac{3 \left[ \sin(qR) - qR \cos(qR) \right]}{(qR)^3} \end{aligned}$
Core:
$\begin{aligned} f_c(q) &= 4\pi \int_{0}^{R_c} \mathrm{d}r \, r^2 \frac{\sin(qR)}{qR} \\ &= \left( \frac{4\pi}{3} R_c^3 \right) \frac{3 \left[ \sin(qR_c) - qR_c \cos(qR_c) \right]}{(qR_c)^3} \end{aligned}$
Then combine to get the overall $F(q)$,
$|F(q)|^2 = \left| \rho_s f(q) + (\rho_c - \rho_s) f_c(q) \right|^2$
Calculate the $P(q)$ by doing normalization, i.e., $P(\mathbf{q}) =\frac{{\left| F(\mathbf{q}) \right|^2}}{\left| F(\mathbf{q} = \mathbf{0}) \right|^2}$.
>[!Notice]
>The $\rho$ here is actually $\Delta \rho$. We did not consider the background medium here.
![[Drawing 2024-05-20 19.37.41.excalidraw.svg]]
In above plot, there are something worth to emphasis:
- $b_{core}=-1$ case have a positive slope at Guinier region, because we have imaginary $R_{g}$ under this condition. This is possible because we have a negative scattering length density. See [[Radius of gyration#Special case negative SLD and complex $R_g$]] for more information.
- It would be hard to read the $R_{g}$ directly from this plot due to the existence of negative SLD, but the first peak (at Porod region) provides some information on $R_{g}q\sim1$. From the plot, one can estimate that $b_{core}=2$ gives a smaller $R_{g}$ compared to $b_{core}=0$, cause at the first peak it has a bigger $q$.
- The extended plot shows that $b_{core}=-1$ will also goes to1 eventually. (This is for $P(q)$, not intensity)
![[Drawing 2024-05-20 23.13.48.excalidraw.svg]]
> [!code]-
> The code for generating extend plot is given here. (Original form is also included in this plot)
> ```python
> import numpy as np
> import matplotlib.pyplot as plt
>
> # Define the core-shell parameters
> R = 100 # nm, radius of the whole sphere
> Rc = 80 # nm, radius of the core
> sigma_p = 0.02 # polydispersity
> rho_s = 1 # a.u., SLD of the shell
> b_core_values = [-1, 0, 2] # a.u., original SLD values for the core
> additional_b_core_values = [-2, 4] # a.u., additional SLD values for the core
>
> # Combine the original and additional b_core values
> all_b_core_values = b_core_values + additional_b_core_values
>
> # Define the scattering vector q with more dense points
> q = np.linspace(0.01, 1, 1000)
>
> # Function to calculate the form factor f(q) for the whole sphere
> def f(q, R):
> return np.where(q != 0, (4 * np.pi / 3 * R**3) * (3 * (np.sin(q * R) - q * R * np.cos(q * R)) / (q * R)**3), 4 * np.pi / 3 * R**3)
>
> # Function to calculate the form factor f_c(q) for the core
> def f_c(q, Rc):
> return np.where(q != 0, (4 * np.pi / 3 * Rc**3) * (3 * (np.sin(q * Rc) - q * Rc * np.cos(q * Rc)) / (q * Rc)**3), 4 * np.pi / 3 * Rc**3)
>
> # Generate the plot
> plt.figure(figsize=(10, 6), facecolor='none')
>
> # Calculate and plot the form factors for all b_core values
> for b_core in all_b_core_values:
> F_q = np.abs(rho_s * f(q, R) + (b_core - rho_s) * f_c(q, Rc))**2
> # Normalization factor |F(q=0)|^2
> F_q0 = np.abs(rho_s * f(0, R) + (b_core - rho_s) * f_c(0, Rc))**2
> P_q = F_q / F_q0 # Normalized form factor
> plt.plot(q, P_q, label=f'b_core = {b_core} (a.u.)')
>
> # Set plot parameters
> plt.xscale('log')
> plt.yscale('log')
> plt.ylim(1e-7, 1e2)
> plt.xlabel('q (1/nm)', color='#849eb8')
> plt.ylabel('P(q)', color='#849eb8')
> plt.legend(facecolor='none', framealpha=0.5, labelcolor='#849eb8')
> plt.grid(True, color='gray', linestyle='--', linewidth=0.5)
>
> # Set plot background to transparent
> plt.gca().patch.set_alpha(0.0)
> plt.gcf().patch.set_alpha(0.0)
>
> # Change the color of tick labels for visibility
> plt.tick_params(axis='x', colors='#849eb8')
> plt.tick_params(axis='y', colors='#849eb8')
>
> # Mark y=1 clearly
> plt.axhline(y=1, color='gray', linestyle='--', linewidth=0.7)
>
> # Display the plot
> plt.show()
>
> ```