optimal energy flow