Changes between Version 7 and Version 8 of ModelConvInst
- Timestamp:
- Nov 3, 2015 9:23:41 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ModelConvInst
v7 v8 12 12 '''CREATE NEW MODEL FILES'''. 13 13 14 In sasmodels/models/copy the appropriate files using the examples above to mymodel.py and mymodel.c as required where “mymodel’ is the NEW name for the model to be moved. Please follow new naming rules:14 In the sasmodels/models directory, copy the appropriate files using the examples above to mymodel.py and mymodel.c as required where “mymodel’ is the NEW name for the model to be moved. Please follow new naming rules: 15 15 - No capitalization and thus no !CamelCase. If necessary use underscore to separate (i.e. barbell not !BarBell or broad_peak not !BroadPeak) 16 16 - Remove “model” from the name (i.e. barbell not !BarBellModel) … … 20 20 21 21 Cut and paste appropriate sections from old model into new sasmodels in appropriate places. Fill out all required sections. Most of the magic is done in the python file. Only the computation section (mainly the Iq method etc) will be either in the python file or the c file as described in the computation section below. 22 - First lengthy docstring starts with an r (for raw) and three sets of quotes to start the doc string and ends with a second set of 3 quotes. This is where the FULL documentation for the model goes (to be picked up by sphinx). Paste the model documentation from the appropriate section of model_functions.rst (found at sasview/src/sas/models/media/model_functions.rst) here. For example, for the !BarBellModel, search for !BarBellModel in the rst file then copy everything after the *2.x.x. !ModelNameModel. Edit the result as follows:22 - First lengthy docstring starts with an r (for raw) and three sets of quotes to start the doc string and ends with a second set of 3 quotes. This is where the FULL documentation for the model goes (to be picked up by sphinx). Paste the model documentation from the appropriate section of model_functions.rst (found at [https://github.com/SasView/sasview/blob/master/src/sas/models/media/model_functions.rst src/sas/models/media/model_functions.rst]) here. For example, for the !BarBellModel, search for !BarBellModel in the rst file then copy everything after the *2.x.x. !ModelNameModel. Edit the result as follows: 23 23 - replace *2.x.x.x. Definition !** with Definition followed by a line of 10 dashes. 24 24 - wherever possible try to replace images of math functions with Latex. you can use the live demo Mathjax page (http://www.mathjax.org/) to make sure the equation looks as expected. also a lot of the Latex code can be taken from (or edited) from the PDF document created by Paul Kienzle: http://sasview.org/attachment/wiki/SasModels%20Work%20Package/Equations.docx.pdf. … … 26 26 - name = mymodel. Use the name of the file as described above in 1. 27 27 - title is a short tool tip description of the model. This is a new value to be used for tooltip for example. Make-up something appropriate but short (one line). 28 - description doc string. Cut and paste the self.description string from the !SasView model. This gives a brief description of the equation and the parameters without the need to read the entire model documentation. 29 - parameters. This is where the parameters get defined. The syntax should be obvious from the default. NAMES: VERY IMPORTANT. We are trying to make the model parameter more consistent between models. So solvent sld for example should have exactly the same name in every model. Current list of new parameters is: 28 - description doc string. Cut and paste the self.description string from the !SasView model header in [https://github.com/SasView/sasview/tree/master/src/sas/models/include srs/sas/models/include]. This gives a brief description of the equation and the parameters without the need to read the entire model documentation. 29 - parameters. This is where the parameters get defined. The syntax should be obvious from the default. Copy the parameters from the model header file [https://github.com/SasView/sasview/tree/master/src/sas/models/include srs/sas/models/include] 30 - PARAMETER NAMES: VERY IMPORTANT. We are trying to make the model parameter more consistent between models. So solvent sld for example should have exactly the same name in every model. Current list of new parameters is: 30 31 - radius = radius 31 32 - sld = scattering length density of particle … … 34 35 - exp = exponent (example: porod_exp) 35 36 - peak_pos = q_peak or q0 etc 36 - lower and upper limits can be any number or -inf or inf (the limits will show up as the default limits for the fit, making it easy for example to force the radius to always be greater than zero) 37 - type can take 3 values at this time: “”, “volume”, or “orientation” 37 - lower and upper limits can be any number or -inf or inf 38 - add limits where required; the sasview models don't usually define them 39 - the limits will show up as the default limits for the fit, making it easy for example to force the radius to always be greater than zero. 40 - type can take 3 values at this time: “”, “volume”, or “orientation” 38 41 - COMPUTATION 39 - P ython42 - Pure Python 40 43 - def Iq (this section does not exist for c models. It is replaced by the list of c files to call) 41 44 - def Iqxy. If this model does not have an oriented form just set it equal to the square root of the sum of Iq(x) squared and Iq(y) squared. 45 - [https://github.com/SasView/sasview/tree/master/src/sas/models src/sas/models] contains the pure python models, mixed together with the python + C models. 42 46 - Python + C 47 - model Iq, Iqxy are defined in [https://github.com/SasView/sasview/tree/master/src/sas/models/c_extension/c_models src/sas/models/c_extension/c_models] 48 - supporting scattering calculations are defined in [https://github.com/SasView/sasview/tree/master/src/sas/models/c_extension/libigor src/sas/models/c_extension/libigor] 49 - special functions are defined in [https://github.com/SasView/sasview/tree/master/src/sas/models/c_extension/cephes src/sas/models/c_extension/cephes]. With model definitions you are limited to the simple math functions defined in [https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/mathFunctions.html opencl] 43 50 - common functions should be moved into their own file, such as lib/J1.c for the bessel function J1. 44 51 - in place of the above methods point to the C source files needed. This will be a list of any lib files needed, followed by the model.c file, where model is the same name as given to the python model.py. For example: