from sans.models.BaseComponent import BaseComponent from sans.models.CoreFourShellModel import CoreFourShellModel import copy max_nshells = 5 class CoreMultiShellModel(BaseComponent): """ This multi-model is based on CoreFourShellModel and provides the capability of changing the number of shells between 1 and 4. """ def __init__(self, multfactor=1): BaseComponent.__init__(self) """ :param n_shells: number of shells in the model, assumes 1<= n_shells <=4. """ ## Setting model name model description self.description="" model = CoreFourShellModel() self.model = model self.name = "CoreMultiShellModel" self.description="" self.n_shells = multfactor ## Define parameters self.params = {} ## Parameter details [units, min, max] self.details = {} # non-fittable parameters self.non_fittable = model.non_fittable ## 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() ## 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) 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 Polydispersion should not be applied to s_model """ ##set dispersion from model for name , value in self.model.dispersion.iteritems(): nshell = 0 if name.split('_')[0] == 'thick': while nshell