[339ce67] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | ############################################################################## |
---|
| 4 | # This software was developed by the University of Tennessee as part of the |
---|
| 5 | # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 6 | # project funded by the US National Science Foundation. |
---|
| 7 | # |
---|
| 8 | # If you use DANSE applications to do scientific research that leads to |
---|
| 9 | # publication, we ask that you acknowledge the use of the software with the |
---|
| 10 | # following sentence: |
---|
| 11 | # |
---|
| 12 | # "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
| 13 | # |
---|
| 14 | # copyright 2008, University of Tennessee |
---|
| 15 | ############################################################################## |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | """ |
---|
| 19 | Provide functionality for a C extension model |
---|
| 20 | |
---|
| 21 | :WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
| 22 | DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\capcyl.h |
---|
| 23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
| 24 | |
---|
| 25 | """ |
---|
| 26 | |
---|
| 27 | from sans.models.BaseComponent import BaseComponent |
---|
[92df66f8] | 28 | from sans.models.sans_extension.c_models import CCappedCylinderModel |
---|
[339ce67] | 29 | import copy |
---|
[96656e3] | 30 | |
---|
| 31 | def create_CappedCylinderModel(): |
---|
| 32 | obj = CappedCylinderModel() |
---|
| 33 | #CCappedCylinderModel.__init__(obj) is called by CappedCylinderModel constructor |
---|
| 34 | return obj |
---|
| 35 | |
---|
[339ce67] | 36 | class CappedCylinderModel(CCappedCylinderModel, BaseComponent): |
---|
| 37 | """ |
---|
| 38 | Class that evaluates a CappedCylinderModel model. |
---|
| 39 | This file was auto-generated from ..\c_extensions\capcyl.h. |
---|
| 40 | Refer to that file and the structure it contains |
---|
| 41 | for details of the model. |
---|
| 42 | List of default parameters: |
---|
| 43 | scale = 1.0 |
---|
| 44 | rad_cyl = 20.0 [A] |
---|
| 45 | len_cyl = 400.0 [A] |
---|
| 46 | rad_cap = 40.0 [A] |
---|
[92df66f8] | 47 | sld_capcyl = 1e-06 [1/A^(2)] |
---|
| 48 | sld_solv = 6.3e-06 [1/A^(2)] |
---|
[339ce67] | 49 | background = 0.0 [1/cm] |
---|
[4628e31] | 50 | theta = 0.0 [deg] |
---|
| 51 | phi = 0.0 [deg] |
---|
[339ce67] | 52 | |
---|
| 53 | """ |
---|
| 54 | |
---|
| 55 | def __init__(self): |
---|
| 56 | """ Initialization """ |
---|
| 57 | |
---|
| 58 | # Initialize BaseComponent first, then sphere |
---|
| 59 | BaseComponent.__init__(self) |
---|
[96656e3] | 60 | #apply(CCappedCylinderModel.__init__, (self,)) |
---|
[339ce67] | 61 | CCappedCylinderModel.__init__(self) |
---|
| 62 | |
---|
| 63 | ## Name of the model |
---|
| 64 | self.name = "CappedCylinderModel" |
---|
| 65 | ## Model description |
---|
[18f2ca1] | 66 | self.description ="""Calculates the scattering from a cylinder with spherical section end-caps. |
---|
| 67 | That is, a sphereocylinder |
---|
[339ce67] | 68 | with end caps that have a radius larger than |
---|
| 69 | that of the cylinder and the center of the |
---|
| 70 | end cap radius lies within the cylinder. |
---|
| 71 | Note: As the length of cylinder -->0, |
---|
| 72 | it becomes a ConvexLens. |
---|
| 73 | It must be that rad_cyl <(=) rad_cap. |
---|
| 74 | [Parameters]; |
---|
| 75 | scale: volume fraction of spheres, |
---|
| 76 | background:incoherent background, |
---|
| 77 | rad_cyl: radius of the cylinder, |
---|
| 78 | len_cyl: length of the cylinder, |
---|
| 79 | rad_cap: radius of the semi-spherical cap, |
---|
| 80 | sld_capcyl: SLD of the capped cylinder, |
---|
| 81 | sld_solv: SLD of the solvent.""" |
---|
| 82 | |
---|
| 83 | ## Parameter details [units, min, max] |
---|
| 84 | self.details = {} |
---|
| 85 | self.details['scale'] = ['', None, None] |
---|
| 86 | self.details['rad_cyl'] = ['[A]', None, None] |
---|
| 87 | self.details['len_cyl'] = ['[A]', None, None] |
---|
| 88 | self.details['rad_cap'] = ['[A]', None, None] |
---|
| 89 | self.details['sld_capcyl'] = ['[1/A^(2)]', None, None] |
---|
| 90 | self.details['sld_solv'] = ['[1/A^(2)]', None, None] |
---|
| 91 | self.details['background'] = ['[1/cm]', None, None] |
---|
[4628e31] | 92 | self.details['theta'] = ['[deg]', None, None] |
---|
| 93 | self.details['phi'] = ['[deg]', None, None] |
---|
[339ce67] | 94 | |
---|
| 95 | ## fittable parameters |
---|
| 96 | self.fixed=['rad_cyl.width', 'len_cyl', 'rad_cap', 'phi.width', 'theta.width'] |
---|
| 97 | |
---|
| 98 | ## non-fittable parameters |
---|
[96656e3] | 99 | self.non_fittable = [] |
---|
[339ce67] | 100 | |
---|
| 101 | ## parameters with orientation |
---|
[96656e3] | 102 | self.orientation_params = ['phi', 'theta', 'phi.width', 'theta.width'] |
---|
[c7a7e1b] | 103 | |
---|
| 104 | def __setstate__(self, state): |
---|
| 105 | """ |
---|
| 106 | restore the state of a model from pickle |
---|
| 107 | """ |
---|
| 108 | self.__dict__, self.params, self.dispersion = state |
---|
| 109 | |
---|
[96656e3] | 110 | def __reduce_ex__(self, proto): |
---|
[339ce67] | 111 | """ |
---|
[96656e3] | 112 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
| 113 | c model. |
---|
[339ce67] | 114 | """ |
---|
[c7a7e1b] | 115 | state = (self.__dict__, self.params, self.dispersion) |
---|
| 116 | return (create_CappedCylinderModel,tuple(), state, None, None) |
---|
[339ce67] | 117 | |
---|
[96656e3] | 118 | def clone(self): |
---|
| 119 | """ Return a identical copy of self """ |
---|
| 120 | return self._clone(CappedCylinderModel()) |
---|
[339ce67] | 121 | |
---|
| 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 | |
---|
| 133 | return CCappedCylinderModel.run(self, x) |
---|
| 134 | |
---|
| 135 | def runXY(self, x=0.0): |
---|
| 136 | """ |
---|
| 137 | Evaluate the model in cartesian coordinates |
---|
| 138 | |
---|
| 139 | :param x: input q, or [qx, qy] |
---|
| 140 | |
---|
| 141 | :return: scattering function P(q) |
---|
| 142 | |
---|
| 143 | """ |
---|
| 144 | |
---|
| 145 | return CCappedCylinderModel.runXY(self, x) |
---|
| 146 | |
---|
| 147 | def evalDistribution(self, x=[]): |
---|
| 148 | """ |
---|
| 149 | Evaluate the model in cartesian coordinates |
---|
| 150 | |
---|
| 151 | :param x: input q[], or [qx[], qy[]] |
---|
| 152 | |
---|
| 153 | :return: scattering function P(q[]) |
---|
| 154 | |
---|
| 155 | """ |
---|
| 156 | return CCappedCylinderModel.evalDistribution(self, x) |
---|
| 157 | |
---|
| 158 | def calculate_ER(self): |
---|
| 159 | """ |
---|
| 160 | Calculate the effective radius for P(q)*S(q) |
---|
| 161 | |
---|
| 162 | :return: the value of the effective radius |
---|
| 163 | |
---|
| 164 | """ |
---|
| 165 | return CCappedCylinderModel.calculate_ER(self) |
---|
| 166 | |
---|
| 167 | def set_dispersion(self, parameter, dispersion): |
---|
| 168 | """ |
---|
| 169 | Set the dispersion object for a model parameter |
---|
| 170 | |
---|
| 171 | :param parameter: name of the parameter [string] |
---|
| 172 | :param dispersion: dispersion object of type DispersionModel |
---|
| 173 | |
---|
| 174 | """ |
---|
| 175 | return CCappedCylinderModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | # End of file |
---|