Magnets play a very important role in particle accelerators; to guide the particle beam, to keep the beam confined, and then can be used to focus the beam. The force that guides particles when they traveled to the magnetic field of a magnet is the Lorentz force, and this force is perpendicular to both the particle velocity and field direction. Because of this, it can change direction of the velocity of the particles but not their speed. A static magnetic field can be generate by permanent magnets or by electromagnets. The magnetic field of an electromagnet is generated by electric currents and coils. To control the magnetic field, we wind the coils around iron cores and let the iron core lead the magnetic flux. The magnetic flux runs along the iron core with a minimum of leakage. This let us not only guide the magnetic field to the region where the particles are traveling, but also to shape the magnetic field such that it has the correct strengths and direction at every position in that region. We can describe the magnetic field mathematically in a region of the beam by using a series expansion of the field. The expansion is very similar to a Maclaurin expansion of a function and it's called a multipole expansion. The first term in the expansion is the dipole field and this field is simply a constant vector. The second term is the quadrupole field and this field is proportional to the radial distance. The third term is the sextupole field which is proportional to the square of the radial distance. Then comes the octupole, the decapole, and so on. To control the beam in the accelerator, we need dipole fields, quadrupole fields, sextupole fields, and sometimes even octupole fields. Each of these fields are created by a separate class of magnets which is dipole magnets, quadrupole magnets, sextupole magnets, and octupole magnets. The dipole magnets are used to bend the beam, they have two poles with flat parallel surfaces and the field vector goes from the north pole to the south pole. In the region between the poles, the ideal dipole has a constant field perpendicular to the surfaces of the iron poles. There are several different classical dipole design concepts. One is the C-type of magnets which give free access of the beam from one side. Another type is the mechanical, more robust H-type. The electromagnetic coils can in both the C and H-type be made in a racetrack shape and placed around the top and bottom poles. There is also the O-type or window frame type of magnets that are typically used for relative weak beam correction applications. Another type is the combine function magnet which has a dipole field in combination with a field gradient. The quadrupole magnet is used for beam focusing and it's made with four poles, two north poles, and two south poles where the pole tip surface has a parabolic profile. The magnetic field is zero in the center of the magnet and increases linearly in the radial direction. In the mid-plane, the field is oriented in the vertical direction with a field strength that varies as a linear function of the horizontal position. There are four classical quadrupole design concept. The first of these is the high field design and the key in this design is the conical coils and poles. They enable high fields since the allowed amount of iron into poles to be maximized. The next type is the cost optimal design for low field levels, it has a relative narrow pole base and racetrack type of coils. The third design is the figure-eight type of quadrupole with free access from the sides. Then finally, the fourth design is called a square Panofsky quadrupole and it's mainly used as a weak correction magnet in special cases. Now, let's look at the sextupole magnet, it has six poles, three north poles and three south poles, each with a pulse profile that is defined by a third order expression. The sextupole creates a magnetic field that has zero field into the magnetic center and a field strength that increase with the square of the radial distance. The next multiple is the octupole which has eight poles that create the octupole magnetic field with a field strength that increases as the cube of the radial distance. The magnetic field in the pole gap of a dipole magnet is proportional to the ampere turns in the coils, that is the number of turns in the coil times the current in the coil. The field is expressed in terms of the pole gap, h, and the path lengths, l, of the flux inside the iron core, and in Mu_r which is the relative permeability of the iron core. When the iron permeability is large, the expression can be simplified by neglecting a term in the denominator. It's important to design the magnets such that the probability is large enough for this to be a good approximation because then the field loss is minimized. It's crucial that we pick the optimal type of iron for our iron cores. The iron that we use is a so-called magnetic soft core material, it's highly non-linear as indicated by the B-H curve. Note that the slope of this curve gives the permeability. We wrap up the magnetic field, H, by increasing the current in the coils. As the magnetic field grows stronger, the relative permeability of the magnetic iron increases to a peak value of typical between 2,000 and 6,000, and then it decays as the magnetic field reaches saturation at about two Tesla. When we decrease the current, the B field ramps down but it is typical between 0.1-1 percent higher than when we ramp up. This difference is because the iron remembers what the B field has been. This memory effect is called hysteresis. When we ramp down the current in the coils down to zero, there will still be a remnant B field of typical a few Millitesla, but that B field is due to the hysteresis. This is the same effect as when we put an iron nail close to a permanent magnet and when you take away the magnet, you may notice that the nail has become a very weak magnet. We can get an estimation of the magnetic field of an electromagnet by doing calculation by hand, but that is not good enough when we design the magnets for accelerators. We didn't have to determine the magnetic field and the permeability in the entire magnet with high accuracy. We do that by numerical simulation using advanced software. Let's look at an example. Here you can see the magnetic field in the top half of a dipole magnet and the relative permeability in the same region. In the top yoke, at a B field of 0.9 Tesla, the relative permeability is seen to be around 5,000. As the field strength increases beyond this value, the permeability starts to decrease due to saturation. Now, we can see that in the part of the site field where the magnetic field is 1.55 Tesla, the permeability has decreased to 800, and in a pole where the field strength is as high as 1.7 Tesla, the permeability drops even further to 350. When we measure the center field of the dipole as a function of the excitation current, there is a linear relation up to around 1.2 Tesla. But when the field reaches the 1.4 Tesla design value, we observe a non-linear drop of three percent, which is the result of iron reluctance as the iron approaches saturation. A general rule of thumb is that the field level should be designed to stay just below 1.5 Tesla in the main part of the yoke and below 1.8 Tesla in the pole.