source: sasview/sansmodels/src/sans/models/RPAModel.py @ da20018

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 da20018 was c7a7e1b, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on model pickle

  • Property mode set to 100644
File size: 7.3 KB
Line 
1#!/usr/bin/env python
2
3##############################################################################
4#       This software was developed by the University of Tennessee as part of the
5#       Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
6#       project funded by the US National Science Foundation.
7#
8#       If you use DANSE applications to do scientific research that leads to
9#       publication, we ask that you acknowledge the use of the software with the
10#       following sentence:
11#
12#       "This work benefited from DANSE software developed under NSF award DMR-0520547."
13#
14#       copyright 2008, University of Tennessee
15##############################################################################
16
17
18"""
19Provide functionality for a C extension model
20
21:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
22         DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\rpa.h
23         AND RE-RUN THE GENERATOR SCRIPT
24
25"""
26
27from sans.models.BaseComponent import BaseComponent
28from sans_extension.c_models import CRPAModel
29import copy   
30
31def create_RPAModel():
32    obj = RPAModel()
33    #CRPAModel.__init__(obj) is called by RPAModel constructor
34    return obj
35
36class RPAModel(CRPAModel, BaseComponent):
37    """
38    Class that evaluates a RPAModel model.
39    This file was auto-generated from ..\c_extensions\rpa.h.
40    Refer to that file and the structure it contains
41    for details of the model.
42    List of default parameters:
43         lcase_n         = 0.0
44         ba              = 5.0
45         bb              = 5.0
46         bc              = 5.0
47         bd              = 5.0
48         Kab             = -0.0004
49         Kac             = -0.0004
50         Kad             = -0.0004
51         Kbc             = -0.0004
52         Kbd             = -0.0004
53         Kcd             = -0.0004
54         scale           = 1.0
55         background      = 0.0 [1/cm]
56         Na              = 1000.0
57         Phia            = 0.25
58         va              = 100.0
59         La              = 1e-012
60         Nb              = 1000.0
61         Phib            = 0.25
62         vb              = 100.0
63         Lb              = 1e-012
64         Nc              = 1000.0
65         Phic            = 0.25
66         vc              = 100.0
67         Lc              = 1e-012
68         Nd              = 1000.0
69         Phid            = 0.25
70         vd              = 100.0
71         Ld              = 0.0
72
73    """
74       
75    def __init__(self):
76        """ Initialization """
77       
78        # Initialize BaseComponent first, then sphere
79        BaseComponent.__init__(self)
80        #apply(CRPAModel.__init__, (self,))
81        CRPAModel.__init__(self)
82       
83        ## Name of the model
84        self.name = "RPAModel"
85        ## Model description
86        self.description ="""  THIS FORMALISM APPLIES TO MULTICOMPONENT POLYMER MIXTURES IN THE
87                HOMOGENEOUS (MIXED) PHASE REGION ONLY.;
88                CASE 0: C/D BINARY MIXTURE OF HOMOPOLYMERS
89                CASE 1: C-D DIBLOCK COPOLYMER
90                CASE 2: B/C/D TERNARY MIXTURE OF HOMOPOLYMERS
91                CASE 3: B/C-D MIXTURE OF HOMOPOLYMER B AND
92                DIBLOCK COPOLYMER C-D
93                CASE 4: B-C-D TRIBLOCK COPOLYMER
94                CASE 5: A/B/C/D QUATERNARY MIXTURE OF HOMOPOLYMERS
95                CASE 6: A/B/C-D MIXTURE OF TWO HOMOPOLYMERS A/B
96                AND A DIBLOCK C-D
97                CASE 7: A/B-C-D MIXTURE OF A HOMOPOLYMER A AND A
98                TRIBLOCK B-C-D
99                CASE 8: A-B/C-D MIXTURE OF TWO DIBLOCK COPOLYMERS
100                A-B AND C-D
101                CASE 9: A-B-C-D FOUR-BLOCK COPOLYMER
102                See details in the model function help"""
103       
104        ## Parameter details [units, min, max]
105        self.details = {}
106        self.details['lcase_n'] = ['', None, None]
107        self.details['ba'] = ['', None, None]
108        self.details['bb'] = ['', None, None]
109        self.details['bc'] = ['', None, None]
110        self.details['bd'] = ['', None, None]
111        self.details['Kab'] = ['', None, None]
112        self.details['Kac'] = ['', None, None]
113        self.details['Kad'] = ['', None, None]
114        self.details['Kbc'] = ['', None, None]
115        self.details['Kbd'] = ['', None, None]
116        self.details['Kcd'] = ['', None, None]
117        self.details['scale'] = ['', None, None]
118        self.details['background'] = ['[1/cm]', None, None]
119        self.details['Na'] = ['', None, None]
120        self.details['Phia'] = ['', None, None]
121        self.details['va'] = ['', None, None]
122        self.details['La'] = ['', None, None]
123        self.details['Nb'] = ['', None, None]
124        self.details['Phib'] = ['', None, None]
125        self.details['vb'] = ['', None, None]
126        self.details['Lb'] = ['', None, None]
127        self.details['Nc'] = ['', None, None]
128        self.details['Phic'] = ['', None, None]
129        self.details['vc'] = ['', None, None]
130        self.details['Lc'] = ['', None, None]
131        self.details['Nd'] = ['', None, None]
132        self.details['Phid'] = ['', None, None]
133        self.details['vd'] = ['', None, None]
134        self.details['Ld'] = ['', None, None]
135
136        ## fittable parameters
137        self.fixed=[]
138       
139        ## non-fittable parameters
140        self.non_fittable = ['lcase_n', 'Na', 'Phia', 'va', 'La', 'Nb', 'Phib', 'vb', 'Lb', 'Nc', 'Phic', 'vc', 'Lc', 'Nd', 'Phid', 'vd', 'Ld']
141       
142        ## parameters with orientation
143        self.orientation_params = []
144
145    def __setstate__(self, state):
146        """
147        restore the state of a model from pickle
148        """
149        self.__dict__, self.params, self.dispersion = state
150       
151    def __reduce_ex__(self, proto):
152        """
153        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
154        c model.
155        """
156        state = (self.__dict__, self.params, self.dispersion)
157        return (create_RPAModel,tuple(), state, None, None)
158       
159    def clone(self):
160        """ Return a identical copy of self """
161        return self._clone(RPAModel())   
162       
163   
164    def run(self, x=0.0):
165        """
166        Evaluate the model
167       
168        :param x: input q, or [q,phi]
169       
170        :return: scattering function P(q)
171       
172        """
173       
174        return CRPAModel.run(self, x)
175   
176    def runXY(self, x=0.0):
177        """
178        Evaluate the model in cartesian coordinates
179       
180        :param x: input q, or [qx, qy]
181       
182        :return: scattering function P(q)
183       
184        """
185       
186        return CRPAModel.runXY(self, x)
187       
188    def evalDistribution(self, x=[]):
189        """
190        Evaluate the model in cartesian coordinates
191       
192        :param x: input q[], or [qx[], qy[]]
193       
194        :return: scattering function P(q[])
195       
196        """
197        return CRPAModel.evalDistribution(self, x)
198       
199    def calculate_ER(self):
200        """
201        Calculate the effective radius for P(q)*S(q)
202       
203        :return: the value of the effective radius
204       
205        """       
206        return CRPAModel.calculate_ER(self)
207       
208    def set_dispersion(self, parameter, dispersion):
209        """
210        Set the dispersion object for a model parameter
211       
212        :param parameter: name of the parameter [string]
213        :param dispersion: dispersion object of type DispersionModel
214       
215        """
216        return CRPAModel.set_dispersion(self, parameter, dispersion.cdisp)
217       
218   
219# End of file
Note: See TracBrowser for help on using the repository browser.