[d5b6a9d] | 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\lamellarPC.h |
---|
| 23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
| 24 | |
---|
| 25 | """ |
---|
| 26 | |
---|
| 27 | from sans.models.BaseComponent import BaseComponent |
---|
| 28 | from sans_extension.c_models import CLamellarPCrystalModel |
---|
| 29 | import copy |
---|
| 30 | |
---|
| 31 | class LamellarPCrystalModel(CLamellarPCrystalModel, BaseComponent): |
---|
| 32 | """ |
---|
| 33 | Class that evaluates a LamellarPCrystalModel model. |
---|
| 34 | This file was auto-generated from ..\c_extensions\lamellarPC.h. |
---|
| 35 | Refer to that file and the structure it contains |
---|
| 36 | for details of the model. |
---|
| 37 | List of default parameters: |
---|
| 38 | scale = 1.0 |
---|
| 39 | thickness = 33.0 [A] |
---|
| 40 | Nlayers = 20.0 |
---|
| 41 | spacing = 250.0 [A] |
---|
| 42 | pd_spacing = 0.0 |
---|
| 43 | sld_layer = 1e-006 [1/A^(2)] |
---|
| 44 | sld_solvent = 6.34e-006 [1/A^(2)] |
---|
| 45 | background = 0.0 [1/cm] |
---|
| 46 | |
---|
| 47 | """ |
---|
| 48 | |
---|
| 49 | def __init__(self): |
---|
| 50 | """ Initialization """ |
---|
| 51 | |
---|
| 52 | # Initialize BaseComponent first, then sphere |
---|
| 53 | BaseComponent.__init__(self) |
---|
| 54 | CLamellarPCrystalModel.__init__(self) |
---|
| 55 | |
---|
| 56 | ## Name of the model |
---|
| 57 | self.name = "LamellarPCrystalModel" |
---|
| 58 | ## Model description |
---|
| 59 | self.description ="""[Lamellar ParaCrystal Model] Parameter Definitions: scale = scale factor, |
---|
| 60 | background = incoherent background |
---|
| 61 | thickness = lamellar thickness, |
---|
| 62 | sld_layer = layer scattering length density , |
---|
| 63 | sld_solvent = solvent scattering length density. |
---|
| 64 | Nlayers = no. of lamellar layers |
---|
| 65 | spacing = spacing between layers |
---|
| 66 | pd_spacing = polydispersity of spacing |
---|
| 67 | Note: This model can be used for large |
---|
| 68 | multilamellar vesicles. |
---|
| 69 | """ |
---|
| 70 | |
---|
| 71 | ## Parameter details [units, min, max] |
---|
| 72 | self.details = {} |
---|
| 73 | self.details['scale'] = ['', None, None] |
---|
| 74 | self.details['thickness'] = ['[A]', None, None] |
---|
| 75 | self.details['Nlayers'] = ['', None, None] |
---|
| 76 | self.details['spacing'] = ['[A]', None, None] |
---|
| 77 | self.details['pd_spacing'] = ['', None, None] |
---|
| 78 | self.details['sld_layer'] = ['[1/A^(2)]', None, None] |
---|
| 79 | self.details['sld_solvent'] = ['[1/A^(2)]', None, None] |
---|
| 80 | self.details['background'] = ['[1/cm]', None, None] |
---|
| 81 | |
---|
| 82 | ## fittable parameters |
---|
| 83 | self.fixed=['thickness.width'] |
---|
| 84 | |
---|
| 85 | ## non-fittable parameters |
---|
| 86 | self.non_fittable=[] |
---|
| 87 | |
---|
| 88 | ## parameters with orientation |
---|
| 89 | self.orientation_params =[] |
---|
| 90 | |
---|
| 91 | def clone(self): |
---|
| 92 | """ Return a identical copy of self """ |
---|
| 93 | return self._clone(LamellarPCrystalModel()) |
---|
| 94 | |
---|
| 95 | def __getstate__(self): |
---|
| 96 | """ |
---|
| 97 | return object state for pickling and copying |
---|
| 98 | """ |
---|
| 99 | model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log} |
---|
| 100 | |
---|
| 101 | return self.__dict__, model_state |
---|
| 102 | |
---|
| 103 | def __setstate__(self, state): |
---|
| 104 | """ |
---|
| 105 | create object from pickled state |
---|
| 106 | |
---|
| 107 | :param state: the state of the current model |
---|
| 108 | |
---|
| 109 | """ |
---|
| 110 | |
---|
| 111 | self.__dict__, model_state = state |
---|
| 112 | self.params = model_state['params'] |
---|
| 113 | self.dispersion = model_state['dispersion'] |
---|
| 114 | self.log = model_state['log'] |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | def run(self, x=0.0): |
---|
| 118 | """ |
---|
| 119 | Evaluate the model |
---|
| 120 | |
---|
| 121 | :param x: input q, or [q,phi] |
---|
| 122 | |
---|
| 123 | :return: scattering function P(q) |
---|
| 124 | |
---|
| 125 | """ |
---|
| 126 | |
---|
| 127 | return CLamellarPCrystalModel.run(self, x) |
---|
| 128 | |
---|
| 129 | def runXY(self, x=0.0): |
---|
| 130 | """ |
---|
| 131 | Evaluate the model in cartesian coordinates |
---|
| 132 | |
---|
| 133 | :param x: input q, or [qx, qy] |
---|
| 134 | |
---|
| 135 | :return: scattering function P(q) |
---|
| 136 | |
---|
| 137 | """ |
---|
| 138 | |
---|
| 139 | return CLamellarPCrystalModel.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 CLamellarPCrystalModel.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 CLamellarPCrystalModel.calculate_ER(self) |
---|
| 160 | |
---|
| 161 | def set_dispersion(self, parameter, dispersion): |
---|
| 162 | """ |
---|
| 163 | Set the dispersion object for a model parameter |
---|
| 164 | |
---|
| 165 | :param parameter: name of the parameter [string] |
---|
| 166 | :param dispersion: dispersion object of type DispersionModel |
---|
| 167 | |
---|
| 168 | """ |
---|
| 169 | return CLamellarPCrystalModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
| 170 | |
---|
| 171 | |
---|
| 172 | # End of file |
---|