Submarines use small fins that we call rudders or seaplanes when diving and ascending. Energy is most often obtained from electric and diesel engines, while in nuclear submarines energy is generated in a nuclear reactor.
When the submarine dives, the ballast tanks are flooded with seawater, and the rudders are turned so that they direct the vessel downwards. As soon as the submarine is below the water surface, the rudders are readjusted and the diving angle is controlled. At the desired depth, the rudders are placed horizontally and water enters the small auxiliary tanks. When emerging, the opposite process takes place. The rudders rotate so that the submarine is directed upwards. When the vessel almost reaches the surface, water is expelled from the ballast tanks by compressed air. Fresh air is sucked into the tanks by the periscope tower emerging. Submarines use underwater electric motors connected to batteries, and on the surface diesel engines. Diesel engines are also used to charge batteries. Nuclear submarines use the heat generated in a nuclear reactor to run a steam turbine that produces all the necessary electricity. Nuclear submarines can stay under water for a very long time.