You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, it would be nice to add photon production XS parsing. I recently had to systematically plot these XS in a V&V campaign for a new release of D1S nuclear data libraries and I noticed that the part that should parse photon XS is under TODO.
I ended up writing a very small parser based on the ace object of this repo in order to complete my task and I wanted to try and implement it back here. Unfortunately it seems that to install the package in editable mode and to work on it I need C++ compiler which for IT restrictions reasons I cannot install.
I figured that reporting here the small code would still be useful (at least the pure parsing part) in case someone else would like to complete the job. I only dealt with MF 13 derived cross sections and not MF 12 or MF 16 ones.
Here is the code:
classParsedAce:
def__init__(self, file: os.PathLike|str) ->None:
self._ace=ace.get_table(file)
self.energy_grid=self._parse_energy_grid()
self.neutron_MT, self.gamma_MT=self._parse_MTs()
self.photon_xs=self._parse_photon_xs()
defget_photon_MTs(self) ->dict:
"""get the photon MTs for all neutron MTs Parameters ---------- neutron_MT : int _description_ Returns ------- dict _description_ """mts_dict= {}
forarb_mtinself.gamma_MT:
num=int(str(arb_mt)[-3:])
mt=int(str(arb_mt)[:-3])
ifmtinmts_dict:
mts_dict[mt].append(num)
else:
mts_dict[mt] = [num]
returnmts_dictdef_parse_energy_grid(self) ->np.ndarray:
"""parse the global energy grid from the ACE table"""S_ESZ=int(self._ace.jxs[1])
NE_ESZ=int(self._ace.nxs[3])
returnself._ace.xss[S_ESZ : S_ESZ+NE_ESZ]
def_parse_MTs(self) ->tuple[np.ndarray, np.ndarray]:
"""parse the MTs for neutron and gamma reactions"""MTR_LMT=self._ace.jxs[3]
MTR_NMT=self._ace.nxs[4]
MTRP_LMT=self._ace.jxs[13]
MTRP_NMT=self._ace.nxs[6]
neutron_MT=self._ace.xss[MTR_LMT : MTR_LMT+MTR_NMT].astype(int)
gamma_MT=self._ace.xss[MTRP_LMT : MTRP_LMT+MTRP_NMT].astype(int)
returnneutron_MT, gamma_MTdef_parse_photon_xs(self) ->dict:
"""parse the photon cross section data"""LXS=self._ace.jxs[14]
xs_data= {}
fori, mtinenumerate(self.gamma_MT):
LOCA=self._ace.xss[LXS+i]
index=int(self._ace.jxs[15] +LOCA-1)
MF=self._ace.xss[index]
xs= []
e= []
ifMF==12orMF==16:
pass# TODOelifMF==13:
IE=int(self._ace.xss[index+1]) # energy grid indexNE=int(self._ace.xss[index+2]) # number of consecutive entriesxs=self._ace.xss[(index+3) : (index+3+NE)]
e=self.energy_grid[IE-1 : IE-1+NE]
else:
raiseValueError(f"MF {MF} not supported")
xs_data[mt] = {"MT": mt, "energy": e, "xs": xs, "MF": MF}
returnxs_data
The text was updated successfully, but these errors were encountered:
Hi, it would be nice to add photon production XS parsing. I recently had to systematically plot these XS in a V&V campaign for a new release of D1S nuclear data libraries and I noticed that the part that should parse photon XS is under
TODO
.I ended up writing a very small parser based on the
ace
object of this repo in order to complete my task and I wanted to try and implement it back here. Unfortunately it seems that to install the package in editable mode and to work on it I need C++ compiler which for IT restrictions reasons I cannot install.I figured that reporting here the small code would still be useful (at least the pure parsing part) in case someone else would like to complete the job. I only dealt with MF 13 derived cross sections and not MF 12 or MF 16 ones.
Here is the code:
The text was updated successfully, but these errors were encountered: