Ejemplo n.º 1
0
 def testAtten(self):
     print("\n========= INITIATING BEAM TEST ==========")
     width, dX = 50.0, 0.4
     sNord = 8
     attnMat = mx.mixedMat({'c12': 1.0})
     attnMat.setDensity(2.24)
     print(attnMat.nDdict)
     mesh1D = sn.Mesh1Dsn([0, width], dX, attnMat, sN=sNord)
     # define fixed boundary cond
     srcStrength = 1.e6  # [n / cm**2-s]
     # energy distribution of source (all born at 0.1MeV
     srcEnergy = np.array([1.0, 0, 0.0, 0, 0, 0, 0, 0, 0, 0])
     bcs = {0: {'fixN': (1, [srcStrength, srcEnergy])},
            -1: {'vac': (2, 0)}}
     mesh1D.setBCs(bcs)
     for si in range(1):
         resid = mesh1D.sweepMesh(1)
         if resid < 1e-5:
             break
     scalarFlux = mesh1D.getScalarFlux()
     for g in range(len(srcEnergy)):
         sfp.plot1DScalarFlux(scalarFlux[:][:, g], np.arange(0, width, dX), label='Group ' + str(g + 1))
         sfp.plot1DNeutronND(scalarFlux[:][:, g], np.arange(0, width, dX), g)
     flxPlt.plotFluxE(scalarFlux[-1][::-1])  # flux vs E at left edge
     # plot ord fluxes at leading edge
     ordFlux = mesh1D.getOrdFlux()
     angles = np.arccos(mesh1D.cells[0].sNmu)
     g = 2
     mag = ordFlux[1][g, 0, :] / sum(ordFlux[1][g, 0, :])
     pof.compass(angles, mag, figName='polar_grp3')
     # plot ord fluxes at mid plane
     g = 3
     mag = ordFlux[1][g, 0, :] / sum(ordFlux[1][g, 0, :])
     pof.compass(angles, mag, figName='polar_grp4')
Ejemplo n.º 2
0
 def testKeigenSweep(self):
     print("\n========= INITIATING K-EIGEN TEST ==========")
     width, dX = 4.0, 0.05
     mesh1D = sn.Mesh1Dsn([0, width], dX, pinMaterial, sN=8)
     #bcs = {0: {'vac': (1, 0)}, -1: {'vac': (2, 0)}}  # vac bc test
     bcs = {0: {'ref': (1, 0)}, -1: {'ref': (2, 0)}}  # ref bc test
     mesh1D.setBCs(bcs)
     #
     fissionSrc = []
     mesh1D.setKeff(1.)
     fissionSrc.append(np.sum(mesh1D.fissionSrc()))  # todo mult by width
     scalarFlux = mesh1D.getScalarFlux()
     sfp.plot1DScalarFlux(scalarFlux[:][:, 1], np.arange(0, width, dX))
     for pI in range(8):
         # Perform source iterations
         nSourceIterations = 80
         for si in range(nSourceIterations):
             mesh1D.sweepMesh(10)
         fissionSrc.append(np.sum(mesh1D.fissionSrc()))
         knew = mesh1D.keff * (fissionSrc[-1] / fissionSrc[-2])
         print("Outter iteration: " + str(pI) + "  k-eff :" + str(knew))
         scalarFlux = mesh1D.getScalarFlux()
         flxPlt.plotFluxE(scalarFlux[len(np.arange(0, width, dX)) /
                                     2][::-1])
         sfp.plot1DScalarFlux(scalarFlux[:][:, 1], np.arange(0, width, dX))
         mesh1D.setKeff(knew)
         mesh1D.postSI()
