Exemplo n.º 1
0
    def test_container_controller(self):
        xs = CrossSection()
        xs.set([[1.58, 0.02, 0.0, 1.0], [0.271, 0.0930, 0.168, 0.0]])
        xs.set_smat([[0.0, 0.0178], [0.0, 0.0]])
        xs.calc_sigr()

        delta = 1.0
        albedo = -1.0
        geom = [{'xs': xs, 'width': 100}]

        container = Container(geom, delta, albedo)
        #cont.debug()

        controller = ContainerController(container)

        count, flag = controller.calc()
        print("outer iterations: ", count)

        keff = controller.get_keff()

        b2 = (math.pi / geom[0]['width'])**2
        kana_nume = (xs.sigr(1) + xs.dif(1) * b2) * xs.nusigf(0) + xs.sigs(
            0, 1) * xs.nusigf(1)
        kana_deno = (xs.dif(0) * b2 + xs.sigr(0)) * (xs.dif(1) * b2 +
                                                     xs.sigr(1))
        kana = kana_nume / kana_deno
        print("kana=", kana)

        self.assertAlmostEqual(keff, kana, places=4)
    def test_calculation_manager(self):

        xs = CrossSection()
        xs.set([[1.58, 0.02, 0.0, 1.0], [0.271, 0.0930, 0.168, 0.0]])
        xs.set_smat([[0.0, 0.0178], [0.0, 0.0]])
        xs.calc_sigr()

        delta = 1.0
        albedo = -1.0
        geom = [{'xs': xs, 'width': 100}]

        config = {'geometry': geom, 'mesh_width': delta, "albedo": albedo}

        calc_man = CalculationManager(config)
        count, flag = calc_man.run()

        keff = calc_man.get_keff()

        b2 = (math.pi / geom[0]['width'])**2
        kana_nume = (xs.sigr(1) + xs.dif(1) * b2) * xs.nusigf(0) + xs.sigs(
            0, 1) * xs.nusigf(1)
        kana_deno = (xs.dif(0) * b2 + xs.sigr(0)) * (xs.dif(1) * b2 +
                                                     xs.sigr(1))
        kana = kana_nume / kana_deno
        print("kana=", kana)

        self.assertAlmostEqual(keff, kana, places=4)
Exemplo n.º 3
0
    def test_onenode(self):
        node = Node()
        xs = CrossSection()

        # two-group problem
        xs.set([[1.58, 0.0032, 0.0, 1.0], [0.271, 0.0930, 0.168, 0.0]])
        xs.set_smat([[0.0, 0.0178], [0.0, 0.0]])
        xs.calc_sigr()

        #xs.debug()
        node.set_xs(xs)

        keff = 1.0
        keff_old = 1.0
        total_fis_src_old = 1.0
        conv = 1.0e-10

        # outer iteration
        for ik in range(1000):

            # normalize total fission source
            total_fis_src = 0.0
            for kg in range(2):
                total_fis_src += node.get_fis_src(kg) * node.get_width()
            factor = 1.0 / (total_fis_src / keff)

            for kg in range(2):
                node.normalize_fis_src(kg, factor)

            # energy loop
            for kg in range(2):
                # update sources
                node.calc_scat_src(kg)

                # inner loop
                for i in range(4):
                    for dir in range(2):
                        node.set_jin(kg, dir, node.get_jout(kg, dir))

                    # calculate jout, flux with response matrix
                    node.calc(kg)

                node.calc_fis_src(kg)

            # calc total fission source and k_eff
            total_fis_src = 0.0
            for kg in range(2):
                total_fis_src += node.get_fis_src(kg) * node.get_width()

            keff = total_fis_src / (total_fis_src_old / keff_old)
            diff = abs((keff - keff_old) / keff)

            # convergence check
            if (diff < conv):
                break

            # update parameters
            total_fis_src_old = total_fis_src
            keff_old = keff
            node.set_keff(keff)

        # --- end of loop for outer iteration

        print("keff=", keff)

        # analytic solution by Eq.(67) on the page 114 where the buckling is zero.
        kana_nume = xs.sigr(1) * xs.nusigf(0) + xs.sigs(0, 1) * xs.nusigf(1)
        kana_deno = xs.sigr(0) * xs.sigr(1)
        kana = kana_nume / kana_deno
        print("kana=", kana)

        self.assertAlmostEqual(keff, kana, places=5)

        for kg in range(2):
            self.assertAlmostEqual(node.get_jout(kg, XM),
                                   node.get_jout(kg, XP),
                                   places=5)
            self.assertAlmostEqual(node.get_jin(kg, XM),
                                   node.get_jout(kg, XM),
                                   places=5)
            self.assertAlmostEqual(node.get_jin(kg, XP),
                                   node.get_jout(kg, XP),
                                   places=5)
            self.assertAlmostEqual(node.get_jout(kg, XM) +
                                   node.get_jin(kg, XM),
                                   node.get_flux(kg) / 2.0,
                                   places=5)
