Atomic-scale engineering of nanomaterials for solar energy