def _ebind(self, n_indent, of): bintable = BindingTable() for nuc in self.unique_nuclei: nuc_in_table = bintable.get_nuclide(n=nuc.N, z=nuc.Z) str_nucbind = self.fmt_to_dp_f90(nuc_in_table.nucbind) of.write('{}ebind_per_nucleon(j{}) = {}\n'.format( self.indent * n_indent, nuc, str_nucbind))
class TestAME(object): @classmethod def setup_class(cls): """ this is run once for each class before any tests """ pass @classmethod def teardown_class(cls): """ this is run once for each class after all tests """ pass def setup_method(self): """ this is run before each test """ self.bintable = BindingTable() def teardown_method(self): """ this is run after each test """ self.bintable = None def test_get(self): nuc = self.bintable.get_nuclide(n=1, z=1) assert nuc.z == 1 assert nuc.n == 1 assert nuc.nucbind == 1.112283 nuc = self.bintable.get_nuclide(n=5, z=6) assert nuc.z == 6 assert nuc.n == 5 assert nuc.nucbind == 6.676456 nuc = self.bintable.get_nuclide(n=17, z=23) assert nuc.z == 23 assert nuc.n == 17 assert nuc.nucbind == 7.317 nuc = self.bintable.get_nuclide(n=90, z=78) assert nuc.z == 78 assert nuc.n == 90 assert nuc.nucbind == 7.773605
def setup_method(self): """ this is run before each test """ self.bintable = BindingTable()
alpha_p = RateFilter(reactants="he4", products="p", exact=False) # Reverse and weak rates gamma_p = RateFilter(products="p", max_reactants=1, exact=False) gamma_alpha = RateFilter(products="he4", max_reactants=1, exact=False) p_alpha = RateFilter(reactants="p", products="he4", exact=False) beta_plus = RateFilter(filter_function=is_beta_plus) # Compute reduced library red_lib = full_lib.filter( (p_gamma, alpha_gamma, alpha_p, gamma_p, gamma_alpha, p_alpha, beta_plus)) # Make BindingTable a dict for easy containment checking # Perhaps we could modify the BindingTable class to use one? # That can be done without changing the interface bintable = BindingTable() nuclides = {(nuc.n, nuc.z): nuc for nuc in bintable.nuclides} def flatten(iterable): """ Take iterable of iterables, and flatten it to one dimension. """ for col in iterable: for item in col: yield item def append_all(q, iterable): """ Append all items in the iterable to the queue. """