[400155b] | 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\core_shell_cylinder.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 CCoreShellCylinderModel |
---|
| 28 | |
---|
| 29 | def create_CoreShellCylinderModel(): |
---|
| 30 | """ |
---|
| 31 | Create a model instance |
---|
| 32 | """ |
---|
| 33 | obj = CoreShellCylinderModel() |
---|
| 34 | # CCoreShellCylinderModel.__init__(obj) is called by |
---|
| 35 | # the CoreShellCylinderModel constructor |
---|
| 36 | return obj |
---|
| 37 | |
---|
| 38 | class CoreShellCylinderModel(CCoreShellCylinderModel, BaseComponent): |
---|
| 39 | """ |
---|
| 40 | Class that evaluates a CoreShellCylinderModel model. |
---|
| 41 | This file was auto-generated from src\sans\models\include\core_shell_cylinder.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 | * radius = 20.0 [A] |
---|
| 48 | * scale = 1.0 |
---|
| 49 | * thickness = 10.0 [A] |
---|
| 50 | * length = 400.0 [A] |
---|
| 51 | * core_sld = 1e-06 [1/A^(2)] |
---|
| 52 | * shell_sld = 4e-06 [1/A^(2)] |
---|
| 53 | * solvent_sld = 1e-06 [1/A^(2)] |
---|
| 54 | * background = 0.0 [1/cm] |
---|
| 55 | * axis_theta = 90.0 [deg] |
---|
| 56 | * axis_phi = 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(CCoreShellCylinderModel.__init__, (self,)) |
---|
| 67 | |
---|
| 68 | CCoreShellCylinderModel.__init__(self) |
---|
| 69 | self.is_multifunc = False |
---|
| 70 | |
---|
| 71 | ## Name of the model |
---|
| 72 | self.name = "CoreShellCylinderModel" |
---|
| 73 | ## Model description |
---|
| 74 | self.description = """ |
---|
| 75 | P(q,alpha)= scale/Vs*f(q)^(2) + bkg, |
---|
| 76 | where: f(q)= 2(core_sld |
---|
| 77 | - solvant_sld)* Vc*sin[qLcos(alpha/2)] |
---|
| 78 | /[qLcos(alpha/2)]*J1(qRsin(alpha)) |
---|
| 79 | /[qRsin(alpha)]+2(shell_sld-solvent_sld) |
---|
| 80 | *Vs*sin[q(L+T)cos(alpha/2)][[q(L+T) |
---|
| 81 | *cos(alpha/2)]*J1(q(R+T)sin(alpha)) |
---|
| 82 | /q(R+T)sin(alpha)] |
---|
| 83 | |
---|
| 84 | alpha:is the angle between the axis of |
---|
| 85 | the cylinder and the q-vector |
---|
| 86 | Vs: the volume of the outer shell |
---|
| 87 | Vc: the volume of the core |
---|
| 88 | L: the length of the core |
---|
| 89 | shell_sld: the scattering length density |
---|
| 90 | of the shell |
---|
| 91 | solvent_sld: the scattering length density |
---|
| 92 | of the solvent |
---|
| 93 | bkg: the background |
---|
| 94 | T: the thickness |
---|
| 95 | R+T: is the outer radius |
---|
| 96 | L+2T: The total length of the outershell |
---|
| 97 | J1: the first order Bessel function |
---|
| 98 | theta: axis_theta of the cylinder |
---|
| 99 | phi: the axis_phi of the cylinder... |
---|
| 100 | """ |
---|
| 101 | |
---|
| 102 | ## Parameter details [units, min, max] |
---|
| 103 | self.details = {} |
---|
| 104 | self.details['radius'] = ['[A]', None, None] |
---|
| 105 | self.details['scale'] = ['', None, None] |
---|
| 106 | self.details['thickness'] = ['[A]', None, None] |
---|
| 107 | self.details['length'] = ['[A]', None, None] |
---|
| 108 | self.details['core_sld'] = ['[1/A^(2)]', None, None] |
---|
| 109 | self.details['shell_sld'] = ['[1/A^(2)]', None, None] |
---|
| 110 | self.details['solvent_sld'] = ['[1/A^(2)]', None, None] |
---|
| 111 | self.details['background'] = ['[1/cm]', None, None] |
---|
| 112 | self.details['axis_theta'] = ['[deg]', None, None] |
---|
| 113 | self.details['axis_phi'] = ['[deg]', None, None] |
---|
| 114 | |
---|
| 115 | ## fittable parameters |
---|
| 116 | self.fixed = ['axis_phi.width', |
---|
| 117 | 'axis_theta.width', |
---|
| 118 | 'length.width', |
---|
| 119 | 'radius.width', |
---|
| 120 | 'thickness.width'] |
---|
| 121 | |
---|
| 122 | ## non-fittable parameters |
---|
| 123 | self.non_fittable = [] |
---|
| 124 | |
---|
| 125 | ## parameters with orientation |
---|
| 126 | self.orientation_params = ['axis_phi', |
---|
| 127 | 'axis_theta', |
---|
| 128 | 'axis_phi.width', |
---|
| 129 | 'axis_theta.width'] |
---|
| 130 | |
---|
| 131 | ## parameters with magnetism |
---|
| 132 | self.magnetic_params = [] |
---|
| 133 | |
---|
| 134 | self.category = None |
---|
| 135 | self.multiplicity_info = None |
---|
| 136 | |
---|
| 137 | def __setstate__(self, state): |
---|
| 138 | """ |
---|
| 139 | restore the state of a model from pickle |
---|
| 140 | """ |
---|
| 141 | self.__dict__, self.params, self.dispersion = state |
---|
| 142 | |
---|
| 143 | def __reduce_ex__(self, proto): |
---|
| 144 | """ |
---|
| 145 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 146 | c model. |
---|
| 147 | """ |
---|
| 148 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 149 | return (create_CoreShellCylinderModel, tuple(), state, None, None) |
---|
| 150 | |
---|
| 151 | def clone(self): |
---|
| 152 | """ Return a identical copy of self """ |
---|
| 153 | return self._clone(CoreShellCylinderModel()) |
---|
| 154 | |
---|
| 155 | def run(self, x=0.0): |
---|
| 156 | """ |
---|
| 157 | Evaluate the model |
---|
| 158 | |
---|
| 159 | :param x: input q, or [q,phi] |
---|
| 160 | |
---|
| 161 | :return: scattering function P(q) |
---|
| 162 | |
---|
| 163 | """ |
---|
| 164 | return CCoreShellCylinderModel.run(self, x) |
---|
| 165 | |
---|
| 166 | def runXY(self, x=0.0): |
---|
| 167 | """ |
---|
| 168 | Evaluate the model in cartesian coordinates |
---|
| 169 | |
---|
| 170 | :param x: input q, or [qx, qy] |
---|
| 171 | |
---|
| 172 | :return: scattering function P(q) |
---|
| 173 | |
---|
| 174 | """ |
---|
| 175 | return CCoreShellCylinderModel.runXY(self, x) |
---|
| 176 | |
---|
| 177 | def evalDistribution(self, x): |
---|
| 178 | """ |
---|
| 179 | Evaluate the model in cartesian coordinates |
---|
| 180 | |
---|
| 181 | :param x: input q[], or [qx[], qy[]] |
---|
| 182 | |
---|
| 183 | :return: scattering function P(q[]) |
---|
| 184 | |
---|
| 185 | """ |
---|
| 186 | return CCoreShellCylinderModel.evalDistribution(self, x) |
---|
| 187 | |
---|
| 188 | def calculate_ER(self): |
---|
| 189 | """ |
---|
| 190 | Calculate the effective radius for P(q)*S(q) |
---|
| 191 | |
---|
| 192 | :return: the value of the effective radius |
---|
| 193 | |
---|
| 194 | """ |
---|
| 195 | return CCoreShellCylinderModel.calculate_ER(self) |
---|
| 196 | |
---|
| 197 | def calculate_VR(self): |
---|
| 198 | """ |
---|
| 199 | Calculate the volf ratio for P(q)*S(q) |
---|
| 200 | |
---|
| 201 | :return: the value of the volf ratio |
---|
| 202 | |
---|
| 203 | """ |
---|
| 204 | return CCoreShellCylinderModel.calculate_VR(self) |
---|
| 205 | |
---|
| 206 | def set_dispersion(self, parameter, dispersion): |
---|
| 207 | """ |
---|
| 208 | Set the dispersion object for a model parameter |
---|
| 209 | |
---|
| 210 | :param parameter: name of the parameter [string] |
---|
| 211 | :param dispersion: dispersion object of type DispersionModel |
---|
| 212 | |
---|
| 213 | """ |
---|
| 214 | return CCoreShellCylinderModel.set_dispersion(self, |
---|
| 215 | parameter, dispersion.cdisp) |
---|
| 216 | |
---|
| 217 | |
---|
| 218 | # End of file |
---|
| 219 | |
---|