sens0_path (str) – Path to the Serpent _sens0.m sensitivity file.
results_path (str) – Path to the Serpent _res.m results file.
kind (str, optional) – Kind of observable, by default "keff". Only "keff" is
supported; other kinds raise a ValueError.
materials (list of str, optional) – Materials for which the sensitivity is extracted. Defaults to
["total"].
zailist (list of int, optional) – ZAIs to extract from the sensitivity file. Defaults to all ZAIs
present in the file.
pertlist (list of str, optional) – Perturbations to extract from the sensitivity file. Defaults to
the standard set of reactions.
m (float, optional) – Measured value for the application. Default is None.
dm (float, optional) – Measurement uncertainty. Default is None.
flux_det (tuple of (str, str), optional) – A (det_name,det_path) pair identifying the Serpent detector
whose tally is used to build a FluxSpectrum. When
None (default) no flux spectrum is attached.
Returns:
An Application with the calculated value, sensitivity, and
(optionally) flux spectrum extracted from the Serpent files.
file_path (str) – file path where the database is located.
titles (list, optional) – Titles which have to be extracted from the database, if None
return all the applications available in the database, by default None.
kind (str, default "keff") – HDF5 group (kind of observable) the applications are read from.
Returns:
Returns an ApplicationSuite object containing the imported Application objects.
Module containing the AssimilationSuite class, which is used to
manage a collection of benchmark, application and covariance data
for assimilation purposes.
Class to manage a collection of benchmark, application and covariance
data for assimilation purposes. This class can be used to assemble a complete
dataset for assimilation, and to perform operations on the entire suite.
Concatenate calculated values from all benchmarks and applications.
This property gathers calculated values from available benchmark and
application suites, aligns them by their titles, and fills missing
values with zeros to create a unified calculated value vector.
Returns:
A combined Series containing calculated values, aligned by index.
Return type:
pd.Series
Raises:
ValueError – If both benchmarks and applications are None or empty.
Generate a ck-similarity matrix for the current assimilation suite.
Returns:
A dataframe containing the similarity coefficients between
all benchmarks and applications in the AssimilationSuite.
Entries are NaN for a case whose nuclear data variance
S^TCS is zero (e.g. no sensitivity to any covaried data).
Concatenate calculated value uncertainties from all benchmarks and applications.
This property gathers calculated value uncertainties from available benchmark
and application suites, aligns them by their titles, and fills missing
values with zeros to create a unified calculated value uncertainty vector.
Returns:
A combined Series containing calculated value uncertainties, aligned by index.
Return type:
pd.Series
Raises:
ValueError – If both benchmarks and applications are None or empty.
Relative first-order change of every case’s response (e.g. keff) when
the prior multigroup data self.prior_xs is replaced by xs_other.
self.prior_xs is the library the sensitivities self.s were generated
with. For a posterior suite, suite.delta_response(suite.xs) gives the
first-order effect of the adjustment. See andalus.utils.delta_response().
Parameters:
xs_other (CrossSectionMG) – Multigroup data to switch to.
by (None, str or list of str, default None) – Index levels to keep, from "ZAI", "MT", "E_min_eV" and "E_max_eV",
e.g. ["ZAI","MT"] for the contribution per reaction. None gives the total
per case. See andalus.utils.delta_response().
Concatenate flux vector uncertainties data from all benchmarks and applications.
This property gathers flux vector uncertainty vectors from available benchmark
and application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity uncertainty matrix.
Returns:
A combined DataFrame containing flux vector uncertainties, aligned
along the columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
Concatenate sensitivity uncertainties data from all benchmarks and applications.
This property gathers sensitivity uncertainty vectors from available benchmark
and application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity uncertainty matrix.
Returns:
A combined DataFrame containing sensitivity uncertainties, aligned
along the columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
This is the cosine similarity of the sensitivity vectors.
Returns:
A DataFrame with shape (N,N) containing the E-index values
between every pair of benchmarks and applications in the suite.
Entries are NaN when either sensitivity vector is all zeros.
Concatenate flux data from all benchmarks and applications.
This property gathers flux vectors from available benchmark and
application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity matrix.
Returns:
A combined DataFrame containing flux vectors, aligned along the
columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
This is the cosine similarity of the flux vectors.
Returns:
A DataFrame with shape (N,N) containing the flux similarity values
between every pair of benchmarks and applications in the suite.
Entries are NaN when either flux vector is all zeros.
Perform a GLLS update [1] on the assimilation suite using the sensitivity
profiles and covariance data loaded in the AssimilationSuite. This method updates
the calculated response and the covariance matrices.
Parameters:
include_sensitivity_uncertainty (bool, default False) – Add the variance caused by the statistical uncertainty of the Monte Carlo
sensitivities to the benchmark covariance, see _sensitivity_covariance().
Returns:
A new AssimilationSuite instance with updated calculated values. Applications
are optional: without them, only the nuclear data and the benchmarks are
adjusted and the posterior keeps the (empty) applications of this suite.
Its xs_adjustment is relative to the original prior (prior_xs): when
this suite is already a posterior, the new step is combined with the earlier
adjustment as (1+previous)*(1+step)-1.
Propagate the nuclear data uncertainty through the sensitivity profiles
to calculate the contribution of the nuclear data uncertainty to the
overall uncertainty in the calculated values.
Returns:
A Series containing the propagated nuclear data uncertainty for each case in the suite.
Concatenate sensitivity data from all benchmarks and applications.
This property gathers sensitivity vectors from available benchmark and
application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity matrix.
Returns:
A combined DataFrame containing sensitivities, aligned along the
columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
Print a summary of the assimilation suite, including the number of benchmarks and applications,
the titles of the cases included, and the chi-squared values with and without nuclear data.
Export the current assimilation suite to an adjusted ACE library format via SANDY.
This method iterates through the unique ZAIs in the cross-section adjustments,
retrieves the base ENDF6 files from the specified library, applies the
calculated perturbations, and generates ACE files. Optionally, it can
append entries to a Serpent-style ‘xsdata’ directory file.
Parameters:
library (str) – Path to the base ENDF6 library or the name of the library
recognized by sandy.
reaction_dict (dict, optional) – A dictionary mapping ENDF6 MF numbers to the ANDALUS MT numbers
exported from that file, {MF:[MT_list]}. Only MF31 (nubar),
MF33 (cross sections) and MF35 (chi, e.g. 35018) are supported, as
these are the only perturbation kinds SANDY applies. Default:
{31:[456],33:[2,4,18,102],35:[35018]}.
verbose (bool, default False) – If True, prints detailed progress and SANDY execution logs.
temperature (int, default 300) – The temperature in Kelvin for the ACE file generation.
create_xsdata (bool, default False) – If True, appends isotope definitions to ‘adjusted.xsdata’
formatted for the Serpent Monte Carlo code.
parallel (bool, default False) – If True, process ZAIs concurrently using a thread pool.
max_workers (int | None, default None) – Maximum number of worker threads used when parallel=True.
If None, Python chooses a default.
only_zais_applications (bool, default False) – If True, only process ZAIs that are present in the application suite,
Raises:
ValueError – If self.xs_adjustment is None, indicating no posterior
has been calculated.
Warns:
UserWarning – If xs_adjustment contains MT numbers that are not exported (not
in a supported reaction_dict entry), e.g. mubar (MT 34251). These
adjustments are left out of the ACE files.
Notes
Currently the method supports perturbations to nubar, cross sections
and prompt fission neutron energy spectrum. Mubar (MF34) adjustments
cannot be exported: SANDY ignores MF34 perturbations.
See also
sandy.get_endf6_file
The underlying function for library retrieval.
sandy.Samples
Object used to containerize perturbations.
sandy.Endf6.apply_perturbations
The function that applies perturbations and generates ACE files.
Export cross-section, nu-bar, and chi adjustments directly onto existing ACE files.
Unlike to_ace, which reprocesses each isotope from ENDF via SANDY/NJOY
(a matter of minutes per isotope), this method edits an already-processed
ACE file’s XSS array directly via andalus.ace.ACE.perturb/perturb_nu/
perturb_chi, which takes a fraction of a second per isotope. It requires
a source ASCII ACE file per ZAI being adjusted; it does not talk to ENDF
or run NJOY.
MTs are routed by ANDALUS’s own numbering convention: 452/456 go to
perturb_nu, MT >= 35000 (ANDALUS’s MF*1000+MT chi encoding, e.g.
35018 for prompt fission chi) go to perturb_chi, MF34 Legendre
moments (34000 <= MT < 35000, e.g. 34251 for mubar) are skipped with a
warning, since the ACE angular distributions are not perturbed, and
everything else goes to perturb.
Source ACE files can be located either by directory convention
(ace_dir) or, for libraries that don’t follow that naming convention
(e.g. JEFF-4.0’s 1-H-1g-300.0), via a Serpent-style xsdata directory
file (xsdata_path). Exactly one of the two must be given.
Parameters:
out_dir (str) – Directory to write perturbed ACE files to (created if it doesn’t
exist). Written files are named {ZAID}.{temperature_code}c
(e.g. 92235.03c for U-235 at 300 K). Metastable states add
300+100*isomeric_state to the mass number in the ZAID, so
Am-242m is written as 95642.03c and Am-242 as 95242.03c.
ace_dir (str, optional) – Directory containing source ACE files, named
{ZAID}.{temperature_code}c with the same ZAID convention as
the written files (95642.03c for Am-242m). Mutually exclusive
with xsdata_path.
xsdata_path (str, optional) – Path to a Serpent-style xsdata file mapping ZAIDs to source ACE
file paths (relative paths are resolved against the xsdata file’s
directory), allowing source libraries with arbitrary file naming.
The transport entry (type 1) with the same ZA, isomeric state and
a temperature within 1 K of temperature is used. Mutually
exclusive with ace_dir.
temperature (int, default 300) – Temperature in Kelvin, used to build the ACE filename suffix
(e.g. 300 -> “03c”) and to select the source file from
xsdata_path.
verbose (bool, default False) – If True, log progress for each ZAI (at INFO level).
only_zais_applications (bool, default False) – If True, only process ZAIs present in the application suite.
create_xsdata (bool, default False) – If True, writes a Serpent-style xsdata directory file
(adjusted.xsdata in out_dir) listing the written ACE files,
with the ZA, isomeric state and atomic mass (from the ACE file’s
AWR) of each nuclide.
Returns:
Paths to the written ACE files, one per processed ZAI.
Return type:
list[str]
Raises:
ValueError – If self.xs_adjustment is None, indicating no posterior has
been calculated, or if ace_dir/xsdata_path are not given
exactly one at a time.
FileNotFoundError – If the source ACE file for a ZAI cannot be located, e.g. when
xsdata_path has no entry for it at temperature.
Warns:
UserWarning – If xs_adjustment contains MF34 Legendre moment adjustments
(e.g. mubar, MT 34251), which are left out of the ACE files.
sens0_path (str) – Path to the Serpent _sens0.m sensitivity file.
results_path (str) – Path to the Serpent _res.m results file.
kind (str, optional) – Kind of observable, by default "keff". Only "keff" is
supported; other kinds raise a ValueError.
materials (list of str, optional) – Materials for which the sensitivity is extracted. Defaults to
["total"].
zailist (list of int, optional) – ZAIs to extract from the sensitivity file. Defaults to all ZAIs
present in the file.
pertlist (list of str, optional) – Perturbations to extract from the sensitivity file. Defaults to
the standard set of reactions.
flux_det (tuple of (str, str), optional) – A (det_name,det_path) pair identifying the Serpent detector
whose tally is used to build a FluxSpectrum. When
None (default) no flux spectrum is attached.
Returns:
A Benchmark with the calculated value, sensitivity, and
(optionally) flux spectrum extracted from the Serpent files.
Experimental correlation coefficients between pairs of benchmarks,
keyed by (title_1,title_2). Pairs not listed are uncorrelated.
(a,b) and (b,a) are equivalent and may not both be given.
file_path (str) – file path where the database is located.
titles (list, optional) – Titles which have to be extracted from the database, if None
return all the benchmarks available in the database, by default None.
kind (str, default "keff") – HDF5 group (kind of observable) the benchmarks are read from.
Returns:
Returns a BenchmarkSuite object containing the imported Benchmark objects.
Module containing the CrossSectionMG class, which is used to represent
and manage multigroup (MG) nuclear data (cross sections, nubar, chi, …).
Cross sections inherit from pandas DataFrames with a
(ZAI,MT,E_min_eV,E_max_eV) MultiIndex and a single column holding
the values of one library. They can be read from NJOY GROUPR (GENDF) or ERRORR files via SANDY,
stored in HDF5, and combined with relative sensitivity profiles to estimate
the effect of a change in nuclear data on a response (e.g. keff).
Multigroup nuclear data with a (ZAI,MT,E_min_eV,E_max_eV) index.
The frame has a single column, named after the library the data comes
from (e.g. "jeff40"). Values are in the natural units of each MT:
barns for cross sections, dimensionless for nubar, and group fractions
(summing to 1) for chi.
Sensitivity coefficients are relative, \(S = (dk/k)/(d\sigma/\sigma)\).
Differences between two libraries must therefore be expressed relative to
the library the sensitivities were computed with, see
relative_difference() and andalus.utils.delta_response().
Construct a CrossSectionMG from NJOY ERRORR output files using SANDY.
Parameters:
files (dict[str, str]) – Dictionary mapping section names ('errorr31', 'errorr33',
'errorr34', 'errorr35') to file paths. The MT numbers of
errorr34/errorr35 are offset by 34000/35000, as in Covariance.
zai (int) – Nuclide identifier (ZAI).
mts (list of int, optional) – Filter for specific MT numbers (after offsetting).
temperature (float, optional) – Temperature at which the data was generated.
label (str, default "xs") – Column name, i.e. the name of the library.
Returns:
Multigroup data with index (ZAI,MT,E_min_eV,E_max_eV).
Construct a CrossSectionMG from an NJOY GROUPR output (GENDF) file using SANDY.
Unlike ERRORR, which only writes the reactions it has a covariance for,
GROUPR gives the multigroup data of every requested reaction, also for
evaluations without any covariance data.
Parameters:
path (str) – Path to the GENDF file, produced with one temperature, one
background cross section and Legendre order 0.
zai (int) – Nuclide identifier (ZAI).
mts (list of int, optional) – Filter for specific MT numbers (after offsetting).
temperature (float, optional) – Temperature at which the data was generated.
label (str, default "xs") – Column name, i.e. the name of the library.
Returns:
Multigroup data with index (ZAI,MT,E_min_eV,E_max_eV).
MT numbers follow the ERRORR convention of from_errorr(): mubar
(MF3 MT251) is stored as 34251 and the fission spectrum (MF5 MT18) as
35018. Only a fission spectrum given as a single vector is read; an
incident-energy dependent chi matrix is skipped with a warning.
items (dict[int, CrossSectionMG]) – Mapping of ZAI to data. Each value may have a 3-level
(MT,E_min_eV,E_max_eV) or a 4-level index; in the latter case
the ZAI level is replaced by the dictionary key.
This is the dimensionless quantity that must be multiplied with a
relative sensitivity coefficient. other must be the library the
sensitivities were computed with. Bins where the reference is zero
(e.g. below a reaction threshold) get \(\delta = 0\).
Only bins present in both objects are returned.
Parameters:
other (CrossSectionMG or pd.Series) – Reference library with a compatible (ZAI,MT,E_min_eV,E_max_eV) index.
Append the data to an HDF5 file, one table per ZAI under zai_{ZAI}/xs/data.
The layout is compatible with the one used by Covariance.to_hdf5,
so both can live in the same file.
Parameters:
file_path (str) – Path to the HDF5 file.
merge (bool, default False) – What to do when a ZAI is already stored. If False, its table is
replaced. If True, the stored table is kept and only the MT numbers
present in this object are replaced or added (for example to add
chi, MT 35018, to a library). The stored column name is kept.
Module containing the Sensitivity class, which is used to represent
and manage sensitivity data. Sensitivities inherit from pandas DataFrames,
and have some additional methods for plotting and loading from Serpent output.
Sensitivities are relative, so the cross section difference is divided by the
reference library, which must be the one used to compute s. Bins with a
zero reference cross section and sensitivity bins without cross section data
contribute zero.
Parameters:
xs_ref (CrossSectionMG) – Reference multigroup data, the library s was generated with.
s (pd.DataFrame) – Sensitivities with index (ZAI,MT,E_min_eV,E_max_eV), one column per case.
xs_other (CrossSectionMG) – Multigroup data to switch to.
by (None, str or list of str, default None) – Index levels to keep in the result, from "ZAI", "MT", "E_min_eV" and
"E_max_eV" (case-insensitive). The contributions are summed over the levels that are
not listed. None gives the total per case. For example ["ZAI"] gives the
contribution per nuclide, ["ZAI","MT"] per reaction and ["ZAI","MT","E_min_eV"]
per energy bin. Listing one energy edge adds the other, since both identify a bin.
Returns:
Relative response change per case (Series), or a DataFrame with one column per case
and the requested levels as index. The contributions add up to the total.
Return type:
pd.Series or pd.DataFrame
Raises:
ValueError – If by is invalid, or if the sensitivity and cross section bins do not overlap.
Warns:
UserWarning – If sensitivity bins with a non-zero value have no cross section data.
s2 (pd.Series or pd.DataFrame, optional) – Second sensitivity vector. If None, s2 is assumed to be s1.
Returns:
A Series with a 4-level MultiIndex:
(ZAI_1, MT_1, E_min_eV_1, E_max_eV_1, ZAI_2, MT_2, E_min_eV_2, E_max_eV_2) representing the contribution
of the correlation between those specific bins.
s2 (pd.Series or pd.DataFrame, optional) – Second sensitivity vector. If None, s2 is assumed to be s1.
Returns:
A Series with a MultiIndex (ZAI_1, MT_1, ZAI_2, MT_2) representing the
uncertainty contribution of each reaction, sorted by absolute value.
Return type:
pd.Series
Notes
The two mirrored off-diagonal blocks of a reaction pair, e.g.
(942390, 18, 942390, 102) and (942390, 102, 942390, 18), are summed into
a single entry with (ZAI_1, MT_1) <= (ZAI_2, MT_2). The variances
(signed squares of the returned values) therefore still add up to the
total variance sandwich(s1,cov,s2).
sens0_path (str) – Path to the Serpent _sens0.m sensitivity file.
results_path (str) – Path to the Serpent _res.m results file.
kind (str, optional) – Kind of observable, by default "keff". Only "keff" is
supported; other kinds raise a ValueError.
materials (list of str, optional) – Materials for which the sensitivity is extracted. Defaults to
["total"].
zailist (list of int, optional) – ZAIs to extract from the sensitivity file. Defaults to all ZAIs
present in the file.
pertlist (list of str, optional) – Perturbations to extract from the sensitivity file. Defaults to
the standard set of reactions.
m (float, optional) – Measured value for the application. Default is None.
dm (float, optional) – Measurement uncertainty. Default is None.
flux_det (tuple of (str, str), optional) – A (det_name,det_path) pair identifying the Serpent detector
whose tally is used to build a FluxSpectrum. When
None (default) no flux spectrum is attached.
Returns:
An Application with the calculated value, sensitivity, and
(optionally) flux spectrum extracted from the Serpent files.
file_path (str) – file path where the database is located.
titles (list, optional) – Titles which have to be extracted from the database, if None
return all the applications available in the database, by default None.
kind (str, default "keff") – HDF5 group (kind of observable) the applications are read from.
Returns:
Returns an ApplicationSuite object containing the imported Application objects.
Class to manage a collection of benchmark, application and covariance
data for assimilation purposes. This class can be used to assemble a complete
dataset for assimilation, and to perform operations on the entire suite.
Concatenate calculated values from all benchmarks and applications.
This property gathers calculated values from available benchmark and
application suites, aligns them by their titles, and fills missing
values with zeros to create a unified calculated value vector.
Returns:
A combined Series containing calculated values, aligned by index.
Return type:
pd.Series
Raises:
ValueError – If both benchmarks and applications are None or empty.
Generate a ck-similarity matrix for the current assimilation suite.
Returns:
A dataframe containing the similarity coefficients between
all benchmarks and applications in the AssimilationSuite.
Entries are NaN for a case whose nuclear data variance
S^TCS is zero (e.g. no sensitivity to any covaried data).
Concatenate calculated value uncertainties from all benchmarks and applications.
This property gathers calculated value uncertainties from available benchmark
and application suites, aligns them by their titles, and fills missing
values with zeros to create a unified calculated value uncertainty vector.
Returns:
A combined Series containing calculated value uncertainties, aligned by index.
Return type:
pd.Series
Raises:
ValueError – If both benchmarks and applications are None or empty.
Relative first-order change of every case’s response (e.g. keff) when
the prior multigroup data self.prior_xs is replaced by xs_other.
self.prior_xs is the library the sensitivities self.s were generated
with. For a posterior suite, suite.delta_response(suite.xs) gives the
first-order effect of the adjustment. See andalus.utils.delta_response().
Parameters:
xs_other (CrossSectionMG) – Multigroup data to switch to.
by (None, str or list of str, default None) – Index levels to keep, from "ZAI", "MT", "E_min_eV" and "E_max_eV",
e.g. ["ZAI","MT"] for the contribution per reaction. None gives the total
per case. See andalus.utils.delta_response().
Concatenate flux vector uncertainties data from all benchmarks and applications.
This property gathers flux vector uncertainty vectors from available benchmark
and application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity uncertainty matrix.
Returns:
A combined DataFrame containing flux vector uncertainties, aligned
along the columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
Concatenate sensitivity uncertainties data from all benchmarks and applications.
This property gathers sensitivity uncertainty vectors from available benchmark
and application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity uncertainty matrix.
Returns:
A combined DataFrame containing sensitivity uncertainties, aligned
along the columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
This is the cosine similarity of the sensitivity vectors.
Returns:
A DataFrame with shape (N,N) containing the E-index values
between every pair of benchmarks and applications in the suite.
Entries are NaN when either sensitivity vector is all zeros.
Concatenate flux data from all benchmarks and applications.
This property gathers flux vectors from available benchmark and
application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity matrix.
Returns:
A combined DataFrame containing flux vectors, aligned along the
columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
This is the cosine similarity of the flux vectors.
Returns:
A DataFrame with shape (N,N) containing the flux similarity values
between every pair of benchmarks and applications in the suite.
Entries are NaN when either flux vector is all zeros.
Perform a GLLS update [1] on the assimilation suite using the sensitivity
profiles and covariance data loaded in the AssimilationSuite. This method updates
the calculated response and the covariance matrices.
Parameters:
include_sensitivity_uncertainty (bool, default False) – Add the variance caused by the statistical uncertainty of the Monte Carlo
sensitivities to the benchmark covariance, see _sensitivity_covariance().
Returns:
A new AssimilationSuite instance with updated calculated values. Applications
are optional: without them, only the nuclear data and the benchmarks are
adjusted and the posterior keeps the (empty) applications of this suite.
Its xs_adjustment is relative to the original prior (prior_xs): when
this suite is already a posterior, the new step is combined with the earlier
adjustment as (1+previous)*(1+step)-1.
Propagate the nuclear data uncertainty through the sensitivity profiles
to calculate the contribution of the nuclear data uncertainty to the
overall uncertainty in the calculated values.
Returns:
A Series containing the propagated nuclear data uncertainty for each case in the suite.
Concatenate sensitivity data from all benchmarks and applications.
This property gathers sensitivity vectors from available benchmark and
application suites, aligns them by their MultiIndex, and fills missing
values with zeros to create a unified sensitivity matrix.
Returns:
A combined DataFrame containing sensitivities, aligned along the
columns (axis=1).
Return type:
pd.DataFrame
Raises:
ValueError – If both benchmarks and applications are None or empty.
Print a summary of the assimilation suite, including the number of benchmarks and applications,
the titles of the cases included, and the chi-squared values with and without nuclear data.
Export the current assimilation suite to an adjusted ACE library format via SANDY.
This method iterates through the unique ZAIs in the cross-section adjustments,
retrieves the base ENDF6 files from the specified library, applies the
calculated perturbations, and generates ACE files. Optionally, it can
append entries to a Serpent-style ‘xsdata’ directory file.
Parameters:
library (str) – Path to the base ENDF6 library or the name of the library
recognized by sandy.
reaction_dict (dict, optional) – A dictionary mapping ENDF6 MF numbers to the ANDALUS MT numbers
exported from that file, {MF:[MT_list]}. Only MF31 (nubar),
MF33 (cross sections) and MF35 (chi, e.g. 35018) are supported, as
these are the only perturbation kinds SANDY applies. Default:
{31:[456],33:[2,4,18,102],35:[35018]}.
verbose (bool, default False) – If True, prints detailed progress and SANDY execution logs.
temperature (int, default 300) – The temperature in Kelvin for the ACE file generation.
create_xsdata (bool, default False) – If True, appends isotope definitions to ‘adjusted.xsdata’
formatted for the Serpent Monte Carlo code.
parallel (bool, default False) – If True, process ZAIs concurrently using a thread pool.
max_workers (int | None, default None) – Maximum number of worker threads used when parallel=True.
If None, Python chooses a default.
only_zais_applications (bool, default False) – If True, only process ZAIs that are present in the application suite,
Raises:
ValueError – If self.xs_adjustment is None, indicating no posterior
has been calculated.
Warns:
UserWarning – If xs_adjustment contains MT numbers that are not exported (not
in a supported reaction_dict entry), e.g. mubar (MT 34251). These
adjustments are left out of the ACE files.
Notes
Currently the method supports perturbations to nubar, cross sections
and prompt fission neutron energy spectrum. Mubar (MF34) adjustments
cannot be exported: SANDY ignores MF34 perturbations.
See also
sandy.get_endf6_file
The underlying function for library retrieval.
sandy.Samples
Object used to containerize perturbations.
sandy.Endf6.apply_perturbations
The function that applies perturbations and generates ACE files.
Export cross-section, nu-bar, and chi adjustments directly onto existing ACE files.
Unlike to_ace, which reprocesses each isotope from ENDF via SANDY/NJOY
(a matter of minutes per isotope), this method edits an already-processed
ACE file’s XSS array directly via andalus.ace.ACE.perturb/perturb_nu/
perturb_chi, which takes a fraction of a second per isotope. It requires
a source ASCII ACE file per ZAI being adjusted; it does not talk to ENDF
or run NJOY.
MTs are routed by ANDALUS’s own numbering convention: 452/456 go to
perturb_nu, MT >= 35000 (ANDALUS’s MF*1000+MT chi encoding, e.g.
35018 for prompt fission chi) go to perturb_chi, MF34 Legendre
moments (34000 <= MT < 35000, e.g. 34251 for mubar) are skipped with a
warning, since the ACE angular distributions are not perturbed, and
everything else goes to perturb.
Source ACE files can be located either by directory convention
(ace_dir) or, for libraries that don’t follow that naming convention
(e.g. JEFF-4.0’s 1-H-1g-300.0), via a Serpent-style xsdata directory
file (xsdata_path). Exactly one of the two must be given.
Parameters:
out_dir (str) – Directory to write perturbed ACE files to (created if it doesn’t
exist). Written files are named {ZAID}.{temperature_code}c
(e.g. 92235.03c for U-235 at 300 K). Metastable states add
300+100*isomeric_state to the mass number in the ZAID, so
Am-242m is written as 95642.03c and Am-242 as 95242.03c.
ace_dir (str, optional) – Directory containing source ACE files, named
{ZAID}.{temperature_code}c with the same ZAID convention as
the written files (95642.03c for Am-242m). Mutually exclusive
with xsdata_path.
xsdata_path (str, optional) – Path to a Serpent-style xsdata file mapping ZAIDs to source ACE
file paths (relative paths are resolved against the xsdata file’s
directory), allowing source libraries with arbitrary file naming.
The transport entry (type 1) with the same ZA, isomeric state and
a temperature within 1 K of temperature is used. Mutually
exclusive with ace_dir.
temperature (int, default 300) – Temperature in Kelvin, used to build the ACE filename suffix
(e.g. 300 -> “03c”) and to select the source file from
xsdata_path.
verbose (bool, default False) – If True, log progress for each ZAI (at INFO level).
only_zais_applications (bool, default False) – If True, only process ZAIs present in the application suite.
create_xsdata (bool, default False) – If True, writes a Serpent-style xsdata directory file
(adjusted.xsdata in out_dir) listing the written ACE files,
with the ZA, isomeric state and atomic mass (from the ACE file’s
AWR) of each nuclide.
Returns:
Paths to the written ACE files, one per processed ZAI.
Return type:
list[str]
Raises:
ValueError – If self.xs_adjustment is None, indicating no posterior has
been calculated, or if ace_dir/xsdata_path are not given
exactly one at a time.
FileNotFoundError – If the source ACE file for a ZAI cannot be located, e.g. when
xsdata_path has no entry for it at temperature.
Warns:
UserWarning – If xs_adjustment contains MF34 Legendre moment adjustments
(e.g. mubar, MT 34251), which are left out of the ACE files.
sens0_path (str) – Path to the Serpent _sens0.m sensitivity file.
results_path (str) – Path to the Serpent _res.m results file.
kind (str, optional) – Kind of observable, by default "keff". Only "keff" is
supported; other kinds raise a ValueError.
materials (list of str, optional) – Materials for which the sensitivity is extracted. Defaults to
["total"].
zailist (list of int, optional) – ZAIs to extract from the sensitivity file. Defaults to all ZAIs
present in the file.
pertlist (list of str, optional) – Perturbations to extract from the sensitivity file. Defaults to
the standard set of reactions.
flux_det (tuple of (str, str), optional) – A (det_name,det_path) pair identifying the Serpent detector
whose tally is used to build a FluxSpectrum. When
None (default) no flux spectrum is attached.
Returns:
A Benchmark with the calculated value, sensitivity, and
(optionally) flux spectrum extracted from the Serpent files.
Experimental correlation coefficients between pairs of benchmarks,
keyed by (title_1,title_2). Pairs not listed are uncorrelated.
(a,b) and (b,a) are equivalent and may not both be given.
file_path (str) – file path where the database is located.
titles (list, optional) – Titles which have to be extracted from the database, if None
return all the benchmarks available in the database, by default None.
kind (str, default "keff") – HDF5 group (kind of observable) the benchmarks are read from.
Returns:
Returns a BenchmarkSuite object containing the imported Benchmark objects.
Save the matrix to HDF5 using sparse lower-triangular storage.
Parameters:
file_path (str) – Path to save the HDF5 file.
merge (bool, default False) – What to do when a covariance is already stored for this ZAI. If False, it is
replaced. If True, the stored covariance is kept and only the MT numbers present
in this object are replaced or added, with zero correlation to the other MT
numbers (for example to add the Legendre moment block, MT 34251, to a library).
Multigroup nuclear data with a (ZAI,MT,E_min_eV,E_max_eV) index.
The frame has a single column, named after the library the data comes
from (e.g. "jeff40"). Values are in the natural units of each MT:
barns for cross sections, dimensionless for nubar, and group fractions
(summing to 1) for chi.
Sensitivity coefficients are relative, \(S = (dk/k)/(d\sigma/\sigma)\).
Differences between two libraries must therefore be expressed relative to
the library the sensitivities were computed with, see
relative_difference() and andalus.utils.delta_response().
Construct a CrossSectionMG from NJOY ERRORR output files using SANDY.
Parameters:
files (dict[str, str]) – Dictionary mapping section names ('errorr31', 'errorr33',
'errorr34', 'errorr35') to file paths. The MT numbers of
errorr34/errorr35 are offset by 34000/35000, as in Covariance.
zai (int) – Nuclide identifier (ZAI).
mts (list of int, optional) – Filter for specific MT numbers (after offsetting).
temperature (float, optional) – Temperature at which the data was generated.
label (str, default "xs") – Column name, i.e. the name of the library.
Returns:
Multigroup data with index (ZAI,MT,E_min_eV,E_max_eV).
Construct a CrossSectionMG from an NJOY GROUPR output (GENDF) file using SANDY.
Unlike ERRORR, which only writes the reactions it has a covariance for,
GROUPR gives the multigroup data of every requested reaction, also for
evaluations without any covariance data.
Parameters:
path (str) – Path to the GENDF file, produced with one temperature, one
background cross section and Legendre order 0.
zai (int) – Nuclide identifier (ZAI).
mts (list of int, optional) – Filter for specific MT numbers (after offsetting).
temperature (float, optional) – Temperature at which the data was generated.
label (str, default "xs") – Column name, i.e. the name of the library.
Returns:
Multigroup data with index (ZAI,MT,E_min_eV,E_max_eV).
MT numbers follow the ERRORR convention of from_errorr(): mubar
(MF3 MT251) is stored as 34251 and the fission spectrum (MF5 MT18) as
35018. Only a fission spectrum given as a single vector is read; an
incident-energy dependent chi matrix is skipped with a warning.
items (dict[int, CrossSectionMG]) – Mapping of ZAI to data. Each value may have a 3-level
(MT,E_min_eV,E_max_eV) or a 4-level index; in the latter case
the ZAI level is replaced by the dictionary key.
This is the dimensionless quantity that must be multiplied with a
relative sensitivity coefficient. other must be the library the
sensitivities were computed with. Bins where the reference is zero
(e.g. below a reaction threshold) get \(\delta = 0\).
Only bins present in both objects are returned.
Parameters:
other (CrossSectionMG or pd.Series) – Reference library with a compatible (ZAI,MT,E_min_eV,E_max_eV) index.
Append the data to an HDF5 file, one table per ZAI under zai_{ZAI}/xs/data.
The layout is compatible with the one used by Covariance.to_hdf5,
so both can live in the same file.
Parameters:
file_path (str) – Path to the HDF5 file.
merge (bool, default False) – What to do when a ZAI is already stored. If False, its table is
replaced. If True, the stored table is kept and only the MT numbers
present in this object are replaced or added (for example to add
chi, MT 35018, to a library). The stored column name is kept.
Sensitivities are relative, so the cross section difference is divided by the
reference library, which must be the one used to compute s. Bins with a
zero reference cross section and sensitivity bins without cross section data
contribute zero.
Parameters:
xs_ref (CrossSectionMG) – Reference multigroup data, the library s was generated with.
s (pd.DataFrame) – Sensitivities with index (ZAI,MT,E_min_eV,E_max_eV), one column per case.
xs_other (CrossSectionMG) – Multigroup data to switch to.
by (None, str or list of str, default None) – Index levels to keep in the result, from "ZAI", "MT", "E_min_eV" and
"E_max_eV" (case-insensitive). The contributions are summed over the levels that are
not listed. None gives the total per case. For example ["ZAI"] gives the
contribution per nuclide, ["ZAI","MT"] per reaction and ["ZAI","MT","E_min_eV"]
per energy bin. Listing one energy edge adds the other, since both identify a bin.
Returns:
Relative response change per case (Series), or a DataFrame with one column per case
and the requested levels as index. The contributions add up to the total.
Return type:
pd.Series or pd.DataFrame
Raises:
ValueError – If by is invalid, or if the sensitivity and cross section bins do not overlap.
Warns:
UserWarning – If sensitivity bins with a non-zero value have no cross section data.