Analysis and optimization of a Puffer-type water heater