1 | Sasmodels |
---|
2 | ========= |
---|
3 | |
---|
4 | Theory models for small angle scattering. |
---|
5 | |
---|
6 | The models provided are usable directly in the bumps fitting package and |
---|
7 | in the sasview analysis package. If OpenCL is available, the models will |
---|
8 | run much faster. If not, then precompiled versions will be included with |
---|
9 | the distributed package. New models can be added if OpenCL or a C compiler |
---|
10 | is available. |
---|
11 | |
---|
12 | Example |
---|
13 | ------- |
---|
14 | |
---|
15 | The example directory contains a radial+tangential data set for an oriented |
---|
16 | rod-like shape. |
---|
17 | |
---|
18 | The data is loaded by sas.dataloader from the sasview package, so sasview |
---|
19 | is needed to run the example. |
---|
20 | |
---|
21 | To run the example, you need sasview, sasmodels and bumps. Assuming these |
---|
22 | repositories are installed side by side, change to the sasmodels/example |
---|
23 | directory and enter:: |
---|
24 | |
---|
25 | PYTHONPATH=..:../../sasview/src ../../bumps/run.py fit.py \ |
---|
26 | cylinder --preview |
---|
27 | |
---|
28 | See bumps documentation for instructions on running the fit. With the |
---|
29 | python packages installed, e.g., into a virtual environment, then the |
---|
30 | python path need not be set, and the command would be:: |
---|
31 | |
---|
32 | bumps fit.py cylinder --preview |
---|
33 | |
---|
34 | The fit.py model accepts up to two arguments. The first argument is the |
---|
35 | model type, which has been defined for cylinder, capped_cylinder, |
---|
36 | core_shell_cylinder, ellipsoid, triaxial_ellipsoid and lamellar. The |
---|
37 | second argument is view, which can be radial or tangential. To fit |
---|
38 | both radial and tangential simultaneously, use the word "both". |
---|
39 | |
---|
40 | Notes |
---|
41 | ----- |
---|
42 | |
---|
43 | cylinder.c + cylinder.py is the cylinder model with renamed variables and |
---|
44 | sld scaled by 1e6 so the numbers are nicer. The model name is "cylinder" |
---|
45 | |
---|
46 | cylinder_clone.c + cylinder_clone.py is the cylinder model using the |
---|
47 | same interface as the sasview, including calling the model CylinderModel, |
---|
48 | so that it can be used as a drop-in replacement for the sasview cylinder |
---|
49 | model. |
---|
50 | |
---|
51 | lamellar.py is an example of a single file model with embedded C code. |
---|
52 | |
---|
53 | Note: may want to rename form_volume to calc_volume and Iq/Iqxy to |
---|
54 | calc_Iq/calc_Iqxy in model interface. Similarly ER/VR go to calc_ER/calc_VR. |
---|
55 | |
---|
56 | Note: It is possible to translate python code automatically to opencl, using |
---|
57 | something like numba, clyther, shedskin or pypy, so maybe the kernel functions |
---|
58 | could be implemented without any C syntax. |
---|
59 | |
---|
60 | Note: angular dispersion in theta is probably not calculated correctly, but |
---|
61 | is left this way for compatibility with sasview. |
---|
62 | |
---|
63 | Magnetism hasn't been implemented yet. We may want a separate Imagnetic |
---|
64 | calculator with the extra parameters and calculations. We should |
---|
65 | return all desired spin states together so we can share the work of |
---|
66 | computing the form factors for the different magnetic contrasts. This |
---|
67 | will mean extending the data handler to support multiple cross sections |
---|
68 | in the same data set. |
---|
69 | |
---|
70 | Need to implement an example kernel directly in python. Polydispersity |
---|
71 | loops should be generated automatically as they are for the OpenCL models. |
---|
72 | The kernels should be vectorized across Q. These will need vectorized |
---|
73 | versions of numerical quadrature if we want to get reasonable performance. |
---|
74 | |
---|