Beispiel #1
0
    def __init__(self, radius=15, thickness=5, density = 0.01):
        from sas.models.CoreShellModel import CoreShellModel
        
        self.name = 'coreshell'
        self.radius = radius
        
        core_vol = 4.0/3.0*math.pi*radius*radius*radius
        self.outer_radius = radius+thickness
        shell_vol = 4.0/3.0*math.pi*self.outer_radius*self.outer_radius*self.outer_radius - core_vol
        self.shell_sld = -1.0*core_vol/shell_vol

        self.density = density
           
        # Core-shell
        sphere = CoreShellModel()
        # Core radius
        sphere.setParam('radius', self.radius)
        # Shell thickness
        sphere.setParam('thickness', thickness)
        sphere.setParam('core_sld', 1.0)
        sphere.setParam('shell_sld', self.shell_sld)
        sphere.setParam('solvent_sld', 0.0)
        sphere.setParam('background', 0.0)
        sphere.setParam('scale', 1.0)
        self.ana = sphere
        self.create()
Beispiel #2
0
    def setUp(self):
        from sas.models.CoreShellModel import CoreShellModel
        radius = 15
        thickness = 5
        core_vol = 4.0 / 3.0 * math.pi * radius * radius * radius
        outer_radius = radius + thickness
        shell_vol = 4.0 / 3.0 * math.pi * outer_radius * outer_radius * outer_radius - core_vol
        self.shell_sld = -1.0 * core_vol / shell_vol

        self.canvas = VolumeCanvas.VolumeCanvas()
        self.canvas.params['lores_density'] = 0.1

        # Core shell model
        sphere = CoreShellModel()
        # Core radius
        sphere.setParam('radius', radius)
        # Shell thickness
        sphere.setParam('thickness', thickness)
        sphere.setParam('core_sld', 1.0)
        sphere.setParam('shell_sld', self.shell_sld)
        sphere.setParam('solvent_sld', 0.0)
        sphere.setParam('background', 0.0)
        sphere.setParam('scale', 1.0)
        self.sphere = sphere
        self.radius = radius
        self.outer_radius = outer_radius
 def setUp(self):
     from sas.models.CoreShellModel import CoreShellModel
     self.model= CoreShellModel()
     
     self.model.setParam('scale', 1.0)
     self.model.setParam('radius', 60.0)
     self.model.setParam('thickness', 10.0)
     self.model.setParam('core_sld', 1.e-6)
     self.model.setParam('shell_sld', 2.e-6)
     self.model.setParam('solvent_sld', 3.e-6)
     self.model.setParam('background', 0.0)
Beispiel #4
0
    def __init__(self):
        BaseComponent.__init__(self)

        ## Setting  model name model description
        model = CoreShellModel()
        self.description = model

        self.model = model
        self.name = "FractalCoreShell"
        self.description = """Scattering  from a fractal structure 
        with a primary building block of a spherical particle 
        with particle with a core-shell structure.
        Note: Setting the (core) radius polydispersion with a Schulz 
        distribution is equivalent to the FractalPolyCore function 
        in NIST/Igor Package.
        List of parameters:
        volfraction: volume fraction of building block spheres
        radius: radius of building block
        thickness: shell thickness
        frac_dim:  fractal dimension
        cor_length: correlation length of fractal-like aggregates
        core_sld: SLD of building block
        shell_sld: SLD of shell
        solvent_sld: SLD of matrix or solution
        background: flat background"""

        ## 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()

        ## parameters with orientation:
        for item in self.model.orientation_params:
            self.orientation_params.append(item)
Beispiel #5
0
def test_7():
    from sas.models.CoreShellModel import CoreShellModel
    print("Testing core-shell")
    radius = 15
    thickness = 5
    density = 5

    core_vol = 4.0 / 3.0 * math.pi * radius * radius * radius
    outer_radius = radius + thickness
    shell_vol = 4.0 / 3.0 * math.pi * outer_radius * outer_radius * outer_radius - core_vol
    shell_sld = -1.0 * core_vol / shell_vol

    # Core-shell
    sphere = CoreShellModel()
    # Core radius
    sphere.setParam('radius', radius)
    # Shell thickness
    sphere.setParam('thickness', thickness)
    sphere.setParam('core_sld', 1.0)
    sphere.setParam('shell_sld', shell_sld)
    sphere.setParam('solvent_sld', 0.0)
    sphere.setParam('background', 0.0)
    sphere.setParam('scale', 1.0)
    ana = sphere

    canvas = VolumeCanvas.VolumeCanvas()
    canvas.setParam('lores_density', density)

    handle = canvas.add('sphere')
    canvas.setParam('%s.radius' % handle, outer_radius)
    canvas.setParam('%s.contrast' % handle, shell_sld)

    handle2 = canvas.add('sphere')
    canvas.setParam('%s.radius' % handle2, radius)
    canvas.setParam('%s.contrast' % handle2, 1.0)

    canvas.setParam('scale', 1.0)
    canvas.setParam('background', 0.0)
    """ Testing default core-shell orientation """
    qlist = [.0001, 0.002, .01, .1, 1.0, 5.]
    for q in qlist:
        ana_val = ana.runXY([q, 0.2])
        sim_val, err = canvas.getIq2DError(q, 0.2)
        print(ana_val, sim_val, sim_val / ana_val, err,
              (sim_val - ana_val) / err)
