Optical generation in semiconductor-device analysis, a general purpose implementation