コード例 #1
0
def cs_Rincl(Z, A, yields):
    """Returns incl of residual production
	
	[description]
	
	Arguments:
		Z {[type]} -- [description]
		A {[type]} -- [description]
	"""
    Amax = max(yields.keys())
    nuclist = [100, 101]
    csilist = [cs_nincl(Z, A), cs_pincl(Z, A)]
    sub_frags = {}
    for nz in range(0, int(Z / 2.) + 1):
        for nn in range(0, int((A - Z) / 2.) + 1):
            Ared = min(Amax, nn + nz)

            # print nn, nz, A-Z, Z
            if nn + nz == 0:
                # add pion contribution
                nuclist += [A * 100 + Z, A * 100 + Z - 1, A * 100 + Z + 1]
                csilist += [
                    cs_gpi(A) / 3,
                ] * 3
                continue

            cs_incl = 0
            new_frag = 0
            if (nn == 1) and (nz == 0):
                cs_incl = cs_gn(A)
            elif (nn > 1) and (nz == 0):
                cs_incl = cs_gxn(A, nn)
            elif (nn == 0) and (nz == 1):
                cs_incl = cs_gp(Z)
            elif (nn >= 1) and (nz >= 1):
                cs_incl = cs_gSp(Z, A, nz, nn)
                new_frag = 100 * Ared + Ared / 2 - nz
                if new_frag > 0:
                    csilist.append(cs_incl)
                    nuclist.append(new_frag)
                sub_frags = yields[Ared]

            if cs_incl > 0:
                csilist.append(cs_incl)
                nuclist.append(100 * (A - nn - nz) + Z - nz)
                if sub_frags:
                    suma = 0
                    for nuc, val in sub_frags.iteritems():
                        Af, _, _ = get_AZN(nuc)
                        suma += Af * val
                    norm = Ared / suma

                    for nuc, val in sub_frags.iteritems():
                        if nuc in nuclist:
                            csilist[nuclist.index(nuc)] += val * norm * cs_incl
                        else:
                            csilist.append(val * norm * cs_incl)

    return nuclist, csilist
コード例 #2
0
def spallation_multiplicities(mother):
    '''Calculates the inclusive cross sections of all fragments
	of mothter species (moter is a neucos id) for spallation
	'''
    Am, Zm, _ = get_AZN(mother)

    incl_tab = {}
    cs_sum = 0
    for A_big_frag in range(Am / 2, Am - 1):
        for big_frag in species_by_mass[A_big_frag]:
            _, x, y = get_AZN(mother - big_frag)
            spalled_id = 100 * (x + y) + x

            if (x < 1) or (y < 1):
                # in spallation at least a neutron and proton escape
                continue

            cs_frag = cs_gSp(Zm, Am, x, y)
            cs_sum += cs_frag  # sum of all cross sections to normalize incl_tab

            if big_frag in incl_tab:
                incl_tab[big_frag] += cs_frag
            else:
                incl_tab[big_frag] = cs_frag

            # get low fragment incl_tab from using Counter on a prepared list with x, y outputs
            for dau in resmul[spalled_id]:
                if dau in incl_tab:
                    incl_tab[dau] += cs_frag * resmul[spalled_id][dau]
                else:
                    incl_tab[dau] = cs_frag * resmul[spalled_id][dau]
    for dau in incl_tab:
        # all spallation cross section should match total spallation cross section
        incl_tab[dau] /= where(cs_sum == 0, inf, cs_sum)

    return incl_tab
コード例 #3
0
def cs_gSp_all_inA(A):
    """Cross section summed for all possible spallation events
    """
    n = 0
    cs_summed = 0
    cs_vals = []
    if A in species_by_mass:
        for nuc in species_by_mass[A]:
            A, Z, N = get_AZN(nuc)
            cs_summed = cs_gSp_all(Z, A)
            cs_vals.append(cs_gSp_all(Z, A))
            n += 1

    # return cs_summed / n
    return max(cs_vals)
コード例 #4
0
def list_species_by_mass(Amax, tau=inf):
    '''Returns a dictionary with the species stable enough
	to be produced in spallation.
	'''
    species = {}
    for nuc in [k for k in sorted(spec_data.keys()) if isinstance(k, int)]:
        if (nuc < 100) or (spec_data[nuc]['lifetime'] < tau):
            continue
        At, _, _ = get_AZN(nuc)

        if At in species:
            species[At].append(nuc)
        else:
            species[At] = [nuc]

    return species
