An Algorithm for the semi-analytical Computation of Fields emitted in layered Ground by HVDC Electrodes