Beispiel #1
0
def depletionModel():
    # Roughly one-fourth volume of fuel in PWR
    VOLUME = math.pi * 0.49**2 * 360 * 264 / 4
    fuel1 = hydep.BurnableMaterial("partially burned PWR fuel",
                                   adens=2.6858e-2,
                                   temperature=900,
                                   volume=VOLUME)

    ISO_THRESH = 1e-10
    CONC_FILE = pathlib.Path(__file__).parent / "partial_burned.dat"
    with CONC_FILE.open("r") as stream:
        for line in stream:
            za, adens = line.split()
            adens = float(adens)
            if adens < ISO_THRESH:
                continue
            z, a = divmod(int(za), 1000)
            fuel1[(z, a, 0)] = adens

    water = hydep.Material("water", mdens=0.7, H1=2, O16=1)
    clad = hydep.Material("clad", mdens=6.6, Zr96=1)

    fuel2 = fuel1.copy()
    fuel3 = fuel1.copy()
    fuel4 = hydep.BurnableMaterial(
        "other fuel",
        adens=fuel1.adens,
        temperature=fuel1.temperature,
        volume=VOLUME,
        O16=4.643355421e-4,
        U234=4.742255584e-9,
        U235=7.403701961e-4,
        U236=1.090905903e-5,
        U238=2.550365361e-2,
    )

    pin1 = hydep.Pin([0.39, 0.42], [fuel1, clad], outer=water)
    pin2 = hydep.Pin([0.39, 0.42], [fuel2, clad], outer=water)
    pin3 = hydep.Pin([0.39, 0.42], [fuel3, clad], outer=water)
    pin4 = hydep.Pin([0.39, 0.42], [fuel4, clad], outer=water)

    PITCH = 1.2

    cart = hydep.CartesianLattice(nx=2,
                                  ny=2,
                                  pitch=1.2,
                                  array=[[pin1, pin2], [pin3, pin4]],
                                  outer=water)

    assembly = hydep.LatticeStack(1, [0, 360], [cart])
    assembly.bounds = ((-PITCH, PITCH), (-PITCH, PITCH), (0, 360))

    # TODO Retrieve boundaries from model if given
    model = hydep.Model(assembly)
    model.bounds = assembly.bounds

    yield model
Beispiel #2
0
def toy2x2Problem(simpleChain, toy2x2lattice):
    # Include the chain so reactions are present
    model = hydep.Model(toy2x2lattice)
    model.differentiateBurnableMaterials(updateVolumes=False)

    burnable = tuple(model.root.findBurnableMaterials())
    for m in burnable:
        m.volume = 1.0

    yield ProblemProxy(model, burnable)
Beispiel #3
0
def test_boundsCheck(root):
    dummy = hydep.Material("dummy", adens=1)
    model = hydep.Model(hydep.InfiniteMaterial(dummy))

    assert model.bounds is None
    assert model.root.bounds is None
    assert not model.isBounded()

    if root:

        def setbounds(x=None, y=None, z=None):
            model.root.bounds = x, y, z

    else:

        def setbounds(x=None, y=None, z=None):
            model.bounds = x, y, z

    setbounds(None, None, None)
    assert not model.isBounded()
    for dim in {"x", "y", "z", "X", "Y", "Z", "all", "AlL"}:
        assert not model.isBounded(dim)

    for dim in {"x", "y", "z"}:
        setbounds(**{dim: (-1, 1)})
        assert model.isBounded(dim)
        setbounds(**{dim: None})

    for bounds in [
        (0, math.inf),
        (-math.inf, math.inf),
        (0, numpy.inf),
        (-math.inf, numpy.inf),
    ]:
        for dim in {"x", "y", "z"}:
            setbounds(**{dim: bounds})
            assert not model.isBounded(dim)
            assert not model.isBounded("all")
            setbounds(**{dim: None})

        setbounds(x=bounds, y=(1, 2), z=None)
        assert not model.isBounded()
        setbounds(x=(1, 2), y=bounds, z=None)
        assert not model.isBounded()

    # Check validity of 2D unbounded Z problems

    setbounds(x=(-1, 1), y=(-1, 1), z=None)
    assert model.isBounded()

    setbounds(x=numpy.arange(2), y=[-0.6, 0.6], z=[0, 360])
    assert model.isBounded()
    assert model.isBounded("x")
    assert model.isBounded("y")
    assert model.isBounded("z")
