pynucastro.reduction.sensitivity_analysis module#
- pynucastro.reduction.sensitivity_analysis.binary_search_trim(network, nuclei, errfunc, thresh=0.05)[source]#
Given an array of nuclei sorted roughly by relative importance, perform a binary search to trim out nuclei from the network until the error is as close as possible to the given threshold without exceeding it. Nuclei whose removal will result in only a small increase in error need to be packed towards the back of the array for the binary search to work effectively.
- Parameters:
network – The network to reduce.
nuclei – Nuclei to consider for the final network, sorted by decreasing importance (i.e. most important nuclei first). Importance can be determined by something like the drgep function.
errfunc – Error function to use when evaluating error. Should take a reduced network as an argument and return the relative error produced by the reduction. This can be a parallel (MPI) function.
thresh – Threshold for acceptable error. Default is 0.05.
- Returns:
A reduced reaction network with an evaluated error approximately equal to the supplied threshold.
- pynucastro.reduction.sensitivity_analysis.sens_analysis(network, errfunc, thresh=0.05, use_mpi=False, print_prog=True)[source]#
Given a reaction network, remove nuclei from the network one-by-one until the induced error is as close to the given threshold as possible without exceeding it. This will test nuclei for removal individually and remove the one that induces the smallest error on each pass. Since it requires O(n^2) error function evaluations, this routine is much more expensive than binary_search, but it will typically trim the network down significantly more.
- Parameters:
network – The network to reduce.
errfunc – Error function to use when evaluating error. Should take a reduced network as an argument and return the relative error produced by the reduction. If use_mpi is False, the error function can be parallelized with MPI. Otherwise sens_analysis will be parallelized and the error function should not be.
thresh – Threshold for acceptable error. Default is 0.05.
use_mpi – Whether to parallelize the loop over nuclei with each pass or not using MPI. For p MPI processes, the parallelized function will require O(n^2/p) error function evaluations per process. This option is False by default. If the error function is parallelized using MPI, this option should be set to False.
print_prog – Whether to print out the progress of the function as it runs or not. Includes a progress bar for each pass and messages indicating when the algorithm starts and ends.
- Returns:
A reduced reaction network with an evaluated error approximately equal to the supplied threshold.