Confused with heat as a form of energy I have quite a simple question. Energy can be defined as capacity to do work. 
But I have read

When energy is exchanged between thermodynamic systems by thermal interaction, the transfer of energy is called heat.

I can't understand what is the work done. For example, what is the work done in cooling water from 20 to 40 celsius (1 atm)? 
So, is heat a form of energy if energy is capacity to do work?
 A: Heat and work can both be referred to in this context as energy in transit. They are not forms of energy themselves but rather a means to transfer energy. As you have described, heat represents the flow of thermal energy by conduction, convection and radiation. Work describes the change of the energy if the system when some external action generates thermal energy. For example the compression work to push a piston or the electrical work to increase the temperature of the element of a stove. In the case where work transfers the energy, the interaction is not strictly thernal energy transferring between objects.
A: Heat is energy, you are correct.  Here is an analogy.  Think of temperature as a kind of measure of an atom's velocity.  The faster an atom jiggles the higher it's temperature.  So far so good?  Now let's take the analogy one step further - if something has a velocity, you can calculate it's kinetic energy by computing 1/2mv^2 right?  In the same way, using our analogy, one can calculate heat from temperature.  The equation is H = cT (where c is a constant, I forget what it is called, heat capacity I think).  So, finally, to answer your actual question - as heat "flows" what is really happening is molecules of higher velocity (and therefore higher temperature) are ramming in to molecules of lower velocity.  Since work is a force x a distance, one can imagine in our analogy that work is being done on that slower atom by the faster atom as they smash (that's the force) over some - very short I'm guessing - distance.  By doing work on the slower atom it's velocity increases, meaning it has a higher temperature and more energy (just as, say, a car with a higher velocity has more energy than the same car at a slower velocity).  Pardon the long answer.
