[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\polygausscoil.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 CPoly_GaussCoil |
---|
| 28 | |
---|
| 29 | def create_Poly_GaussCoil(): |
---|
| 30 | """ |
---|
| 31 | Create a model instance |
---|
| 32 | """ |
---|
| 33 | obj = Poly_GaussCoil() |
---|
| 34 | # CPoly_GaussCoil.__init__(obj) is called by |
---|
| 35 | # the Poly_GaussCoil constructor |
---|
| 36 | return obj |
---|
| 37 | |
---|
| 38 | class Poly_GaussCoil(CPoly_GaussCoil, BaseComponent): |
---|
| 39 | """ |
---|
| 40 | Class that evaluates a Poly_GaussCoil model. |
---|
| 41 | This file was auto-generated from src\sans\models\include\polygausscoil.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 | * rg = 60.0 [A] |
---|
| 48 | * scale = 1.0 |
---|
| 49 | * poly_m = 2.0 [Mw/Mn] |
---|
| 50 | * background = 0.001 [1/cm] |
---|
| 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(CPoly_GaussCoil.__init__, (self,)) |
---|
| 61 | |
---|
| 62 | CPoly_GaussCoil.__init__(self) |
---|
| 63 | self.is_multifunc = False |
---|
| 64 | |
---|
| 65 | ## Name of the model |
---|
| 66 | self.name = "Poly_GaussCoil" |
---|
| 67 | ## Model description |
---|
| 68 | self.description = """ |
---|
| 69 | I(q)=(scale)*2*[(1+U*x)^(-1/U)+x-1]/[(1+U)*x^2] + background |
---|
| 70 | where x = [rg^2*q^2] |
---|
| 71 | and the polydispersity is |
---|
| 72 | U = [M_w/M_n]-1. |
---|
| 73 | scale = scale factor * volume fraction |
---|
| 74 | rg = radius of gyration |
---|
| 75 | poly_m = polydispersity of molecular weight |
---|
| 76 | background = incoherent background |
---|
| 77 | """ |
---|
| 78 | |
---|
| 79 | ## Parameter details [units, min, max] |
---|
| 80 | self.details = {} |
---|
| 81 | self.details['rg'] = ['[A]', None, None] |
---|
| 82 | self.details['scale'] = ['', None, None] |
---|
| 83 | self.details['poly_m'] = ['[Mw/Mn]', None, None] |
---|
| 84 | self.details['background'] = ['[1/cm]', None, None] |
---|
| 85 | |
---|
| 86 | ## fittable parameters |
---|
| 87 | self.fixed = [] |
---|
| 88 | |
---|
| 89 | ## non-fittable parameters |
---|
| 90 | self.non_fittable = [] |
---|
| 91 | |
---|
| 92 | ## parameters with orientation |
---|
| 93 | self.orientation_params = [] |
---|
| 94 | |
---|
| 95 | ## parameters with magnetism |
---|
| 96 | self.magnetic_params = [] |
---|
| 97 | |
---|
| 98 | self.category = None |
---|
| 99 | self.multiplicity_info = None |
---|
| 100 | |
---|
| 101 | def __setstate__(self, state): |
---|
| 102 | """ |
---|
| 103 | restore the state of a model from pickle |
---|
| 104 | """ |
---|
| 105 | self.__dict__, self.params, self.dispersion = state |
---|
| 106 | |
---|
| 107 | def __reduce_ex__(self, proto): |
---|
| 108 | """ |
---|
| 109 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 110 | c model. |
---|
| 111 | """ |
---|
| 112 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 113 | return (create_Poly_GaussCoil, tuple(), state, None, None) |
---|
| 114 | |
---|
| 115 | def clone(self): |
---|
| 116 | """ Return a identical copy of self """ |
---|
| 117 | return self._clone(Poly_GaussCoil()) |
---|
| 118 | |
---|
| 119 | def run(self, x=0.0): |
---|
| 120 | """ |
---|
| 121 | Evaluate the model |
---|
| 122 | |
---|
| 123 | :param x: input q, or [q,phi] |
---|
| 124 | |
---|
| 125 | :return: scattering function P(q) |
---|
| 126 | |
---|
| 127 | """ |
---|
| 128 | return CPoly_GaussCoil.run(self, x) |
---|
| 129 | |
---|
| 130 | def runXY(self, x=0.0): |
---|
| 131 | """ |
---|
| 132 | Evaluate the model in cartesian coordinates |
---|
| 133 | |
---|
| 134 | :param x: input q, or [qx, qy] |
---|
| 135 | |
---|
| 136 | :return: scattering function P(q) |
---|
| 137 | |
---|
| 138 | """ |
---|
| 139 | return CPoly_GaussCoil.runXY(self, x) |
---|
| 140 | |
---|
| 141 | def evalDistribution(self, x): |
---|
| 142 | """ |
---|
| 143 | Evaluate the model in cartesian coordinates |
---|
| 144 | |
---|
| 145 | :param x: input q[], or [qx[], qy[]] |
---|
| 146 | |
---|
| 147 | :return: scattering function P(q[]) |
---|
| 148 | |
---|
| 149 | """ |
---|
| 150 | return CPoly_GaussCoil.evalDistribution(self, x) |
---|
| 151 | |
---|
| 152 | def calculate_ER(self): |
---|
| 153 | """ |
---|
| 154 | Calculate the effective radius for P(q)*S(q) |
---|
| 155 | |
---|
| 156 | :return: the value of the effective radius |
---|
| 157 | |
---|
| 158 | """ |
---|
| 159 | return CPoly_GaussCoil.calculate_ER(self) |
---|
| 160 | |
---|
| 161 | def calculate_VR(self): |
---|
| 162 | """ |
---|
| 163 | Calculate the volf ratio for P(q)*S(q) |
---|
| 164 | |
---|
| 165 | :return: the value of the volf ratio |
---|
| 166 | |
---|
| 167 | """ |
---|
| 168 | return CPoly_GaussCoil.calculate_VR(self) |
---|
| 169 | |
---|
| 170 | def set_dispersion(self, parameter, dispersion): |
---|
| 171 | """ |
---|
| 172 | Set the dispersion object for a model parameter |
---|
| 173 | |
---|
| 174 | :param parameter: name of the parameter [string] |
---|
| 175 | :param dispersion: dispersion object of type DispersionModel |
---|
| 176 | |
---|
| 177 | """ |
---|
| 178 | return CPoly_GaussCoil.set_dispersion(self, |
---|
| 179 | parameter, dispersion.cdisp) |
---|
| 180 | |
---|
| 181 | |
---|
| 182 | # End of file |
---|
| 183 | |
---|