Kilonovae
Kilonovae are electromagnetic transients observable in the infrared, optical, and ultraviolet bands (see below for a comparison between the observed data for AT2017gfo and theoretical predictions). Kilonovae originate from the neutron-rich outflows that are created during and after the merger of a binary neutron star or black hole – neutron star systems. During these outflows, it is possible that due to the r-process (see below), heavy, unstable elements can form. These unstable elements decay and form the heavy elements that are present in our Universe. During this decay, they release energy and heat the outflowing material. At some point, the opacity of the ejected material becomes so low that photons can escape, and we are able to observe the thermal spectrum of the merger outflows.
Heavy-element production
The following picture (source: Wikipedia) provides an overview about the creation process of chemical elements in our Universe. While most of the light elements are formed during the big bang (Hydrogen, Helium, Lithium), one needs nuclear physics reactions to form at a later stage more heavy elements. Important channels to produce elements are nuclear fusion in the center of stars or also supernova explosions. The heaviest elements that can be found in our Universe are created during and after the merger process of neutron stars.
Material that gets ejected from neutron stars (see image) leaves the system has initially very high neutron fraction and density. Later, once the matter decompresses due to its expansion, it becomes possible that heavy elements can form due to the so-called r-process The r-process has its name from the word `rapid' and stands for rapid neutron-capture process. The r-process creates the most neutron-rich stable isotopes of each heavy element. The r-process is overall characterized by a rapid capturing of neutron by the nuclei. This process is extremely quick such that the formed elements have time no time to undergo radioactive decay (beta-decay) until another neutron is again captured. This process continues up to the limit of stability of the increasingly neutron-rich nuclei.