source: sasmodels/sasmodels/models/lamellar_hg_stack_caille.py @ 0507e09

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 0507e09 was 0507e09, checked in by smk78, 5 years ago

Added link to source code to each model. Closes #883

  • Property mode set to 100644
File size: 5.6 KB
RevLine 
[dc02af0]1# Note: model title and parameter table are inserted automatically
2r"""
[12c810f]3This model provides the scattering intensity, $I(q) = P(q)S(q)$, for a lamellar
[eb69cce]4phase where a random distribution in solution are assumed. Here a Caille $S(q)$
[12c810f]5is used for the lamellar stacks.
[dc02af0]6
[12c810f]7The scattering intensity $I(q)$ is
[dc02af0]8
[12c810f]9.. math::
10
[6ab4ed8]11    I(q) = 2 \pi \frac{P(q)S(q)}{q^2\delta }
[12c810f]12
13
14The form factor $P(q)$ is
15
16.. math::
[dc02af0]17
[12c810f]18        P(q) = \frac{4}{q^2}\big\{
19        \Delta\rho_H \left[\sin[q(\delta_H + \delta_T)] - \sin(q\delta_T)\right]
20            + \Delta\rho_T\sin(q\delta_T)\big\}^2
[dc02af0]21
[12c810f]22and the structure factor $S(q)$ is
[dc02af0]23
[12c810f]24.. math::
[dc02af0]25
[12c810f]26    S(q) = 1 + 2 \sum_1^{N-1}\left(1-\frac{n}{N}\right)
27        \cos(qdn)\exp\left(-\frac{2q^2d^2\alpha(n)}{2}\right)
[dc02af0]28
29where
30
[12c810f]31.. math::
[d18f8a8]32    :nowrap:
[12c810f]33
[d18f8a8]34    \begin{align*}
[eb69cce]35    \alpha(n) &= \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right)
[d18f8a8]36              &&  \\
[eb69cce]37    \gamma_E  &= 0.5772156649
[d18f8a8]38              && \text{Euler's constant} \\
[eb69cce]39    \eta_{cp} &= \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}}
[d18f8a8]40              && \text{Caille constant}
41    \end{align*}
[12c810f]42
[dc02af0]43
[a807206]44$\delta_T$ is the tail length (or *length_tail*), $\delta_H$ is the head
45thickness (or *length_head*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent),
[12c810f]46and $\Delta\rho_T$ is SLD(tail) - SLD(headgroup). Here $d$ is (repeat) spacing,
47$K$ is smectic bending elasticity, $B$ is compression modulus, and $N$ is the
48number of lamellar plates (*Nlayers*).
[dc02af0]49
[12c810f]50NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the
51assumptions of the model are incorrect.**  And due to a complication of the
52model function, users are responsible for making sure that all the assumptions
53are handled accurately (see the original reference below for more details).
[dc02af0]54
[12c810f]55Non-integer numbers of stacks are calculated as a linear combination of
56results for the next lower and higher values.
[dc02af0]57
[6ab4ed8]58Be aware that the computations may be very slow.
59
[12c810f]60The 2D scattering intensity is calculated in the same way as 1D, where
61the $q$ vector is defined as
[dc02af0]62
63.. math::
64
[12c810f]65    q = \sqrt{q_x^2 + q_y^2}
[dc02af0]66
67
[eb69cce]68References
69----------
[dc02af0]70
[0507e09]71.. [#] F Nallet, R Laversanne, and D Roux, *J. Phys. II France*, 3, (1993) 487-502
72.. [#] J Berghausen, J Zipfel, P Lindner, W Richtering, *J. Phys. Chem. B*, 105, (2001) 11081-11088
[dc02af0]73
[0507e09]74Source
75------
76
77`lamellar_hg_stack_caille.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lamellar_hg_stack_caille.py>`_
78
79`lamellar_hg_stack_caille.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/lamellar_hg_stack_caille.c>`_
80
81Authorship and Verification
82----------------------------
83
84* **Author:**
85* **Last Modified by:**
86* **Last Reviewed by:**
87* **Source added by :** Steve King **Date:** March 25, 2019
[dc02af0]88"""
[2d81cfe]89
90import numpy as np
[3c56da87]91from numpy import inf
[dc02af0]92
[6ab4ed8]93name = "lamellar_hg_stack_caille"
94title = "Random lamellar head/tail/tail/head sheet with Caille structure factor"
[dc02af0]95description = """\
[3e428ec]96    [Random lamellar phase with Caille  structure factor]
[dc02af0]97        randomly oriented stacks of infinite sheets
[3e428ec]98        with Caille S(Q), having polydisperse spacing.
99        layer thickness =(H+T+T+H) = 2(Head+Tail)
100        sld = Tail scattering length density
101        sld_head = Head scattering length density
102        sld_solvent = solvent scattering length density
103        background = incoherent background
104        scale = scale factor
[dc02af0]105"""
[a5d0d00]106category = "shape:lamellae"
[dc02af0]107
[7f1ee79]108single = False  # TODO: check
[dc02af0]109parameters = [
[d4666ca]110    #   [ "name", "units", default, [lower, upper], "type",
111    #     "description" ],
[a807206]112    ["length_tail", "Ang", 10, [0, inf], "volume",
[d4666ca]113     "Tail thickness"],
[a807206]114    ["length_head", "Ang", 2, [0, inf], "volume",
[d4666ca]115     "head thickness"],
[a57b31d]116    ["Nlayers", "", 30, [1, inf], "",
[d4666ca]117     "Number of layers"],
[7c57861]118    ["d_spacing", "Ang", 40., [0.0, inf], "volume",
119     "lamellar d-spacing of Caille S(Q)"],
[d4666ca]120    ["Caille_parameter", "", 0.001, [0.0, 0.8], "",
121     "Caille parameter"],
[42356c8]122    ["sld", "1e-6/Ang^2", 0.4, [-inf, inf], "sld",
[d4666ca]123     "Tail scattering length density"],
[42356c8]124    ["sld_head", "1e-6/Ang^2", 2.0, [-inf, inf], "sld",
[d4666ca]125     "Head scattering length density"],
[42356c8]126    ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld",
[d4666ca]127     "Solvent scattering length density"],
[dc02af0]128    ]
129
[0bef47b]130source = ["lamellar_hg_stack_caille.c"]
[dc02af0]131
132# No volume normalization despite having a volume parameter
133# This should perhaps be volume normalized?
134form_volume = """
135    return 1.0;
136    """
137
[404ebbd]138def random():
[b297ba9]139    """Return a random parameter set for the model."""
[404ebbd]140    total_thickness = 10**np.random.uniform(2, 4.7)
141    Nlayers = np.random.randint(2, 200)
142    d_spacing = total_thickness / Nlayers
143    thickness = d_spacing * np.random.uniform(0, 1)
144    length_head = thickness * np.random.uniform(0, 1)
145    length_tail = thickness - length_head
146    Caille_parameter = np.random.uniform(0, 0.8)
147    pars = dict(
148        length_head=length_head,
149        length_tail=length_tail,
150        Nlayers=Nlayers,
151        d_spacing=d_spacing,
152        Caille_parameter=Caille_parameter,
153    )
154    return pars
155
[dc02af0]156demo = dict(
[d4666ca]157    scale=1, background=0,
[7c57861]158    Nlayers=20, d_spacing=200., Caille_parameter=0.05,
[a807206]159    length_tail=15, length_head=10,
[6ab4ed8]160    #sld=-1, sld_head=4.0, sld_solvent=6.0,
161    sld=-1, sld_head=4.1, sld_solvent=6.0,
[a807206]162    length_tail_pd=0.1, length_tail_pd_n=20,
163    length_head_pd=0.05, length_head_pd_n=30,
[7c57861]164    d_spacing_pd=0.2, d_spacing_pd_n=40,
[d4666ca]165    )
[dc02af0]166
[7f47777]167#
[a807206]168tests = [[{'scale': 1.0, 'background': 0.0, 'length_tail': 10.0, 'length_head': 2.0,
[7c57861]169           'Nlayers': 30.0, 'd_spacing': 40., 'Caille_parameter': 0.001, 'sld': 0.4,
[a807206]170           'sld_head': 2.0, 'sld_solvent': 6.0, 'length_tail_pd': 0.0,
[7c57861]171           'length_head_pd': 0.0, 'd_spacing_pd': 0.0}, [0.001], [6838238.571488]]]
[40a87fa]172# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs
Note: See TracBrowser for help on using the repository browser.