[81b524f] | 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: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
| 19 | DO NOT MODIFY THIS FILE, MODIFY |
---|
| 20 | src\sans\models\include\StickyHS.h |
---|
| 21 | AND RE-RUN THE GENERATOR SCRIPT |
---|
| 22 | """ |
---|
| 23 | |
---|
| 24 | from sans.models.BaseComponent import BaseComponent |
---|
| 25 | from sans.models.sans_extension.c_models import CStickyHSStructure |
---|
| 26 | |
---|
| 27 | def create_StickyHSStructure(): |
---|
| 28 | """ |
---|
| 29 | Create a model instance |
---|
| 30 | """ |
---|
| 31 | obj = StickyHSStructure() |
---|
| 32 | # CStickyHSStructure.__init__(obj) is called by |
---|
| 33 | # the StickyHSStructure constructor |
---|
| 34 | return obj |
---|
| 35 | |
---|
| 36 | class StickyHSStructure(CStickyHSStructure, BaseComponent): |
---|
| 37 | """ |
---|
| 38 | Class that evaluates a StickyHSStructure model. |
---|
| 39 | This file was auto-generated from src\sans\models\include\StickyHS.h. |
---|
| 40 | Refer to that file and the structure it contains |
---|
| 41 | for details of the model. |
---|
| 42 | List of default parameters: |
---|
| 43 | effect_radius = 50.0 [A] |
---|
| 44 | volfraction = 0.1 |
---|
| 45 | perturb = 0.05 |
---|
| 46 | stickiness = 0.2 |
---|
| 47 | |
---|
| 48 | """ |
---|
| 49 | |
---|
| 50 | def __init__(self, multfactor=1): |
---|
| 51 | """ Initialization """ |
---|
| 52 | self.__dict__ = {} |
---|
| 53 | |
---|
| 54 | # Initialize BaseComponent first, then sphere |
---|
| 55 | BaseComponent.__init__(self) |
---|
| 56 | #apply(CStickyHSStructure.__init__, (self,)) |
---|
| 57 | |
---|
| 58 | CStickyHSStructure.__init__(self) |
---|
| 59 | self.is_multifunc = False |
---|
| 60 | |
---|
| 61 | ## Name of the model |
---|
| 62 | self.name = "StickyHSStructure" |
---|
| 63 | ## Model description |
---|
| 64 | self.description = """ |
---|
| 65 | Structure Factor for interacting particles: . |
---|
| 66 | |
---|
| 67 | The interaction potential is |
---|
| 68 | |
---|
| 69 | U(r)= inf , r < 2R |
---|
| 70 | = -Uo , 2R < r < 2R + w |
---|
| 71 | = 0 , r >= 2R +w |
---|
| 72 | |
---|
| 73 | R: effective radius of the hardsphere |
---|
| 74 | stickiness = [exp(Uo/kT)]/(12*perturb) |
---|
| 75 | perturb = w/(w+ 2R) , 0.01 =< w <= 0.1 |
---|
| 76 | w: The width of the square well ,w > 0 |
---|
| 77 | v: The volume fraction , v > 0 |
---|
| 78 | |
---|
| 79 | Ref: Menon, S. V. G.,et.al., J. Chem. |
---|
| 80 | Phys., 1991, 95(12), 9186-9190. |
---|
| 81 | """ |
---|
| 82 | |
---|
| 83 | ## Parameter details [units, min, max] |
---|
| 84 | self.details = {} |
---|
| 85 | self.details['effect_radius'] = ['[A]', None, None] |
---|
| 86 | self.details['volfraction'] = ['', None, None] |
---|
| 87 | self.details['perturb'] = ['', None, None] |
---|
| 88 | self.details['stickiness'] = ['', None, None] |
---|
| 89 | |
---|
| 90 | ## fittable parameters |
---|
| 91 | self.fixed = ['effect_radius.width'] |
---|
| 92 | |
---|
| 93 | ## non-fittable parameters |
---|
| 94 | self.non_fittable = [] |
---|
| 95 | |
---|
| 96 | ## parameters with orientation |
---|
| 97 | self.orientation_params = [] |
---|
| 98 | |
---|
| 99 | ## parameters with magnetism |
---|
| 100 | self.magnetic_params = [] |
---|
| 101 | |
---|
| 102 | self.category = None |
---|
| 103 | self.multiplicity_info = None |
---|
| 104 | |
---|
| 105 | def __setstate__(self, state): |
---|
| 106 | """ |
---|
| 107 | restore the state of a model from pickle |
---|
| 108 | """ |
---|
| 109 | self.__dict__, self.params, self.dispersion = state |
---|
| 110 | |
---|
| 111 | def __reduce_ex__(self, proto): |
---|
| 112 | """ |
---|
| 113 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 114 | c model. |
---|
| 115 | """ |
---|
| 116 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 117 | return (create_StickyHSStructure, tuple(), state, None, None) |
---|
| 118 | |
---|
| 119 | def clone(self): |
---|
| 120 | """ Return a identical copy of self """ |
---|
| 121 | return self._clone(StickyHSStructure()) |
---|
| 122 | |
---|
| 123 | def run(self, x=0.0): |
---|
| 124 | """ |
---|
| 125 | Evaluate the model |
---|
| 126 | |
---|
| 127 | :param x: input q, or [q,phi] |
---|
| 128 | |
---|
| 129 | :return: scattering function P(q) |
---|
| 130 | |
---|
| 131 | """ |
---|
| 132 | return CStickyHSStructure.run(self, x) |
---|
| 133 | |
---|
| 134 | def runXY(self, x=0.0): |
---|
| 135 | """ |
---|
| 136 | Evaluate the model in cartesian coordinates |
---|
| 137 | |
---|
| 138 | :param x: input q, or [qx, qy] |
---|
| 139 | |
---|
| 140 | :return: scattering function P(q) |
---|
| 141 | |
---|
| 142 | """ |
---|
| 143 | return CStickyHSStructure.runXY(self, x) |
---|
| 144 | |
---|
| 145 | def evalDistribution(self, x): |
---|
| 146 | """ |
---|
| 147 | Evaluate the model in cartesian coordinates |
---|
| 148 | |
---|
| 149 | :param x: input q[], or [qx[], qy[]] |
---|
| 150 | |
---|
| 151 | :return: scattering function P(q[]) |
---|
| 152 | |
---|
| 153 | """ |
---|
| 154 | return CStickyHSStructure.evalDistribution(self, x) |
---|
| 155 | |
---|
| 156 | def calculate_ER(self): |
---|
| 157 | """ |
---|
| 158 | Calculate the effective radius for P(q)*S(q) |
---|
| 159 | |
---|
| 160 | :return: the value of the effective radius |
---|
| 161 | |
---|
| 162 | """ |
---|
| 163 | return CStickyHSStructure.calculate_ER(self) |
---|
| 164 | |
---|
| 165 | def calculate_VR(self): |
---|
| 166 | """ |
---|
| 167 | Calculate the volf ratio for P(q)*S(q) |
---|
| 168 | |
---|
| 169 | :return: the value of the volf ratio |
---|
| 170 | |
---|
| 171 | """ |
---|
| 172 | return CStickyHSStructure.calculate_VR(self) |
---|
| 173 | |
---|
| 174 | def set_dispersion(self, parameter, dispersion): |
---|
| 175 | """ |
---|
| 176 | Set the dispersion object for a model parameter |
---|
| 177 | |
---|
| 178 | :param parameter: name of the parameter [string] |
---|
| 179 | :param dispersion: dispersion object of type DispersionModel |
---|
| 180 | |
---|
| 181 | """ |
---|
| 182 | return CStickyHSStructure.set_dispersion(self, |
---|
| 183 | parameter, dispersion.cdisp) |
---|
| 184 | |
---|
| 185 | |
---|
| 186 | # End of file |
---|
| 187 | |
---|