An integrated computational tool for the study of the optical properties of nanoscale devices: Application to solar cells and molecular wires