Beispiel #6
0
    def setUp(self):
        """ Set up zero-SLD-average core-shell model """
        from sas.models.CoreShellModel import CoreShellModel
        
        radius = 15
        thickness = 5
        density = 5
        
        core_vol = 4.0/3.0*math.pi*radius*radius*radius
        self.outer_radius = radius+thickness
        shell_vol = 4.0/3.0*math.pi*self.outer_radius*self.outer_radius*self.outer_radius - core_vol
        self.shell_sld = -1.0*core_vol/shell_vol

        self.density = density
           
        # Core-shell
        sphere = CoreShellModel()
        # Core radius
        sphere.setParam('radius', radius)
        # Shell thickness
        sphere.setParam('thickness', thickness)
        sphere.setParam('core_sld', 1.0)
        sphere.setParam('shell_sld', self.shell_sld)
        sphere.setParam('solvent_sld', 0.0)
        sphere.setParam('background', 0.0)
        sphere.setParam('scale', 1.0)
        self.ana = sphere
       
        canvas = VolumeCanvas.VolumeCanvas()        
        canvas.setParam('lores_density', self.density)
        
        handle = canvas.add('sphere')
        canvas.setParam('%s.radius' % handle, self.outer_radius)
        canvas.setParam('%s.contrast' % handle, self.shell_sld)
       
        handle2 = canvas.add('sphere')
        canvas.setParam('%s.radius' % handle2, radius)
        canvas.setParam('%s.contrast' % handle2, 1.0)
               
        canvas.setParam('scale' , 1.0)
        canvas.setParam('background' , 0.0)
        self.canvas = canvas 
 def setUp(self):
     from sas.models.CoreShellModel import CoreShellModel
     self.comp = CoreShellModel()
Beispiel #8
0
def test_2():
    radius = 15.0
    thickness = 5.0

    core_vol = 4.0 / 3.0 * math.pi * radius * radius * radius
    outer_radius = radius + thickness
    shell_vol = 4.0 / 3.0 * math.pi * outer_radius * outer_radius * outer_radius - core_vol
    shell_sld = -1.0 * core_vol / shell_vol
    print("Shell SLD", shell_sld)

    density = .1
    vol = 4 / 3 * math.pi * radius * radius * radius
    npts = vol * density

    canvas = VolumeCanvas.VolumeCanvas()
    canvas.setParam('lores_density', density)
    handle = canvas.add('sphere')
    canvas.setParam('%s.radius' % handle, outer_radius)
    canvas.setParam('%s.contrast' % handle, shell_sld)

    handle2 = canvas.add('sphere')
    canvas.setParam('%s.radius' % handle2, radius)
    canvas.setParam('%s.contrast' % handle2, 1.0)

    # Core-shell
    sphere = CoreShellModel()
    # Core radius
    sphere.setParam('radius', radius)
    # Shell thickness
    sphere.setParam('thickness', thickness)
    sphere.setParam('core_sld', 1.0)

    sphere.setParam('shell_sld', shell_sld)
    sphere.setParam('solvent_sld', 0.0)
    sphere.setParam('background', 0.0)
    sphere.setParam('scale', 1.0)

    out = open("lores_test.txt", 'w')
    out.write("<q> <sim> <ana>\n")

    for i in range(65):
        q = 0.001 + 0.01 * i

        # For each volume integral that we change to a sum,
        # we must multiply by 1/density = V/N
        # Since we want P(r)/V, we will need to multiply
        # the sum by 1/(N*density), where N is the number of
        # points without overlap. Since we already divide
        # by N when calculating I(q), we only need to divide
        # by the density here. We divide by N in the
        # calculation because it is difficult to estimate it here.

        # Put the factor 2 in the simulation two...
        sim_1 = canvas.getIq(q)
        ana_1 = sphere.run(q)

        print("q=%g  sim=%g  ana=%g   ratio=%g" %
              (q, sim_1, ana_1, sim_1 / ana_1))
        out.write("%g  %g  %g\n" % (q, sim_1, ana_1))

    out.close()