Thermodynamic system
In thermodynamics, a thermodynamic system, originally called a working substance, is defined as that part of the universe that is under consideration. A real or imaginary boundary separates the system from the rest of the universe, which is referred to as the environment or surroundings (sometimes called a reservoir.) A useful classification of thermodynamic systems is based on the nature of the boundary and the quantities flowing through it, such as matter, energy, work, heat, and entropy. A system can be anything, for example a piston, a solution in a test tube, a living organism, a planet, etc.

# History of term
The first to develop the concept of a "thermodynamic system" was the French physicist Sadi Carnot who in his 1824 Reflections on the Motive Power of Fire studied what he called the working substance (system), i.e. typically a body of water vapor, in steam engines, in regards to the system's ability to do work when heat is applied to it.  The working substance could be put in contact with either a heat reservoir (a boiler), a cold reservoir (a stream of cold water), or a piston (to which the working body could do work by pushing on it).  In 1850, the German physicist Rudolf Clausius generalized this picture to include the concept of the surroundings and when referring to the system began to use the term "working body" .  From his 1850 manuscript On the Motive Power of Fire Clausius states:
The article Carnot heat engine shows the original piston-and-cylinder diagram used by Carnot in discussing his ideal engine; below, we see the Carnot engine as is typically modeled in current use:
In the diagram shown, the working body (system), a term introduced by Clausius in 1850, can be any fluid or vapor body through which heat Q can be introduced or transmitted through to produce work.  In 1824, Sadi Carnot, in his famous paper Reflections on the Motive Power of Fire, had postulated that the fluid body could be any substance capable of expansion, such as vapor of water, vapor of alcohol, vapor of mercury, a permanent gas, or air, etc.  Although, in these early years, engines came in a number of configurations, typically QH was supplied by a boiler, wherein water was boiled over a furnace; QC was typically a stream of cold flowing water in the form of a condenser located on a separate part of the engine.  The output work W here is the movement of the piston as it is used to turn a crank-arm, which was then typically used to turn a pulley so to lift water out of flooded salt mines.  Carnot defined work as weight lifted through a height.

# Overview
Thermodynamics is conducted under a system-centered view of the universe.  All quantities, such as pressure or mechanical work, in an equation refer to the system unless labeled otherwise. Thermodynamics is basically concerned with the flow and balance of energy and matter in a thermodynamic system. Three types of thermodynamic systems are distinguished depending on the kinds of interaction and energy exchange taking place between the system and its surrounding environment:
- Isolated systems are completely isolated in every way from their environment. They do not exchange heat, work or matter with their environment. An example of an isolated system would be an insulated rigid container, such as an insulated gas cylinder.
- Closed systems are able to exchange energy (heat and work) but not matter with their environment. A greenhouse is an example of a closed system exchanging heat but not work with its environment. Whether a system exchanges heat, work or both is usually thought of as a property of its boundary.
- Open systems: exchanging energy (heat and work) and matter with their environment. A boundary allowing matter exchange is called permeable. The ocean would be an example of an open system.
In reality, a system can never be absolutely isolated from its environment, because there is always at least some slight coupling, even if only via minimal gravitational attraction. In analyzing a system in steady-state, the energy into the system is equal to the energy leaving the system .
As an example, consider the system of hot liquid water and solid table salt in a sealed, insulated test tube held in a vacuum (the surroundings). The test tube constantly loses heat (in the form of black-body radiation), but the heat loss progresses very slowly. If there is another process going on in the test tube, for example the dissolution of the salt crystals, it will probably occur so quickly that any heat lost to the test tube during that time can be neglected. (Thermodynamics does not measure time, but it does sometimes accept limitations on the timeframe of a process.)

# Systems in equilibrium
It is a fact that, for isolated systems, as time goes by, internal differences in the system tend to even out. Pressures and temperatures tend to equalize, as do density differences. A system in which all these equalizing processes have gone practically to completion, is considered to be in a state of thermodynamic equilibrium. Its thermodynamic properties are, by definition, unchanging in time. Systems in equilibrium are much simpler and easier to understand than systems which are not in equilibrium. Often, when analysing a thermodynamic process, it can be assumed that each intermediate state in the process is at equilibrium. This will also considerably simplify the situation. Thermodynamic processes which develop so slowly as to allow each intermediate step to be an equilibrium state are said to be reversible processes.

# Open systems
In open systems, matter may flow in and out of the system boundaries.    The first law of thermodynamics for open systems states: the increase in the internal energy of a system is equal to the amount of energy added to the system by matter flowing in and by heating, minus the amount lost by matter flowing out and in the form of work done by the system. The first law for open systems is given by:
where Uin is the average internal energy entering the system and Uout is the average internal energy leaving the system
The region of space enclosed by open system boundaries is usually called a control volume, and it may or may not correspond to physical walls.  If we choose the shape of the control volume such that all flow in or out occurs perpendicular to its surface, then the flow of matter into the system performs work as if it were a piston of fluid pushing mass into the system, and the system performs work on the flow of matter out as if it were driving a piston of fluid.  There are then two types of work performed: flow work described above which is performed on the fluid (this is also often called PV work) and shaft work which may be performed on some mechanical device. These two types of work are expressed in the equation:
Substitution into the equation above for the control volume cv yields:
The definition of enthalpy, H, permits us to use this thermodynamic potential to account for both internal energy and PV work in fluids for open systems:
During steady-state operation of a device (see turbine, pump, and engine), the expression above may be set equal to zero.  This yields a useful expression for the power generation or requirement for these devices in the absence of chemical reactions:
This expression is described by the diagram above.