Simulation of organic light-emitting diodes and organic photovoltaic devices