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
def toy2x2lattice(): """A simple 2x2 model with 4 UO2 fuel pins""" fuel = hydep.BurnableMaterial("fuel", mdens=10.4, U235=8e-4, U238=2e-2, O16=4e-4) clad = hydep.Material("clad", mdens=6, Zr91=4e-2) water = hydep.Material("water", mdens=1, H1=5e-2, O16=2e-2) pin = hydep.Pin([0.42, 0.45], [fuel, clad], outer=water) return hydep.CartesianLattice(2, 2, 1.23, [[pin, pin], [pin, pin]])
def materials(): # TODO Global fixture? fuel = hydep.BurnableMaterial("fuel", mdens=10.4, U235=8.0e-4, U238=2.5e-2, O16=4.6e-4) water = hydep.Material("water", mdens=1.0, H1=4.7e-2, O16=2.4e-2) clad = hydep.Material("clad", mdens=6.5, Zr90=4.32e-2) return {mat.name: mat for mat in [fuel, water, clad]}
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(), )
def test_compBundle(passIsotopes, applyThreshold): fuel0 = hydep.BurnableMaterial("comp bundle 0", mdens=10.4) fuel0[922350] = 7e-4 fuel0[80160] = 4e-2 fuel0[922380] = 2e-2 fuel1 = fuel0.copy() fuel1[942390] = 1e-6 # add trace isotope TRACE_KEY = 541350 TRACE_VALUE = 1e-7 fuel0[TRACE_KEY] = TRACE_VALUE expIsotopes = set(fuel0).union(fuel1) if applyThreshold: for iso in fuel0: if iso.zai == TRACE_KEY: break else: raise ValueError(TRACE_KEY) expIsotopes.remove(iso) kwargs = dict(threshold=TRACE_VALUE) else: kwargs = {} args = [[fuel0, fuel1]] if passIsotopes: args.append(list(expIsotopes)) bundle = utils.compBundleFromMaterials(*args, **kwargs) assert len(bundle.isotopes) == len(expIsotopes) if applyThreshold: assert TRACE_KEY not in bundle.isotopes assert bundle.densities.shape == (2, len(bundle.isotopes)) # check materials for isox, key in enumerate(bundle.isotopes): d0 = fuel0.get(key) assert bundle.densities[0, isox] == (0.0 if d0 is None else d0), key d1 = fuel1.get(key) assert bundle.densities[1, isox] == (0.0 if d1 is None else d1), key
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))
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
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
def model(): mat = hydep.BurnableMaterial("analytic", adens=1.0, volume=1.0) mat["U235"] = 1.0 return hydep.Model(hydep.InfiniteMaterial(mat))
def beavrsMaterials(): """Dictionary of materials from the BEAVRS specification Currently provides: fuel32 -> 3.2 wt% enriched UO2 air -> air zirc4 -> zircaloy 4 cladding water -> unborated water helium -> helium bglass -> boroscillicate glass ss304 -> stainless steel 304 """ fuel3_2 = hydep.BurnableMaterial("fuel32", mdens=10.34, temperature=900, O16=4.6026E-2, O17=1.7533E-5, U234=5.9959E-6, U235=7.4629E-4, U238=2.2317E-2) air = hydep.Material("air", mdens=0.000616, O16=5.2863E-6, O17=2.0137E-9, N14=1.9681E-5, N15=7.1899E-8, Ar36=7.8729E-10, Ar38=1.4844E-10, Ar40=2.3506E-7, C12=6.7564E-9) zirc4 = hydep.Material( "zirc4", mdens=6.55, O16=3.0743E-04, O17=1.1711E-07, Cr50=3.2962E-06, Cr52=6.3564E-05, Cr53=7.2076E-06, Cr54=1.7941E-06, Fe54=8.6699E-06, Fe56=1.3610E-04, Fe57=3.1431E-06, Fe58=4.1829E-07, Zr90=2.1827E-02, Zr91=4.7600E-03, Zr92=7.2758E-03, Zr94=7.3734E-03, Zr96=1.1879E-03, Sn112=4.6735E-06, Sn114=3.1799E-06, Sn115=1.6381E-06, Sn116=7.0055E-05, Sn117=3.7003E-05, Sn118=1.1669E-04, Sn119=4.1387E-05, Sn120=1.5697E-04, Sn122=2.2308E-05, Sn124=2.7897E-05, ) water = hydep.Material("water", mdens=0.7405, temperature=600, B11=3.2210E-5, H1=4.9458E-2, H2=5.6883E-6, O16=2.4672E-2, O17=9.3981E-06) water.addSAlphaBeta("HinH2O") helium = hydep.Material("helium", mdens=0.0015981, He3=3.2219E-10, He4=2.4044E-4) bglass = hydep.BurnableMaterial("bglass", mdens=2.26) for za, adens in ( (130270, 1.74520e-03), (140280, 1.69250e-02), (140290, 8.59790e-04), (140300, 5.67440e-04), (50100, 9.65060e-04), (50110, 3.91890e-03), (80160, 4.65110e-02), (80170, 1.77170e-05), ): bglass[za] = adens ss304 = hydep.Material("ss304", mdens=8.03) for za, adens in ( (140280, 9.52760e-04), (140290, 4.84010e-05), (140300, 3.19440e-05), (240500, 7.67780e-03), (240520, 1.48060e-02), (240530, 1.67890e-03), (240540, 4.17910e-04), (250550, 1.76040e-03), (260540, 3.46200e-03), (260560, 5.43450e-02), (260570, 1.23310e-03), (260580, 1.67030e-04), (280580, 5.60890e-03), (280600, 2.16050e-03), (280610, 9.39170e-05), (280620, 2.99460e-04), (280640, 7.62520e-05), ): ss304[za] = adens return { m.name: m for m in [ss304, bglass, fuel3_2, air, zirc4, water, helium] }