[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\SquareWell.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 CSquareWellStructure |
---|
| 28 | |
---|
| 29 | def create_SquareWellStructure(): |
---|
| 30 | """ |
---|
| 31 | Create a model instance |
---|
| 32 | """ |
---|
| 33 | obj = SquareWellStructure() |
---|
| 34 | # CSquareWellStructure.__init__(obj) is called by |
---|
| 35 | # the SquareWellStructure constructor |
---|
| 36 | return obj |
---|
| 37 | |
---|
| 38 | class SquareWellStructure(CSquareWellStructure, BaseComponent): |
---|
| 39 | """ |
---|
| 40 | Class that evaluates a SquareWellStructure model. |
---|
| 41 | This file was auto-generated from src\sans\models\include\SquareWell.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 | * effect_radius = 50.0 [A] |
---|
| 48 | * volfraction = 0.04 |
---|
| 49 | * welldepth = 1.5 [kT] |
---|
| 50 | * wellwidth = 1.2 |
---|
| 51 | |
---|
| 52 | """ |
---|
| 53 | |
---|
| 54 | def __init__(self, multfactor=1): |
---|
| 55 | """ Initialization """ |
---|
| 56 | self.__dict__ = {} |
---|
| 57 | |
---|
| 58 | # Initialize BaseComponent first, then sphere |
---|
| 59 | BaseComponent.__init__(self) |
---|
| 60 | #apply(CSquareWellStructure.__init__, (self,)) |
---|
| 61 | |
---|
| 62 | CSquareWellStructure.__init__(self) |
---|
| 63 | self.is_multifunc = False |
---|
| 64 | |
---|
| 65 | ## Name of the model |
---|
| 66 | self.name = "SquareWellStructure" |
---|
| 67 | ## Model description |
---|
| 68 | self.description = """ |
---|
| 69 | Structure Factor for interacting particles: . |
---|
| 70 | |
---|
| 71 | The interaction potential is |
---|
| 72 | |
---|
| 73 | U(r)= inf , r < 2R |
---|
| 74 | = -d , 2R <= r <=2Rw |
---|
| 75 | = 0 , r >= 2Rw |
---|
| 76 | |
---|
| 77 | R: effective radius (A)of the particle |
---|
| 78 | v: volume fraction |
---|
| 79 | d: well depth |
---|
| 80 | w: well width; multiples of the |
---|
| 81 | particle diameter |
---|
| 82 | |
---|
| 83 | Ref: Sharma, R. V.; Sharma, |
---|
| 84 | K. C., Physica, 1977, 89A, 213. |
---|
| 85 | """ |
---|
| 86 | |
---|
| 87 | ## Parameter details [units, min, max] |
---|
| 88 | self.details = {} |
---|
| 89 | self.details['effect_radius'] = ['[A]', None, None] |
---|
| 90 | self.details['volfraction'] = ['', None, None] |
---|
| 91 | self.details['welldepth'] = ['[kT]', None, None] |
---|
| 92 | self.details['wellwidth'] = ['', None, None] |
---|
| 93 | |
---|
| 94 | ## fittable parameters |
---|
| 95 | self.fixed = ['effect_radius.width'] |
---|
| 96 | |
---|
| 97 | ## non-fittable parameters |
---|
| 98 | self.non_fittable = [] |
---|
| 99 | |
---|
| 100 | ## parameters with orientation |
---|
| 101 | self.orientation_params = [] |
---|
| 102 | |
---|
| 103 | ## parameters with magnetism |
---|
| 104 | self.magnetic_params = [] |
---|
| 105 | |
---|
| 106 | self.category = None |
---|
| 107 | self.multiplicity_info = None |
---|
| 108 | |
---|
| 109 | def __setstate__(self, state): |
---|
| 110 | """ |
---|
| 111 | restore the state of a model from pickle |
---|
| 112 | """ |
---|
| 113 | self.__dict__, self.params, self.dispersion = state |
---|
| 114 | |
---|
| 115 | def __reduce_ex__(self, proto): |
---|
| 116 | """ |
---|
| 117 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 118 | c model. |
---|
| 119 | """ |
---|
| 120 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 121 | return (create_SquareWellStructure, tuple(), state, None, None) |
---|
| 122 | |
---|
| 123 | def clone(self): |
---|
| 124 | """ Return a identical copy of self """ |
---|
| 125 | return self._clone(SquareWellStructure()) |
---|
| 126 | |
---|
| 127 | def run(self, x=0.0): |
---|
| 128 | """ |
---|
| 129 | Evaluate the model |
---|
| 130 | |
---|
| 131 | :param x: input q, or [q,phi] |
---|
| 132 | |
---|
| 133 | :return: scattering function P(q) |
---|
| 134 | |
---|
| 135 | """ |
---|
| 136 | return CSquareWellStructure.run(self, x) |
---|
| 137 | |
---|
| 138 | def runXY(self, x=0.0): |
---|
| 139 | """ |
---|
| 140 | Evaluate the model in cartesian coordinates |
---|
| 141 | |
---|
| 142 | :param x: input q, or [qx, qy] |
---|
| 143 | |
---|
| 144 | :return: scattering function P(q) |
---|
| 145 | |
---|
| 146 | """ |
---|
| 147 | return CSquareWellStructure.runXY(self, x) |
---|
| 148 | |
---|
| 149 | def evalDistribution(self, x): |
---|
| 150 | """ |
---|
| 151 | Evaluate the model in cartesian coordinates |
---|
| 152 | |
---|
| 153 | :param x: input q[], or [qx[], qy[]] |
---|
| 154 | |
---|
| 155 | :return: scattering function P(q[]) |
---|
| 156 | |
---|
| 157 | """ |
---|
| 158 | return CSquareWellStructure.evalDistribution(self, x) |
---|
| 159 | |
---|
| 160 | def calculate_ER(self): |
---|
| 161 | """ |
---|
| 162 | Calculate the effective radius for P(q)*S(q) |
---|
| 163 | |
---|
| 164 | :return: the value of the effective radius |
---|
| 165 | |
---|
| 166 | """ |
---|
| 167 | return CSquareWellStructure.calculate_ER(self) |
---|
| 168 | |
---|
| 169 | def calculate_VR(self): |
---|
| 170 | """ |
---|
| 171 | Calculate the volf ratio for P(q)*S(q) |
---|
| 172 | |
---|
| 173 | :return: the value of the volf ratio |
---|
| 174 | |
---|
| 175 | """ |
---|
| 176 | return CSquareWellStructure.calculate_VR(self) |
---|
| 177 | |
---|
| 178 | def set_dispersion(self, parameter, dispersion): |
---|
| 179 | """ |
---|
| 180 | Set the dispersion object for a model parameter |
---|
| 181 | |
---|
| 182 | :param parameter: name of the parameter [string] |
---|
| 183 | :param dispersion: dispersion object of type DispersionModel |
---|
| 184 | |
---|
| 185 | """ |
---|
| 186 | return CSquareWellStructure.set_dispersion(self, |
---|
| 187 | parameter, dispersion.cdisp) |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | # End of file |
---|
| 191 | |
---|