コード例 #5
0
def combinations(x, y):
    '''Returns possible combinations of nuclei with mass A<=4
	such that they contain x protons and y neutrons.
	'''
    ncos_id = int((x + y) * 100 + x)
    mass_partitions = partitions(x + y)

    for mass_partition in mass_partitions:
        mass_partition = [f for f in mass_partition if f > 1]
        species = [
            species_by_mass[Af] for Af in mass_partition
            if Af in species_by_mass
        ]
        for c in list(itertools.product(*species)):
            _, z, n = get_AZN(sum(c))
            if (z <= x) and (n <= y):
                yield int(y - n) * (100, ) + int(x - z) * (101, ) + c
コード例 #6
0
def cs_gSp_all(Z, A):
    """Cross section summed for all possible spallation events
	"""
    mother = 100 * A + Z
    cs_tot = 0
    for A_big_frag in range(A / 2, A - 1):
        for big_frag in species_by_mass[A_big_frag]:
            _, x, y = get_AZN(mother - big_frag)
            spalled_id = 100 * (x + y) + x

            if (x < 1) or (y < 1):
                # in spallation at least a neutron and proton escape
                continue

        cs_frag = cs_gSp(Z, A, x, y)
        cs_tot += cs_frag

    return cs_tot
コード例 #7
0
def gxn_multiplicities(mother):
    """Multiplicities for multineutron emission A(g,xn)X
	
	Arguments:
		A {int} -- Nucleon number of the target nucleus
	"""
    cs_sum = 0
    cs_gxn_incl = {100: 0}
    Am, _, _ = get_AZN(mother)

    for xi in range(2, xm(Am)):
        cs = cs_gxn(Am, xi)
        cs_gxn_incl[100] += xi * cs
        cs_gxn_incl[mother - xi * 100] = cs

        cs_sum += cs

    for dau in cs_gxn_incl:
        if cs_gxn_incl[dau] != 0:
            cs_gxn_incl[dau] /= cs_sum

    return cs_gxn_incl
コード例 #8
0
def residual_multiplicities():
    '''Makes a dictionary where the ncos id with x,y number of protons and 
	neutrons emitted are the keys, and the multiplicities of species between A=1-4
	are given, normalized such that they add up to x protons and y neutrons.
	This is a function to precompute the table which is used to find the multiplicities
	of the empirical photomeson model.
	'''
    spalled_nucleons = []
    for Am in species_by_mass:
        for mother in species_by_mass[Am]:
            for A_big_frag in range(Am / 2, Am - 1):
                for big_frag in species_by_mass[A_big_frag]:
                    if big_frag % 100 > mother % 100:
                        continue
                    spalled_frag = mother - big_frag
                    spalled_nucleons.append(spalled_frag)
                    # print spalled_nucleons[-1]
    residual_list = {}
    count = 0
    last = 0
    print 'Completed.... ', 0
    cant = float(len(set(spalled_nucleons)))
    for tot in set(spalled_nucleons):
        count += 1
        # print '--', tot, '--', '{:3.3f}'.format(count/cant)
        if int(100 * count / cant) >= last + 5:
            print 'Completed.... ', int(100 * count / cant)
            last += 5
        _, x, y = get_AZN(tot)
        counts = Counter([e for elem in combinations(x, y) for e in elem])
        suma = 0
        for k, v in counts.iteritems():
            suma += k * v
        for k in counts:
            counts[k] *= tot / float(suma)
        residual_list[tot] = counts.copy()

    return residual_list
コード例 #9
0
def multiplicity_table(mother):
    '''Returns a dict with the multiplicities
	for all fragments from mother is contained.
	The differentence with spallation_inclusive is that
	here all processes are contained
	'''
    gxn_mult = gxn_multiplicities(mother)
    sp_mult = spallation_multiplicities(mother)

    Am, Zm, _ = get_AZN(mother)

    cspi = cs_gpi(Am)
    csp = cs_gp(A=Am)
    csn = cs_gn(Am)
    csxn = cs_gxn_all(Am)
    cs_tot = .28 * Am
    csSp = cs_tot - (cspi + csp + csn + csxn)

    multiplicities = {
        100: 1. * csn / cs_tot,
        101: 1. * csp / cs_tot,
        mother - 100: 1. * csn / cs_tot,
        mother - 101: 1. * csp / cs_tot,
    }

    for dau, mult in gxn_mult.iteritems():
        if dau in multiplicities:
            multiplicities[dau] += mult * csxn / cs_tot
        else:
            multiplicities[dau] = mult * csxn / cs_tot

    for dau, mult in sp_mult.iteritems():
        if dau in multiplicities:
            multiplicities[dau] += mult * csSp / cs_tot
        else:
            multiplicities[dau] = mult * csSp / cs_tot

    return multiplicities