Beispiel #1
0
def run(name, Model, pars, Dispersion):

    disp = {'npts':15, 'width':0.1666666667, 'nsigmas':2}
    q1,q2 = 0.1, 0.2
    q = numpy.linspace(q1,q2,128)    #print "q",q.shape,q.dtype
    model = Model()
    for k,v in pars.items(): model.setParam(k,v)


    print "===", name, "without polydispersity"
    _run_one(model, q, q1, q2)
    _run_two(model, q, q1, q2)


    # Set up dispersion
    rdisp = Dispersion()
    model.set_dispersion('radius', rdisp)
    for k,v in disp.items(): model.dispersion['radius'][k] = v

    ldisp = Dispersion()
    model.set_dispersion('length', ldisp)
    for k,v in disp.items(): model.dispersion['length'][k] = v

    print "===", name, "with %dx%d polydispersity"%(disp['npts'],disp['npts'])
    _run_one(model, q, q1, q2)
    _run_two(model, q, q1, q2)
Beispiel #2
0
    def testCylinder(self):
        """Make sure cylinder works over different r-ranges"""
        radius = 100
        length = 30

        from sans.models.CylinderModel import CylinderModel
        model = CylinderModel()
        model.setParam("radius", radius)
        model.setParam("length", length)

        ff = cf.SASCF("cylinder", model)

        r1 = numpy.arange(0, 10, 0.1, dtype = float)
        r2 = numpy.arange(0, 50, 0.1, dtype = float)
        r3 = numpy.arange(0, 100, 0.1, dtype = float)
        r4 = numpy.arange(0, 500, 0.1, dtype = float)

        fr1 = ff(r1)
        fr2 = ff(r2)
        fr3 = ff(r3)
        fr4 = ff(r4)

        d = fr1 - numpy.interp(r1, r2, fr2)
        res12 = numpy.dot(d,d)
        res12 /= numpy.dot(fr1, fr1)
        self.assertAlmostEqual(0, res12, 4)

        d = fr1 - numpy.interp(r1, r3, fr3)
        res13 = numpy.dot(d,d)
        res13 /= numpy.dot(fr1, fr1)
        self.assertAlmostEqual(0, res13, 4)

        d = fr1 - numpy.interp(r1, r4, fr4)
        res14 = numpy.dot(d,d)
        res14 /= numpy.dot(fr1, fr1)
        self.assertAlmostEqual(0, res14, 4)

        d = fr2 - numpy.interp(r2, r3, fr3)
        res23 = numpy.dot(d,d)
        res23 /= numpy.dot(fr2, fr2)
        self.assertAlmostEqual(0, res23, 4)

        d = fr2 - numpy.interp(r2, r4, fr4)
        res24 = numpy.dot(d,d)
        res24 /= numpy.dot(fr2, fr2)
        self.assertAlmostEqual(0, res24, 4)

        d = fr3 - numpy.interp(r3, r4, fr4)
        res34 = numpy.dot(d,d)
        res34 /= numpy.dot(fr3, fr3)
        self.assertAlmostEqual(0, res34, 4)
        return
Beispiel #3
0
import sys, os, math
from sans.models.CylinderModel import CylinderModel
from sans.models.DisperseModel import DisperseModel

os.system(
    'gcc -c ../../../libigor/libCylinder.c -o libigor.o -I../c_extensions -I../../../libigor'
)
os.system(
    'gcc -c ../c_extensions/cylinder.c -o libcyl.o -I../c_extensions -I../../../libigor'
)
os.system(
    'g++ -mno-cygwin cylinder.cpp parameters.cpp  dispersion_visitor.cpp libigor.o libcyl.o -D__MODELS_STANDALONE__ -I../c_extensions -I../../../libigor'
)
os.system('a.exe')

cyl = CylinderModel()
cyl.setParam('cyl_phi', 0.0)
cyl.setParam('cyl_theta', 0.0)

disp = DisperseModel(cyl, ['radius'], [5])
disp.setParam('n_pts', 100)
print ""
print "Cyl (python): ", cyl.run(0.001)
print "Disp(pyhton): ", disp.run(0.001)
Beispiel #4
0
def cylinder(data): ##################################################################################
    from sans.models.CylinderModel import CylinderModel
    model1 = CylinderModel()
    model1.setParam("scale", 10.0)
    model1.setParam("radius",18)
    model1.setParam("length", 397)
    model1.setParam("sldCyl",3e-006 )
    model1.setParam("sldSolv",0.0 )
    model1.setParam("background", 0.0)

    # Dispersion parameters
    model1.dispersion['radius']['width'] = 0.25
    model1.dispersion['radius']['npts'] = 50

    theory = model1.evalDistribution([data.qx_data, data.qy_data])
    return theory
Beispiel #5
0
def cylinder(
    data
):  ##################################################################################
    from sans.models.CylinderModel import CylinderModel
    model1 = CylinderModel()
    model1.setParam("scale", 10.0)
    model1.setParam("radius", 18)
    model1.setParam("length", 397)
    model1.setParam("sldCyl", 3e-006)
    model1.setParam("sldSolv", 0.0)
    model1.setParam("background", 0.0)

    # Dispersion parameters
    model1.dispersion['radius']['width'] = 0.25
    model1.dispersion['radius']['npts'] = 50

    theory = model1.evalDistribution([data.qx_data, data.qy_data])
    return theory
Beispiel #6
0
import sys, os, math
from sans.models.CylinderModel import CylinderModel
from sans.models.DisperseModel import DisperseModel

os.system('gcc -c ../../../libigor/libCylinder.c -o libigor.o -I../c_extensions -I../../../libigor')
os.system('gcc -c ../c_extensions/cylinder.c -o libcyl.o -I../c_extensions -I../../../libigor')
os.system('g++ -mno-cygwin cylinder.cpp parameters.cpp  dispersion_visitor.cpp libigor.o libcyl.o -D__MODELS_STANDALONE__ -I../c_extensions -I../../../libigor')
os.system('a.exe')


cyl = CylinderModel()
cyl.setParam('cyl_phi', 0.0)
cyl.setParam('cyl_theta', 0.0)

disp = DisperseModel(cyl, ['radius'], [5])
disp.setParam('n_pts', 100)
print "" 
print "Cyl (python): ", cyl.run(0.001)
print "Disp(pyhton): ", disp.run(0.001)