Beispiel #4
0
def test_model(toy2x2lattice):

    with pytest.raises(TypeError):
        hydep.Model(None)

    with pytest.raises(TypeError):
        hydep.Model(hydep.BurnableMaterial("fuel", adens=1))

    model = hydep.Model(toy2x2lattice)

    assert len([model.root.findBurnableMaterials()]) == 1

    volume = 100
    referenceVol = copy.copy(volume)

    fuel = model.root[0, 0].materials[0]
    assert isinstance(fuel, hydep.BurnableMaterial)

    fuel.volume = volume

    model.differentiateBurnableMaterials(updateVolumes=True)
    assert volume == referenceVol

    N_EXPECTED = model.root.size
    foundOrig = False

    for ix, mat in enumerate(model.root.findBurnableMaterials()):
        assert ix < N_EXPECTED
        assert mat.volume == pytest.approx(referenceVol / N_EXPECTED)
        if mat is fuel:
            assert not foundOrig, "Found fuel multiple times"
            foundOrig = False

    assert model.bounds is None
    width = model.root.pitch * model.root.nx
    height = model.root.pitch * model.root.ny
    bounds = ((-width / 2, width), (-height / 2, height), None)
    model.bounds = bounds

    assert model.bounds.x == pytest.approx(bounds[0])
    assert model.bounds.y == pytest.approx(bounds[1])
    assert model.bounds.z == pytest.approx((-numpy.inf, numpy.inf))
Beispiel #5
0
def serpent2x2Problem(simpleChain, toy2x2lattice):
    # Include the chain so reactions are present
    model = hydep.Model(toy2x2lattice)
    model.differentiateBurnableMaterials(updateVolumes=False)

    burnable = tuple(model.root.findBurnableMaterials())
    for m in burnable:
        m.volume = 2.0  # enforce some division in volumes

    manager = Mock()
    manager.burnable = burnable
    manager.chain = simpleChain

    yield ProblemProxy(model, manager)
Beispiel #6
0
def mockProblem():
    fuel = hydep.BurnableMaterial("fuel", mdens=10.4, volume=1.0, U235=1e-5)
    univ = hydep.InfiniteMaterial(fuel)
    model = hydep.Model(univ)

    # manager
    chain = hydep.DepletionChain(fuel.keys())
    manager = hydep.Manager(chain, [10], 1e6, 1)

    return hydep.PredictorIntegrator(
        model,
        MockHFSolver(),
        MockROMSolver(),
        manager,
        MockStore(),
    )
Beispiel #7
0
def test_manager(toy2x2lattice, manager):

    for ix, (sec, power) in enumerate(manager.preliminarySteps()):
        assert ix < manager.numPreliminary
        assert sec == manager.timesteps[ix]
        assert power == manager.powers[ix]

    numActive = len(manager.timesteps) - manager.numPreliminary
    for ix, (sec, power) in enumerate(manager.activeSteps()):
        assert ix < numActive
        assert sec == manager.timesteps[manager.numPreliminary + ix]
        assert power == manager.powers[manager.numPreliminary + ix]

    toymodel = hydep.Model(toy2x2lattice)

    with pytest.raises(AttributeError, match=".*volume"):
        manager.beforeMain(toymodel)

    fuelM = toymodel.root[0, 0].materials[0]
    assert isinstance(fuelM, hydep.BurnableMaterial)

    ORIG_FUEL_VOLUME = 100
    fuelM.volume = copy.copy(ORIG_FUEL_VOLUME)

    origBurnable = tuple(toymodel.root.findBurnableMaterials())
    assert len(origBurnable) == 1
    assert origBurnable[0] is fuelM

    # Create new burnable materials using Model interface
    # Update volumes along the way
    toymodel.differentiateBurnableMaterials(True)
    N_EXP_MATS = toymodel.root.size

    manager.beforeMain(toymodel)
    foundOrig = False

    for ix, m in enumerate(toymodel.root.findBurnableMaterials()):
        assert ix < N_EXP_MATS
        assert m.volume == pytest.approx(ORIG_FUEL_VOLUME / N_EXP_MATS)
        assert m.index == ix
        assert m is manager.burnable[ix]
        if m is fuelM:
            assert not foundOrig, "Found original fuel multiple times"
            foundOrig = True

    assert foundOrig, "Original fuel was not recovered"
