[2e66ef5] | 1 | .. py:currentmodule:: sasmodels |
---|
| 2 | |
---|
| 3 | *************************** |
---|
| 4 | Code Overview |
---|
| 5 | *************************** |
---|
| 6 | |
---|
| 7 | Computational kernels |
---|
| 8 | --------------------- |
---|
| 9 | |
---|
| 10 | At the heart of *sasmodels* are the individual computational kernels. These |
---|
| 11 | functions take a particular $q$ value and a set of parameter values and |
---|
| 12 | return the expected scattering for that $q$. The instructions for writing |
---|
| 13 | a kernel are documented in :ref:`Writing_a_Plugin`. The source code for |
---|
| 14 | the kernels is stored in :mod:`sasmodels.models`. |
---|
| 15 | |
---|
| 16 | The primary interface to the models is through :mod:`sasmodels.core`, which |
---|
| 17 | provides functions for listing available models, loading the model definition |
---|
| 18 | and compiling the model. Use :func:`sasmodels.core.load_model` to load in |
---|
| 19 | a model definition and compile it. |
---|
| 20 | |
---|
| 21 | The computational kernels are difficult to call directly, but an example |
---|
| 22 | was provided in :ref:`Scripting_Interface`. |
---|
| 23 | |
---|
| 24 | The code for loading the kernel is in |
---|
| 25 | :mod:`sasmodels.generate`, but a big part of it, which is interpreting the |
---|
| 26 | definition, lives in :mod:`sasmodels.modelinfo`. This defines the properties |
---|
| 27 | of the model in :class:`sasmodels.modelinfo.ModelInfo`, the available |
---|
| 28 | model parameters in :class:`sasmodels.modelinfo.ParameterTable` and the |
---|
| 29 | individual parameter attributes such as units and hard limits in |
---|
| 30 | :class:`sasmodels.modelinfo.Parameter`. |
---|
| 31 | |
---|
| 32 | The kernel functions for the most part do not define polydispersity, |
---|
| 33 | resolution functions or magnetism. Instead, code for these is generated in |
---|
| 34 | :mod:`sasmodels.generate` |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | Sasview kernels: |
---|
| 39 | |
---|
| 40 | * :mod:` |
---|
| 41 | ('kernel', 'Evaluator type definitions'), |
---|
| 42 | ('kernelcl', 'OpenCL model evaluator'), |
---|
| 43 | ('kerneldll', 'Ctypes model evaluator'), |
---|
| 44 | ('kernelpy', 'Python model evaluator'), |
---|
| 45 | |
---|
| 46 | Bumps fitting routines: |
---|
| 47 | |
---|
| 48 | * :mod:`sasmodels.bumps_model` is a wrapper around |
---|
| 49 | ('bumps_model', 'Bumps interface'), |
---|
| 50 | ('direct_model', 'Simple interface'), |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | Utility functions: |
---|
| 54 | |
---|
| 55 | * :mod:`sasmodels` provides :func:`sasmodels.__init__.data_files` for the installer. |
---|
| 56 | * :mod:`sasmodels.rst2html` provides tools for converting model docs to html and viewing |
---|
| 57 | the html. When run as a main program, it can display arbitrary rst files. |
---|
| 58 | * :mod:`sasmodels.exception` annotates the current exception with a context string, |
---|
| 59 | such as "while opening myfile.dat" without adjusting the traceback. |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | And so on:: |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | ('compare_many', 'Batch compare models on different compute engines'), |
---|
| 66 | ('compare', 'Compare models on different compute engines'), |
---|
| 67 | ('convert', 'Sasview to sasmodel converter'), |
---|
| 68 | ('core', 'Model access'), |
---|
| 69 | ('data', 'Data layout and plotting routines'), |
---|
| 70 | ('details', 'Parameter packing for kernel calls'), |
---|
| 71 | ('generate', 'Model parser'), |
---|
| 72 | ('list_pars', 'Identify all parameters in all models'), |
---|
| 73 | ('mixture', 'Mixture model evaluator'), |
---|
| 74 | ('model_test', 'Unit test support'), |
---|
| 75 | ('modelinfo', 'Parameter and model definitions'), |
---|
| 76 | ('product', 'Product model evaluator'), |
---|
| 77 | ('resolution', '1-D resolution functions'), |
---|
| 78 | ('resolution2d', '2-D resolution functions'), |
---|
| 79 | ('sasview_model', 'Sasview interface'), |
---|
| 80 | ('sesans', 'SESANS calculation routines'), |
---|
| 81 | ('weights', 'Distribution functions'), |
---|