Analysis and design of energy systems : fundamentals and mathematical techniques