An application of optimal control to semiconductor bandgap engineering