Changes in doc/guide/plugin.rst [94bfa42:81751c2] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/plugin.rst
r94bfa42 r81751c2 273 273 `Form_Factors`_ for more details. 274 274 275 **model_info = ...** lets you define a model directly, for example, by276 loading and modifying existing models. This is done implicitly by277 :func:`sasmodels.core.load_model_info`, which can create a mixture model278 from a pair of existing models. For example::279 280 from sasmodels.core import load_model_info281 model_info = load_model_info('sphere+cylinder')282 283 See :class:`sasmodels.modelinfo.ModelInfo` for details about the model284 attributes that are defined.285 286 275 Model Parameters 287 276 ................ … … 302 291 303 292 **Note: The order of the parameters in the definition will be the order of the 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.**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.** 308 297 309 298 - **"name"** is the name of the parameter shown on the FitPage. … … 374 363 scattered intensity. 375 364 376 - "volume" parameters are passed to Iq(), Iqac(), Iqabc() and form_volume(),377 and have polydispersity loops generated automatically.365 - "volume" parameters are passed to Fq(), Iq(), Iqac(), Iqabc(), form_volume() 366 and shell_volume(), and have polydispersity loops generated automatically. 378 367 379 368 - "orientation" parameters are not passed, but instead are combined with … … 503 492 used. 504 493 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 505 506 Embedded C Models 506 507 ................. … … 514 515 This expands into the equivalent C code:: 515 516 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 in 527 python models, it includes only the volume parameters. 525 528 526 529 **source=['fn.c', ...]** includes the listed C source files in the … … 559 562 The INVALID define can go into *Iq*, or *c_code*, or an external C file 560 563 listed 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. 561 593 562 594 Oriented Shapes … … 712 744 erf, erfc, tgamma, lgamma: **do not use** 713 745 Special functions that should be part of the standard, but are missing 714 or inaccurate on some platforms. Use sas_erf, sas_erfc ,sas_gamma715 and sas_lgamma instead (see below).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. 716 748 717 749 Some non-standard constants and functions are also provided: … … 780 812 Gamma function sas_gamma\ $(x) = \Gamma(x)$. 781 813 782 The standard math function, tgamma(x) ,is unstable for $x < 1$814 The standard math function, tgamma(x) is unstable for $x < 1$ 783 815 on some platforms. 784 816 785 817 :code:`source = ["lib/sas_gamma.c", ...]` 786 818 (`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 single792 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 function799 sas_gammainc\ $(a, x) = \int_0^x t^{a-1}e^{-t}\,dt / \Gamma(a)$800 and complementary incomplete gamma function801 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>`_)805 819 806 820 sas_erf(x), sas_erfc(x): … … 840 854 If $n$ = 0 or 1, it uses sas_J0($x$) or sas_J1($x$), respectively. 841 855 842 Warning: JN(n,x) can be very inaccurate (0.1%) for x not in [0.1, 100].843 844 856 The standard math function jn(n, x) is not available on all platforms. 845 857 … … 850 862 Sine integral Si\ $(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. 851 863 852 Warning: Si(x) can be very inaccurate (0.1%) for x in [0.1, 100].853 854 864 This function uses Taylor series for small and large arguments: 855 865 856 For large arguments use the following Taylor series,866 For large arguments, 857 867 858 868 .. math:: … … 1023 1033 "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 1024 1034 0.2, 0.228843], 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.], 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], 1027 1038 ] 1028 1039 1029 1040 1030 **tests=[[{parameters}, q, result], ...]** is a list of lists.1041 **tests=[[{parameters}, q, Iq], ...]** is a list of lists. 1031 1042 Each list is one test and contains, in order: 1032 1043 … … 1040 1051 - input and output values can themselves be lists if you have several 1041 1052 $q$ values to test for the same model parameters. 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. 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. 1045 1062 1046 1063 .. _Test_Your_New_Model:
Note: See TracChangeset
for help on using the changeset viewer.