Changeset c1799d3 in sasmodels for sasmodels/modelinfo.py


Ignore:
Timestamp:
Nov 9, 2018 12:16:05 PM (5 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:
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.
Message:

Merge branch 'beta_approx' into ticket-1157

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/modelinfo.py

    r17695aa rc1799d3  
    164164    parameter.length = length 
    165165    parameter.length_control = control 
    166  
    167166    return parameter 
    168167 
     
    265264    will have a magnitude and a direction, which may be different from 
    266265    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 ratio 
    269     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. 
    270269 
    271270    *description* is a short description of the parameter.  This will 
     
    431430        self.kernel_parameters = parameters 
    432431        self._set_vector_lengths() 
    433  
    434432        self.npars = sum(p.length for p in self.kernel_parameters) 
    435433        self.nmagnetic = sum(p.length for p in self.kernel_parameters 
     
    438436        if self.nmagnetic: 
    439437            self.nvalues += 3 + 3*self.nmagnetic 
    440  
    441438        self.call_parameters = self._get_call_parameters() 
    442439        self.defaults = self._get_defaults() 
     
    740737 
    741738#: Set of variables defined in the model that might contain C code 
    742 C_SYMBOLS = ['Imagnetic', 'Iq', 'Iqxy', 'Iqac', 'Iqabc', 'form_volume', 'c_code'] 
     739C_SYMBOLS = ['Imagnetic', 'Iq', 'Iqxy', 'Iqac', 'Iqabc', 'form_volume', 'shell_volume', 'c_code'] 
    743740 
    744741def _find_source_lines(model_info, kernel_module): 
     
    789786        # Custom sum/multi models 
    790787        return kernel_module.model_info 
     788 
    791789    info = ModelInfo() 
    792790 
     
    822820    info.docs = kernel_module.__doc__ 
    823821    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) 
    825826    info.profile_axes = getattr(kernel_module, 'profile_axes', ['x', 'y']) 
    826827    # Note: custom.load_custom_kernel_module assumes the C sources are defined 
     
    828829    info.source = getattr(kernel_module, 'source', []) 
    829830    info.c_code = getattr(kernel_module, 'c_code', None) 
     831    info.effective_radius = getattr(kernel_module, 'effective_radius', None) 
    830832    # TODO: check the structure of the tests 
    831833    info.tests = getattr(kernel_module, 'tests', []) 
    832     info.ER = getattr(kernel_module, 'ER', None) # type: ignore 
    833     info.VR = getattr(kernel_module, 'VR', None) # type: ignore 
    834834    info.form_volume = getattr(kernel_module, 'form_volume', None) # type: ignore 
     835    info.shell_volume = getattr(kernel_module, 'shell_volume', None) # type: ignore 
    835836    info.Iq = getattr(kernel_module, 'Iq', None) # type: ignore 
    836837    info.Iqxy = getattr(kernel_module, 'Iqxy', None) # type: ignore 
     
    856857    info.lineno = {} 
    857858    _find_source_lines(info, kernel_module) 
    858  
    859859    return info 
    860860 
     
    949949    #: provided in the file. 
    950950    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] 
    951957    #: List of C source files used to define the model.  The source files 
    952958    #: should define the *Iq* function, and possibly *Iqac* or *Iqabc* if the 
    953959    #: model defines orientation parameters. Files containing the most basic 
    954960    #: 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. 
    957962    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] 
    985965    #: Returns the form volume for python-based models.  Form volume is needed 
    986966    #: for volume normalization in the polydispersity integral.  If no 
     
    990970    #: C code, either defined as a string, or in the sources. 
    991971    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]] 
    992980    #: Returns *I(q, a, b, ...)* for parameters *a*, *b*, etc. defined 
    993981    #: by the parameter table.  *Iq* can be defined as a python function, or 
     
    10241012    #: Line numbers for symbols defining C code 
    10251013    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] 
    10261017 
    10271018    def __init__(self): 
Note: See TracChangeset for help on using the changeset viewer.