def test_serpentSolver(runInTempDir, regressionSettings, serpent2x2Problem): # Set hooks for slightly realistic problem XS_KEYS = {"abs", "fiss"} hooks = hdfeat.FeatureCollection( {hdfeat.HOMOG_LOCAL, hdfeat.FISSION_MATRIX, hdfeat.FISSION_YIELDS}, XS_KEYS) solver = hydep.serpent.SerpentSolver() solver.setHooks(hooks) assert solver.hooks == hooks solver.beforeMain(serpent2x2Problem.model, serpent2x2Problem.manager, regressionSettings) timeStep = hydep.internal.TimeStep(0, 0, 0, 0) concentrations = hydep.internal.compBundleFromMaterials( serpent2x2Problem.manager.burnable) # Set a realistic power for this time step POWER = 6e6 res = solver.bosSolve(concentrations, timeStep, POWER) tester = ResultComparator(pathlib.Path(__file__).parent) tester.main(res)
def needs(self): return hdfeat.FeatureCollection( { hdfeat.FISSION_MATRIX, hdfeat.MICRO_REACTION_XS, hdfeat.HOMOG_LOCAL }, {"abs", "nubar", "nsf"}, )
class AnalyticROSolver(hydep.lib.ReducedOrderSolver): """Interface for reduced-order solver Provides the exact flux given the compositions in the same manner as the high-fidelity solver. """ needs = hdfeat.FeatureCollection() @staticmethod def substepSolve(timestep, compositions, _mxs): return transportSolution(compositions.densities[0])
class AnalyticHFSolver(hydep.lib.HighFidelitySolver): """Concrete interface for high fidelity solver""" features = hdfeat.FeatureCollection( {hdfeat.MICRO_REACTION_XS, hdfeat.FISSION_YIELDS}, ) @staticmethod def bosSolve(compositions, timestep, _power): return transportSolution(compositions.densities[0]) @staticmethod def setHooks(needs): pass
def __init__(self): self._model = None self.burnable = None self.hooks = hdfeat.FeatureCollection() self.datafiles = None self._buleads = {} self._problemIsotopes = ProblematicIsotopes(missing=set(), replacements={}) self._textwrapper = TextWrapper(width=75) self._commenter = TextWrapper( width=75, initial_indent=" * ", subsequent_indent=" * ", )
def test_features(): """Test the feature capabilities""" s = hdfeat.FeatureCollection({hdfeat.FISSION_MATRIX}) assert hdfeat.FISSION_MATRIX in s assert len(s) == len(s.features) == 1 assert bool(s) o = hdfeat.FeatureCollection( {hdfeat.MICRO_REACTION_XS, hdfeat.HOMOG_GLOBAL}, {"ABS"}) assert hdfeat.MICRO_REACTION_XS in o assert "ABS" in o for ix, f in enumerate(o): assert f in o if ix >= len(o.features): assert f in o.macroXS else: assert f in o.features # Unions and subsets u = s.union(o) assert all(f in u.features for f in s.features) assert all(f in u.features for f in o.features) assert all(f in u for f in s) assert all(f in u for f in s) assert all(f in u.macroXS for f in s.macroXS) assert all(f in u.macroXS for f in o.macroXS) a = o.union(s) assert a == u assert hash(a) == hash(u) assert s.issubset(u) assert o.issubset(u) with pytest.raises(TypeError): hdfeat.FeatureCollection({"ABS"}) assert not hdfeat.FeatureCollection()
from hydep.lib import HighFidelitySolver from hydep.internal import TransportResult import hydep.internal.features as hdfeat from .writer import BaseWriter, SerpentWriter, ExtDepWriter from .runner import BaseRunner, SerpentRunner, ExtDepRunner from .processor import SerpentProcessor, WeightedFPYHelper, ConstantFPYHelper from .xsavail import XS_2_1_30 __logger__ = logging.getLogger("hydep.serpent") _FEATURES_ATLEAST_2_1_30 = hdfeat.FeatureCollection( ( hdfeat.FISSION_MATRIX, hdfeat.FISSION_YIELDS, hdfeat.HOMOG_GLOBAL, hdfeat.HOMOG_LOCAL, hdfeat.MICRO_REACTION_XS, ), XS_2_1_30, ) class BaseSolver(HighFidelitySolver): """Base solver for interfacing with Serpent >= 2.1.30 Does not provide all methods needed by the :class:`hydep.lib.HighFidelitySolver` other than :attr:`features`, :meth:`setHooks`. :meth:`beforeMain` is partially implemented, but requires a helper method for writing solver-specific input files. Other methods for directly interacting with Serpent are left to concrete