Changeset fd7291e in sasmodels for doc/guide/plugin.rst


Ignore:
Timestamp:
Mar 6, 2019 6:05:52 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
c11d09f
Parents:
21c93c3 (diff), 9150036 (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.
Message:

Merge branch 'beta_approx' into ticket-1022-sum_multiplicity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/plugin.rst

    r9d8a027 r9150036  
    302302 
    303303**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.** 
     304parameters in the user interface and the order of the parameters in Fq(), Iq(), 
     305Iqac(), Iqabc(), form_volume() and shell_volume(). 
     306And** *scale* **and** *background* **parameters are implicit to all models, 
     307so they do not need to be included in the parameter table.** 
    308308 
    309309- **"name"** is the name of the parameter shown on the FitPage. 
     
    374374    scattered intensity. 
    375375 
    376   - "volume" parameters are passed to Iq(), Iqac(), Iqabc() and form_volume(), 
    377     and have polydispersity loops generated automatically. 
     376  - "volume" parameters are passed to Fq(), Iq(), Iqac(), Iqabc(), form_volume() 
     377    and shell_volume(), and have polydispersity loops generated automatically. 
    378378 
    379379  - "orientation" parameters are not passed, but instead are combined with 
     
    503503used. 
    504504 
     505Hollow shapes, where the volume fraction of particle corresponds to the 
     506material in the shell rather than the volume enclosed by the shape, must 
     507also define a *shell_volume(par1, par2, ...)* function.  The parameters 
     508are the same as for *form_volume*.  The *I(q)* calculation should use 
     509*shell_volume* squared as its scale factor for the volume normalization. 
     510The structure factor calculation needs *form_volume* in order to properly 
     511scale the volume fraction parameter, so both functions are required for 
     512hollow shapes. 
     513 
     514Note: Pure python models do not yet support direct computation of the 
     515average of $F(q)$ and $F^2(q)$. 
     516 
    505517Embedded C Models 
    506518................. 
     
    514526This expands into the equivalent C code:: 
    515527 
    516     #include <math.h> 
    517528    double Iq(double q, double par1, double par2, ...); 
    518529    double Iq(double q, double par1, double par2, ...) 
     
    523534*form_volume* defines the volume of the shape. As in python models, it 
    524535includes only the volume parameters. 
     536 
     537*form_volume* defines the volume of the shell for hollow shapes. As in 
     538python models, it includes only the volume parameters. 
    525539 
    526540**source=['fn.c', ...]** includes the listed C source files in the 
     
    559573The INVALID define can go into *Iq*, or *c_code*, or an external C file 
    560574listed in *source*. 
     575 
     576Structure Factors 
     577................. 
     578 
     579Structure factor calculations may need the underlying $<F(q)>$ and $<F^2(q)>$ 
     580rather than $I(q)$.  This is used to compute $\beta = <F(q)>^2/<F^2(q)>$ in 
     581the decoupling approximation to the structure factor. 
     582 
     583Instead of defining the *Iq* function, models can define *Fq* as 
     584something like:: 
     585 
     586    double Fq(double q, double *F1, double *F2, double par1, double par2, ...); 
     587    double Fq(double q, double *F1, double *F2, double par1, double par2, ...) 
     588    { 
     589        // Polar integration loop over all orientations. 
     590        ... 
     591        *F1 = 1e-2 * total_F1 * contrast * volume; 
     592        *F2 = 1e-4 * total_F2 * square(contrast * volume); 
     593        return I(q, par1, par2, ...); 
     594    } 
     595 
     596If the volume fraction scale factor is built into the model (as occurs for 
     597the vesicle model, for example), then scale *F1* by $\surd V_f$ so that 
     598$\beta$ is computed correctly. 
     599 
     600Structure factor calculations are not yet supported for oriented shapes. 
     601 
     602Note: only available as a separate C file listed in *source*, or within 
     603a *c_code* block within the python model definition file. 
    561604 
    562605Oriented Shapes 
     
    862905             - \frac{\sin(x)}{x}\left(\frac{1}{x} - \frac{3!}{x^3} + \frac{5!}{x^5} - \frac{7!}{x^7}\right) 
    863906 
    864         For small arguments , 
     907        For small arguments, 
    865908 
    866909        .. math:: 
     
    10231066          "radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    10241067         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.], 
     1068        [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
     1069         0.1, None, None, 120., None, 1.],  # q, F, F^2, R_eff, V, form:shell 
     1070        [{"@S": "hardsphere"}, 0.1, None], 
    10271071    ] 
    10281072 
    10291073 
    1030 **tests=[[{parameters}, q, result], ...]** is a list of lists. 
     1074**tests=[[{parameters}, q, Iq], ...]** is a list of lists. 
    10311075Each list is one test and contains, in order: 
    10321076 
     
    10401084- input and output values can themselves be lists if you have several 
    10411085  $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. 
     1086- for testing effective radius, volume and form:shell volume ratio, use the 
     1087  extended form of the tests results, with *None, None, R_eff, V, V_r* 
     1088  instead of *Iq*.  This calls the kernel *Fq* function instead of *Iq*. 
     1089- for testing F and F^2 (used for beta approximation) do the same as the 
     1090  effective radius test, but include values for the first two elements, 
     1091  $<F(q)>$ and $<F^2(q)>$. 
     1092- for testing interaction between form factor and structure factor, specify 
     1093  the structure factor name in the parameters as *{"@S": "name", ...}* with 
     1094  the remaining list of parameters defined by the *P@S* product model. 
    10451095 
    10461096.. _Test_Your_New_Model: 
Note: See TracChangeset for help on using the changeset viewer.