Source code for sas.models.OnionModel

##############################################################################
# This software was developed by the University of Tennessee as part of the
# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
# project funded by the US National Science Foundation.
#
# If you use DANSE applications to do scientific research that leads to
# publication, we ask that you acknowledge the use of the software with the
# following sentence:
#
# This work benefited from DANSE software developed under NSF award DMR-0520547
#
# Copyright 2008-2011, University of Tennessee
##############################################################################

""" 
Provide functionality for a C extension model

.. WARNING::

   THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
   DO NOT MODIFY THIS FILE, MODIFY
   src/sas/models/include/onion.h
   AND RE-RUN THE GENERATOR SCRIPT
"""

from sas.models.BaseComponent import BaseComponent
from sas.models.sas_extension.c_models import COnionModel

[docs]def create_OnionModel(): """ Create a model instance """ obj = OnionModel() # COnionModel.__init__(obj) is called by # the OnionModel constructor return obj
[docs]class OnionModel(COnionModel, BaseComponent): """ Class that evaluates a OnionModel model. This file was auto-generated from src/sas/models/include/onion.h. Refer to that file and the structure it contains for details of the model. List of default parameters: * n_shells = 1.0 * scale = 1.0 * rad_core0 = 200.0 [A] * sld_core0 = 1e-06 [1/A^(2)] * sld_solv = 6.4e-06 [1/A^(2)] * background = 0.0 [1/cm] * sld_out_shell1 = 2e-06 [1/A^(2)] * sld_out_shell2 = 2.5e-06 [1/A^(2)] * sld_out_shell3 = 3e-06 [1/A^(2)] * sld_out_shell4 = 3.5e-06 [1/A^(2)] * sld_out_shell5 = 4e-06 [1/A^(2)] * sld_out_shell6 = 4.5e-06 [1/A^(2)] * sld_out_shell7 = 5e-06 [1/A^(2)] * sld_out_shell8 = 5.5e-06 [1/A^(2)] * sld_out_shell9 = 6e-06 [1/A^(2)] * sld_out_shell10 = 6.2e-06 [1/A^(2)] * sld_in_shell1 = 1.7e-06 [1/A^(2)] * sld_in_shell2 = 2.2e-06 [1/A^(2)] * sld_in_shell3 = 2.7e-06 [1/A^(2)] * sld_in_shell4 = 3.2e-06 [1/A^(2)] * sld_in_shell5 = 3.7e-06 [1/A^(2)] * sld_in_shell6 = 4.2e-06 [1/A^(2)] * sld_in_shell7 = 4.7e-06 [1/A^(2)] * sld_in_shell8 = 5.2e-06 [1/A^(2)] * sld_in_shell9 = 5.7e-06 [1/A^(2)] * sld_in_shell10 = 6e-06 [1/A^(2)] * A_shell1 = 1.0 * A_shell2 = 1.0 * A_shell3 = 1.0 * A_shell4 = 1.0 * A_shell5 = 1.0 * A_shell6 = 1.0 * A_shell7 = 1.0 * A_shell8 = 1.0 * A_shell9 = 1.0 * A_shell10 = 1.0 * thick_shell1 = 50.0 [A] * thick_shell2 = 50.0 [A] * thick_shell3 = 50.0 [A] * thick_shell4 = 50.0 [A] * thick_shell5 = 50.0 [A] * thick_shell6 = 50.0 [A] * thick_shell7 = 50.0 [A] * thick_shell8 = 50.0 [A] * thick_shell9 = 50.0 [A] * thick_shell10 = 50.0 [A] * func_shell1 = 2.0 * func_shell2 = 2.0 * func_shell3 = 2.0 * func_shell4 = 2.0 * func_shell5 = 2.0 * func_shell6 = 2.0 * func_shell7 = 2.0 * func_shell8 = 2.0 * func_shell9 = 2.0 * func_shell10 = 2.0 """ def __init__(self, multfactor=1): """ Initialization """ self.__dict__ = {} # Initialize BaseComponent first, then sphere BaseComponent.__init__(self) #apply(COnionModel.__init__, (self,)) COnionModel.__init__(self) self.is_multifunc = False ## Name of the model self.name = "OnionModel" ## Model description self.description = """ Form factor of mutishells normalized by the volume. Here each shell is described by an exponential function; I) For A_shell != 0, f(r) = B*exp(A_shell*(r-r_in)/thick_shell)+C where B=(sld_out-sld_in)/(exp(A_shell)-1) C=sld_in-B. Note that in the above case, the function becomes a linear function as A_shell --> 0+ or 0-. II) For the exact point of A_shell == 0, f(r) = sld_in ,i.e., it crosses over flat function Note that the 'sld_out' becaomes NULL in this case. background:background, rad_core0: radius of sphere(core) thick_shell#:the thickness of the shell# sld_core0: the SLD of the sphere sld_solv: the SLD of the solvent sld_shell: the SLD of the shell# A_shell#: the coefficient in the exponential function """ ## Parameter details [units, min, max] self.details = {} self.details['n_shells'] = ['', None, None] self.details['scale'] = ['', None, None] self.details['rad_core0'] = ['[A]', None, None] self.details['sld_core0'] = ['[1/A^(2)]', None, None] self.details['sld_solv'] = ['[1/A^(2)]', None, None] self.details['background'] = ['[1/cm]', None, None] self.details['sld_out_shell1'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell2'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell3'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell4'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell5'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell6'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell7'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell8'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell9'] = ['[1/A^(2)]', None, None] self.details['sld_out_shell10'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell1'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell2'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell3'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell4'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell5'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell6'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell7'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell8'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell9'] = ['[1/A^(2)]', None, None] self.details['sld_in_shell10'] = ['[1/A^(2)]', None, None] self.details['A_shell1'] = ['', None, None] self.details['A_shell2'] = ['', None, None] self.details['A_shell3'] = ['', None, None] self.details['A_shell4'] = ['', None, None] self.details['A_shell5'] = ['', None, None] self.details['A_shell6'] = ['', None, None] self.details['A_shell7'] = ['', None, None] self.details['A_shell8'] = ['', None, None] self.details['A_shell9'] = ['', None, None] self.details['A_shell10'] = ['', None, None] self.details['thick_shell1'] = ['[A]', None, None] self.details['thick_shell2'] = ['[A]', None, None] self.details['thick_shell3'] = ['[A]', None, None] self.details['thick_shell4'] = ['[A]', None, None] self.details['thick_shell5'] = ['[A]', None, None] self.details['thick_shell6'] = ['[A]', None, None] self.details['thick_shell7'] = ['[A]', None, None] self.details['thick_shell8'] = ['[A]', None, None] self.details['thick_shell9'] = ['[A]', None, None] self.details['thick_shell10'] = ['[A]', None, None] self.details['func_shell1'] = ['', None, None] self.details['func_shell2'] = ['', None, None] self.details['func_shell3'] = ['', None, None] self.details['func_shell4'] = ['', None, None] self.details['func_shell5'] = ['', None, None] self.details['func_shell6'] = ['', None, None] self.details['func_shell7'] = ['', None, None] self.details['func_shell8'] = ['', None, None] self.details['func_shell9'] = ['', None, None] self.details['func_shell10'] = ['', None, None] ## fittable parameters self.fixed = ['rad_core0.width', 'thick_shell1.width', 'thick_shell2.width', 'thick_shell3.width', 'thick_shell4.width', 'thick_shell5.width', 'thick_shell6.width', 'thick_shell7.width', 'thick_shell8.width', 'thick_shell9.width', 'thick_shell10.width'] ## non-fittable parameters self.non_fittable = [] ## parameters with orientation self.orientation_params = [] ## parameters with magnetism self.magnetic_params = [] self.category = None self.multiplicity_info = None def __setstate__(self, state): """ restore the state of a model from pickle """ self.__dict__, self.params, self.dispersion = state def __reduce_ex__(self, proto): """ Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of c model. """ state = (self.__dict__, self.params, self.dispersion) return (create_OnionModel, tuple(), state, None, None)
[docs] def clone(self): """ Return a identical copy of self """ return self._clone(OnionModel())
[docs] def run(self, x=0.0): """ Evaluate the model :param x: input q, or [q,phi] :return: scattering function P(q) """ return COnionModel.run(self, x)
[docs] def runXY(self, x=0.0): """ Evaluate the model in cartesian coordinates :param x: input q, or [qx, qy] :return: scattering function P(q) """ return COnionModel.runXY(self, x)
[docs] def evalDistribution(self, x): """ Evaluate the model in cartesian coordinates :param x: input q[], or [qx[], qy[]] :return: scattering function P(q[]) """ return COnionModel.evalDistribution(self, x)
[docs] def calculate_ER(self): """ Calculate the effective radius for P(q)*S(q) :return: the value of the effective radius """ return COnionModel.calculate_ER(self)
[docs] def calculate_VR(self): """ Calculate the volf ratio for P(q)*S(q) :return: the value of the volf ratio """ return COnionModel.calculate_VR(self)
[docs] def set_dispersion(self, parameter, dispersion): """ Set the dispersion object for a model parameter :param parameter: name of the parameter [string] :param dispersion: dispersion object of type DispersionModel """ return COnionModel.set_dispersion(self, parameter, dispersion.cdisp) # End of file