A performance analysis of ideal engine and heat pump interacting with an external fluid subject to periodic temperature variation