[81b524f] | 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: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
| 19 | DO NOT MODIFY THIS FILE, MODIFY |
---|
| 20 | src\sans\models\include\sphere.h |
---|
| 21 | AND RE-RUN THE GENERATOR SCRIPT |
---|
| 22 | """ |
---|
| 23 | |
---|
| 24 | from sans.models.BaseComponent import BaseComponent |
---|
| 25 | from sans.models.sans_extension.c_models import CSphereModel |
---|
| 26 | |
---|
| 27 | def create_SphereModel(): |
---|
| 28 | """ |
---|
| 29 | Create a model instance |
---|
| 30 | """ |
---|
| 31 | obj = SphereModel() |
---|
| 32 | # CSphereModel.__init__(obj) is called by |
---|
| 33 | # the SphereModel constructor |
---|
| 34 | return obj |
---|
| 35 | |
---|
| 36 | class SphereModel(CSphereModel, BaseComponent): |
---|
| 37 | """ |
---|
| 38 | Class that evaluates a SphereModel model. |
---|
| 39 | This file was auto-generated from src\sans\models\include\sphere.h. |
---|
| 40 | Refer to that file and the structure it contains |
---|
| 41 | for details of the model. |
---|
| 42 | List of default parameters: |
---|
| 43 | scale = 1.0 |
---|
| 44 | radius = 60.0 [A] |
---|
| 45 | sldSph = 2e-06 [1/A^(2)] |
---|
| 46 | sldSolv = 1e-06 [1/A^(2)] |
---|
| 47 | background = 0.0 [1/cm] |
---|
| 48 | M0_sld_sph = 0.0 [1/A^(2)] |
---|
| 49 | M_theta_sph = 0.0 [deg] |
---|
| 50 | M_phi_sph = 0.0 [deg] |
---|
| 51 | M0_sld_solv = 0.0 [1/A^(2)] |
---|
| 52 | M_theta_solv = 0.0 [deg] |
---|
| 53 | M_phi_solv = 0.0 [deg] |
---|
| 54 | Up_frac_i = 0.5 [u/(u+d)] |
---|
| 55 | Up_frac_f = 0.5 [u/(u+d)] |
---|
| 56 | Up_theta = 0.0 [deg] |
---|
| 57 | |
---|
| 58 | """ |
---|
| 59 | |
---|
| 60 | def __init__(self, multfactor=1): |
---|
| 61 | """ Initialization """ |
---|
| 62 | self.__dict__ = {} |
---|
| 63 | |
---|
| 64 | # Initialize BaseComponent first, then sphere |
---|
| 65 | BaseComponent.__init__(self) |
---|
| 66 | #apply(CSphereModel.__init__, (self,)) |
---|
| 67 | |
---|
| 68 | CSphereModel.__init__(self) |
---|
| 69 | self.is_multifunc = False |
---|
| 70 | |
---|
| 71 | ## Name of the model |
---|
| 72 | self.name = "SphereModel" |
---|
| 73 | ## Model description |
---|
| 74 | self.description = """ |
---|
| 75 | P(q)=(scale/V)*[3V(sldSph-sldSolv)*(sin(qR)-qRcos(qR)) |
---|
| 76 | /(qR)^3]^(2)+bkg |
---|
| 77 | |
---|
| 78 | bkg:background, R: radius of sphere |
---|
| 79 | V:The volume of the scatter |
---|
| 80 | sldSph: the SLD of the sphere |
---|
| 81 | sldSolv: the SLD of the solvent |
---|
| 82 | |
---|
| 83 | """ |
---|
| 84 | |
---|
| 85 | ## Parameter details [units, min, max] |
---|
| 86 | self.details = {} |
---|
| 87 | self.details['scale'] = ['', None, None] |
---|
| 88 | self.details['radius'] = ['[A]', None, None] |
---|
| 89 | self.details['sldSph'] = ['[1/A^(2)]', None, None] |
---|
| 90 | self.details['sldSolv'] = ['[1/A^(2)]', None, None] |
---|
| 91 | self.details['background'] = ['[1/cm]', None, None] |
---|
| 92 | self.details['M0_sld_sph'] = ['[1/A^(2)]', None, None] |
---|
| 93 | self.details['M_theta_sph'] = ['[deg]', None, None] |
---|
| 94 | self.details['M_phi_sph'] = ['[deg]', None, None] |
---|
| 95 | self.details['M0_sld_solv'] = ['[1/A^(2)]', None, None] |
---|
| 96 | self.details['M_theta_solv'] = ['[deg]', None, None] |
---|
| 97 | self.details['M_phi_solv'] = ['[deg]', None, None] |
---|
| 98 | self.details['Up_frac_i'] = ['[u/(u+d)]', None, None] |
---|
| 99 | self.details['Up_frac_f'] = ['[u/(u+d)]', None, None] |
---|
| 100 | self.details['Up_theta'] = ['[deg]', None, None] |
---|
| 101 | |
---|
| 102 | ## fittable parameters |
---|
| 103 | self.fixed = ['radius.width'] |
---|
| 104 | |
---|
| 105 | ## non-fittable parameters |
---|
| 106 | self.non_fittable = [] |
---|
| 107 | |
---|
| 108 | ## parameters with orientation |
---|
| 109 | self.orientation_params = ['M0_sld_sph', |
---|
| 110 | 'M_theta_sph', |
---|
| 111 | 'M_phi_sph', |
---|
| 112 | 'M0_sld_solv', |
---|
| 113 | 'M_theta_solv', |
---|
| 114 | 'M_phi_solv', |
---|
| 115 | 'Up_frac_i', |
---|
| 116 | 'Up_frac_f', |
---|
| 117 | 'Up_theta'] |
---|
| 118 | |
---|
| 119 | ## parameters with magnetism |
---|
| 120 | self.magnetic_params = ['M0_sld_sph', 'M_theta_sph', 'M_phi_sph', 'M0_sld_solv', 'M_theta_solv', 'M_phi_solv', 'Up_frac_i', 'Up_frac_f', 'Up_theta'] |
---|
| 121 | |
---|
| 122 | self.category = "Shapes & Spheres" |
---|
| 123 | self.multiplicity_info = None |
---|
| 124 | |
---|
| 125 | def __setstate__(self, state): |
---|
| 126 | """ |
---|
| 127 | restore the state of a model from pickle |
---|
| 128 | """ |
---|
| 129 | self.__dict__, self.params, self.dispersion = state |
---|
| 130 | |
---|
| 131 | def __reduce_ex__(self, proto): |
---|
| 132 | """ |
---|
| 133 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 134 | c model. |
---|
| 135 | """ |
---|
| 136 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 137 | return (create_SphereModel, tuple(), state, None, None) |
---|
| 138 | |
---|
| 139 | def clone(self): |
---|
| 140 | """ Return a identical copy of self """ |
---|
| 141 | return self._clone(SphereModel()) |
---|
| 142 | |
---|
| 143 | def run(self, x=0.0): |
---|
| 144 | """ |
---|
| 145 | Evaluate the model |
---|
| 146 | |
---|
| 147 | :param x: input q, or [q,phi] |
---|
| 148 | |
---|
| 149 | :return: scattering function P(q) |
---|
| 150 | |
---|
| 151 | """ |
---|
| 152 | return CSphereModel.run(self, x) |
---|
| 153 | |
---|
| 154 | def runXY(self, x=0.0): |
---|
| 155 | """ |
---|
| 156 | Evaluate the model in cartesian coordinates |
---|
| 157 | |
---|
| 158 | :param x: input q, or [qx, qy] |
---|
| 159 | |
---|
| 160 | :return: scattering function P(q) |
---|
| 161 | |
---|
| 162 | """ |
---|
| 163 | return CSphereModel.runXY(self, x) |
---|
| 164 | |
---|
| 165 | def evalDistribution(self, x): |
---|
| 166 | """ |
---|
| 167 | Evaluate the model in cartesian coordinates |
---|
| 168 | |
---|
| 169 | :param x: input q[], or [qx[], qy[]] |
---|
| 170 | |
---|
| 171 | :return: scattering function P(q[]) |
---|
| 172 | |
---|
| 173 | """ |
---|
| 174 | return CSphereModel.evalDistribution(self, x) |
---|
| 175 | |
---|
| 176 | def calculate_ER(self): |
---|
| 177 | """ |
---|
| 178 | Calculate the effective radius for P(q)*S(q) |
---|
| 179 | |
---|
| 180 | :return: the value of the effective radius |
---|
| 181 | |
---|
| 182 | """ |
---|
| 183 | return CSphereModel.calculate_ER(self) |
---|
| 184 | |
---|
| 185 | def calculate_VR(self): |
---|
| 186 | """ |
---|
| 187 | Calculate the volf ratio for P(q)*S(q) |
---|
| 188 | |
---|
| 189 | :return: the value of the volf ratio |
---|
| 190 | |
---|
| 191 | """ |
---|
| 192 | return CSphereModel.calculate_VR(self) |
---|
| 193 | |
---|
| 194 | def set_dispersion(self, parameter, dispersion): |
---|
| 195 | """ |
---|
| 196 | Set the dispersion object for a model parameter |
---|
| 197 | |
---|
| 198 | :param parameter: name of the parameter [string] |
---|
| 199 | :param dispersion: dispersion object of type DispersionModel |
---|
| 200 | |
---|
| 201 | """ |
---|
| 202 | return CSphereModel.set_dispersion(self, |
---|
| 203 | parameter, dispersion.cdisp) |
---|
| 204 | |
---|
| 205 | |
---|
| 206 | # End of file |
---|
| 207 | |
---|