Changeset 12c810f in sasmodels


Ignore:
Timestamp:
Mar 4, 2015 2:33:25 PM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
b89f519
Parents:
d6adfbe
Message:

fix summation limits on LamellarCailleHG

Location:
sasmodels/models
Files:
3 deleted
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • sasmodels/models/lamellarCailleHG.py

    rbfb195e r12c810f  
    11# Note: model title and parameter table are inserted automatically 
    22r""" 
    3 This model provides the scattering intensity, *I(q)* = *P(q)* \* *S(q)*, for a lamellar phase where a random 
    4 distribution in solution are assumed. Here a Caille S(Q) is used for the lamellar stacks. 
     3This model provides the scattering intensity, $I(q) = P(q)S(q)$, for a lamellar 
     4phase where a random distribution in solution are assumed. Here a Caille $S(Q)$ 
     5is used for the lamellar stacks. 
    56 
    6 The scattering intensity *I(q)* is 
     7The scattering intensity $I(q)$ is 
    78 
    8 .. image:: img/lamellarCailleHG_139.PNG 
     9.. math:: 
    910 
    10 The form factor is 
     11    I(q) = 2 \pi \frac{P(q)S(q)}{\delta q^2} 
    1112 
    12 .. image:: img/lamellarCailleHG_143.PNG 
    1313 
    14 and the structure factor is 
     14The form factor $P(q)$ is 
    1515 
    16 .. image:: img/lamellarCailleHG_140.PNG 
     16.. math:: 
     17 
     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 
     21 
     22and the structure factor $S(q)$ is 
     23 
     24.. math:: 
     25 
     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) 
    1728 
    1829where 
    1930 
    20 .. image:: img/lamellarCailleHG_141.PNG 
     31.. math:: 
    2132 
    22 where |delta|\ T = tail length (or *tail_length*), |delta|\ H = head thickness (or *h_thickness*), 
    23 |drho|\ H = SLD(headgroup) - SLD(solvent), and |drho|\ T = SLD(tail) - SLD(headgroup). 
    24 Here *d* = (repeat) spacing, *K* = smectic bending elasticity, *B* = compression modulus, and N = number of lamellar 
    25 plates (*n_plates*). 
     33    \begin{eqnarray} 
     34    \alpha(n) &=& \frac{\eta_{cp}}{4\pi^2} \left(\ln(\pi n)+\gamma_E\right)  \\ 
     35    \gamma_E &=& 0.5772156649&&\text{Euler's constant} \\ 
     36    \eta_{cp} &=& \frac{q_o^2k_B T}{8\pi\sqrt{K\overline{B}}} && \text{Caille constant} 
     37    \end{eqnarray} 
    2638 
    27 NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the assumptions of the model are incorrect.** 
    28 And due to a complication of the model function, users are responsible for making sure that all the assumptions are 
    29 handled accurately (see the original reference below for more details). 
    3039 
    31 Non-integer numbers of stacks are calculated as a linear combination of results for the next lower and higher values. 
     40$\delta_T$ is the tail length (or *tail_length*), $\delta_H$ is the head 
     41thickness (or *head_length*), $\Delta\rho_H$ is SLD(headgroup) - SLD(solvent), 
     42and $\Delta\rho_T$ is SLD(tail) - SLD(headgroup). Here $d$ is (repeat) spacing, 
     43$K$ is smectic bending elasticity, $B$ is compression modulus, and $N$ is the 
     44number of lamellar plates (*Nlayers*). 
    3245 
    33 The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as 
     46NB: **When the Caille parameter is greater than approximately 0.8 to 1.0, the 
     47assumptions of the model are incorrect.**  And due to a complication of the 
     48model function, users are responsible for making sure that all the assumptions 
     49are handled accurately (see the original reference below for more details). 
     50 
     51Non-integer numbers of stacks are calculated as a linear combination of 
     52results for the next lower and higher values. 
     53 
     54The 2D scattering intensity is calculated in the same way as 1D, where 
     55the $q$ vector is defined as 
    3456 
    3557.. math:: 
    3658 
    37     Q = \sqrt{Q_x^2 + Q_y^2} 
     59    q = \sqrt{q_x^2 + q_y^2} 
    3860 
    3961The returned value is in units of |cm^-1|, on absolute scale. 
    4062 
    41 ==============  ========  ============= 
    42 Parameter name  Units     Default value 
    43 ==============  ========  ============= 
    44 background      |cm^-1|   0.001 
    45 sld_head        |Ang^-2|  2e-06 
    46 scale           None      1 
    47 sld_solvent     |Ang^-2|  6e-06 
    48 deltaH          |Ang|     2 
    49 deltaT          |Ang|     10 
    50 sld_tail        |Ang^-2|  0 
    51 n_plates        None      30 
    52 spacing         |Ang|     40 
    53 caille          |Ang^-2|  0.001 
    54 ==============  ========  ============= 
    55  
    56 .. image:: img/lamellarCailleHG_142.jpg 
     63.. image:: img/lamellarCailleHG_1d.jpg 
    5764 
    5865*Figure. 1D plot using the default values (w/6000 data point).* 
    5966 
    60 Our model uses the form factor calculations implemented in a c-library provided by the NIST Center for Neutron Research 
    61 (Kline, 2006). 
     67Our model uses the form factor calculations implemented in a C library provided 
     68by the NIST Center for Neutron Research (Kline, 2006). 
    6269 
    6370REFERENCE 
     
    122129demo = dict( 
    123130        scale=1, background=0, 
    124                 Nlayers=20,spacing=200., 
    125         Caille_parameter=0.05, 
    126                 tail_length=15,head_length=10, 
    127         sld=-1, head_sld=4.0, solvent_sld=6.0, 
    128                 tail_length_pd= 0.1, tail_length_pd_n=20, 
    129                 head_length_pd= 0.05, head_length_pd_n=30, 
    130                 spacing_pd= 0.2, spacing_pd_n=40 
    131          ) 
     131        Nlayers=20, 
     132        spacing=200., Caille_parameter=0.05, 
     133        tail_length=15,head_length=10, 
     134        #sld=-1, head_sld=4.0, solvent_sld=6.0, 
     135        sld=-1, head_sld=4.1, solvent_sld=6.0, 
     136        tail_length_pd= 0.1, tail_length_pd_n=20, 
     137        head_length_pd= 0.05, head_length_pd_n=30, 
     138        spacing_pd= 0.2, spacing_pd_n=40 
     139   ) 
    132140 
    133141oldname = 'LamellarPSHGModel' 
  • sasmodels/models/lamellarCailleHG_kernel.c

    r95e861b r12c810f  
    88      double Nlayers,  
    99      double dd, 
    10           double Cp,  
     10      double Cp, 
    1111      double tail_sld, 
    1212      double head_sld, 
     
    1818      double Nlayers,  
    1919      double dd, 
    20           double Cp,  
     20      double Cp, 
    2121      double tail_sld, 
    2222      double head_sld, 
     
    3434  NN = trunc(Nlayers);    //be sure that NN is an integer 
    3535   
    36   Pq = (head_sld-solvent_sld)*(sin(qval*(head_length+tail_length))-sin(qval*tail_length)) +  
     36  Pq = (head_sld-solvent_sld)*(sin(qval*(head_length+tail_length))-sin(qval*tail_length)) + 
    3737              (tail_sld-solvent_sld)*sin(qval*tail_length); 
    3838  Pq *= Pq; 
     
    4242  ii=0; 
    4343  Sq = 0.0; 
    44   for(ii=1;ii<(NNint-1);ii+=1) { 
     44  for(ii=1;ii<=(NNint-1);ii+=1) { 
    4545 
    4646    //fii = (double)ii;   //do I really need to do this? - unused variable, removed 18Feb2015 
     
    6666  Sq += 1.0; 
    6767 
     68  //if (Sq < 0) printf("q=%g: S(q) =%g\n", qval, Sq); 
     69 
    6870  inten = 2.0*M_PI*Pq*Sq/(dd*qval*qval); 
    6971 
Note: See TracChangeset for help on using the changeset viewer.