[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\parallelepiped.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 CParallelepipedModel |
---|
| 28 | |
---|
| 29 | def create_ParallelepipedModel(): |
---|
| 30 | """ |
---|
| 31 | Create a model instance |
---|
| 32 | """ |
---|
| 33 | obj = ParallelepipedModel() |
---|
| 34 | # CParallelepipedModel.__init__(obj) is called by |
---|
| 35 | # the ParallelepipedModel constructor |
---|
| 36 | return obj |
---|
| 37 | |
---|
| 38 | class ParallelepipedModel(CParallelepipedModel, BaseComponent): |
---|
| 39 | """ |
---|
| 40 | Class that evaluates a ParallelepipedModel model. |
---|
| 41 | This file was auto-generated from src\sans\models\include\parallelepiped.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 | * scale = 1.0 |
---|
| 48 | * short_a = 35.0 [A] |
---|
| 49 | * short_b = 75.0 [A] |
---|
| 50 | * long_c = 400.0 [A] |
---|
| 51 | * sldPipe = 6.3e-06 [1/A^(2)] |
---|
| 52 | * sldSolv = 1e-06 [1/A^(2)] |
---|
| 53 | * background = 0.0 [1/cm] |
---|
| 54 | * parallel_theta = 0.0 [deg] |
---|
| 55 | * parallel_phi = 0.0 [deg] |
---|
| 56 | * parallel_psi = 0.0 [deg] |
---|
| 57 | * M0_sld_pipe = 0.0 [1/A^(2)] |
---|
| 58 | * M_theta_pipe = 0.0 [deg] |
---|
| 59 | * M_phi_pipe = 0.0 [deg] |
---|
| 60 | * M0_sld_solv = 0.0 [1/A^(2)] |
---|
| 61 | * M_theta_solv = 0.0 [deg] |
---|
| 62 | * M_phi_solv = 0.0 [deg] |
---|
| 63 | * Up_frac_i = 0.5 [u/(u+d)] |
---|
| 64 | * Up_frac_f = 0.5 [u/(u+d)] |
---|
| 65 | * Up_theta = 0.0 [deg] |
---|
| 66 | |
---|
| 67 | """ |
---|
| 68 | |
---|
| 69 | def __init__(self, multfactor=1): |
---|
| 70 | """ Initialization """ |
---|
| 71 | self.__dict__ = {} |
---|
| 72 | |
---|
| 73 | # Initialize BaseComponent first, then sphere |
---|
| 74 | BaseComponent.__init__(self) |
---|
| 75 | #apply(CParallelepipedModel.__init__, (self,)) |
---|
| 76 | |
---|
| 77 | CParallelepipedModel.__init__(self) |
---|
| 78 | self.is_multifunc = False |
---|
| 79 | |
---|
| 80 | ## Name of the model |
---|
| 81 | self.name = "ParallelepipedModel" |
---|
| 82 | ## Model description |
---|
| 83 | self.description = """ |
---|
| 84 | Form factor for a rectangular solid with uniform scattering length density. |
---|
| 85 | |
---|
| 86 | scale:Scale factor |
---|
| 87 | short_a: length of short edge [A] |
---|
| 88 | short_b: length of another short edge [A] |
---|
| 89 | long_c: length of long edge of the parallelepiped [A] |
---|
| 90 | sldPipe: Pipe_sld |
---|
| 91 | sldSolv: solvent_sld |
---|
| 92 | background:Incoherent Background [1/cm] |
---|
| 93 | """ |
---|
| 94 | |
---|
| 95 | ## Parameter details [units, min, max] |
---|
| 96 | self.details = {} |
---|
| 97 | self.details['scale'] = ['', None, None] |
---|
| 98 | self.details['short_a'] = ['[A]', None, None] |
---|
| 99 | self.details['short_b'] = ['[A]', None, None] |
---|
| 100 | self.details['long_c'] = ['[A]', None, None] |
---|
| 101 | self.details['sldPipe'] = ['[1/A^(2)]', None, None] |
---|
| 102 | self.details['sldSolv'] = ['[1/A^(2)]', None, None] |
---|
| 103 | self.details['background'] = ['[1/cm]', None, None] |
---|
| 104 | self.details['parallel_theta'] = ['[deg]', None, None] |
---|
| 105 | self.details['parallel_phi'] = ['[deg]', None, None] |
---|
| 106 | self.details['parallel_psi'] = ['[deg]', None, None] |
---|
| 107 | self.details['M0_sld_pipe'] = ['[1/A^(2)]', None, None] |
---|
| 108 | self.details['M_theta_pipe'] = ['[deg]', None, None] |
---|
| 109 | self.details['M_phi_pipe'] = ['[deg]', None, None] |
---|
| 110 | self.details['M0_sld_solv'] = ['[1/A^(2)]', None, None] |
---|
| 111 | self.details['M_theta_solv'] = ['[deg]', None, None] |
---|
| 112 | self.details['M_phi_solv'] = ['[deg]', None, None] |
---|
| 113 | self.details['Up_frac_i'] = ['[u/(u+d)]', None, None] |
---|
| 114 | self.details['Up_frac_f'] = ['[u/(u+d)]', None, None] |
---|
| 115 | self.details['Up_theta'] = ['[deg]', None, None] |
---|
| 116 | |
---|
| 117 | ## fittable parameters |
---|
| 118 | self.fixed = ['short_a.width', |
---|
| 119 | 'short_b.width', |
---|
| 120 | 'long_c.width', |
---|
| 121 | 'parallel_phi.width', |
---|
| 122 | 'parallel_psi.width', |
---|
| 123 | 'parallel_theta.width'] |
---|
| 124 | |
---|
| 125 | ## non-fittable parameters |
---|
| 126 | self.non_fittable = [] |
---|
| 127 | |
---|
| 128 | ## parameters with orientation |
---|
| 129 | self.orientation_params = ['parallel_phi', |
---|
| 130 | 'parallel_psi', |
---|
| 131 | 'parallel_theta', |
---|
| 132 | 'parallel_phi.width', |
---|
| 133 | 'parallel_psi.width', |
---|
| 134 | 'parallel_theta.width', |
---|
| 135 | 'M0_sld_pipe', |
---|
| 136 | 'M_theta_pipe', |
---|
| 137 | 'M_phi_pipe', |
---|
| 138 | 'M0_sld_solv', |
---|
| 139 | 'M_theta_solv', |
---|
| 140 | 'M_phi_solv', |
---|
| 141 | 'Up_frac_i', |
---|
| 142 | 'Up_frac_f', |
---|
| 143 | 'Up_theta'] |
---|
| 144 | |
---|
| 145 | ## parameters with magnetism |
---|
| 146 | self.magnetic_params = ['M0_sld_pipe', 'M_theta_pipe', 'M_phi_pipe', 'M0_sld_solv', 'M_theta_solv', 'M_phi_solv', 'Up_frac_i', 'Up_frac_f', 'Up_theta'] |
---|
| 147 | |
---|
| 148 | self.category = None |
---|
| 149 | self.multiplicity_info = None |
---|
| 150 | |
---|
| 151 | def __setstate__(self, state): |
---|
| 152 | """ |
---|
| 153 | restore the state of a model from pickle |
---|
| 154 | """ |
---|
| 155 | self.__dict__, self.params, self.dispersion = state |
---|
| 156 | |
---|
| 157 | def __reduce_ex__(self, proto): |
---|
| 158 | """ |
---|
| 159 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 160 | c model. |
---|
| 161 | """ |
---|
| 162 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 163 | return (create_ParallelepipedModel, tuple(), state, None, None) |
---|
| 164 | |
---|
| 165 | def clone(self): |
---|
| 166 | """ Return a identical copy of self """ |
---|
| 167 | return self._clone(ParallelepipedModel()) |
---|
| 168 | |
---|
| 169 | def run(self, x=0.0): |
---|
| 170 | """ |
---|
| 171 | Evaluate the model |
---|
| 172 | |
---|
| 173 | :param x: input q, or [q,phi] |
---|
| 174 | |
---|
| 175 | :return: scattering function P(q) |
---|
| 176 | |
---|
| 177 | """ |
---|
| 178 | return CParallelepipedModel.run(self, x) |
---|
| 179 | |
---|
| 180 | def runXY(self, x=0.0): |
---|
| 181 | """ |
---|
| 182 | Evaluate the model in cartesian coordinates |
---|
| 183 | |
---|
| 184 | :param x: input q, or [qx, qy] |
---|
| 185 | |
---|
| 186 | :return: scattering function P(q) |
---|
| 187 | |
---|
| 188 | """ |
---|
| 189 | return CParallelepipedModel.runXY(self, x) |
---|
| 190 | |
---|
| 191 | def evalDistribution(self, x): |
---|
| 192 | """ |
---|
| 193 | Evaluate the model in cartesian coordinates |
---|
| 194 | |
---|
| 195 | :param x: input q[], or [qx[], qy[]] |
---|
| 196 | |
---|
| 197 | :return: scattering function P(q[]) |
---|
| 198 | |
---|
| 199 | """ |
---|
| 200 | return CParallelepipedModel.evalDistribution(self, x) |
---|
| 201 | |
---|
| 202 | def calculate_ER(self): |
---|
| 203 | """ |
---|
| 204 | Calculate the effective radius for P(q)*S(q) |
---|
| 205 | |
---|
| 206 | :return: the value of the effective radius |
---|
| 207 | |
---|
| 208 | """ |
---|
| 209 | return CParallelepipedModel.calculate_ER(self) |
---|
| 210 | |
---|
| 211 | def calculate_VR(self): |
---|
| 212 | """ |
---|
| 213 | Calculate the volf ratio for P(q)*S(q) |
---|
| 214 | |
---|
| 215 | :return: the value of the volf ratio |
---|
| 216 | |
---|
| 217 | """ |
---|
| 218 | return CParallelepipedModel.calculate_VR(self) |
---|
| 219 | |
---|
| 220 | def set_dispersion(self, parameter, dispersion): |
---|
| 221 | """ |
---|
| 222 | Set the dispersion object for a model parameter |
---|
| 223 | |
---|
| 224 | :param parameter: name of the parameter [string] |
---|
| 225 | :param dispersion: dispersion object of type DispersionModel |
---|
| 226 | |
---|
| 227 | """ |
---|
| 228 | return CParallelepipedModel.set_dispersion(self, |
---|
| 229 | parameter, dispersion.cdisp) |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | # End of file |
---|
| 233 | |
---|