def _sum_piece(wavelength, compound):
    """
    Helper for neutron_composite_sld which precomputes quantities of interest
    for material fragments in a composite formula.
    """
    molar_mass = num_atoms = 0
    sigma_a = sigma_s = b_c = 0
    is_energy_dependent = False
    for element, quantity in compound.atoms.items():
        molar_mass += element.mass * quantity
        num_atoms += quantity
        sigma_a += quantity * element.neutron.absorption
        sigma_s += quantity * element.neutron.total
        b_c += quantity * element.neutron.b_c
        is_energy_dependent |= element.neutron.is_energy_dependent
    return num_atoms, molar_mass, b_c, sigma_s, sigma_a
