def updateBaseNuclide(self): """Update the nuclide base for this :py:class:`~armi.nucDirectory.nuclide.XSNuclide`. Notes ----- During instantiation, not everything is available, only they user-supplied nuclide label, i.e. :py:class:`~armi.nucDirectory.nuclideBases.NuclideWrapper.containerKey`. During the read operation, """ if self._base is not None: return # most nuclides have the correct NuclideBase ID nuclideId = self.isotxsMetadata["nuclideId"] nuclideBase = nuclideBases.byMccId.get(nuclideId, None) if nuclideBase is None or isinstance(nuclideBase, nuclideBases.DummyNuclideBase): # FP, DUMMY, DUMP nuclideBase = nuclideBases.byLabel.get(self.nucLabel, None) if nuclideBase is None: raise exceptions.IsotxsError( "Could not determine NuclideBase for label {}".format( self.nucLabel)) if self.nucLabel != nuclideBase.label: warnings.nuclide_NuclideLabelDoesNotMatchNuclideLabel( nuclideBase, self.nucLabel, self.xsId) nuclideBases.changeLabel(nuclideBase, self.nucLabel) self._base = nuclideBase
def _rw5DRecord(self): """Read principal microscopic MG XS data for a nuclide.""" with self._isotxsIO.createRecord() as record: micros = self._getMicros() nuc = self._nuclide numGroups = self._numGroups micros.transport = record.rwMatrix(micros.transport, self._metadata["ltrn"], numGroups) micros.total = record.rwMatrix(micros.total, self._metadata["ltot"], numGroups) micros.nGamma = record.rwMatrix(micros.nGamma, numGroups) if self._metadata["fisFlag"] > 0: micros.fission = record.rwMatrix(micros.fission, numGroups) micros.neutronsPerFission = record.rwMatrix( micros.neutronsPerFission, numGroups) else: micros.fission = micros.getDefaultXs(numGroups) micros.neutronsPerFission = micros.getDefaultXs(numGroups) if self._metadata["chiFlag"] == 1: micros.chi = record.rwMatrix(micros.chi, numGroups) elif self._metadata["fisFlag"] > 0: if self._fileWideChiFlag != 1: raise exceptions.IsotxsError( "Fissile nuclide {} in library but no individual or global chi!" .format(nuc)) micros.chi = self._fileWideChi else: micros.chi = micros.getDefaultXs(numGroups) # read some other important XS, if they exist for xstype in ["nalph", "np", "n2n", "nd", "nt"]: if self._metadata[xstype]: micros.__dict__[xstype] = record.rwMatrix( micros.__dict__[xstype], numGroups) else: micros.__dict__[xstype] = micros.getDefaultXs(numGroups) # coordinate direction transport cross section (for various coordinate directions) if self._metadata["strpd"] > 0: micros.strpd = record.rwMatrix(micros.strpd, self._metadata["strpd"], numGroups) else: micros.strpd = micros.getDefaultXs(numGroups)
def readWrite(self): self._rwMessage() properties.unlockImmutableProperties(self._lib) try: self._fileID() numNucs = self._rw1DRecord(len(self._lib)) nucNames = self._rw2DRecord(numNucs, self._lib.nuclideLabels) if self._metadata["fileWideChiFlag"] > 1: self._rw3DRecord() for nucLabel in nucNames: # read nuclide name, other global stuff from the ISOTXS library nuc = self._getNuclide(nucLabel) if "r" in self._fileMode: # on add nuclides when reading self._lib[nucLabel] = nuc nuclideIO = self._getNuclideIO()(nuc, self, self._lib) nuclideIO.rwNuclide() except: raise exceptions.IsotxsError( "Failed to read/write {} \n\n\n{}".format( self, traceback.format_exc())) finally: properties.lockImmutableProperties(self._lib)