source: sasview/sansmodels/src/sans/models/CoreFourShellModel.py @ 04349fe

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 04349fe was ec658c85, checked in by Jae Cho <jhjcho@…>, 15 years ago

python files of new models and unit tests

  • Property mode set to 100644
File size: 5.6 KB
Line 
1#!/usr/bin/env python
2"""
3        This software was developed by the University of Tennessee as part of the
4        Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
5        project funded by the US National Science Foundation.
6
7        If you use DANSE applications to do scientific research that leads to
8        publication, we ask that you acknowledge the use of the software with the
9        following sentence:
10
11        "This work benefited from DANSE software developed under NSF award DMR-0520547."
12
13        copyright 2008, University of Tennessee
14"""
15
16""" Provide functionality for a C extension model
17
18        WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
19                 DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\corefourshell.h
20                 AND RE-RUN THE GENERATOR SCRIPT
21
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans_extension.c_models import CCoreFourShellModel
26import copy   
27   
28class CoreFourShellModel(CCoreFourShellModel, BaseComponent):
29    """ Class that evaluates a CoreFourShellModel model.
30        This file was auto-generated from ..\c_extensions\corefourshell.h.
31        Refer to that file and the structure it contains
32        for details of the model.
33        List of default parameters:
34         scale           = 1.0
35         rad_core        = 60.0 [A]
36         sld_core        = 6.4e-006 [1/A^(2)]
37         thick_shell1    = 10.0 [A]
38         sld_shell1      = 1e-006 [1/A^(2)]
39         thick_shell2    = 10.0 [A]
40         sld_shell2      = 2e-006 [1/A^(2)]
41         thick_shell3    = 10.0 [A]
42         sld_shell3      = 3e-006 [1/A^(2)]
43         thick_shell4    = 10.0 [A]
44         sld_shell4      = 4e-006 [1/A^(2)]
45         sld_solv        = 6.4e-006 [1/A^(2)]
46         background      = 0.001 [1/cm]
47
48    """
49       
50    def __init__(self):
51        """ Initialization """
52       
53        # Initialize BaseComponent first, then sphere
54        BaseComponent.__init__(self)
55        CCoreFourShellModel.__init__(self)
56       
57        ## Name of the model
58        self.name = "CoreFourShellModel"
59        ## Model description
60        self.description =""" Calculates the scattering intensity from a core-4 shell structure.
61                scale = scale factor * volume fraction
62                rad_core: the radius of the core
63                sld_core: the SLD of the core
64                thick_shelli: the thickness of the i'th shell from the core
65                sld_shelli: the SLD of the i'th shell from the core
66                sld_solv: the SLD of the solvent
67                background: incoherent background"""
68       
69        ## Parameter details [units, min, max]
70        self.details = {}
71        self.details['scale'] = ['', None, None]
72        self.details['rad_core'] = ['[A]', None, None]
73        self.details['sld_core'] = ['[1/A^(2)]', None, None]
74        self.details['thick_shell1'] = ['[A]', None, None]
75        self.details['sld_shell1'] = ['[1/A^(2)]', None, None]
76        self.details['thick_shell2'] = ['[A]', None, None]
77        self.details['sld_shell2'] = ['[1/A^(2)]', None, None]
78        self.details['thick_shell3'] = ['[A]', None, None]
79        self.details['sld_shell3'] = ['[1/A^(2)]', None, None]
80        self.details['thick_shell4'] = ['[A]', None, None]
81        self.details['sld_shell4'] = ['[1/A^(2)]', None, None]
82        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
83        self.details['background'] = ['[1/cm]', None, None]
84
85        ## fittable parameters
86        self.fixed=['thick_shell4.width', 'thick_shell1.width', 'thick_shell2.width', 'thick_shell3.width', 'rad_core.width']
87       
88        ## parameters with orientation
89        self.orientation_params =[]
90   
91    def clone(self):
92        """ Return a identical copy of self """
93        return self._clone(CoreFourShellModel())   
94       
95    def __getstate__(self):
96        """ return object state for pickling and copying """
97        model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log}
98       
99        return self.__dict__, model_state
100       
101    def __setstate__(self, state):
102        """ create object from pickled state """
103       
104        self.__dict__, model_state = state
105        self.params = model_state['params']
106        self.dispersion = model_state['dispersion']
107        self.log = model_state['log']
108       
109   
110    def run(self, x = 0.0):
111        """ Evaluate the model
112            @param x: input q, or [q,phi]
113            @return: scattering function P(q)
114        """
115       
116        return CCoreFourShellModel.run(self, x)
117   
118    def runXY(self, x = 0.0):
119        """ Evaluate the model in cartesian coordinates
120            @param x: input q, or [qx, qy]
121            @return: scattering function P(q)
122        """
123       
124        return CCoreFourShellModel.runXY(self, x)
125       
126    def evalDistribution(self, x = []):
127        """ Evaluate the model in cartesian coordinates
128            @param x: input q[], or [qx[], qy[]]
129            @return: scattering function P(q[])
130        """
131        return CCoreFourShellModel.evalDistribution(self, x)
132       
133    def calculate_ER(self):
134        """ Calculate the effective radius for P(q)*S(q)
135            @return: the value of the effective radius
136        """       
137        return CCoreFourShellModel.calculate_ER(self)
138       
139    def set_dispersion(self, parameter, dispersion):
140        """
141            Set the dispersion object for a model parameter
142            @param parameter: name of the parameter [string]
143            @dispersion: dispersion object of type DispersionModel
144        """
145        return CCoreFourShellModel.set_dispersion(self, parameter, dispersion.cdisp)
146       
147   
148# End of file
Note: See TracBrowser for help on using the repository browser.