r""" This model describes the scattering from polymer chains subject to excluded volume effects and has been used as a template for describing mass fractals. Definition ---------- The form factor was originally presented in the following integral form (Benoit, 1957) .. math:: P(Q)=2\int_0^{1}dx(1-x)exp\left[-\frac{Q^2a^2}{6}n^{2v}x^{2v}\right] where $\nu$ is the excluded volume parameter (which is related to the Porod exponent $m$ as $\nu=1/m$ ), $a$ is the statistical segment length of the polymer chain, and $n$ is the degree of polymerization. This integral was later put into an almost analytical form as follows (Hammouda, 1993) .. math:: P(Q)=\frac{1}{\nu U^{1/2\nu}}\gamma\left(\frac{1}{2\nu},U\right) - \frac{1}{\nu U^{1/\nu}}\gamma\left(\frac{1}{\nu},U\right) where $\gamma(x,U)$ is the incomplete gamma function .. math:: \gamma(x,U)=\int_0^{U}dt\ exp(-t)t^{x-1} and the variable $U$ is given in terms of the scattering vector $Q$ as .. math:: U=\frac{Q^2a^2n^{2\nu}}{6} = \frac{Q^2R_{g}^2(2\nu+1)(2\nu+2)}{6} The square of the radius-of-gyration is defined as .. math:: R_{g}^2 = \frac{a^2n^{2\nu}}{(2\nu+1)(2\nu+2)} Note that this model applies only in the mass fractal range (ie, $5/3<=m<=3$ ) and **does not apply** to surface fractals ( $3 0) + 1.0*(q <= 0) return intensity Iq.vectorized = True # Iq accepts an array of q values def Iqxy(qx, qy, *args): """ :param qx: Input q_x-value :param qy: Input q_y-value :param args: Remaining arguments :return: 2D-Intensity """ return Iq(sqrt(qx**2 + qy**2), *args) Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values demo = dict(scale=1, background=0.0, rg=60.0, porod_exp=3.0) oldname = "PolymerExclVolume" oldpars = dict(background='background', scale='scale', rg='rg', porod_exp='m') tests = [ # Accuracy tests based on content in test/polyexclvol_default_igor.txt [{'rg': 60, 'porod_exp': 3.0}, 0.001, 0.998801], [{'rg': 60, 'porod_exp': 3.0}, 0.105363, 0.0162751], [{'rg': 60, 'porod_exp': 3.0}, 0.665075, 6.56261e-05], # Additional tests with larger range of parameters [{'rg': 10, 'porod_exp': 4.0}, 0.1, 0.723436675809], [{'rg': 2.2, 'porod_exp': 22.0, 'background': 100.0}, 5.0, 100.0], [{'rg': 1.1, 'porod_exp': 1, 'background': 10.0, 'scale': 1.25}, 20000., 10.0000712097] ]