1 | ############################################################################## |
---|
2 | # This software was developed by the University of Tennessee as part of the |
---|
3 | # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
4 | # project funded by the US National Science Foundation. |
---|
5 | # |
---|
6 | # If you use DANSE applications to do scientific research that leads to |
---|
7 | # publication, we ask that you acknowledge the use of the software with the |
---|
8 | # following sentence: |
---|
9 | # |
---|
10 | # This work benefited from DANSE software developed under NSF award DMR-0520547 |
---|
11 | # |
---|
12 | # Copyright 2008-2011, University of Tennessee |
---|
13 | ############################################################################## |
---|
14 | |
---|
15 | """ |
---|
16 | Provide functionality for a C extension model |
---|
17 | |
---|
18 | .. WARNING:: |
---|
19 | |
---|
20 | THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
21 | DO NOT MODIFY THIS FILE, MODIFY |
---|
22 | src\sans\models\include\linearpearls.h |
---|
23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
24 | """ |
---|
25 | |
---|
26 | from sans.models.BaseComponent import BaseComponent |
---|
27 | from sans.models.sans_extension.c_models import CLinearPearlsModel |
---|
28 | |
---|
29 | def create_LinearPearlsModel(): |
---|
30 | """ |
---|
31 | Create a model instance |
---|
32 | """ |
---|
33 | obj = LinearPearlsModel() |
---|
34 | # CLinearPearlsModel.__init__(obj) is called by |
---|
35 | # the LinearPearlsModel constructor |
---|
36 | return obj |
---|
37 | |
---|
38 | class LinearPearlsModel(CLinearPearlsModel, BaseComponent): |
---|
39 | """ |
---|
40 | Class that evaluates a LinearPearlsModel model. |
---|
41 | This file was auto-generated from src\sans\models\include\linearpearls.h. |
---|
42 | Refer to that file and the structure it contains |
---|
43 | for details of the model. |
---|
44 | |
---|
45 | List of default parameters: |
---|
46 | |
---|
47 | * scale = 1.0 |
---|
48 | * radius = 80.0 [A] |
---|
49 | * edge_separation = 350.0 [A] |
---|
50 | * num_pearls = 3.0 |
---|
51 | * sld_pearl = 1e-06 [1/A^(2)] |
---|
52 | * sld_solv = 6.3e-06 [1/A^(2)] |
---|
53 | * background = 0.0 |
---|
54 | * scale = 1.0 |
---|
55 | * radius = 80.0 [A] |
---|
56 | * edge_separation = 350.0 [A] |
---|
57 | * num_pearls = 3.0 |
---|
58 | * sld_pearl = 1e-06 [1/A^(2)] |
---|
59 | * sld_solv = 6.3e-06 [1/A^(2)] |
---|
60 | * background = 0.0 |
---|
61 | |
---|
62 | """ |
---|
63 | |
---|
64 | def __init__(self, multfactor=1): |
---|
65 | """ Initialization """ |
---|
66 | self.__dict__ = {} |
---|
67 | |
---|
68 | # Initialize BaseComponent first, then sphere |
---|
69 | BaseComponent.__init__(self) |
---|
70 | #apply(CLinearPearlsModel.__init__, (self,)) |
---|
71 | |
---|
72 | CLinearPearlsModel.__init__(self) |
---|
73 | self.is_multifunc = False |
---|
74 | |
---|
75 | ## Name of the model |
---|
76 | self.name = "LinearPearlsModel" |
---|
77 | ## Model description |
---|
78 | self.description = """ |
---|
79 | Calculate form factor for Pearl Necklace Model |
---|
80 | [Macromol. 1996, 29, 2974-2979] |
---|
81 | Parameters: |
---|
82 | background:background |
---|
83 | scale: scale factor |
---|
84 | sld_pearl: the SLD of the pearl spheres |
---|
85 | sld_solv: the SLD of the solvent |
---|
86 | num_pearls: number of the pearls |
---|
87 | radius: the radius of a pearl |
---|
88 | edge_separation: the length of string segment; surface to surface |
---|
89 | """ |
---|
90 | |
---|
91 | ## Parameter details [units, min, max] |
---|
92 | self.details = {} |
---|
93 | self.details['scale'] = ['', None, None] |
---|
94 | self.details['radius'] = ['[A]', None, None] |
---|
95 | self.details['edge_separation'] = ['[A]', None, None] |
---|
96 | self.details['num_pearls'] = ['', None, None] |
---|
97 | self.details['sld_pearl'] = ['[1/A^(2)]', None, None] |
---|
98 | self.details['sld_solv'] = ['[1/A^(2)]', None, None] |
---|
99 | self.details['background'] = ['', None, None] |
---|
100 | self.details['scale'] = ['', None, None] |
---|
101 | self.details['radius'] = ['[A]', None, None] |
---|
102 | self.details['edge_separation'] = ['[A]', None, None] |
---|
103 | self.details['num_pearls'] = ['', None, None] |
---|
104 | self.details['sld_pearl'] = ['[1/A^(2)]', None, None] |
---|
105 | self.details['sld_solv'] = ['[1/A^(2)]', None, None] |
---|
106 | self.details['background'] = ['', None, None] |
---|
107 | |
---|
108 | ## fittable parameters |
---|
109 | self.fixed = ['radius.width', |
---|
110 | 'edge_separation.width'] |
---|
111 | |
---|
112 | ## non-fittable parameters |
---|
113 | self.non_fittable = [] |
---|
114 | |
---|
115 | ## parameters with orientation |
---|
116 | self.orientation_params = [] |
---|
117 | |
---|
118 | ## parameters with magnetism |
---|
119 | self.magnetic_params = [] |
---|
120 | |
---|
121 | self.category = None |
---|
122 | self.multiplicity_info = None |
---|
123 | |
---|
124 | def __setstate__(self, state): |
---|
125 | """ |
---|
126 | restore the state of a model from pickle |
---|
127 | """ |
---|
128 | self.__dict__, self.params, self.dispersion = state |
---|
129 | |
---|
130 | def __reduce_ex__(self, proto): |
---|
131 | """ |
---|
132 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
133 | c model. |
---|
134 | """ |
---|
135 | state = (self.__dict__, self.params, self.dispersion) |
---|
136 | return (create_LinearPearlsModel, tuple(), state, None, None) |
---|
137 | |
---|
138 | def clone(self): |
---|
139 | """ Return a identical copy of self """ |
---|
140 | return self._clone(LinearPearlsModel()) |
---|
141 | |
---|
142 | def run(self, x=0.0): |
---|
143 | """ |
---|
144 | Evaluate the model |
---|
145 | |
---|
146 | :param x: input q, or [q,phi] |
---|
147 | |
---|
148 | :return: scattering function P(q) |
---|
149 | |
---|
150 | """ |
---|
151 | return CLinearPearlsModel.run(self, x) |
---|
152 | |
---|
153 | def runXY(self, x=0.0): |
---|
154 | """ |
---|
155 | Evaluate the model in cartesian coordinates |
---|
156 | |
---|
157 | :param x: input q, or [qx, qy] |
---|
158 | |
---|
159 | :return: scattering function P(q) |
---|
160 | |
---|
161 | """ |
---|
162 | return CLinearPearlsModel.runXY(self, x) |
---|
163 | |
---|
164 | def evalDistribution(self, x): |
---|
165 | """ |
---|
166 | Evaluate the model in cartesian coordinates |
---|
167 | |
---|
168 | :param x: input q[], or [qx[], qy[]] |
---|
169 | |
---|
170 | :return: scattering function P(q[]) |
---|
171 | |
---|
172 | """ |
---|
173 | return CLinearPearlsModel.evalDistribution(self, x) |
---|
174 | |
---|
175 | def calculate_ER(self): |
---|
176 | """ |
---|
177 | Calculate the effective radius for P(q)*S(q) |
---|
178 | |
---|
179 | :return: the value of the effective radius |
---|
180 | |
---|
181 | """ |
---|
182 | return CLinearPearlsModel.calculate_ER(self) |
---|
183 | |
---|
184 | def calculate_VR(self): |
---|
185 | """ |
---|
186 | Calculate the volf ratio for P(q)*S(q) |
---|
187 | |
---|
188 | :return: the value of the volf ratio |
---|
189 | |
---|
190 | """ |
---|
191 | return CLinearPearlsModel.calculate_VR(self) |
---|
192 | |
---|
193 | def set_dispersion(self, parameter, dispersion): |
---|
194 | """ |
---|
195 | Set the dispersion object for a model parameter |
---|
196 | |
---|
197 | :param parameter: name of the parameter [string] |
---|
198 | :param dispersion: dispersion object of type DispersionModel |
---|
199 | |
---|
200 | """ |
---|
201 | return CLinearPearlsModel.set_dispersion(self, |
---|
202 | parameter, dispersion.cdisp) |
---|
203 | |
---|
204 | |
---|
205 | # End of file |
---|
206 | |
---|