[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\fcc.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 CFCCrystalModel |
---|
| 29 | import copy |
---|
| 30 | |
---|
| 31 | class FCCrystalModel(CFCCrystalModel, BaseComponent): |
---|
| 32 | """ |
---|
| 33 | Class that evaluates a FCCrystalModel model. |
---|
| 34 | This file was auto-generated from ..\c_extensions\fcc.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 | dnn = 220.0 [A] |
---|
| 40 | d_factor = 0.06 |
---|
| 41 | radius = 40.0 [A] |
---|
| 42 | sldSph = 3e-006 [1/A^(2)] |
---|
| 43 | sldSolv = 6.3e-006 [1/A^(2)] |
---|
| 44 | background = 0.0 [1/cm] |
---|
[4628e31] | 45 | theta = 0.0 [deg] |
---|
| 46 | phi = 0.0 [deg] |
---|
| 47 | psi = 0.0 [deg] |
---|
[d5b6a9d] | 48 | |
---|
| 49 | """ |
---|
| 50 | |
---|
| 51 | def __init__(self): |
---|
| 52 | """ Initialization """ |
---|
| 53 | |
---|
| 54 | # Initialize BaseComponent first, then sphere |
---|
| 55 | BaseComponent.__init__(self) |
---|
| 56 | CFCCrystalModel.__init__(self) |
---|
| 57 | |
---|
| 58 | ## Name of the model |
---|
| 59 | self.name = "FCCrystalModel" |
---|
| 60 | ## Model description |
---|
| 61 | self.description ="""P(q)=(scale/Vp)*V_lattice*P(q)*Z(q)+bkg where scale is the volume |
---|
| 62 | fraction of sphere, |
---|
| 63 | Vp = volume of the primary particle, |
---|
| 64 | V_lattice = volume correction for |
---|
| 65 | for the crystal structure, |
---|
| 66 | P(q)= form factor of the sphere (normalized), |
---|
| 67 | Z(q)= paracrystalline structure factor |
---|
| 68 | for a face centered cubic structure. |
---|
| 69 | [Face Centered Cubic ParaCrystal Model] |
---|
| 70 | Parameters; |
---|
| 71 | scale: volume fraction of spheres |
---|
| 72 | bkg:background, R: radius of sphere |
---|
| 73 | dnn: Nearest neighbor distance |
---|
| 74 | d_factor: Paracrystal distortion factor |
---|
| 75 | radius: radius of the spheres |
---|
| 76 | sldSph: SLD of the sphere |
---|
| 77 | sldSolv: SLD of the solvent |
---|
| 78 | """ |
---|
| 79 | |
---|
| 80 | ## Parameter details [units, min, max] |
---|
| 81 | self.details = {} |
---|
| 82 | self.details['scale'] = ['', None, None] |
---|
| 83 | self.details['dnn'] = ['[A]', None, None] |
---|
| 84 | self.details['d_factor'] = ['', None, None] |
---|
| 85 | self.details['radius'] = ['[A]', None, None] |
---|
| 86 | self.details['sldSph'] = ['[1/A^(2)]', None, None] |
---|
| 87 | self.details['sldSolv'] = ['[1/A^(2)]', None, None] |
---|
| 88 | self.details['background'] = ['[1/cm]', None, None] |
---|
[4628e31] | 89 | self.details['theta'] = ['[deg]', None, None] |
---|
| 90 | self.details['phi'] = ['[deg]', None, None] |
---|
| 91 | self.details['psi'] = ['[deg]', None, None] |
---|
[d5b6a9d] | 92 | |
---|
| 93 | ## fittable parameters |
---|
| 94 | self.fixed=['radius.width', 'phi.width', 'psi.width', 'theta.width'] |
---|
| 95 | |
---|
| 96 | ## non-fittable parameters |
---|
| 97 | self.non_fittable=[] |
---|
| 98 | |
---|
| 99 | ## parameters with orientation |
---|
| 100 | self.orientation_params =['phi', 'psi', 'theta', 'phi.width', 'psi.width', 'theta.width'] |
---|
| 101 | |
---|
| 102 | def clone(self): |
---|
| 103 | """ Return a identical copy of self """ |
---|
| 104 | return self._clone(FCCrystalModel()) |
---|
| 105 | |
---|
| 106 | def __getstate__(self): |
---|
| 107 | """ |
---|
| 108 | return object state for pickling and copying |
---|
| 109 | """ |
---|
| 110 | model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log} |
---|
| 111 | |
---|
| 112 | return self.__dict__, model_state |
---|
| 113 | |
---|
| 114 | def __setstate__(self, state): |
---|
| 115 | """ |
---|
| 116 | create object from pickled state |
---|
| 117 | |
---|
| 118 | :param state: the state of the current model |
---|
| 119 | |
---|
| 120 | """ |
---|
| 121 | |
---|
| 122 | self.__dict__, model_state = state |
---|
| 123 | self.params = model_state['params'] |
---|
| 124 | self.dispersion = model_state['dispersion'] |
---|
| 125 | self.log = model_state['log'] |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | def run(self, x=0.0): |
---|
| 129 | """ |
---|
| 130 | Evaluate the model |
---|
| 131 | |
---|
| 132 | :param x: input q, or [q,phi] |
---|
| 133 | |
---|
| 134 | :return: scattering function P(q) |
---|
| 135 | |
---|
| 136 | """ |
---|
| 137 | |
---|
| 138 | return CFCCrystalModel.run(self, x) |
---|
| 139 | |
---|
| 140 | def runXY(self, x=0.0): |
---|
| 141 | """ |
---|
| 142 | Evaluate the model in cartesian coordinates |
---|
| 143 | |
---|
| 144 | :param x: input q, or [qx, qy] |
---|
| 145 | |
---|
| 146 | :return: scattering function P(q) |
---|
| 147 | |
---|
| 148 | """ |
---|
| 149 | |
---|
| 150 | return CFCCrystalModel.runXY(self, x) |
---|
| 151 | |
---|
| 152 | def evalDistribution(self, x=[]): |
---|
| 153 | """ |
---|
| 154 | Evaluate the model in cartesian coordinates |
---|
| 155 | |
---|
| 156 | :param x: input q[], or [qx[], qy[]] |
---|
| 157 | |
---|
| 158 | :return: scattering function P(q[]) |
---|
| 159 | |
---|
| 160 | """ |
---|
| 161 | return CFCCrystalModel.evalDistribution(self, x) |
---|
| 162 | |
---|
| 163 | def calculate_ER(self): |
---|
| 164 | """ |
---|
| 165 | Calculate the effective radius for P(q)*S(q) |
---|
| 166 | |
---|
| 167 | :return: the value of the effective radius |
---|
| 168 | |
---|
| 169 | """ |
---|
| 170 | return CFCCrystalModel.calculate_ER(self) |
---|
| 171 | |
---|
| 172 | def set_dispersion(self, parameter, dispersion): |
---|
| 173 | """ |
---|
| 174 | Set the dispersion object for a model parameter |
---|
| 175 | |
---|
| 176 | :param parameter: name of the parameter [string] |
---|
| 177 | :param dispersion: dispersion object of type DispersionModel |
---|
| 178 | |
---|
| 179 | """ |
---|
| 180 | return CFCCrystalModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
| 181 | |
---|
| 182 | |
---|
| 183 | # End of file |
---|