source: sasview/src/sans/models/TwoYukawaModel.py @ 81b524f

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 81b524f was 81b524f, checked in by Jeff Krzywon <jeffery.krzywon@…>, 11 years ago

This branch is now merged with the latest trunk release. I will merge them next.

  • Property mode set to 100644
File size: 5.8 KB
Line 
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"""
16Provide functionality for a C extension model
17
18:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
19         DO NOT MODIFY THIS FILE, MODIFY
20            src\sans\models\include\TwoYukawa.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CTwoYukawaModel
26
27def create_TwoYukawaModel():
28    """
29       Create a model instance
30    """
31    obj = TwoYukawaModel()
32    # CTwoYukawaModel.__init__(obj) is called by
33    # the TwoYukawaModel constructor
34    return obj
35
36class TwoYukawaModel(CTwoYukawaModel, BaseComponent):
37    """
38    Class that evaluates a TwoYukawaModel model.
39    This file was auto-generated from src\sans\models\include\TwoYukawa.h.
40    Refer to that file and the structure it contains
41    for details of the model.
42    List of default parameters:
43         volfraction     = 0.2
44         effect_radius   = 50.0 [A]
45         scale_K1        = 6.0
46         decayConst_Z1   = 10.0
47         scale_K2        = -1.0
48         decayConst_Z2   = 2.0
49
50    """
51       
52    def __init__(self, multfactor=1):
53        """ Initialization """
54        self.__dict__ = {}
55       
56        # Initialize BaseComponent first, then sphere
57        BaseComponent.__init__(self)
58        #apply(CTwoYukawaModel.__init__, (self,))
59
60        CTwoYukawaModel.__init__(self)
61        self.is_multifunc = False
62                       
63        ## Name of the model
64        self.name = "TwoYukawaModel"
65        ## Model description
66        self.description = """
67        Structure factor for interacting particles:                   .
68               
69                Calculates the structure factor, S(q), for a monodisperse spherical particle interacting
70                through a two-Yukawa potential. The Mean Spherical Approximation is used as the
71                closure to solve the Ornstein-Zernicke equations.
72               
73                The function calculated is S(q), based on the solution of the Ornstein-Zernicke equations
74                using the Two-Yukawa potential (in its scaled form, r=r/diam):
75               
76                Radius is that of the hard core. The returned value is dimensionless.
77        """
78       
79        ## Parameter details [units, min, max]
80        self.details = {}
81        self.details['volfraction'] = ['', None, None]
82        self.details['effect_radius'] = ['[A]', None, None]
83        self.details['scale_K1'] = ['', None, None]
84        self.details['decayConst_Z1'] = ['', None, None]
85        self.details['scale_K2'] = ['', None, None]
86        self.details['decayConst_Z2'] = ['', None, None]
87
88        ## fittable parameters
89        self.fixed = []
90       
91        ## non-fittable parameters
92        self.non_fittable = []
93       
94        ## parameters with orientation
95        self.orientation_params = []
96
97        ## parameters with magnetism
98        self.magnetic_params = []
99
100        self.category = None
101        self.multiplicity_info = None
102       
103    def __setstate__(self, state):
104        """
105        restore the state of a model from pickle
106        """
107        self.__dict__, self.params, self.dispersion = state
108       
109    def __reduce_ex__(self, proto):
110        """
111        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
112        c model.
113        """
114        state = (self.__dict__, self.params, self.dispersion)
115        return (create_TwoYukawaModel, tuple(), state, None, None)
116       
117    def clone(self):
118        """ Return a identical copy of self """
119        return self._clone(TwoYukawaModel())   
120       
121    def run(self, x=0.0):
122        """
123        Evaluate the model
124       
125        :param x: input q, or [q,phi]
126       
127        :return: scattering function P(q)
128       
129        """
130        return CTwoYukawaModel.run(self, x)
131   
132    def runXY(self, x=0.0):
133        """
134        Evaluate the model in cartesian coordinates
135       
136        :param x: input q, or [qx, qy]
137       
138        :return: scattering function P(q)
139       
140        """
141        return CTwoYukawaModel.runXY(self, x)
142       
143    def evalDistribution(self, x):
144        """
145        Evaluate the model in cartesian coordinates
146       
147        :param x: input q[], or [qx[], qy[]]
148       
149        :return: scattering function P(q[])
150       
151        """
152        return CTwoYukawaModel.evalDistribution(self, x)
153       
154    def calculate_ER(self):
155        """
156        Calculate the effective radius for P(q)*S(q)
157       
158        :return: the value of the effective radius
159       
160        """       
161        return CTwoYukawaModel.calculate_ER(self)
162       
163    def calculate_VR(self):
164        """
165        Calculate the volf ratio for P(q)*S(q)
166       
167        :return: the value of the volf ratio
168       
169        """       
170        return CTwoYukawaModel.calculate_VR(self)
171             
172    def set_dispersion(self, parameter, dispersion):
173        """
174        Set the dispersion object for a model parameter
175       
176        :param parameter: name of the parameter [string]
177        :param dispersion: dispersion object of type DispersionModel
178       
179        """
180        return CTwoYukawaModel.set_dispersion(self,
181               parameter, dispersion.cdisp)
182       
183   
184# End of file
185
Note: See TracBrowser for help on using the repository browser.