Beispiel #8
0
def pincell():
    fuel = hydep.BurnableMaterial("fuel", mdens=10.4, volume=math.pi * 0.39 * 0.39)
    fuel["O16"] = 4.6391716e-2
    fuel["U234"] = 9.3422610e-6
    fuel["U235"] = 1.0452130e-3
    fuel["U236"] = 4.7875776e-6
    fuel["U238"] = 2.2145310e-2

    water = hydep.Material("water", mdens=1, temperature=600)
    water["H1"] = 5.01543e-2
    water["O16"] = 2.50771e-2
    water.addSAlphaBeta("HinH2O")

    clad = hydep.Material("clad", mdens=6.6, temperature=600)
    clad["Fe56"] = 1.24985e-2
    clad["H1"] = 3.34334e-2
    clad["O16"] = 1.66170e-2

    pin = hydep.Pin([0.39, 0.402], [fuel, clad], outer=water)

    HPITCH = 0.63
    model = hydep.Model(pin)
    model.bounds = pin.bounds = ((-HPITCH, HPITCH), (-HPITCH, HPITCH), None)
    return model
Beispiel #9
0
def simpleSfvProblem(endfChain):
    PIN_RAD = 0.39
    PIN_HEIGHT = 10
    PITCH = 1.2

    volume = math.pi * PIN_RAD**2 * PIN_HEIGHT

    fuel1 = hydep.BurnableMaterial("partial burned PWR fuel",
                                   adens=2.6856e-2,
                                   temperature=900,
                                   volume=volume)

    fuel1[80160] = 4.643e-04
    fuel1[922340] = 4.742e-9
    fuel1[922350] = 7.404e-4
    fuel1[922360] = 1.091e-5
    fuel1[922380] = 2.550e-5
    fuel1[942390] = 2.569e-05
    fuel1[942400] = 1.099e-06
    fuel1[942410] = 1.225e-07
    fuel1[942420] = 1.866e-09

    fuel2 = fuel1.copy()
    fuel3 = fuel1.copy()

    fuel4 = hydep.BurnableMaterial(
        "other fuel",
        adens=fuel1.adens,
        temperature=fuel1.temperature,
        volume=volume,
        O16=4.6433e-4,
        U234=4.742e-9,
        U235=7.403e-4,
        U236=1.091e-5,
        U238=2.55e-2,
    )

    water = hydep.Material("water", mdens=0.7, H1=2, O16=1)
    clad = hydep.Material("clad", mdens=6.6, Zr96=1)

    pin1 = hydep.Pin([PIN_RAD, 0.42], [fuel1, clad], outer=water)
    pin2 = hydep.Pin([PIN_RAD, 0.42], [fuel2, clad], outer=water)
    pin3 = hydep.Pin([PIN_RAD, 0.42], [fuel3, clad], outer=water)
    pin4 = hydep.Pin([PIN_RAD, 0.42], [fuel4, clad], outer=water)

    cart = hydep.CartesianLattice(nx=2,
                                  ny=2,
                                  pitch=1.2,
                                  array=[[pin1, pin2], [pin3, pin4]],
                                  outer=water)

    assembly = hydep.LatticeStack(2, [0, PIN_HEIGHT, 2 * PIN_HEIGHT],
                                  [cart, cart])
    assembly.bounds = ((-PITCH, PITCH), (-PITCH, PITCH), (0, 2 * PIN_HEIGHT))

    model = hydep.Model(assembly)
    model.bounds = assembly.bounds
    model.root.differentiateBurnableMaterials()

    problem = Mock()
    problem.model = model
    problem.dep.burnable = tuple(model.root.findBurnableMaterials())
    problem.dep.chain = endfChain

    settings = hydep.settings.Settings(fittingOrder=1, numFittingPoints=2)
    settings.sfv.densityCutoff = 0.0
    settings.sfv.modes = len(problem.dep.burnable) - 2
    problem.settings = settings

    yield problem
Beispiel #10
0
def model():
    mat = hydep.BurnableMaterial("analytic", adens=1.0, volume=1.0)
    mat["U235"] = 1.0

    return hydep.Model(hydep.InfiniteMaterial(mat))
Beispiel #11
0
def simpleModel():
    univ = hydep.InfiniteMaterial(hydep.Material("inf", adens=1))
    return hydep.Model(univ)
Beispiel #12
0
def write2x2Model(beavrsFuelPin, beavrsControlPin, beavrsGuideTube):
    template = [[0, 0], [1, 2]]
    fill = {0: beavrsFuelPin, 1: beavrsGuideTube, 2: beavrsControlPin}
    asymmetric2x2 = hydep.CartesianLattice.fromMask(1.3, template, fill)

    return hydep.Model(asymmetric2x2)