Residual stresses are stresses that remain in a solid material after the original cause of the stresses has been removed. Residual stress may be desirable or undesirable. For example, laser peening imparts deep beneficial compressive residual stresses into metal components such as turbine engine fan blades, and it is used in toughened glass to allow for large, thin, crack- and scratch-resistant glass displays on smartphones. However, unintended residual stress in a designed structure may cause it to fail prematurely.
Residual stresses can occur through a variety of mechanisms including inelastic (plastic) deformations, temperature gradients (during thermal cycle) or structural changes (phase transformation). Heat from welding may cause localized expansion, which is taken up during welding by either the molten metal or the placement of parts being welded. When the finished weldment cools, some areas cool and contract more than others, leaving residual stresses. Another example occurs during semiconductor fabrication and microsystem fabrication when thin film materials with different thermal and crystalline properties are deposited sequentially under different process conditions. The stress variation through a stack of thin film materials can be very complex and can vary between compressive and tensile stresses from layer to layer.
While uncontrolled residual stresses are undesirable, some designs rely on them. In particular, brittle materials can be toughened by including compressive residual stress, as in the case for toughened glass and pre-stressed concrete. The predominant mechanism for failure in brittle materials is brittle fracture, which begins with initial crack formation. When an external tensile stress is applied to the material, the crack tips concentrate stress, increasing the local tensile stresses experienced at the crack tips to a greater extent than the average stress on the bulk material. This causes the initial crack to enlarge quickly (propagate) as the surrounding material is overwhelmed by the stress concentration, leading to fracture.
A material having compressive residual stress helps to prevent brittle fracture because the initial crack is formed under compressive (negative tensile) stress. To cause brittle fracture by crack propagation of the initial crack, the external tensile stress must overcome the compressive residual stress before the crack tips experience sufficient tensile stress to propagate.
The manufacture of some swords utilises a gradient in martensite formation to produce particularly hard edges (notably the katana). The difference in residual stress between the harder cutting edge and the softer back of the sword gives such swords their characteristic curve.
In toughened glass, compressive stresses are induced on the surface of the glass, balanced by tensile stresses in the body of the glass. Due to the residual compressive stress on the surface, toughened glass is more resistant to cracks, but shatter into small shards when the outer surface is broken. A demonstration of the effect is shown by Prince Rupert's Drop, a material-science novelty in which a molten glass globule is quenched in water: Because the outer surface cools and solidifies first, when the volume cools and solidifies, it "wants" to take up a smaller volume than the outer "skin" has already defined; this puts much of the volume in tension, pulling the "skin" in, putting the "skin" in compression. As a result, the solid globule is extremely tough, able to be hit with a hammer, but if its long tail is broken, the balance of forces is upset, causing the entire piece to shatter violently.
In certain types of gun barrels made with two tubes forced together, the inner tube is compressed while the outer tube stretches, preventing cracks from opening in the rifling when the gun is fired.
Castings may also have large residual stresses due to uneven cooling. Residual stress is often a cause of premature failure of critical components, and was probably a factor in the collapse of the Silver Bridge in West Virginia, United States in December 1967. The eyebar links were castings which showed high levels of residual stress, which in one eyebar, encouraged crack growth. When the crack reached a critical size, it grew catastrophically, and from that moment, the whole structure started to fail in a chain reaction. Because the structure failed in less than a minute, 46 drivers and passengers in cars on the bridge at the time were killed as the suspended roadway fell into the river below.
Common methods to induce compressive residual stress are shot peening for surfaces and High frequency impact treatment for weld toes. Depth of compressive residual stress varies depending of the method. Both methods can increase lifetime of constructions significiantly.
There are some techniques which are used to create uniform residual stress in a beam. For example, the four point bend allows inserting residual stress by applying a load on a beam using two cylinders. 
There are many techniques used to measure residual stresses, which are broadly categorised into destructive, semi-destructive and non-destructive techniques. The selection of the technique depends on the information required and the nature of the measurement specimen. Factors include the depth/penetration of the measurement (surface or through-thickness), the length scale to be measured over (macroscopic, mesoscopic or microscopic), the resolution of the information required, and also the composition geometry and location of the specimen. Additionally, some of the techniques need to be performed in specialised laboratory facilities, meaning that "on-site" measurements are not possible for all of the techniques.
Destructive techniques result in large and irreparable structural change to the specimen, meaning that either the specimen cannot be returned to service or a mock-up or spare must be used. These techniques function using a "strain release" principle; cutting the measurement specimen to relax the residual stresses and then measuring the deformed shape. As these deformations are usually elastic, there is an exploitable linear relationship between the magnitude of the deformation and magnitude of the released residual stress. Destructive techniques include:
Similarly to the destructive techniques, these also function using the "strain release" principle. However, they remove only a small amount of material, leaving the overall integrity of the structure intact. These include:
The non-destructive techniques measure the effects of relationships between the residual stresses and their action of crystallographic properties of the measured material. Some of these work by measuring the diffraction of high frequency electromagnetic radiation through the atomic lattice spacing (which has been deformed due to the stress) relative to a stress-free sample. The Ultrasonic and Magnetic techniques exploit the acoustic and ferromagnetic properties of materials to perform relative measurements of residual stress. Non-destructive techniques include:
When undesired residual stress is present from prior metalworking operations, the amount of residual stress may be reduced using several methods. These methods may be classified into thermal and mechanical (or nonthermal) methods. All the methods involve processing the part to be stress relieved as a whole.
The thermal method involves changing the temperature of the entire part uniformly, either through heating or cooling. When parts are heated for stress relief, the process may also be known as stress relief bake. Cooling parts for stress relief is known as cryogenic stress relief and is relatively uncommon.
Most metals, when heated, experience a reduction in yield strength. If the material's yield strength is sufficiently lowered by heating, locations within the material that experienced residual stresses greater than the yield strength (in the heated state) would yield or deform. This leaves the material with residual stresses that are at most as high as the yield strength of the material in its heated state.
Stress relief bake should not be confused with annealing or tempering, which are heat treatments to increase ductility of a metal. Although those processes also involve heating the material to high temperatures and reduce residual stresses, they also involve a change in metallurgical properties, which may be undesired.
For certain materials such as low alloy steel, care must be taken during stress relief bake so as not to exceed the temperature at which the material achieves maximum hardness (See Tempering in alloy steels).
Cryogenic stress relief involves placing the material (usually steel) into a cryogenic environment such as liquid nitrogen. In this process, the material to be stress relieved will be cooled to a cryogenic temperature for a long period, then slowly brought back to room temperature.
Mechanical methods to relieve undesirable surface tensile stresses and replace them with beneficial compressive residual stresses include shot peening and laser peening. Each works the surface of the material with a media: shot peening typically uses a metal or glass material; laser peening uses high intensity beams of light to induce a shock wave that propagates deep into the material.