Changeset c1799d3 in sasmodels for sasmodels/modelinfo.py
- Timestamp:
- Nov 9, 2018 12:16:05 PM (5 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- c11d09f
- Parents:
- 17695aa (diff), cf3d0ce (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
r17695aa rc1799d3 164 164 parameter.length = length 165 165 parameter.length_control = control 166 167 166 return parameter 168 167 … … 265 264 will have a magnitude and a direction, which may be different from 266 265 other sld parameters. The volume parameters are used for calls 267 to form_volume within the kernel (required for volume normalization) 268 and for calls to ER and VR for effective radius and volume ratio269 respectively.266 to form_volume within the kernel (required for volume normalization), 267 to shell_volume (for hollow shapes), and to effective_radius (for 268 structure factor interactions) respectively. 270 269 271 270 *description* is a short description of the parameter. This will … … 431 430 self.kernel_parameters = parameters 432 431 self._set_vector_lengths() 433 434 432 self.npars = sum(p.length for p in self.kernel_parameters) 435 433 self.nmagnetic = sum(p.length for p in self.kernel_parameters … … 438 436 if self.nmagnetic: 439 437 self.nvalues += 3 + 3*self.nmagnetic 440 441 438 self.call_parameters = self._get_call_parameters() 442 439 self.defaults = self._get_defaults() … … 740 737 741 738 #: Set of variables defined in the model that might contain C code 742 C_SYMBOLS = ['Imagnetic', 'Iq', 'Iqxy', 'Iqac', 'Iqabc', 'form_volume', ' c_code']739 C_SYMBOLS = ['Imagnetic', 'Iq', 'Iqxy', 'Iqac', 'Iqabc', 'form_volume', 'shell_volume', 'c_code'] 743 740 744 741 def _find_source_lines(model_info, kernel_module): … … 789 786 # Custom sum/multi models 790 787 return kernel_module.model_info 788 791 789 info = ModelInfo() 792 790 … … 822 820 info.docs = kernel_module.__doc__ 823 821 info.category = getattr(kernel_module, 'category', None) 824 info.structure_factor = structure_factor 822 info.structure_factor = getattr(kernel_module, 'structure_factor', False) 823 # TODO: find Fq by inspection 824 info.effective_radius_type = getattr(kernel_module, 'effective_radius_type', None) 825 info.have_Fq = getattr(kernel_module, 'have_Fq', False) 825 826 info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) 826 827 # Note: custom.load_custom_kernel_module assumes the C sources are defined … … 828 829 info.source = getattr(kernel_module, 'source', []) 829 830 info.c_code = getattr(kernel_module, 'c_code', None) 831 info.effective_radius = getattr(kernel_module, 'effective_radius', None) 830 832 # TODO: check the structure of the tests 831 833 info.tests = getattr(kernel_module, 'tests', []) 832 info.ER = getattr(kernel_module, 'ER', None) # type: ignore833 info.VR = getattr(kernel_module, 'VR', None) # type: ignore834 834 info.form_volume = getattr(kernel_module, 'form_volume', None) # type: ignore 835 info.shell_volume = getattr(kernel_module, 'shell_volume', None) # type: ignore 835 836 info.Iq = getattr(kernel_module, 'Iq', None) # type: ignore 836 837 info.Iqxy = getattr(kernel_module, 'Iqxy', None) # type: ignore … … 856 857 info.lineno = {} 857 858 _find_source_lines(info, kernel_module) 858 859 859 return info 860 860 … … 949 949 #: provided in the file. 950 950 structure_factor = None # type: bool 951 #: True if the model defines an Fq function with signature 952 #: void Fq(double q, double *F1, double *F2, ...) 953 have_Fq = False 954 #: List of options for computing the effective radius of the shape, 955 #: or None if the model is not usable as a form factor model. 956 effective_radius_type = None # type: List[str] 951 957 #: List of C source files used to define the model. The source files 952 958 #: should define the *Iq* function, and possibly *Iqac* or *Iqabc* if the 953 959 #: model defines orientation parameters. Files containing the most basic 954 960 #: functions must appear first in the list, followed by the files that 955 #: use those functions. Form factors are indicated by providing 956 #: an :attr:`ER` function. 961 #: use those functions. 957 962 source = None # type: List[str] 958 #: The set of tests that must pass. The format of the tests is described 959 #: in :mod:`model_test`. 960 tests = None # type: List[TestCondition] 961 #: Returns the effective radius of the model given its volume parameters. 962 #: The presence of *ER* indicates that the model is a form factor model 963 #: that may be used together with a structure factor to form an implicit 964 #: multiplication model. 965 #: 966 #: The parameters to the *ER* function must be marked with type *volume*. 967 #: in the parameter table. They will appear in the same order as they 968 #: do in the table. The values passed to *ER* will be vectors, with one 969 #: value for each polydispersity condition. For example, if the model 970 #: is polydisperse over both length and radius, then both length and 971 #: radius will have the same number of values in the vector, with one 972 #: value for each *length X radius*. If only *radius* is polydisperse, 973 #: then the value for *length* will be repeated once for each value of 974 #: *radius*. The *ER* function should return one effective radius for 975 #: each parameter set. Multiplicity parameters will be received as 976 #: arrays, with one row per polydispersity condition. 977 ER = None # type: Optional[Callable[[np.ndarray], np.ndarray]] 978 #: Returns the occupied volume and the total volume for each parameter set. 979 #: See :attr:`ER` for details on the parameters. 980 VR = None # type: Optional[Callable[[np.ndarray], Tuple[np.ndarray, np.ndarray]]] 981 #: Arbitrary C code containing supporting functions, etc., to be inserted 982 #: after everything in source. This can include Iq and Iqxy functions with 983 #: the full function signature, including all parameters. 984 c_code = None 963 #: inline source code, added after all elements of source 964 c_code = None # type: Optional[str] 985 965 #: Returns the form volume for python-based models. Form volume is needed 986 966 #: for volume normalization in the polydispersity integral. If no … … 990 970 #: C code, either defined as a string, or in the sources. 991 971 form_volume = None # type: Union[None, str, Callable[[np.ndarray], float]] 972 #: Returns the shell volume for python-based models. Form volume and 973 #: shell volume are needed for volume normalization in the polydispersity 974 #: integral and structure interactions for hollow shapes. If no 975 #: parameters are *volume* parameters, then shell volume is not needed. 976 #: For C-based models, (with :attr:`sources` defined, or with :attr:`Iq` 977 #: defined using a string containing C code), shell_volume must also be 978 #: C code, either defined as a string, or in the sources. 979 shell_volume = None # type: Union[None, str, Callable[[np.ndarray], float]] 992 980 #: Returns *I(q, a, b, ...)* for parameters *a*, *b*, etc. defined 993 981 #: by the parameter table. *Iq* can be defined as a python function, or … … 1024 1012 #: Line numbers for symbols defining C code 1025 1013 lineno = None # type: Dict[str, int] 1014 #: The set of tests that must pass. The format of the tests is described 1015 #: in :mod:`model_test`. 1016 tests = None # type: List[TestCondition] 1026 1017 1027 1018 def __init__(self):
Note: See TracChangeset
for help on using the changeset viewer.