from sans.models.BaseComponent import BaseComponent from sans.models.OnionModel import OnionModel import copy max_nshells = 10 class OnionExpShellModel(BaseComponent): """ This multi-model is based on CoreMultiShellModel with exponential func shells and provides the capability of changing the number of shells between 1 and 10. """ def __init__(self, n_shells=1): BaseComponent.__init__(self) """ :param n_shells: number of shells in the model, assumes 1<= n_shells <=10. """ ## Setting model name model description self.description="" model = OnionModel() self.model = model self.name = "OnionExpShellModel" self.description=model.description self.n_shells = n_shells ## Define parameters self.params = {} ## Parameter details [units, min, max] self.details = {} ## dispersion self._set_dispersion() ## Define parameters self._set_params() ## Parameter details [units, min, max] self._set_details() #list of parameter that can be fitted self._set_fixed_params() self.model.params['n_shells'] = self.n_shells ## functional multiplicity info of the model # [int(maximum no. of functionality),"str(Titl), # [str(name of function0),...], [str(x-asix name of sld),...]] self.multiplicity_info = [max_nshells,"No. of Shells:",[],['Radius']] ## parameters with orientation: can be removed since there is # no orientational params for item in self.model.orientation_params: self.orientation_params.append(item) self.getProfile() def _clone(self, obj): """ Internal utility function to copy the internal data members to a fresh copy. """ obj.params = copy.deepcopy(self.params) obj.description = copy.deepcopy(self.description) obj.details = copy.deepcopy(self.details) obj.dispersion = copy.deepcopy(self.dispersion) obj.model = self.model.clone() return obj def _set_dispersion(self): """ model dispersions """ ##set dispersion from model for name , value in self.model.dispersion.iteritems(): nshell = 0 if name.split('_')[0] == 'thick': while nshell