Changes in doc/guide/plugin.rst [81751c2:94bfa42] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/plugin.rst

    r81751c2 r94bfa42  
    273273`Form_Factors`_ for more details. 
    274274 
     275**model_info = ...** lets you define a model directly, for example, by 
     276loading and modifying existing models.  This is done implicitly by 
     277:func:`sasmodels.core.load_model_info`, which can create a mixture model 
     278from a pair of existing models.  For example:: 
     279 
     280    from sasmodels.core import load_model_info 
     281    model_info = load_model_info('sphere+cylinder') 
     282 
     283See :class:`sasmodels.modelinfo.ModelInfo` for details about the model 
     284attributes that are defined. 
     285 
    275286Model Parameters 
    276287................ 
     
    291302 
    292303**Note: The order of the parameters in the definition will be the order of the 
    293 parameters in the user interface and the order of the parameters in Fq(), Iq(), 
    294 Iqac(), Iqabc(), form_volume() and shell_volume(). 
    295 And** *scale* **and** *background* **parameters are implicit to all models, 
    296 so they do not need to be included in the parameter table.** 
     304parameters in the user interface and the order of the parameters in Iq(), 
     305Iqac(), Iqabc() and form_volume(). And** *scale* **and** *background* 
     306**parameters are implicit to all models, so they do not need to be included 
     307in the parameter table.** 
    297308 
    298309- **"name"** is the name of the parameter shown on the FitPage. 
     
    363374    scattered intensity. 
    364375 
    365   - "volume" parameters are passed to Fq(), Iq(), Iqac(), Iqabc(), form_volume() 
    366     and shell_volume(), and have polydispersity loops generated automatically. 
     376  - "volume" parameters are passed to Iq(), Iqac(), Iqabc() and form_volume(), 
     377    and have polydispersity loops generated automatically. 
    367378 
    368379  - "orientation" parameters are not passed, but instead are combined with 
     
    492503used. 
    493504 
    494 Hollow shapes, where the volume fraction of particle corresponds to the 
    495 material in the shell rather than the volume enclosed by the shape, must 
    496 also define a *shell_volume(par1, par2, ...)* function.  The parameters 
    497 are the same as for *form_volume*.  The *I(q)* calculation should use 
    498 *shell_volume* squared as its scale factor for the volume normalization. 
    499 The structure factor calculation needs *form_volume* in order to properly 
    500 scale the volume fraction parameter, so both functions are required for 
    501 hollow shapes. 
    502  
    503 Note: Pure python models do not yet support direct computation of the 
    504 average of $F(q)$ and $F^2(q)$. 
    505  
    506505Embedded C Models 
    507506................. 
     
    515514This expands into the equivalent C code:: 
    516515 
     516    #include <math.h> 
    517517    double Iq(double q, double par1, double par2, ...); 
    518518    double Iq(double q, double par1, double par2, ...) 
     
    523523*form_volume* defines the volume of the shape. As in python models, it 
    524524includes only the volume parameters. 
    525  
    526 *form_volume* defines the volume of the shell for hollow shapes. As in 
    527 python models, it includes only the volume parameters. 
    528525 
    529526**source=['fn.c', ...]** includes the listed C source files in the 
     
    562559The INVALID define can go into *Iq*, or *c_code*, or an external C file 
    563560listed in *source*. 
    564  
    565 Structure Factors 
    566 ................. 
    567  
    568 Structure factor calculations may need the underlying $<F(q)>$ and $<F^2(q)>$ 
    569 rather than $I(q)$.  This is used to compute $\beta = <F(q)>^2/<F^2(q)>$ in 
    570 the decoupling approximation to the structure factor. 
    571  
    572 Instead of defining the *Iq* function, models can define *Fq* as 
    573 something like:: 
    574  
    575     double Fq(double q, double *F1, double *F2, double par1, double par2, ...); 
    576     double Fq(double q, double *F1, double *F2, double par1, double par2, ...) 
    577     { 
    578         // Polar integration loop over all orientations. 
    579         ... 
    580         *F1 = 1e-2 * total_F1 * contrast * volume; 
    581         *F2 = 1e-4 * total_F2 * square(contrast * volume); 
    582         return I(q, par1, par2, ...); 
    583     } 
    584  
    585 If the volume fraction scale factor is built into the model (as occurs for 
    586 the vesicle model, for example), then scale *F1* by $\surd V_f$ so that 
    587 $\beta$ is computed correctly. 
    588  
    589 Structure factor calculations are not yet supported for oriented shapes. 
    590  
    591 Note: only available as a separate C file listed in *source*, or within 
    592 a *c_code* block within the python model definition file. 
    593561 
    594562Oriented Shapes 
     
    744712    erf, erfc, tgamma, lgamma:  **do not use** 
    745713        Special functions that should be part of the standard, but are missing 
    746         or inaccurate on some platforms. Use sas_erf, sas_erfc and sas_gamma 
    747         instead (see below). Note: lgamma(x) has not yet been tested. 
     714        or inaccurate on some platforms. Use sas_erf, sas_erfc, sas_gamma 
     715        and sas_lgamma instead (see below). 
    748716 
    749717Some non-standard constants and functions are also provided: 
     
    812780        Gamma function sas_gamma\ $(x) = \Gamma(x)$. 
    813781 
    814         The standard math function, tgamma(x) is unstable for $x < 1$ 
     782        The standard math function, tgamma(x), is unstable for $x < 1$ 
    815783        on some platforms. 
    816784 
    817785        :code:`source = ["lib/sas_gamma.c", ...]` 
    818786        (`sas_gamma.c <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_gamma.c>`_) 
     787 
     788    sas_gammaln(x): 
     789        log gamma function sas_gammaln\ $(x) = \log \Gamma(|x|)$. 
     790 
     791        The standard math function, lgamma(x), is incorrect for single 
     792        precision on some platforms. 
     793 
     794        :code:`source = ["lib/sas_gammainc.c", ...]` 
     795        (`sas_gammainc.c <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_gammainc.c>`_) 
     796 
     797    sas_gammainc(a, x), sas_gammaincc(a, x): 
     798        Incomplete gamma function 
     799        sas_gammainc\ $(a, x) = \int_0^x t^{a-1}e^{-t}\,dt / \Gamma(a)$ 
     800        and complementary incomplete gamma function 
     801        sas_gammaincc\ $(a, x) = \int_x^\infty t^{a-1}e^{-t}\,dt / \Gamma(a)$ 
     802 
     803        :code:`source = ["lib/sas_gammainc.c", ...]` 
     804        (`sas_gammainc.c <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_gammainc.c>`_) 
    819805 
    820806    sas_erf(x), sas_erfc(x): 
     
    854840        If $n$ = 0 or 1, it uses sas_J0($x$) or sas_J1($x$), respectively. 
    855841 
     842        Warning: JN(n,x) can be very inaccurate (0.1%) for x not in [0.1, 100]. 
     843 
    856844        The standard math function jn(n, x) is not available on all platforms. 
    857845 
     
    862850        Sine integral Si\ $(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. 
    863851 
     852        Warning: Si(x) can be very inaccurate (0.1%) for x in [0.1, 100]. 
     853 
    864854        This function uses Taylor series for small and large arguments: 
    865855 
    866         For large arguments, 
     856        For large arguments use the following Taylor series, 
    867857 
    868858        .. math:: 
     
    10331023          "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    10341024         0.2, 0.228843], 
    1035         [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    1036          0.1, None, None, 120., None, 1.],  # q, F, F^2, R_eff, V, form:shell 
    1037         [{"@S": "hardsphere"}, 0.1, None], 
     1025        [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, "ER", 120.], 
     1026        [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, "VR", 1.], 
    10381027    ] 
    10391028 
    10401029 
    1041 **tests=[[{parameters}, q, Iq], ...]** is a list of lists. 
     1030**tests=[[{parameters}, q, result], ...]** is a list of lists. 
    10421031Each list is one test and contains, in order: 
    10431032 
     
    10511040- input and output values can themselves be lists if you have several 
    10521041  $q$ values to test for the same model parameters. 
    1053 - for testing effective radius, volume and form:shell volume ratio, use the 
    1054   extended form of the tests results, with *None, None, R_eff, V, V_r* 
    1055   instead of *Iq*.  This calls the kernel *Fq* function instead of *Iq*. 
    1056 - for testing F and F^2 (used for beta approximation) do the same as the 
    1057   effective radius test, but include values for the first two elements, 
    1058   $<F(q)>$ and $<F^2(q)>$. 
    1059 - for testing interaction between form factor and structure factor, specify 
    1060   the structure factor name in the parameters as *{"@S": "name", ...}* with 
    1061   the remaining list of parameters defined by the *P@S* product model. 
     1042- for testing *ER* and *VR*, give the inputs as "ER" and "VR" respectively; 
     1043  the output for *VR* should be the sphere/shell ratio, not the individual 
     1044  sphere and shell values. 
    10621045 
    10631046.. _Test_Your_New_Model: 
Note: See TracChangeset for help on using the changeset viewer.