Ejemplo n.º 3
0
 def testKeigenSweep(self):
     print("\n========= INITIATING K-EIGEN TEST ==========")
     width, dX = 4.0, 0.05
     mesh1D = sn.Mesh1Dsn([0, width], dX, pinMaterial, sN=8)
     #bcs = {0: {'vac': (1, 0)}, -1: {'vac': (2, 0)}}  # vac bc test
     bcs = {0: {'ref': (1, 0)}, -1: {'ref': (2, 0)}}   # ref bc test
     mesh1D.setBCs(bcs)
     #
     fissionSrc = []
     mesh1D.setKeff(1.)
     fissionSrc.append(np.sum(mesh1D.fissionSrc()))  # todo mult by width
     scalarFlux = mesh1D.getScalarFlux()
     sfp.plot1DScalarFlux(scalarFlux[:][:, 1], np.arange(0, width, dX))
     for pI in range(8):
         # Perform source iterations
         nSourceIterations = 80
         for si in range(nSourceIterations):
             mesh1D.sweepMesh(10)
         fissionSrc.append(np.sum(mesh1D.fissionSrc()))
         knew = mesh1D.keff * (fissionSrc[-1] / fissionSrc[-2])
         print("Outter iteration: " + str(pI) + "  k-eff :" + str(knew))
         scalarFlux = mesh1D.getScalarFlux()
         flxPlt.plotFluxE(scalarFlux[len(np.arange(0, width, dX)) / 2][::-1])
         sfp.plot1DScalarFlux(scalarFlux[:][:, 1], np.arange(0, width, dX))
         mesh1D.setKeff(knew)
         mesh1D.postSI()
Ejemplo n.º 4
0
 def testAtten(self):
     print("\n========= INITIATING MULT REGION BEAM TEST ==========")
     sNord = 18
     # define fixed source boundary cond
     srcStrength = 1.e6  # [n / cm**2-s]
     # energy distribution of source (all born at 0.1MeV
     srcEnergy = np.array([1.0, 0, 0.0, 0, 0, 0, 0, 0, 0, 0])
     #
     # ## REGION 1 - GRAPHITE ###
     width1, dX1 = 25.0, 1.0
     region1Mat = mx.mixedMat({'c12': 1.0})
     region1Mat.setDensity(1.96)
     region1mesh1D = sn.Mesh1Dsn([0, width1], dX1, region1Mat, sN=sNord)
     bcs1 = {0: {'fixN': (1, [srcStrength, srcEnergy])}}
     region1mesh1D.setBCs(bcs1)
     # ## REGION 2 - BORATED CARBON ###
     width2, dX2 = 25.0, 0.05
     region2Mat = mx.mixedMat({'c12': 0.99, 'b10': 0.01})
     region2Mat.setDensity(1.9)
     region2mesh1D = sn.Mesh1Dsn([width1 + dX1 / 2. + dX2 / 2., width1 + dX1 / 2. + dX2 / 2. + width2], dX2, region2Mat, sN=sNord)
     bcs2 = {-1: {'vac': (2, 0)}}
     region2mesh1D.setBCs(bcs2)
     #
     # ## BUILD DOMAIN ###
     domain = sn.SubDomain()
     domain.addRegion(region1mesh1D)
     domain.addRegion(region2mesh1D)
     domain.buildSweepTree()
     #
     # ## SWEEP DOMAIN ###
     for si in range(180):
         resid = domain.sweepSubDomain(1)
         if resid < 1e-5:
             break
     scalarFlux = domain.getScalarFlux()
     for g in range(len(srcEnergy)):
         pass
     flxPlt.plotFluxE(scalarFlux[-1][::-1])  # flux vs E at left edge
     centroids = [cell.centroid for cell in domain.regions[0].cells]
     centroids += [cell.centroid for cell in domain.regions[1].cells]
     for g in range(len(srcEnergy)):
         sfp.plot1DScalarFlux(scalarFlux[:][:, g], centroids, label='Group ' + str(g + 1))
         # sfp.plot1DNeutronND(scalarFlux[:][:, g], centroids, g)
     # plot ord fluxes at leading edge
     ordFlux = domain.getOrdFlux()
     angles = np.arccos(domain.regions[0].cells[0].sNmu)
     g = 2
     mag = ordFlux[1][g, 0, :] / sum(ordFlux[1][g, 0, :])
     pof.compass(angles, mag, figName='polar_grp3')
     # plot ord fluxes at mid plane
     g = 3
     mag = ordFlux[1][g, 0, :] / sum(ordFlux[1][g, 0, :])
     pof.compass(angles, mag, figName='polar_grp4')
Ejemplo n.º 5
0
 def testAtten(self):
     print("\n========= INITIATING BEAM TEST ==========")
     width, dX = 50.0, 0.4
     sNord = 8
     attnMat = mx.mixedMat({'c12': 1.0})
     attnMat.setDensity(2.24)
     print(attnMat.nDdict)
     mesh1D = sn.Mesh1Dsn([0, width], dX, attnMat, sN=sNord)
     # define fixed boundary cond
     srcStrength = 1.e6  # [n / cm**2-s]
     # energy distribution of source (all born at 0.1MeV
     srcEnergy = np.array([1.0, 0, 0.0, 0, 0, 0, 0, 0, 0, 0])
     bcs = {0: {'fixN': (1, [srcStrength, srcEnergy])}, -1: {'vac': (2, 0)}}
     mesh1D.setBCs(bcs)
     for si in range(1):
         resid = mesh1D.sweepMesh(1)
         if resid < 1e-5:
             break
     scalarFlux = mesh1D.getScalarFlux()
     for g in range(len(srcEnergy)):
         sfp.plot1DScalarFlux(scalarFlux[:][:, g],
                              np.arange(0, width, dX),
                              label='Group ' + str(g + 1))
         sfp.plot1DNeutronND(scalarFlux[:][:, g], np.arange(0, width, dX),
                             g)
     flxPlt.plotFluxE(scalarFlux[-1][::-1])  # flux vs E at left edge
     # plot ord fluxes at leading edge
     ordFlux = mesh1D.getOrdFlux()
     angles = np.arccos(mesh1D.cells[0].sNmu)
     g = 2
     mag = ordFlux[1][g, 0, :] / sum(ordFlux[1][g, 0, :])
     pof.compass(angles, mag, figName='polar_grp3')
     # plot ord fluxes at mid plane
     g = 3
     mag = ordFlux[1][g, 0, :] / sum(ordFlux[1][g, 0, :])
     pof.compass(angles, mag, figName='polar_grp4')
Ejemplo n.º 6
0
def testSlab(widths, modMat, borMat):
    print("\n========= INITIATING MULT REGION TEST ==========")
    ngrps = 10
    sNord = 8
    srcStrength = 1.e10  # [n / cm**3-s]
    # ## REGION WIDTHS
    width1, dx1 = widths[0], 0.1
    end1 = 0 + width1 - dx1
    #
    width2, dx2 = widths[1], 0.02
    start2 = end1 + dx1 / 2 + dx2 / 2
    end2 = start2 + width2 - dx2
    #
    width3, dx3 = widths[2], 0.1
    start3 = end2 + dx2 / 2 + dx3 / 2
    end3 = start3 + width3 - dx3
    #
    width4, dx4 = widths[3], 0.02
    start4 = end3 + dx3 / 2 + dx4 / 2
    #start4 = end3 + dx3 / 1. + dx4 / 1. + 0.04
    end4 = start4 + width4 - dx4
    #
    width5, dx5 = widths[4], 0.1
    start5 = end4 + dx4 / 2 + dx5 / 2
    end5 = start5 + width5 - dx5
    #
    width6, dx6 = widths[5], 0.02
    start6 = end5 + dx5 / 2 + dx6 / 2
    end6 = start6 + width6 - dx6
    #
    width7, dx7 = widths[6], 0.1
    start7 = end6 + dx6 / 2 + dx7 / 2
    end7 = start7 + width7 - dx7
    #
    # ## REGIONS Defs ###
    region1mesh1D = sn.Mesh1Dsn([0, end1 + dx1], dx1, modMat, sN=sNord)
    src = np.zeros((10, 3, sNord))
    src[0, 0, :] = srcStrength
    bcs1 = {0: {'vac': (1, 0)}}
    region1mesh1D.setBCs(bcs1)
    region2mesh1D = sn.Mesh1Dsn([start2, end2], dx2, borMat, sN=sNord, source=src)
    region3mesh1D = sn.Mesh1Dsn([start3, end3], dx3, modMat, sN=sNord)
    region4mesh1D = sn.Mesh1Dsn([start4, end4], dx4, borMat, sN=sNord, source=src)
    region5mesh1D = sn.Mesh1Dsn([start5, end5], dx5, modMat, sN=sNord)
    region6mesh1D = sn.Mesh1Dsn([start6, end6], dx6, borMat, sN=sNord, source=src)
    region7mesh1D = sn.Mesh1Dsn([start7, end7 + dx7], dx7, modMat, sN=sNord)
    bcs2 = {-1: {'vac': (2, 0)}}
    region7mesh1D.setBCs(bcs2)
    # ## BUILD DOMAIN ###
    domain = sn.SubDomain()
    domain.addRegion(region1mesh1D)
    domain.addRegion(region2mesh1D)
    domain.addRegion(region3mesh1D)
    domain.addRegion(region4mesh1D)
    domain.addRegion(region5mesh1D)
    domain.addRegion(region6mesh1D)
    domain.addRegion(region7mesh1D)
    domain.buildSweepTree()
    #
    # ## SWEEP DOMAIN ###
    for si in range(180):
        resid = domain.sweepSubDomain(1)
        if resid < 1e-6:
            pass
            #break
    scalarFlux = domain.getScalarFlux()
    #flxPlt.plotFluxE(scalarFlux[-1][::-1])  # flux vs E at left edge
    centroids = domain.getCentroids()
    # plot all grp fluxes vs space
    for g in range(ngrps):
        sfp.plot1DScalarFlux(scalarFlux[:][:, g], centroids, label='Group ' + str(g + 1), legend=True, enableYlog=False)
        pass
    # plot ord fluxes at center of first absorber strip
    ordFlux = domain.getOrdFlux()
    angles = np.arccos(domain.regions[0].cells[0].sNmu)
    print("ord flux plots at " + str(centroids[92]) + "[cm]")
    for g in range(10):
        mag = ordFlux[92][g, 0, :] / sum(ordFlux[92][g, 0, :])
        #pof.compass(angles, mag, figName='hw3_polar_grp' + str(g + 1))
    # plot absorption rate
    absRate = domain.getAbsRate()
    #sfp.plot1DScalarFlux(absRate, centroids, label='absRate', legend=True, fnameOut='absRate', figNum=20)
    # Rate of leakage out of left and right faces
    leftGrpCurrent, rightGrpCurrent = 0, 0
    for g in range(ngrps):
        leftGrpCurrent += 0.5 * np.sum((domain.regions[0].cells[0].wN[:] * np.abs(domain.regions[0].cells[0].sNmu[:]) *
                                       domain.regions[0].cells[0].totOrdFlux[g, 1, :])[sNord/2:])
        rightGrpCurrent += 0.5 * np.sum((domain.regions[6].cells[-1].wN[:] * np.abs(domain.regions[6].cells[-1].sNmu[:]) *
                                         domain.regions[6].cells[-1].totOrdFlux[g, 2, :])[:sNord/2])
    # total neutron production rate (3x abs pins of width 2cm)
    totProd = 1e10 * 2 * 3   # (n/s-cm^3) * (cm)  -> n/s-cm^2
    # fraction out left and right face
    lfl = leftGrpCurrent / totProd
    rfl = rightGrpCurrent / totProd
    print("Fraction of source neutrons leaking left= " + str(lfl))
    print("Fraction of source neutrons leaking right= " + str(rfl))
    # non leakage prob
    nlp = 1 - (leftGrpCurrent + rightGrpCurrent) / totProd
    print("Non Leakage Probability= " + str(nlp))
    # compute dimensionless parameter: pi1
    totXS = domain.regions[1].totalXs
    weightedXS = np.max(totXS)
    #weightedXS = np.sum(totXS * domain.getScalarFlux([0, 6]), axis=1)
    totFlux = np.sum(domain.getScalarFlux([0, 6]), axis=1)
    #flux = np.sum(domain.getScalarFlux([1, 3, 5]))
    #pi1 = 6.0 * np.average(weightedXS / totFlux)
    pi1 = 6.0 * weightedXS
    # dump ord fluxes and source to h5 file
    h5data = {'mesh': domain.getCentroids(), 'ordFluxes': domain.getOrdFlux(), 'source': domain.getSource(),
              'scalarFluxes': scalarFlux[:]}
    h5d.writeToHdf5(h5data, '1d_7region.h5')
    return nlp, pi1