[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\sld_cal.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 CSLDCalFunc |
---|
| 26 | |
---|
| 27 | def create_SLDCalFunc(): |
---|
| 28 | """ |
---|
| 29 | Create a model instance |
---|
| 30 | """ |
---|
| 31 | obj = SLDCalFunc() |
---|
| 32 | # CSLDCalFunc.__init__(obj) is called by |
---|
| 33 | # the SLDCalFunc constructor |
---|
| 34 | return obj |
---|
| 35 | |
---|
| 36 | class SLDCalFunc(CSLDCalFunc, BaseComponent): |
---|
| 37 | """ |
---|
| 38 | Class that evaluates a SLDCalFunc model. |
---|
| 39 | This file was auto-generated from src\sans\models\include\sld_cal.h. |
---|
| 40 | Refer to that file and the structure it contains |
---|
| 41 | for details of the model. |
---|
| 42 | List of default parameters: |
---|
| 43 | fun_type = 0.0 |
---|
| 44 | npts_inter = 21.0 |
---|
| 45 | shell_num = 0.0 |
---|
| 46 | nu_inter = 2.5 |
---|
| 47 | sld_left = 0.0 [1/A^(2)] |
---|
| 48 | sld_right = 0.0 [1/A^(2)] |
---|
| 49 | |
---|
| 50 | """ |
---|
| 51 | |
---|
| 52 | def __init__(self, multfactor=1): |
---|
| 53 | """ Initialization """ |
---|
| 54 | self.__dict__ = {} |
---|
| 55 | |
---|
| 56 | # Initialize BaseComponent first, then sphere |
---|
| 57 | BaseComponent.__init__(self) |
---|
| 58 | #apply(CSLDCalFunc.__init__, (self,)) |
---|
| 59 | |
---|
| 60 | CSLDCalFunc.__init__(self) |
---|
| 61 | self.is_multifunc = False |
---|
| 62 | |
---|
| 63 | ## Name of the model |
---|
| 64 | self.name = "SLDCalFunc" |
---|
| 65 | ## Model description |
---|
| 66 | self.description = """ |
---|
| 67 | To calculate sld values |
---|
| 68 | """ |
---|
| 69 | |
---|
| 70 | ## Parameter details [units, min, max] |
---|
| 71 | self.details = {} |
---|
| 72 | self.details['fun_type'] = ['', None, None] |
---|
| 73 | self.details['npts_inter'] = ['', None, None] |
---|
| 74 | self.details['shell_num'] = ['', None, None] |
---|
| 75 | self.details['nu_inter'] = ['', None, None] |
---|
| 76 | self.details['sld_left'] = ['[1/A^(2)]', None, None] |
---|
| 77 | self.details['sld_right'] = ['[1/A^(2)]', None, None] |
---|
| 78 | |
---|
| 79 | ## fittable parameters |
---|
| 80 | self.fixed = ['</text>'] |
---|
| 81 | |
---|
| 82 | ## non-fittable parameters |
---|
| 83 | self.non_fittable = [] |
---|
| 84 | |
---|
| 85 | ## parameters with orientation |
---|
| 86 | self.orientation_params = [] |
---|
| 87 | |
---|
| 88 | ## parameters with magnetism |
---|
| 89 | self.magnetic_params = [] |
---|
| 90 | |
---|
| 91 | self.category = None |
---|
| 92 | self.multiplicity_info = None |
---|
| 93 | |
---|
| 94 | def __setstate__(self, state): |
---|
| 95 | """ |
---|
| 96 | restore the state of a model from pickle |
---|
| 97 | """ |
---|
| 98 | self.__dict__, self.params, self.dispersion = state |
---|
| 99 | |
---|
| 100 | def __reduce_ex__(self, proto): |
---|
| 101 | """ |
---|
| 102 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 103 | c model. |
---|
| 104 | """ |
---|
| 105 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 106 | return (create_SLDCalFunc, tuple(), state, None, None) |
---|
| 107 | |
---|
| 108 | def clone(self): |
---|
| 109 | """ Return a identical copy of self """ |
---|
| 110 | return self._clone(SLDCalFunc()) |
---|
| 111 | |
---|
| 112 | def run(self, x=0.0): |
---|
| 113 | """ |
---|
| 114 | Evaluate the model |
---|
| 115 | |
---|
| 116 | :param x: input q, or [q,phi] |
---|
| 117 | |
---|
| 118 | :return: scattering function P(q) |
---|
| 119 | |
---|
| 120 | """ |
---|
| 121 | return CSLDCalFunc.run(self, x) |
---|
| 122 | |
---|
| 123 | def runXY(self, x=0.0): |
---|
| 124 | """ |
---|
| 125 | Evaluate the model in cartesian coordinates |
---|
| 126 | |
---|
| 127 | :param x: input q, or [qx, qy] |
---|
| 128 | |
---|
| 129 | :return: scattering function P(q) |
---|
| 130 | |
---|
| 131 | """ |
---|
| 132 | return CSLDCalFunc.runXY(self, x) |
---|
| 133 | |
---|
| 134 | def evalDistribution(self, x): |
---|
| 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 CSLDCalFunc.evalDistribution(self, x) |
---|
| 144 | |
---|
| 145 | def calculate_ER(self): |
---|
| 146 | """ |
---|
| 147 | Calculate the effective radius for P(q)*S(q) |
---|
| 148 | |
---|
| 149 | :return: the value of the effective radius |
---|
| 150 | |
---|
| 151 | """ |
---|
| 152 | return CSLDCalFunc.calculate_ER(self) |
---|
| 153 | |
---|
| 154 | def calculate_VR(self): |
---|
| 155 | """ |
---|
| 156 | Calculate the volf ratio for P(q)*S(q) |
---|
| 157 | |
---|
| 158 | :return: the value of the volf ratio |
---|
| 159 | |
---|
| 160 | """ |
---|
| 161 | return CSLDCalFunc.calculate_VR(self) |
---|
| 162 | |
---|
| 163 | def set_dispersion(self, parameter, dispersion): |
---|
| 164 | """ |
---|
| 165 | Set the dispersion object for a model parameter |
---|
| 166 | |
---|
| 167 | :param parameter: name of the parameter [string] |
---|
| 168 | :param dispersion: dispersion object of type DispersionModel |
---|
| 169 | |
---|
| 170 | """ |
---|
| 171 | return CSLDCalFunc.set_dispersion(self, |
---|
| 172 | parameter, dispersion.cdisp) |
---|
| 173 | |
---|
| 174 | |
---|
| 175 | # End of file |
---|
| 176 | |
---|