[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\flexcyl_ellipX.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 CFlexCylEllipXModel |
---|
| 28 | |
---|
| 29 | def create_FlexCylEllipXModel(): |
---|
| 30 | """ |
---|
| 31 | Create a model instance |
---|
| 32 | """ |
---|
| 33 | obj = FlexCylEllipXModel() |
---|
| 34 | # CFlexCylEllipXModel.__init__(obj) is called by |
---|
| 35 | # the FlexCylEllipXModel constructor |
---|
| 36 | return obj |
---|
| 37 | |
---|
| 38 | class FlexCylEllipXModel(CFlexCylEllipXModel, BaseComponent): |
---|
| 39 | """ |
---|
| 40 | Class that evaluates a FlexCylEllipXModel model. |
---|
| 41 | This file was auto-generated from src\sans\models\include\flexcyl_ellipX.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 | * length = 1000.0 [A] |
---|
| 49 | * kuhn_length = 100.0 [A] |
---|
| 50 | * radius = 20.0 [A] |
---|
| 51 | * axis_ratio = 1.5 |
---|
| 52 | * sldCyl = 1e-06 [1/A^(2)] |
---|
| 53 | * sldSolv = 6.3e-06 [1/A^(2)] |
---|
| 54 | * background = 0.0001 [1/cm] |
---|
| 55 | |
---|
| 56 | """ |
---|
| 57 | |
---|
| 58 | def __init__(self, multfactor=1): |
---|
| 59 | """ Initialization """ |
---|
| 60 | self.__dict__ = {} |
---|
| 61 | |
---|
| 62 | # Initialize BaseComponent first, then sphere |
---|
| 63 | BaseComponent.__init__(self) |
---|
| 64 | #apply(CFlexCylEllipXModel.__init__, (self,)) |
---|
| 65 | |
---|
| 66 | CFlexCylEllipXModel.__init__(self) |
---|
| 67 | self.is_multifunc = False |
---|
| 68 | |
---|
| 69 | ## Name of the model |
---|
| 70 | self.name = "FlexCylEllipXModel" |
---|
| 71 | ## Model description |
---|
| 72 | self.description = """ |
---|
| 73 | Note : scale and contrast=sldCyl-sldSolv are both multiplicative factors in the |
---|
| 74 | model and are perfectly correlated. One or |
---|
| 75 | both of these parameters must be held fixed |
---|
| 76 | during model fitting. |
---|
| 77 | """ |
---|
| 78 | |
---|
| 79 | ## Parameter details [units, min, max] |
---|
| 80 | self.details = {} |
---|
| 81 | self.details['scale'] = ['', None, None] |
---|
| 82 | self.details['length'] = ['[A]', None, None] |
---|
| 83 | self.details['kuhn_length'] = ['[A]', None, None] |
---|
| 84 | self.details['radius'] = ['[A]', None, None] |
---|
| 85 | self.details['axis_ratio'] = ['', None, None] |
---|
| 86 | self.details['sldCyl'] = ['[1/A^(2)]', None, None] |
---|
| 87 | self.details['sldSolv'] = ['[1/A^(2)]', None, None] |
---|
| 88 | self.details['background'] = ['[1/cm]', None, None] |
---|
| 89 | |
---|
| 90 | ## fittable parameters |
---|
| 91 | self.fixed = ['length.width', |
---|
| 92 | 'kuhn_length.width', |
---|
| 93 | 'radius.width', |
---|
| 94 | 'axis_ratio.width'] |
---|
| 95 | |
---|
| 96 | ## non-fittable parameters |
---|
| 97 | self.non_fittable = [] |
---|
| 98 | |
---|
| 99 | ## parameters with orientation |
---|
| 100 | self.orientation_params = [] |
---|
| 101 | |
---|
| 102 | ## parameters with magnetism |
---|
| 103 | self.magnetic_params = [] |
---|
| 104 | |
---|
| 105 | self.category = None |
---|
| 106 | self.multiplicity_info = None |
---|
| 107 | |
---|
| 108 | def __setstate__(self, state): |
---|
| 109 | """ |
---|
| 110 | restore the state of a model from pickle |
---|
| 111 | """ |
---|
| 112 | self.__dict__, self.params, self.dispersion = state |
---|
| 113 | |
---|
| 114 | def __reduce_ex__(self, proto): |
---|
| 115 | """ |
---|
| 116 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 117 | c model. |
---|
| 118 | """ |
---|
| 119 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 120 | return (create_FlexCylEllipXModel, tuple(), state, None, None) |
---|
| 121 | |
---|
| 122 | def clone(self): |
---|
| 123 | """ Return a identical copy of self """ |
---|
| 124 | return self._clone(FlexCylEllipXModel()) |
---|
| 125 | |
---|
| 126 | def run(self, x=0.0): |
---|
| 127 | """ |
---|
| 128 | Evaluate the model |
---|
| 129 | |
---|
| 130 | :param x: input q, or [q,phi] |
---|
| 131 | |
---|
| 132 | :return: scattering function P(q) |
---|
| 133 | |
---|
| 134 | """ |
---|
| 135 | return CFlexCylEllipXModel.run(self, x) |
---|
| 136 | |
---|
| 137 | def runXY(self, x=0.0): |
---|
| 138 | """ |
---|
| 139 | Evaluate the model in cartesian coordinates |
---|
| 140 | |
---|
| 141 | :param x: input q, or [qx, qy] |
---|
| 142 | |
---|
| 143 | :return: scattering function P(q) |
---|
| 144 | |
---|
| 145 | """ |
---|
| 146 | return CFlexCylEllipXModel.runXY(self, x) |
---|
| 147 | |
---|
| 148 | def evalDistribution(self, x): |
---|
| 149 | """ |
---|
| 150 | Evaluate the model in cartesian coordinates |
---|
| 151 | |
---|
| 152 | :param x: input q[], or [qx[], qy[]] |
---|
| 153 | |
---|
| 154 | :return: scattering function P(q[]) |
---|
| 155 | |
---|
| 156 | """ |
---|
| 157 | return CFlexCylEllipXModel.evalDistribution(self, x) |
---|
| 158 | |
---|
| 159 | def calculate_ER(self): |
---|
| 160 | """ |
---|
| 161 | Calculate the effective radius for P(q)*S(q) |
---|
| 162 | |
---|
| 163 | :return: the value of the effective radius |
---|
| 164 | |
---|
| 165 | """ |
---|
| 166 | return CFlexCylEllipXModel.calculate_ER(self) |
---|
| 167 | |
---|
| 168 | def calculate_VR(self): |
---|
| 169 | """ |
---|
| 170 | Calculate the volf ratio for P(q)*S(q) |
---|
| 171 | |
---|
| 172 | :return: the value of the volf ratio |
---|
| 173 | |
---|
| 174 | """ |
---|
| 175 | return CFlexCylEllipXModel.calculate_VR(self) |
---|
| 176 | |
---|
| 177 | def set_dispersion(self, parameter, dispersion): |
---|
| 178 | """ |
---|
| 179 | Set the dispersion object for a model parameter |
---|
| 180 | |
---|
| 181 | :param parameter: name of the parameter [string] |
---|
| 182 | :param dispersion: dispersion object of type DispersionModel |
---|
| 183 | |
---|
| 184 | """ |
---|
| 185 | return CFlexCylEllipXModel.set_dispersion(self, |
---|
| 186 | parameter, dispersion.cdisp) |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | # End of file |
---|
| 190 | |
---|