Exemplo n.º 4
0
    def test_container(self):

        xs = CrossSection()
        xs.set([[1.58, 0.02, 0.0, 1.0],[0.271, 0.0930, 0.168, 0.0]])
        xs.set_smat( [[0.0, 0.0178], [0.0, 0.0]])
        xs.calc_sigr()

        delta = 1.0
        albedo = -1.0
        geom = [{'xs':xs, 'width':100}]

        cont = Container(geom, delta, albedo)
        #cont.debug()
        
        keff = 1.0
        keff_old = 1.0
        total_fis_src_old = 1.0
        conv = 1.0e-7
        
        for idx_outer in range(100):

            total_fis_src = cont.get_total_fis_src()
            norm_factor = 1.0 / (total_fis_src/keff)
            cont.normalize_fis_src(norm_factor)

            for kg in range(2):
                cont.calc_scat_src(kg)

                for idx_inner in range(4):
                    for color in range(2):
                        cont.calc(kg, color)
            
                cont.calc_fis_src(kg)

            total_fis_src = cont.get_total_fis_src()
            
            keff = total_fis_src / (total_fis_src_old/keff_old)
            diff = abs((keff - keff_old)/keff)
            #print( keff, diff)
            if(diff < conv):
                break
            keff_old = keff
            total_fis_src_old = total_fis_src

            cont.set_keff(keff)

        b2 = (math.pi / geom[0]['width'])**2
        kana_nume = (xs.sigr(1) + xs.dif(1)*b2)*xs.nusigf(0) + xs.sigs(0,1)*xs.nusigf(1)
        kana_deno = (xs.dif(0)*b2 + xs.sigr(0) ) * (xs.dif(1)*b2 + xs.sigr(1))
        kana = kana_nume / kana_deno
        print("kana=", kana)

        self.assertAlmostEqual(keff, kana, places=4)


        flux = cont.get_flux_dist(0)  # first energy
        self.assertEqual(len(flux), 2)  # x, y
        self.assertEqual(len(flux[0]), int(geom[0]['width']/delta))
        self.assertEqual(flux[0][0], delta/2.0)
        self.assertEqual(flux[0][-1], geom[0]['width']-delta/2.0)
        self.assertEqual(len(flux[1]), int(geom[0]['width']/delta))
Exemplo n.º 5
0
    def test_uniform_zeroflux_bc(self):
        
        xs = CrossSection()
        xs.set([[1.58, 0.02, 0.0, 1.0],[0.271, 0.0930, 0.168, 0.0]])
        xs.set_smat( [[0.0, 0.0178], [0.0, 0.0]])
        xs.calc_sigr()

        delta = 1.0
        geom = [{'xs':xs, 'width':100}]

        # geometry setting
        nodes = []        
        for r in geom:
            for k in range(int(r['width']/delta)):
                the_node = Node(r['xs'])
                the_node.set_width(delta)
                nodes.append(the_node)
        
        keff = 1.0
        keff_old = 1.0
        total_fis_src_old = 1.0
        conv = 1.0e-8
        
        # outer iteration
        for ik in range(100):

            # normalize total fission source
            total_fis_src = 0.0
            for the_node in nodes:
                for kg in range(2):
                    total_fis_src += the_node.get_fis_src(kg) * the_node.get_width()
            factor = 1.0 / (total_fis_src/keff)

            for the_node in nodes:
                for kg in range(2):
                    the_node.normalize_fis_src(kg, factor)       

            # energy loop
            for kg in range(2):

                # update scattering source
                for the_node in nodes:
                    the_node.calc_scat_src(kg)

                # inner loop
                for i in range(4):
                    for istart in range(2):  # start color (0: red, 1:black)
                        for ix in range(istart, len(nodes), 2):
                        
                            # pass partial currents to adjacent nodes
                            if(ix==0):
                                jin_xm = -nodes[ix].get_jout(kg, XM)
                            else:
                                jin_xm = nodes[ix-1].get_jout(kg, XP)
                            
                            if(ix==len(nodes)-1):
                                jin_xp = -nodes[ix].get_jout(kg, XP)
                            else:
                                jin_xp = nodes[ix+1].get_jout(kg, XM)

                            nodes[ix].set_jin(kg, XM, jin_xm)
                            nodes[ix].set_jin(kg, XP, jin_xp)
                            
                            # calculate jout, flux with response matrix
                            nodes[ix].calc(kg)
                
                # update fission source
                for the_node in nodes:
                    the_node.calc_fis_src(kg)

            # calc total fission source and keff
            total_fis_src = 0.0
            for the_node in nodes:
                for kg in range(2):
                    total_fis_src += the_node.get_fis_src(kg) * the_node.get_width()   
                
            keff = total_fis_src / (total_fis_src_old/keff_old)
            diff = abs((keff - keff_old)/keff)
            # print( keff, diff)            

            # convergence check
            if(diff < conv):
                break

            # update parameters
            total_fis_src_old = total_fis_src
            keff_old = keff
            for the_node in nodes:
                the_node.set_keff(keff)

        # --- end of loop for outer iterations

        # converged
        print("keff=", keff)

        # debug
        #print("fast flux")
        #for ix in range(len(nodes)):
        #    print(ix, nodes[ix].get_flux(0))

        b2 = (math.pi / geom[0]['width'])**2

        kana_nume = (xs.sigr(1) + xs.dif(1)*b2)*xs.nusigf(0) + xs.sigs(0,1)*xs.nusigf(1)
        kana_deno = (xs.dif(0)*b2 + xs.sigr(0) ) * (xs.dif(1)*b2 + xs.sigr(1))
        kana = kana_nume / kana_deno
        print("kana=", kana)

        self.assertAlmostEqual(keff, kana, places=4)