def _perturbTemps(self, block, cName, tCold, tHot): "Give the component different ref and hot temperatures than in test_Blocks." c = block.getComponent(Flags.fromString(cName)) c.refTemp, c.refHot = tCold, tHot c.applyHotHeightDensityReduction() c.setTemperature(tHot) return block
def _setComponentFlags(component, flags, blueprint): """Update component flags based on user input in blueprint""" # the component __init__ calls setType(), which gives us our initial guess at # what the flags should be. if flags is not None: # override the flags from __init__ with the ones from the blueprint component.p.flags = Flags.fromString(flags) else: # potentially add the DEPLETABLE flag. Don't do this if we set flags # explicitly. WARNING: If you add flags explicitly, it will # turn off depletion so be sure to add depletable to your list of flags # if you expect depletion if any(nuc in blueprint.activeNuclides for nuc in component.getNuclides()): component.p.flags |= Flags.DEPLETABLE
def construct(self, blueprint, matMods): """Construct a component""" runLog.debug("Constructing component {}".format(self.name)) kwargs = self._conformKwargs(blueprint, matMods) component = components.factory(self.shape.strip().lower(), [], kwargs) # the component __init__ calls setType(), which gives us our initial guess at # what the flags should be. if self.flags is not None: # override the flags from __init__ with the ones from the blueprint component.p.flags = Flags.fromString(self.flags) else: # potentially add the DEPLETABLE flag. Don't do this if we set flags # explicitly _insertDepletableNuclideKeys(component, blueprint) return component
def _constructAssembly(self, cs, blueprint): """Construct the current assembly.""" blocks = [] for axialIndex, bDesign in enumerate(self.blocks): b = self._createBlock(cs, blueprint, bDesign, axialIndex) blocks.append(b) assemblyClass = self.getAssemClass(blocks) a = assemblyClass(self.name) flags = None if self.flags is not None: flags = Flags.fromString(self.flags) a.p.flags = flags # set a basic grid with the right number of blocks with bounds to be adjusted. a.spatialGrid = grids.axialUnitGrid(len(blocks)) a.spatialGrid.armiObject = a # TODO: Remove mesh points from blueprints entirely. Submeshing should be # handled by specific physics interfaces radMeshPoints = self.radialMeshPoints or 1 a.p.RadMesh = radMeshPoints aziMeshPoints = self.azimuthalMeshPoints or 1 a.p.AziMesh = aziMeshPoints # loop a second time because we needed all the blocks before choosing the # assembly class. for axialIndex, block in enumerate(blocks): b.p.assemNum = a.p.assemNum b.name = b.makeName(a.p.assemNum, axialIndex) a.add(block) # Assign values for the parameters if they are defined on the blueprints for paramDef in a.p.paramDefs.inCategory( parameters.Category.assignInBlueprints ): val = getattr(self, paramDef.name) if val is not None: a.p[paramDef.name] = val return a
def schema(val) -> List[Flags]: """ Return a list of :py:class:`Flags <armi.reactor.flags.Flags`. Raises ------ TypeError When ``val`` is not a list. ValueError When ``val`` is not an instance of str or Flags. """ if not isinstance(val, list): raise TypeError(f"Expected `{val}` to be a list.") flagVals = [] for v in val: if isinstance(v, str): flagVals.append(Flags.fromString(v)) elif isinstance(v, Flags): flagVals.append(v) else: raise ValueError(f"Invalid flag input `{v}` in `{self}`") return flagVals
def construct(self, blueprint, matMods): """Construct a component""" runLog.debug("Constructing component {}".format(self.name)) kwargs = self._conformKwargs(blueprint, matMods) component = components.factory(self.shape.strip().lower(), [], kwargs) # the component __init__ calls setType(), which gives us our initial guess at # what the flags should be. if self.flags is not None: # override the flags from __init__ with the ones from the blueprint component.p.flags = Flags.fromString(self.flags) else: # potentially add the DEPLETABLE flag. Don't do this if we set flags # explicitly. WARNING: If you add flags explicitly, it will # turn off depletion so be sure to add depletable to your list of flags # if you expect depletion if any(nuc in blueprint.activeNuclides for nuc in component.getNuclides()): component.p.flags |= Flags.DEPLETABLE if component.hasFlags(Flags.DEPLETABLE): # depletable components, whether auto-derived or explicitly flagged need expanded nucs _insertDepletableNuclideKeys(component, blueprint) return component
def dump(self) -> List[str]: """Return a list of strings converted from the flag values.""" return [Flags.toString(v) for v in self.value]
def type(self, value): # pylint: disable=method-hidden """Always set flags when type changes.""" self._p_type = value # pylint: disable=attribute-defined-outside-init self._p_flags = Flags.fromStringIgnoreErrors( value ) # pylint: disable=attribute-defined-outside-init
def type(self, value): self._p_type = value self._p_flags = Flags.fromStringIgnoreErrors(value)
def typeSetter(self, value): """Always set flags when type changes.""" self._p_type = value self._p_flags = Flags.fromStringIgnoreErrors(value)