Energy, Heat & Work
In mechanics, the key forms of energy are kinetic and potential. These energies apply to a body as a whole, and so can be seen as macroscopic.
Microscopic energies are the forms of energy within that body: bond energies, kinetic and potential energies of individual particles (sometimes known as the ‘sensible’ energy), nuclear energy etc. All these microscopic energies are grouped together as internal energy, U.
The total energy of a system, E, is given as the sum of the internal, kinetic, and potential energies:

By dividing by the mass, the specific energies can be found:

Closed systems generally remain motionless, so rarely experience a change in kinetic or potential energies. In this case, the change in total energy is equal to the change in internal energy.
For control volumes, fluid may be moving in and out at a mass flow rate (represented by an m with a dot above it). In this instance, the energy flow rate is:

We can group internal energies into two parts: the static energies and the dynamic energies. The former are fixed within the system, and so cannot change the overall internal energy. The latter are free to cross the system boundary, and so it is these that we are interested in.
There are only two forms of energy transfer for a closed system: heat transfer and work.
In a closed system, an energy transfer is always a heat transfer if it is brought about by a temperature difference. In all other situations, the energy transfer takes the form of a work transfer.
Heat Transfer
Heat transfer, Q, is the transfer of energy due to a difference in temperature between a system and its surroundings. In thermodynamics, the term ‘heat’ should only be used to refer to heat transfer. If you are talking about the energy due to temperature of a substance or system, call this ‘thermal energy’.

It is convention to define heat transfer from the surroundings to the system as positive, and heat transfer from the system to the surroundings as negative.
Heat transfer can take one of three forms:
Conduction between neighbouring particles
Convection between a solid and a fluid
Radiation through electromagnetic waves or photons
Work Transfer
Work transfer, W, is the transfer of energy between a system and its surroundings that is not caused by a difference in temperature. Sometimes it is useful to think about work transfer as the lifting of a mass: if the energy transfer can in any way be modelled as raising a mass, then it is a work transfer and not a heat transfer.
The sign convention for work transfer is the opposite to that of heat transfer.
A positive work transfer means work transfer from the system to the surroundings
A negative work transfer means work transfer from the surroundings to the system
There are two key types of mechanical work transfer: displacement work and shaft work.
Displacement Work
Displacement work is the work done in moving a system boundary by a certain distance in the direction of a normal force. A common example is a piston moving due to a change in pressure, volume, and/or temperature. In this instance, the change in work is given as the product of the pressure and the change in volume:

If the expansion is fully resisted, it can be modelled as a quasi-equilibrium process. When this is the case, we can plot it on a P-V graph where the work is the area under the graph:

Therefore, the work done is given as the integral of P dv:

There are a few key forms that are useful to know, to spare integrating them every time:

Shaft Work
Shear work is the work done in moving a system boundary in the direction of a tangential force (a shear force). This is very common in liquids, where they interact with their container. Shear work transfer into a fluid typically comes from a stirring force:

Instead of modelling the system as just the fluid, we can model the system as the fluid, the paddle, and the shaft. This means the only input to the system is a shear work on the shaft, known as shaft work.
The force involved is a torque couple, and so the power of the shaft (the rate of work transfer) is given as: