コード例 #1
0
              str("%.6e" % kResid[-1]) + "     " + str("%.6e" % fluxResid[-1]))
        if i > 10:
            break
        i += 1
    print("======================================================")
    print("Final Flux Vector Estimate:")
    print(flux[-1])
    print("======================================================")
    return k, flux


if __name__ == "__main__":
    # Load xs database
    import materials.materialMixxer as mx
    import utils.pinCellMatCalc as pcm
    mx.genMaterialDict('./materials/newXS')
    # Create pin cell material
    pinCellMaterial = pcm.createPinCellMat()
    modDict = {'u235': False, 'u238': False, 'zr90': False}
    resDict = {'h1': False, 'o16': False, 'zr90': False}
    ssPinCellMaterial = pinCellMaterial.selfSheild(modDict, resDict)
    # ssPinCellMaterial = pinCellMaterial.selfSheild()
    # Solve k-eigenvalue problem
    kVec, fluxVec = solveCrit(ssPinCellMaterial, k0=1.1)
    # Print f-factors for u238 and u235
    print(ssPinCellMaterial.microDat['u235']['f'])
    print(ssPinCellMaterial.microDat['u238']['f'])
    # Compute U235 and U238 reaction rates
    # numberDensity235 = pinCellMaterial.nDdict['u235']
    # numberDensity238 = pinCellMaterial.nDdict['u238']
    # u235 = mx.mixedMat({'u235': numberDensity235})
コード例 #2
0
# To execute unittests ensure your pwd is in ./src
# exec:
#   python -m unittest unittest.test1DsnCell
#
# Author: William Gurecky
# Contact: [email protected]
#

import unittest
import numpy as np
import sn1Dcell as snc1d

# Load xs database
import materials.materialMixxer as mx
import utils.pinCellMatCalc as pcm
mx.genMaterialDict('./materials/hw2')
pinMaterial = pcm.createPinCellMat()


class test1DsnCell(unittest.TestCase):
    def testCheckScalarFlux(self):
        cell = snc1d.Cell1DSn(1.0, 1.0, source='fission', places=4)
        # group 1 scalar flux:
        self.assertAlmostEqual(cell._evalScalarFlux(1), 1., places=4)
        # group 9 scalar flux:
        self.assertAlmostEqual(cell._evalScalarFlux(9), 1.0)
        # sum over all groups (default is 10 energy grps)
        grpScalarFlux = []
        for g in range(10):
            grpScalarFlux.append(cell._evalScalarFlux(g))
        # 10 energy groups with flux == 1.0 in each group should sum to 10.
コード例 #3
0
ファイル: test1DsnSweep.py プロジェクト: wgurecky/spyTran
import unittest
import numpy as np
import sn1D as sn

# Load xs database
import materials.materialMixxer as mx
import utils.pinCellMatCalc as pcm
mx.genMaterialDict('./materials/hw2')
pinMaterial = pcm.createPinCellMat()

# plotters
import plotters.fluxEplot as flxPlt
import plotters.scalarFluxPlot as sfp


class test1DsnCell(unittest.TestCase):

    def testSetBCs(self):
        print("\n========= CHECKING BOUNDARY CONDITION ASSIGNMENT ==========")
        mesh1D = sn.Mesh1Dsn([0, 100], 1.0, pinMaterial, sN=4)
        bcs = {0: {'vac': (1, 0)}, -1: {'vac': (2, 0)}}
        mesh1D.setBCs(bcs)
        #
        # exterior cells
        self.assertEqual(mesh1D.cells[0].applyBC(0), True)
        self.assertEqual(mesh1D.cells[-1].applyBC(0), True)
        self.assertEqual(mesh1D.cells[0].ordFlux[:, 1, :].all(), 0.0)
        self.assertEqual(mesh1D.cells[0].ordFlux[:, 0, :].all(), 1.0)
        self.assertEqual(mesh1D.cells[0].ordFlux[:, 2, :].all(), 1.0)
        self.assertEqual(mesh1D.cells[-1].ordFlux[:, 2, :].all(), 0.0)
        self.assertEqual(mesh1D.cells[-1].ordFlux[:, 1, :].all(), 1.0)
コード例 #4
0
import unittest
import numpy as np
# Load xs database
import materials.materialMixxer as mx
mx.genMaterialDict('./materials/testXS')

# plotters
import plotters.xsPlot as xsplt


class test1Dbeam(unittest.TestCase):
    def testXSplot(self):
        """ Test ability to read XS file, and
        plot xs at multiple dilutions.
        """
        feMat = mx.mixedMat({'fe56': 1.0})
        feMat.setDensity(8.0)
        ffactors = feMat.microDat['fe56']['ffactor']
        totxs = feMat.microDat['fe56']['total']
        # plot at infinite dilution
        xsplt.xsPlot(totxs[::-1], label='Fe56 inf dilution')
        # plot at 10e-1 dilution
        totxs_ssheild = totxs * ffactors[:, 5]
        xsplt.xsPlot(totxs_ssheild[::-1],
                     label='Fe56 10e-1 dilution',
                     style='--')
        # Verify thermal XS is close to true val
        xsAt00253ev = 14.96
        print("Thermal XS diff: " + str(xsAt00253ev - totxs_ssheild[-2]) +
              " [b]")
        xsplt.xsPlot(np.ones(10) * xsAt00253ev, label='XS at 0.0253eV [KAERI]')
コード例 #5
0
ファイル: testXS.py プロジェクト: wgurecky/spyTran
import unittest
import numpy as np
# Load xs database
import materials.materialMixxer as mx
mx.genMaterialDict('./materials/testXS')

# plotters
import plotters.xsPlot as xsplt


class test1Dbeam(unittest.TestCase):

    def testXSplot(self):
        """ Test ability to read XS file, and
        plot xs at multiple dilutions.
        """
        feMat = mx.mixedMat({'fe56': 1.0})
        feMat.setDensity(8.0)
        ffactors = feMat.microDat['fe56']['ffactor']
        totxs = feMat.microDat['fe56']['total']
        # plot at infinite dilution
        xsplt.xsPlot(totxs[::-1], label='Fe56 inf dilution')
        # plot at 10e-1 dilution
        totxs_ssheild = totxs * ffactors[:, 5]
        xsplt.xsPlot(totxs_ssheild[::-1], label='Fe56 10e-1 dilution', style='--')
        # Verify thermal XS is close to true val
        xsAt00253ev = 14.96
        print("Thermal XS diff: " + str(xsAt00253ev - totxs_ssheild[-2]) + " [b]")
        xsplt.xsPlot(np.ones(10) * xsAt00253ev, label='XS at 0.0253eV [KAERI]')

    def testSSheild(self):