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