import escape as esc
esc.require('0.9.1')
import numpy as np
from escape.utils import show
In this notebook we continue to demonstrate the capabilities of ESCAPE to simulate small-angle scattering data with custom model functions.
The following example implements a single polymer form-factor for branched polymers formulated by B. Hammouda et al. ( https://doi.org/10.1002/mats.201100111)
Full article is available here: http://www.sciencetopics.net/5.recent_scientific_publications/4.publications_4/2012_hammouda_macromol_theory_and_simul.pdf
Without going into details of the (mass)fractal model, the form-factor of branched polymer is given by:
$P_B(Q)=\frac{1}{Norm}\left[\frac{1}{\nu U_B^{c/2\nu}}\gamma\left(c/2\nu, U_B\right)-\frac{1}{\nu U_B^{(c+1)/2\nu}}\gamma\left((c+1)/2\nu, U_B\right)\right]$
where $Norm = \frac{2}{c(c+1)}$ - the normalization factor,
$U_B=Q^2R_g^2(2\nu+c)(2\nu+c+1)/6$ - scattering variable which expressed in terms of the radii of gyration.
$\nu$ - excluded volume, $c$ - scaling factor and raddi of gyration are the model fit parameters.
The implementation of this model in terms of ESCAPE entities is straightforward.
# Q variable
q = esc.var("Q")
# Radii of gyration
RG = esc.par("RG", 150, units="nm")
#excluded volume
VM = esc.par("VM", 0.6, units="arbitr")
#scaling factor
C = esc.par("C", 1, units="arbitr", fixed=True, userlim=[1, 2])
f = 2*VM+C
Ub = q*q*RG*RG*f*(f+1)/6
norm_inv = 0.5*(C*C+C)
#we need normalized lower gamma function
gamma = esc.gamma_p
pow = esc.pow
#intensity
P = (gamma(0.5*C/VM, Ub)/(VM*pow(Ub, 0.5*C/VM))-gamma(0.5*(C+1)/VM, Ub)/(VM*pow(Ub, 0.5*(C+1)/VM)))*norm_inv;
show(P, coordinates=np.linspace(0, 1, 1000), ylog=True)