Ejemplo n.º 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
Ejemplo n.º 2
0
    def test_copy(self):
        '''copy'''
        print "This test creates two identical blocks, each of which "\
              "does not interact with neutrons. They print the info "\
              "about the neutrons passing thru them, however. "\
              "This test then send one neutron through these two "\
              "blocks, so we should see two printings of neutron info, "\
              "differing only on time-of-flight."
        # create a shape
        from mccomposite.geometry import primitives
        smallblock = primitives.block((1, 1, 1))

        #create pure python representation of scatterer composite
        composite1 = mccomposite.composite(smallblock)
        import UseNeutronPrinter2
        nprinter = UseNeutronPrinter2.NeutronPrinter(smallblock)
        composite1.addElement(nprinter)
        #create a copy
        copy = Copy.Copy(composite1)

        #create a larget composite
        largeblock = primitives.block((1, 1, 2))
        composite = mccomposite.composite(largeblock)
        composite.addElement(composite1, (0, 0, -0.5))
        #composite.addElement( nprinter, (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
Ejemplo n.º 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
Ejemplo n.º 4
0
    def test_copy(self):
        '''copy'''
        print "This test creates two identical blocks, each of which "\
              "does not interact with neutrons. They print the info "\
              "about the neutrons passing thru them, however. "\
              "This test then send one neutron through these two "\
              "blocks, so we should see two printings of neutron info, "\
              "differing only on time-of-flight."
        # create a shape
        from mccomposite.geometry import primitives
        smallblock = primitives.block( (1,1,1) )

        #create pure python representation of scatterer composite
        composite1 = mccomposite.composite( smallblock )
        import UseNeutronPrinter2
        nprinter = UseNeutronPrinter2.NeutronPrinter( smallblock )
        composite1.addElement( nprinter )
        #create a copy
        copy = Copy.Copy( composite1 )
        
        #create a larget composite
        largeblock = primitives.block( (1,1,2) )
        composite = mccomposite.composite( largeblock )
        composite.addElement( composite1, (0,0,-0.5) )
        #composite.addElement( nprinter, (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
Ejemplo n.º 5
0
    def test(self):
        # create a weird shape
        from mccomposite.geometry import primitives
        block = primitives.block((1, 1, 1))
        sphere = primitives.sphere(1)
        cylinder = primitives.cylinder(2, 2.001)

        from mccomposite.geometry import operations
        dilated = operations.dilate(sphere, 2)
        translated = operations.translate(block, (0, 0, 0.5))
        united = operations.unite(dilated, translated)

        rotated = operations.rotate(united, (90, 0, 0))

        intersect = operations.intersect(rotated, cylinder)

        difference = operations.subtract(intersect, sphere)

        print mccomposite.scattererEngine(difference)

        shape = difference
        #shape = block
        #shape = dilated
        #shape = united
        #shape = intersect
        #shape = operations.rotate(block, (90,0,0) )
        #shape = rotated
        #shape = sphere
        #shape = operations.subtract(sphere, block)
        #shape = operations.subtract( primitives.cylinder(1, 2.1), sphere )

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

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

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

        return
Ejemplo n.º 6
0
    def test(self):
        # create a weird shape
        from mccomposite.geometry import primitives
        block = primitives.block( (1,1,1) )
        sphere = primitives.sphere( 1 )
        cylinder = primitives.cylinder( 2,2.001 )

        from mccomposite.geometry import operations
        dilated = operations.dilate( sphere, 2 )
        translated = operations.translate( block, (0,0,0.5) )
        united = operations.unite( dilated, translated )

        rotated = operations.rotate( united, (90,0,0) )

        intersect = operations.intersect( rotated, cylinder )

        difference = operations.subtract( intersect, sphere )
        
        print mccomposite.scattererEngine( difference )

        shape = difference
        #shape = block
        #shape = dilated
        #shape = united
        #shape = intersect
        #shape = operations.rotate(block, (90,0,0) )
        #shape = rotated
        #shape = sphere
        #shape = operations.subtract(sphere, block)
        #shape = operations.subtract( primitives.cylinder(1, 2.1), sphere )

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

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

        ev = mcni.neutron( r = (0,0,-5), v = (0,0,1) )
        ccomposite.scatter(ev)
        
        return
    def test(self):
        '''HollowCylinder'''
        print "This test creates a hollow cylinder."\
              "It does not interact with neutrons. It prints the info "\
              "about the neutrons passing thru them, however. "\
              "This test then send one neutron through this hollow cylinder, "\
              "and we should see two printings of neutron info, "\
              "differing only on time-of-flight."
        # create a shape
        shape = HollowCylinder.HollowCylinder( 1, 1.2, 1 )
        import UseNeutronPrinter2
        nprinter = UseNeutronPrinter2.NeutronPrinter( shape )

        #render the c++ representation
        cinstance = mccomposite.scattererEngine( nprinter )

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

        cinstance.scatter(ev)
        return