[577912b] | 1 | r""" |
---|
| 2 | This model provides the form factor for $N$ spherical pearls of radius $R$ |
---|
| 3 | linearly joined by short strings (or segment length or edge separation) |
---|
| 4 | $l$ $(= A - 2R)$. $A$ is the center-to-center pearl separation distance. |
---|
| 5 | The thickness of each string is assumed to be negligible. |
---|
| 6 | |
---|
[2f0c07d] | 7 | .. figure:: img/linear_pearls_geometry.jpg |
---|
[577912b] | 8 | |
---|
| 9 | |
---|
| 10 | Definition |
---|
| 11 | ---------- |
---|
| 12 | |
---|
| 13 | The output of the scattering intensity function for the linear_pearls model |
---|
| 14 | is given by (Dobrynin, 1996) |
---|
| 15 | |
---|
| 16 | .. math:: |
---|
| 17 | |
---|
[e9b0ef3] | 18 | P(Q) = \frac{\text{scale}}{V}\left[ m_{p}^2 |
---|
| 19 | \left(N+2\sum_{n-1}^{N-1}(N-n)\frac{\sin(qnl)}{qnl}\right) |
---|
| 20 | \left( 3\frac{\sin(qR)-qR\cos(qR)}{(qr)^3}\right)^2\right] |
---|
[577912b] | 21 | |
---|
| 22 | where the mass $m_p$ is $(SLD_{pearl}-SLD_{solvent})*(volume\ of\ N\ pearls)$. |
---|
| 23 | V is the total volume. |
---|
| 24 | |
---|
| 25 | The 2D scattering intensity is the same as P(q) above, |
---|
| 26 | regardless of the orientation of the q vector. |
---|
| 27 | |
---|
| 28 | References |
---|
| 29 | ---------- |
---|
| 30 | |
---|
[0507e09] | 31 | .. [#] A V Dobrynin, M Rubinstein and S P Obukhov, *Macromol.*, 29 (1996) 2974-2979 |
---|
| 32 | |
---|
| 33 | Source |
---|
| 34 | ------ |
---|
| 35 | |
---|
| 36 | `linear_pearls.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/linear_pearls.py>`_ |
---|
| 37 | |
---|
| 38 | `linear_pearls.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/linear_pearls.c>`_ |
---|
| 39 | |
---|
| 40 | Authorship and Verification |
---|
| 41 | ---------------------------- |
---|
| 42 | |
---|
| 43 | * **Author:** |
---|
| 44 | * **Last Modified by:** |
---|
| 45 | * **Last Reviewed by:** |
---|
| 46 | * **Source added by :** Steve King **Date:** March 25, 2019""" |
---|
[577912b] | 47 | |
---|
[2d81cfe] | 48 | import numpy as np |
---|
[577912b] | 49 | from numpy import inf |
---|
| 50 | |
---|
| 51 | name = "linear_pearls" |
---|
| 52 | title = "Linear pearls model of scattering from spherical pearls." |
---|
| 53 | description = """ |
---|
| 54 | Calculate form factor for Pearl Necklace Model |
---|
| 55 | [Macromol. 1996, 29, 2974-2979] |
---|
| 56 | Parameters: |
---|
| 57 | |
---|
| 58 | sld_pearl: the SLD of the pearl spheres |
---|
| 59 | sld_solv: the SLD of the solvent |
---|
| 60 | num_pearls: number of the pearls |
---|
| 61 | radius: the radius of a pearl |
---|
| 62 | edge_separation: the length of string segment; surface to surface |
---|
| 63 | """ |
---|
| 64 | category = "shape:sphere" |
---|
| 65 | |
---|
| 66 | # pylint: disable=bad-whitespace, line-too-long |
---|
| 67 | # ["name", "units", default, [lower, upper], "type", "description"], |
---|
| 68 | parameters = [ |
---|
| 69 | ["radius", "Ang", 80.0, [0, inf], "", "Radius of the pearls"], |
---|
| 70 | ["edge_sep", "Ang", 350.0, [0, inf], "", "Length of the string segment - surface to surface"], |
---|
[e9b0ef3] | 71 | ["num_pearls", "", 3.0, [1, inf], "", "Number of the pearls"], |
---|
[42356c8] | 72 | ["sld", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "SLD of the pearl spheres"], |
---|
| 73 | ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "SLD of the solvent"], |
---|
[577912b] | 74 | ] |
---|
| 75 | # pylint: enable=bad-whitespace, line-too-long |
---|
[40a87fa] | 76 | single = False |
---|
[577912b] | 77 | |
---|
[925ad6e] | 78 | source = ["lib/sas_3j1x_x.c", "linear_pearls.c"] |
---|
[577912b] | 79 | |
---|
[8f04da4] | 80 | def random(): |
---|
[b297ba9] | 81 | """Return a random parameter set for the model.""" |
---|
[8f04da4] | 82 | radius = 10**np.random.uniform(1, 3) # 1 - 1000 |
---|
| 83 | edge_sep = 10**np.random.uniform(0, 3) # 1 - 1000 |
---|
| 84 | num_pearls = np.round(10**np.random.uniform(0.3, 3)) # 2 - 1000 |
---|
| 85 | pars = dict( |
---|
| 86 | radius=radius, |
---|
| 87 | edge_sep=edge_sep, |
---|
| 88 | num_pearls=num_pearls, |
---|
| 89 | ) |
---|
| 90 | return pars |
---|
[577912b] | 91 | |
---|
[b297ba9] | 92 | _ = """ |
---|
[577912b] | 93 | Tests temporarily disabled, until single-double precision accuracy issue solved. |
---|
| 94 | |
---|
| 95 | tests = [ |
---|
| 96 | # Accuracy tests based on content in test/utest_model_pearlnecklace.py |
---|
| 97 | [{'radius': 20.0, |
---|
| 98 | 'num_pearls': 2.0, |
---|
[a2f9aa2] | 99 | 'sld': 1.0, |
---|
| 100 | 'sld_solvent': 6.3, |
---|
[577912b] | 101 | 'edge_sep': 400.0, |
---|
| 102 | }, 0.001, 185.135], |
---|
| 103 | |
---|
| 104 | # Additional tests with larger range of parameters |
---|
| 105 | [{'radius': 120.0, |
---|
| 106 | 'num_pearls': 5.0, |
---|
[a2f9aa2] | 107 | 'sld': 2.0, |
---|
| 108 | 'sld_solvent': 2.3, |
---|
[577912b] | 109 | 'edge_sep': 100.0, |
---|
| 110 | }, 0.01, 45.4984], |
---|
| 111 | |
---|
| 112 | [{'radius': 7.0, |
---|
| 113 | 'num_pearls': 2.0, |
---|
[a2f9aa2] | 114 | 'sld': 10.0, |
---|
| 115 | 'sld_solvent': 99.3, |
---|
[577912b] | 116 | 'edge_sep': 20.0, |
---|
| 117 | }, 1.0, 0.632811], |
---|
| 118 | ] |
---|
[32c743d] | 119 | """ |
---|