コード例 #1
0
    def test_scatterercopy(self):
        '''scatterercopy'''
        # create a weird shape
        from mccomposite.geometry import primitives
        shape = primitives.block((1, 1, 1))

        #create pure python representation of scatterer composite
        composite1 = mccomposite.composite(shape)
        nprinter = NeutronPrinter(shape)
        composite1.addElement(nprinter)
        #create a copy
        copy = mccomposite.scatterercopy(composite1)

        #create a larget composite
        shape = primitives.block((1, 1, 2))
        composite = mccomposite.composite(shape)
        composite.addElement(composite1, (0, 0, -0.5))
        composite.addElement(copy, (0, 0, +0.5))

        #render the c++ representation
        ccomposite = mccomposite.scattererEngine(composite)

        ev = mcni.neutron(r=(0, 0, -5), v=(0, 0, 1))
        ccomposite.scatter(ev)

        return
コード例 #2
0
    def test1(self):
        'complex. pack, detector, pixel hierarchy'
        
        mca = md.eventModeMCA(
            outfilename,
            (npacks, ndetsperpack, npixelsperdet,) )
        cylinder = operations.subtract( primitives.cylinder( sample2det * 1.1, detlength ),
                                        primitives.cylinder( sample2det * 0.9, detlength ) )
        ds = md.detectorSystem( cylinder, tofparams, mca )

        pack0 = makepack()
        packs = [pack0]
        for i in range(1, npacks):
            packs.append( mccomposite.scatterercopy( pack0, id = i ) )
            continue

        for i in range( npacks ):
            z = 0 * meter
            angle = (i-packindexat0)* 5./180 * N.pi
            x = sample2det * math.cos(angle)
            y = sample2det * math.sin(angle)
            ds.addElement( packs[i], (x,y,z) )
            continue

        cds = mh.scattererEngine( ds, coordinate_system = "InstrumentScientist" )

        for i in range(nevents):
            if i%1000 == 0: print i
            ev = mcni.neutron( r = (-L1,0,0), v = (vi,0,0) )
            cds.scatter(ev)
            continue

        return
コード例 #3
0
    def test_scatterercopy(self):
        '''scatterercopy'''
        # create a weird shape
        from mccomposite.geometry import primitives
        shape = primitives.block( (1,1,1) )

        #create pure python representation of scatterer composite
        composite1 = mccomposite.composite( shape )
        nprinter = NeutronPrinter( shape )
        composite1.addElement( nprinter )
        #create a copy
        copy = mccomposite.scatterercopy( composite1 )
        
        #create a larget composite
        shape = primitives.block( (1,1,2) )
        composite = mccomposite.composite( shape )
        composite.addElement( composite1, (0,0,-0.5) )
        composite.addElement( copy, (0,0,+0.5) )

        #render the c++ representation
        ccomposite = mccomposite.scattererEngine( composite )

        ev = mcni.neutron( r = (0,0,-5), v = (0,0,1) )
        ccomposite.scatter(ev)
        
        return
コード例 #4
0
def makepack():
    pack = md.pack(
        primitives.block(
            (detradius * 2, detradius * 2 * ndetsperpack, detlength)))
    he3tube0 = md.he3tube_withpixels(radius=detradius,
                                     height=detlength,
                                     npixels=npixelsperdet,
                                     direction='z',
                                     id=0,
                                     pressure=detpressure,
                                     mcweights=(absorption_weight,
                                                scattering_weight,
                                                transmission_weight))
    tubes = [he3tube0]
    for i in range(1, ndetsperpack):
        tubes.append(mccomposite.scatterercopy(he3tube0, id=i))
        continue

    for i in range(ndetsperpack):
        y = -(ndetsperpack - 1.) / 2 * 2 * detradius + i * 2 * detradius
        pack.addElement(tubes[i], (0 * meter, y, 0 * meter))
        continue
    return pack
コード例 #5
0
    def test1(self):
        'complex. pack, detector, pixel hierarchy'

        mca = md.eventModeMCA(outfilename, (
            npacks,
            ndetsperpack,
            npixelsperdet,
        ))
        cylinder = operations.subtract(
            primitives.cylinder(sample2det * 1.1, detlength),
            primitives.cylinder(sample2det * 0.9, detlength))
        ds = md.detectorSystem(cylinder, tofparams, mca)

        pack0 = makepack()
        packs = [pack0]
        for i in range(1, npacks):
            packs.append(mccomposite.scatterercopy(pack0, id=i))
            continue

        for i in range(npacks):
            z = 0 * meter
            angle = (i - packindexat0) * 5. / 180 * N.pi
            x = sample2det * math.cos(angle)
            y = sample2det * math.sin(angle)
            ds.addElement(packs[i], (x, y, z))
            continue

        cds = mh.scattererEngine(ds, coordinate_system="InstrumentScientist")

        for i in range(nevents):
            if i % 1000 == 0: print i
            ev = mcni.neutron(r=(-L1, 0, 0), v=(vi, 0, 0))
            cds.scatter(ev)
            continue

        return
コード例 #6
0
def makepack( ):
    pack = md.pack(
        primitives.block(
        (detradius*2, detradius*2*ndetsperpack, detlength)
        )
        )
    he3tube0 = md.he3tube_withpixels(
        radius = detradius,
        height = detlength,
        npixels = npixelsperdet, direction = 'z',
        id = 0, pressure = detpressure,
        mcweights = (
        absorption_weight, scattering_weight, transmission_weight)
        )
    tubes = [he3tube0]
    for i in range(1,ndetsperpack):
        tubes.append( mccomposite.scatterercopy( he3tube0, id = i) )
        continue

    for i in range(ndetsperpack):
        y = -(ndetsperpack-1.)/2*2*detradius + i*2*detradius
        pack.addElement( tubes[i], (0*meter, y, 0*meter) )
        continue
    return pack