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\rpa.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 CRPAModel |
---|
28 | |
---|
29 | def create_RPAModel(): |
---|
30 | """ |
---|
31 | Create a model instance |
---|
32 | """ |
---|
33 | obj = RPAModel() |
---|
34 | # CRPAModel.__init__(obj) is called by |
---|
35 | # the RPAModel constructor |
---|
36 | return obj |
---|
37 | |
---|
38 | class RPAModel(CRPAModel, BaseComponent): |
---|
39 | """ |
---|
40 | Class that evaluates a RPAModel model. |
---|
41 | This file was auto-generated from src\sans\models\include\rpa.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 | * lcase_n = 0.0 |
---|
48 | * ba = 5.0 |
---|
49 | * bb = 5.0 |
---|
50 | * bc = 5.0 |
---|
51 | * bd = 5.0 |
---|
52 | * Kab = -0.0004 |
---|
53 | * Kac = -0.0004 |
---|
54 | * Kad = -0.0004 |
---|
55 | * Kbc = -0.0004 |
---|
56 | * Kbd = -0.0004 |
---|
57 | * Kcd = -0.0004 |
---|
58 | * scale = 1.0 |
---|
59 | * background = 0.0 [1/cm] |
---|
60 | * Na = 1000.0 |
---|
61 | * Phia = 0.25 |
---|
62 | * va = 100.0 |
---|
63 | * La = 1e-12 |
---|
64 | * Nb = 1000.0 |
---|
65 | * Phib = 0.25 |
---|
66 | * vb = 100.0 |
---|
67 | * Lb = 1e-12 |
---|
68 | * Nc = 1000.0 |
---|
69 | * Phic = 0.25 |
---|
70 | * vc = 100.0 |
---|
71 | * Lc = 1e-12 |
---|
72 | * Nd = 1000.0 |
---|
73 | * Phid = 0.25 |
---|
74 | * vd = 100.0 |
---|
75 | * Ld = 0.0 |
---|
76 | |
---|
77 | """ |
---|
78 | |
---|
79 | def __init__(self, multfactor=1): |
---|
80 | """ Initialization """ |
---|
81 | self.__dict__ = {} |
---|
82 | |
---|
83 | # Initialize BaseComponent first, then sphere |
---|
84 | BaseComponent.__init__(self) |
---|
85 | #apply(CRPAModel.__init__, (self,)) |
---|
86 | |
---|
87 | CRPAModel.__init__(self) |
---|
88 | self.is_multifunc = False |
---|
89 | |
---|
90 | ## Name of the model |
---|
91 | self.name = "RPAModel" |
---|
92 | ## Model description |
---|
93 | self.description = """ |
---|
94 | THIS FORMALISM APPLIES TO MULTICOMPONENT POLYMER MIXTURES IN THE |
---|
95 | HOMOGENEOUS (MIXED) PHASE REGION ONLY.; |
---|
96 | CASE 0: C/D BINARY MIXTURE OF HOMOPOLYMERS |
---|
97 | CASE 1: C-D DIBLOCK COPOLYMER |
---|
98 | CASE 2: B/C/D TERNARY MIXTURE OF HOMOPOLYMERS |
---|
99 | CASE 3: B/C-D MIXTURE OF HOMOPOLYMER B AND |
---|
100 | DIBLOCK COPOLYMER C-D |
---|
101 | CASE 4: B-C-D TRIBLOCK COPOLYMER |
---|
102 | CASE 5: A/B/C/D QUATERNARY MIXTURE OF HOMOPOLYMERS |
---|
103 | CASE 6: A/B/C-D MIXTURE OF TWO HOMOPOLYMERS A/B |
---|
104 | AND A DIBLOCK C-D |
---|
105 | CASE 7: A/B-C-D MIXTURE OF A HOMOPOLYMER A AND A |
---|
106 | TRIBLOCK B-C-D |
---|
107 | CASE 8: A-B/C-D MIXTURE OF TWO DIBLOCK COPOLYMERS |
---|
108 | A-B AND C-D |
---|
109 | CASE 9: A-B-C-D FOUR-BLOCK COPOLYMER |
---|
110 | See details in the model function help |
---|
111 | """ |
---|
112 | |
---|
113 | ## Parameter details [units, min, max] |
---|
114 | self.details = {} |
---|
115 | self.details['lcase_n'] = ['', None, None] |
---|
116 | self.details['ba'] = ['', None, None] |
---|
117 | self.details['bb'] = ['', None, None] |
---|
118 | self.details['bc'] = ['', None, None] |
---|
119 | self.details['bd'] = ['', None, None] |
---|
120 | self.details['Kab'] = ['', None, None] |
---|
121 | self.details['Kac'] = ['', None, None] |
---|
122 | self.details['Kad'] = ['', None, None] |
---|
123 | self.details['Kbc'] = ['', None, None] |
---|
124 | self.details['Kbd'] = ['', None, None] |
---|
125 | self.details['Kcd'] = ['', None, None] |
---|
126 | self.details['scale'] = ['', None, None] |
---|
127 | self.details['background'] = ['[1/cm]', None, None] |
---|
128 | self.details['Na'] = ['', None, None] |
---|
129 | self.details['Phia'] = ['', None, None] |
---|
130 | self.details['va'] = ['', None, None] |
---|
131 | self.details['La'] = ['', None, None] |
---|
132 | self.details['Nb'] = ['', None, None] |
---|
133 | self.details['Phib'] = ['', None, None] |
---|
134 | self.details['vb'] = ['', None, None] |
---|
135 | self.details['Lb'] = ['', None, None] |
---|
136 | self.details['Nc'] = ['', None, None] |
---|
137 | self.details['Phic'] = ['', None, None] |
---|
138 | self.details['vc'] = ['', None, None] |
---|
139 | self.details['Lc'] = ['', None, None] |
---|
140 | self.details['Nd'] = ['', None, None] |
---|
141 | self.details['Phid'] = ['', None, None] |
---|
142 | self.details['vd'] = ['', None, None] |
---|
143 | self.details['Ld'] = ['', None, None] |
---|
144 | |
---|
145 | ## fittable parameters |
---|
146 | self.fixed = [] |
---|
147 | |
---|
148 | ## non-fittable parameters |
---|
149 | self.non_fittable = ['lcase_n', |
---|
150 | 'Na', |
---|
151 | 'Phia', |
---|
152 | 'va', |
---|
153 | 'La', |
---|
154 | 'Nb', |
---|
155 | 'Phib', |
---|
156 | 'vb', |
---|
157 | 'Lb', |
---|
158 | 'Nc', |
---|
159 | 'Phic', |
---|
160 | 'vc', |
---|
161 | 'Lc', |
---|
162 | 'Nd', |
---|
163 | 'Phid', |
---|
164 | 'vd', |
---|
165 | 'Ld'] |
---|
166 | |
---|
167 | ## parameters with orientation |
---|
168 | self.orientation_params = [] |
---|
169 | |
---|
170 | ## parameters with magnetism |
---|
171 | self.magnetic_params = [] |
---|
172 | |
---|
173 | self.category = None |
---|
174 | self.multiplicity_info = None |
---|
175 | |
---|
176 | def __setstate__(self, state): |
---|
177 | """ |
---|
178 | restore the state of a model from pickle |
---|
179 | """ |
---|
180 | self.__dict__, self.params, self.dispersion = state |
---|
181 | |
---|
182 | def __reduce_ex__(self, proto): |
---|
183 | """ |
---|
184 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
185 | c model. |
---|
186 | """ |
---|
187 | state = (self.__dict__, self.params, self.dispersion) |
---|
188 | return (create_RPAModel, tuple(), state, None, None) |
---|
189 | |
---|
190 | def clone(self): |
---|
191 | """ Return a identical copy of self """ |
---|
192 | return self._clone(RPAModel()) |
---|
193 | |
---|
194 | def run(self, x=0.0): |
---|
195 | """ |
---|
196 | Evaluate the model |
---|
197 | |
---|
198 | :param x: input q, or [q,phi] |
---|
199 | |
---|
200 | :return: scattering function P(q) |
---|
201 | |
---|
202 | """ |
---|
203 | return CRPAModel.run(self, x) |
---|
204 | |
---|
205 | def runXY(self, x=0.0): |
---|
206 | """ |
---|
207 | Evaluate the model in cartesian coordinates |
---|
208 | |
---|
209 | :param x: input q, or [qx, qy] |
---|
210 | |
---|
211 | :return: scattering function P(q) |
---|
212 | |
---|
213 | """ |
---|
214 | return CRPAModel.runXY(self, x) |
---|
215 | |
---|
216 | def evalDistribution(self, x): |
---|
217 | """ |
---|
218 | Evaluate the model in cartesian coordinates |
---|
219 | |
---|
220 | :param x: input q[], or [qx[], qy[]] |
---|
221 | |
---|
222 | :return: scattering function P(q[]) |
---|
223 | |
---|
224 | """ |
---|
225 | return CRPAModel.evalDistribution(self, x) |
---|
226 | |
---|
227 | def calculate_ER(self): |
---|
228 | """ |
---|
229 | Calculate the effective radius for P(q)*S(q) |
---|
230 | |
---|
231 | :return: the value of the effective radius |
---|
232 | |
---|
233 | """ |
---|
234 | return CRPAModel.calculate_ER(self) |
---|
235 | |
---|
236 | def calculate_VR(self): |
---|
237 | """ |
---|
238 | Calculate the volf ratio for P(q)*S(q) |
---|
239 | |
---|
240 | :return: the value of the volf ratio |
---|
241 | |
---|
242 | """ |
---|
243 | return CRPAModel.calculate_VR(self) |
---|
244 | |
---|
245 | def set_dispersion(self, parameter, dispersion): |
---|
246 | """ |
---|
247 | Set the dispersion object for a model parameter |
---|
248 | |
---|
249 | :param parameter: name of the parameter [string] |
---|
250 | :param dispersion: dispersion object of type DispersionModel |
---|
251 | |
---|
252 | """ |
---|
253 | return CRPAModel.set_dispersion(self, |
---|
254 | parameter, dispersion.cdisp) |
---|
255 | |
---|
256 | |
---|
257 | # End of file |
---|
258 | |
---|