Changeset dd4f5ed in sasmodels


Ignore:
Timestamp:
Sep 13, 2017 8:15:12 AM (7 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
058460c
Parents:
ca04add (diff), 9644b5a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Lewis O'Driscoll <lewis.o'driscoll@…> (09/13/17 08:15:12)
git-committer:
GitHub <noreply@…> (09/13/17 08:15:12)
Message:

Merge pull request #41 from SasView?/ticket-741

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    rbcdd6c9 r9644b5a  
    169169    return make_model_from_info(model_info) 
    170170 
    171      
     171 
    172172def _register_old_models(): 
    173173    # type: () -> None 
     
    597597                            % type(qdist)) 
    598598 
    599     def get_composition_models(self): 
    600         """ 
    601             Returns usable models that compose this model 
    602         """ 
    603         s_model = None 
    604         p_model = None 
    605         if hasattr(self._model_info, "composition") \ 
    606            and self._model_info.composition is not None: 
    607             p_model = make_model_from_info(self._model_info.composition[1][0])() 
    608             s_model = make_model_from_info(self._model_info.composition[1][1])() 
    609         return p_model, s_model 
     599    def calc_composition_models(self, qx): 
     600        """ 
     601        returns parts of the composition model or None if not a composition 
     602        model. 
     603        """ 
     604        # TODO: have calculate_Iq return the intermediates. 
     605        # 
     606        # The current interface causes calculate_Iq() to be called twice, 
     607        # once to get the combined result and again to get the intermediate 
     608        # results.  This is necessary for now. 
     609        # Long term, the solution is to change the interface to calculate_Iq 
     610        # so that it returns a results object containing all the bits: 
     611        #     the A, B, C, ... of the composition model (and any subcomponents?) 
     612        #     the P and S of the product model, 
     613        #     the combined model before resolution smearing, 
     614        #     the sasmodel before sesans conversion, 
     615        #     the oriented 2D model used to fit oriented usans data, 
     616        #     the final I(q), 
     617        #     ... 
     618        # 
     619        # Have the model calculator add all of these blindly to the data 
     620        # tree, and update the graphs which contain them.  The fitter 
     621        # needs to be updated to use the I(q) value only, ignoring the rest. 
     622        # 
     623        # The simple fix of returning the existing intermediate results 
     624        # will not work for a couple of reasons: (1) another thread may 
     625        # sneak in to compute its own results before calc_composition_models 
     626        # is called, and (2) calculate_Iq is currently called three times: 
     627        # once with q, once with q values before qmin and once with q values 
     628        # after q max.  Both of these should be addressed before 
     629        # replacing this code. 
     630        composition = self._model_info.composition 
     631        if composition and composition[0] == 'product': # only P*S for now 
     632            with calculation_lock: 
     633                self._calculate_Iq(qx) 
     634                return self._intermediate_results 
     635        else: 
     636            return None 
    610637 
    611638    def calculate_Iq(self, qx, qy=None): 
     
    648675        result = calculator(call_details, values, cutoff=self.cutoff, 
    649676                            magnetic=is_magnetic) 
     677        self._intermediate_results = getattr(calculator, 'results', None) 
    650678        calculator.release() 
    651679        self._model.release() 
  • deploy.sh

    r9d1e3e4 r2ba5ba5  
    1 if [[ $encrypted_cb04388797b6_iv ]] 
     1if [ "$encrypted_cb04388797b6_iv" ] 
    22then 
    33    eval "$(ssh-agent -s)" 
  • sasmodels/models/fractal_core_shell.py

    r64eecf7 rca04add  
    2222    \frac{\sin(qr_c)-qr_c\cos(qr_c)}{(qr_c)^3}+ 
    2323    3V_s(\rho_s-\rho_{solv}) 
    24     \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 
    25  
     24    \frac{\sin(qr_s)-qr_s\cos(qr_s)}{(qr_s)^3}\right]^2 \\ 
    2625    S(q) &= 1 + \frac{D_f\ \Gamma\!(D_f-1)}{[1+1/(q\xi)^2]^{(D_f-1)/2}} 
    2726    \frac{\sin[(D_f-1)\tan^{-1}(q\xi)]}{(qr_s)^{D_f}} 
  • sasmodels/models/mass_surface_fractal.py

    r232bb12 rca04add  
    2222.. math:: 
    2323 
    24     I(q) = scale \times P(q) + background 
    25  
     24    I(q) = scale \times P(q) + background \\ 
    2625    P(q) = \left\{ \left[ 1+(q^2a)\right]^{D_m/2} \times 
    2726                   \left[ 1+(q^2b)\right]^{(6-D_s-D_m)/2} 
    28            \right\}^{-1} 
    29  
    30     a = R_{g}^2/(3D_m/2) 
    31  
    32     b = r_{g}^2/[-3(D_s+D_m-6)/2] 
    33  
     27           \right\}^{-1} \\ 
     28    a = R_{g}^2/(3D_m/2) \\ 
     29    b = r_{g}^2/[-3(D_s+D_m-6)/2] \\ 
    3430    scale = scale\_factor \times NV^2 (\rho_{particle} - \rho_{solvent})^2 
    3531 
  • sasmodels/models/mono_gauss_coil.py

    r404ebbd rca04add  
    2424 
    2525     I_0 &= \phi_\text{poly} \cdot V 
    26             \cdot (\rho_\text{poly} - \rho_\text{solv})^2 
    27  
    28      P(q) &= 2 [\exp(-Z) + Z - 1] / Z^2 
    29  
    30      Z &= (q R_g)^2 
    31  
     26            \cdot (\rho_\text{poly} - \rho_\text{solv})^2 \\ 
     27     P(q) &= 2 [\exp(-Z) + Z - 1] / Z^2 \\ 
     28     Z &= (q R_g)^2 \\ 
    3229     V &= M / (N_A \delta) 
    3330 
  • sasmodels/models/onion.py

    rbccb40f rca04add  
    8181        \left[ B\exp 
    8282            \left(A (r - r_{\text{shell}-1}) / \Delta t_\text{shell} \right) + C 
    83         \right] \frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r 
    84  
     83        \right] \frac{\sin(qr)}{qr}\,r^2\,\mathrm{d}r \\ 
    8584    &= 3BV(r_\text{shell}) e^A h(\alpha_\text{out},\beta_\text{out}) 
    8685        - 3BV(r_{\text{shell}-1}) h(\alpha_\text{in},\beta_\text{in}) 
     
    9594    \begin{align*} 
    9695    B&=\frac{\rho_\text{out} - \rho_\text{in}}{e^A-1} 
    97          &C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\ 
     96         & C &= \frac{\rho_\text{in}e^A - \rho_\text{out}}{e^A-1} \\ 
    9897    \alpha_\text{in} &= A\frac{r_{\text{shell}-1}}{\Delta t_\text{shell}} 
    99          &\alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\ 
     98         & \alpha_\text{out} &= A\frac{r_\text{shell}}{\Delta t_\text{shell}} \\ 
    10099    \beta_\text{in} &= qr_{\text{shell}-1} 
    101         &\beta_\text{out} &= qr_\text{shell} \\ 
     100        & \beta_\text{out} &= qr_\text{shell} \\ 
    102101    \end{align*} 
    103102 
  • sasmodels/models/parallelepiped.py

    r30b60d2 rca04add  
    6262        \left\{S\left[\frac{\mu}{2}\cos\left(\frac{\pi}{2}u\right)\right] 
    6363               S\left[\frac{\mu a}{2}\sin\left(\frac{\pi}{2}u\right)\right] 
    64                \right\}^2 du 
    65  
    66     S(x) &= \frac{\sin x}{x} 
    67  
     64               \right\}^2 du \\ 
     65    S(x) &= \frac{\sin x}{x} \\ 
    6866    \mu &= qB 
    6967 
     
    133131.. math:: 
    134132 
    135     \cos\alpha &= \hat A \cdot \hat q, 
    136  
    137     \cos\beta  &= \hat B \cdot \hat q, 
    138  
     133    \cos\alpha &= \hat A \cdot \hat q, \\ 
     134    \cos\beta  &= \hat B \cdot \hat q, \\ 
    139135    \cos\gamma &= \hat C \cdot \hat q 
    140136 
  • sasmodels/models/poly_gauss_coil.py

    r404ebbd rca04add  
    2121.. math:: 
    2222 
    23      I_0 &= \phi_\text{poly} \cdot V \cdot (\rho_\text{poly}-\rho_\text{solv})^2 
    24  
    25      P(q) &= 2 [(1 + UZ)^{-1/U} + Z - 1] / [(1 + U) Z^2] 
    26  
    27      Z &= [(q R_g)^2] / (1 + 2U) 
    28  
    29      U &= (Mw / Mn) - 1 = \text{polydispersity ratio} - 1 
    30  
     23     I_0 &= \phi_\text{poly} \cdot V \cdot (\rho_\text{poly}-\rho_\text{solv})^2 \\ 
     24     P(q) &= 2 [(1 + UZ)^{-1/U} + Z - 1] / [(1 + U) Z^2] \\ 
     25     Z &= [(q R_g)^2] / (1 + 2U) \\ 
     26     U &= (Mw / Mn) - 1 = \text{polydispersity ratio} - 1 \\ 
    3127     V &= M / (N_A \delta) 
    3228 
  • sasmodels/models/polymer_micelle.py

    r404ebbd rca04add  
    2626 
    2727.. math:: 
    28     P(q) = N^2\beta^2_s\Phi(qR)^2+N\beta^2_cP_c(q)+2N^2\beta_s\beta_cS_{sc}s_c(q)+N(N-1)\beta_c^2S_{cc}(q) 
    29  
    30     \beta_s = v\_core(sld\_core - sld\_solvent) 
    31  
     28    P(q) = N^2\beta^2_s\Phi(qR)^2+N\beta^2_cP_c(q)+2N^2\beta_s\beta_cS_{sc}s_c(q)+N(N-1)\beta_c^2S_{cc}(q) \\ 
     29    \beta_s = v\_core(sld\_core - sld\_solvent) \\ 
    3230    \beta_c = v\_corona(sld\_corona - sld\_solvent) 
    3331 
     
    4139.. math:: 
    4240 
    43    P_c(q) &= 2 [\exp(-Z) + Z - 1] / Z^2 
    44  
     41   P_c(q) &= 2 [\exp(-Z) + Z - 1] / Z^2 \\ 
    4542   Z &= (q R_g)^2 
    4643 
     
    5047.. math:: 
    5148 
    52    S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} 
    53  
    54    S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2 
    55  
     49   S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \\ 
     50   S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2 \\ 
    5651   \psi(Z)=\frac{[1-exp^{-Z}]}{Z} 
    5752 
  • sasmodels/models/spherical_sld.py

    r2ad5d30 rca04add  
    5151    3 \rho_\text{core} V(r_\text{core}) 
    5252    \Big[ \frac{\sin(qr_\text{core}) - qr_\text{core} \cos(qr_\text{core})} 
    53     {qr_\text{core}^3} \Big] 
    54  
     53    {qr_\text{core}^3} \Big] \\ 
    5554    f_{\text{inter}_i} &= 4 \pi \int_{\Delta t_{ \text{inter}_i } } 
    56     \rho_{ \text{inter}_i } \frac{\sin(qr)} {qr} r^2 dr 
    57  
     55    \rho_{ \text{inter}_i } \frac{\sin(qr)} {qr} r^2 dr \\ 
    5856    f_{\text{shell}_i} &= 4 \pi \int_{\Delta t_{ \text{inter}_i } } 
    5957    \rho_{ \text{flat}_i } \frac{\sin(qr)} {qr} r^2 dr = 
     
    6664    -3 \rho_{ \text{flat}_i } V(r_{ \text{inter}_i }) 
    6765    \Big[ \frac{\sin(qr_{\text{inter}_i}) - qr_{\text{flat}_i} 
    68     \cos(qr_{\text{inter}_i}) } {qr_{\text{inter}_i}^3} \Big] 
    69  
     66    \cos(qr_{\text{inter}_i}) } {qr_{\text{inter}_i}^3} \Big] \\ 
    7067    f_\text{solvent} &= 4 \pi \int_{r_N}^{\infty} \rho_\text{solvent} 
    7168    \frac{\sin(qr)} {qr} r^2 dr = 
     
    122119    4 \pi \sum_{j=1}^{n_\text{steps}} 
    123120    \int_{r_j}^{r_{j+1}} \rho_{ \text{inter}_i } (r_j) 
    124     \frac{\sin(qr)} {qr} r^2 dr 
    125  
    126     &\approx 4 \pi \sum_{j=1}^{n_\text{steps}} \Big[ 
     121    \frac{\sin(qr)} {qr} r^2 dr \\ 
     122    \approx 4 \pi \sum_{j=1}^{n_\text{steps}} \Big[ 
    127123    3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } 
    128124    ( r_{j} ) V (r_j) 
    129125    \Big[ \frac {r_j^2 \beta_\text{out}^2 \sin(\beta_\text{out}) 
    130126    - (\beta_\text{out}^2-2) \cos(\beta_\text{out}) } 
    131     {\beta_\text{out}^4 } \Big] 
    132  
    133     &{} - 3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } 
     127    {\beta_\text{out}^4 } \Big] \\ 
     128    {} - 3 ( \rho_{ \text{inter}_i } ( r_{j+1} ) - \rho_{ \text{inter}_i } 
    134129    ( r_{j} ) V ( r_{j-1} ) 
    135130    \Big[ \frac {r_{j-1}^2 \sin(\beta_\text{in}) 
    136131    - (\beta_\text{in}^2-2) \cos(\beta_\text{in}) } 
    137     {\beta_\text{in}^4 } \Big] 
    138  
    139     &{} + 3 \rho_{ \text{inter}_i } ( r_{j+1} )  V ( r_j ) 
     132    {\beta_\text{in}^4 } \Big] \\ 
     133    {} + 3 \rho_{ \text{inter}_i } ( r_{j+1} )  V ( r_j ) 
    140134    \Big[ \frac {\sin(\beta_\text{out}) - \cos(\beta_\text{out}) } 
    141135    {\beta_\text{out}^4 } \Big] 
     
    152146    \begin{align*} 
    153147    V(a) &= \frac {4\pi}{3}a^3 && \\ 
    154     a_\text{in} &\sim \frac{r_j}{r_{j+1} -r_j} \text{, } &a_\text{out} 
    155     &\sim \frac{r_{j+1}}{r_{j+1} -r_j} \\ 
    156     \beta_\text{in} &= qr_j \text{, } &\beta_\text{out} &= qr_{j+1} 
     148    a_\text{in} \sim \frac{r_j}{r_{j+1} -r_j} \text{, } & a_\text{out} 
     149    \sim \frac{r_{j+1}}{r_{j+1} -r_j} \\ 
     150    \beta_\text{in} &= qr_j \text{, } & \beta_\text{out} &= qr_{j+1} 
    157151    \end{align*} 
    158152 
  • sasmodels/models/star_polymer.py

    r30b60d2 rbef029d  
    3636   Star polymers in solutions tend to have strong interparticle and osmotic 
    3737   effects. Thus the Benoit equation may not work well for many real cases. 
    38    At small $q$ the Guinier term and hence $I(q=0)$ is the same as for $f$ arms 
    39    of radius of gyration $R_g$, as described for the :ref:`mono-gauss-coil` 
    40    model. A newer model for star polymer incorporating excluded volume has been 
    41    developed by Li et al in arXiv:1404.6269 [physics.chem-ph]. 
     38   A newer model for star polymer incorporating excluded volume has been 
     39   developed by Li et al in arXiv:1404.6269 [physics.chem-ph].  Also, at small 
     40   $q$ the scattering, i.e. the Guinier term, is not sensitive to the number of 
     41   arms, and hence 'scale' here is simply $I(q=0)$ as described for the 
     42   :ref:`mono-gauss-coil` model, using volume fraction $\phi$ and volume V 
     43   for the whole star polymer. 
    4244 
    4345References 
Note: See TracChangeset for help on using the changeset viewer.