Changes in doc/guide/plugin.rst [81751c2:94bfa42] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/plugin.rst
r81751c2 r94bfa42 273 273 `Form_Factors`_ for more details. 274 274 275 **model_info = ...** lets you define a model directly, for example, by 276 loading and modifying existing models. This is done implicitly by 277 :func:`sasmodels.core.load_model_info`, which can create a mixture model 278 from 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 283 See :class:`sasmodels.modelinfo.ModelInfo` for details about the model 284 attributes that are defined. 285 275 286 Model Parameters 276 287 ................ … … 291 302 292 303 **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 includedin the parameter table.**304 parameters in the user interface and the order of the parameters in Iq(), 305 Iqac(), Iqabc() and form_volume(). And** *scale* **and** *background* 306 **parameters are implicit to all models, so they do not need to be included 307 in the parameter table.** 297 308 298 309 - **"name"** is the name of the parameter shown on the FitPage. … … 363 374 scattered intensity. 364 375 365 - "volume" parameters are passed to Fq(), Iq(), Iqac(), Iqabc(), form_volume()366 and shell_volume(), andhave polydispersity loops generated automatically.376 - "volume" parameters are passed to Iq(), Iqac(), Iqabc() and form_volume(), 377 and have polydispersity loops generated automatically. 367 378 368 379 - "orientation" parameters are not passed, but instead are combined with … … 492 503 used. 493 504 494 Hollow shapes, where the volume fraction of particle corresponds to the495 material in the shell rather than the volume enclosed by the shape, must496 also define a *shell_volume(par1, par2, ...)* function. The parameters497 are the same as for *form_volume*. The *I(q)* calculation should use498 *shell_volume* squared as its scale factor for the volume normalization.499 The structure factor calculation needs *form_volume* in order to properly500 scale the volume fraction parameter, so both functions are required for501 hollow shapes.502 503 Note: Pure python models do not yet support direct computation of the504 average of $F(q)$ and $F^2(q)$.505 506 505 Embedded C Models 507 506 ................. … … 515 514 This expands into the equivalent C code:: 516 515 516 #include <math.h> 517 517 double Iq(double q, double par1, double par2, ...); 518 518 double Iq(double q, double par1, double par2, ...) … … 523 523 *form_volume* defines the volume of the shape. As in python models, it 524 524 includes only the volume parameters. 525 526 *form_volume* defines the volume of the shell for hollow shapes. As in527 python models, it includes only the volume parameters.528 525 529 526 **source=['fn.c', ...]** includes the listed C source files in the … … 562 559 The INVALID define can go into *Iq*, or *c_code*, or an external C file 563 560 listed in *source*. 564 565 Structure Factors566 .................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)>$ in570 the decoupling approximation to the structure factor.571 572 Instead of defining the *Iq* function, models can define *Fq* as573 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 for586 the vesicle model, for example), then scale *F1* by $\surd V_f$ so that587 $\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 within592 a *c_code* block within the python model definition file.593 561 594 562 Oriented Shapes … … 744 712 erf, erfc, tgamma, lgamma: **do not use** 745 713 Special functions that should be part of the standard, but are missing 746 or inaccurate on some platforms. Use sas_erf, sas_erfc andsas_gamma747 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). 748 716 749 717 Some non-standard constants and functions are also provided: … … 812 780 Gamma function sas_gamma\ $(x) = \Gamma(x)$. 813 781 814 The standard math function, tgamma(x) is unstable for $x < 1$782 The standard math function, tgamma(x), is unstable for $x < 1$ 815 783 on some platforms. 816 784 817 785 :code:`source = ["lib/sas_gamma.c", ...]` 818 786 (`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>`_) 819 805 820 806 sas_erf(x), sas_erfc(x): … … 854 840 If $n$ = 0 or 1, it uses sas_J0($x$) or sas_J1($x$), respectively. 855 841 842 Warning: JN(n,x) can be very inaccurate (0.1%) for x not in [0.1, 100]. 843 856 844 The standard math function jn(n, x) is not available on all platforms. 857 845 … … 862 850 Sine integral Si\ $(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. 863 851 852 Warning: Si(x) can be very inaccurate (0.1%) for x in [0.1, 100]. 853 864 854 This function uses Taylor series for small and large arguments: 865 855 866 For large arguments ,856 For large arguments use the following Taylor series, 867 857 868 858 .. math:: … … 1033 1023 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 1034 1024 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.], 1038 1027 ] 1039 1028 1040 1029 1041 **tests=[[{parameters}, q, Iq], ...]** is a list of lists.1030 **tests=[[{parameters}, q, result], ...]** is a list of lists. 1042 1031 Each list is one test and contains, in order: 1043 1032 … … 1051 1040 - input and output values can themselves be lists if you have several 1052 1041 $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. 1062 1045 1063 1046 .. _Test_Your_New_Model:
Note: See TracChangeset
for help on using the changeset viewer.