Magnetic fields are vector fields associated with magnetic forces. Magnetic fields are generated by Hard Ferromagnets. Unlike electric fields, magnetic fields always make closed loops and are never created nor destroyed. Though magnetic field lines go out of north poles and end at south poles, within the magnet they form a closed loop. The closer together the field lines are, the stronger the field. When opposite ends of two magnets interact, their field lines connect the north pole of one with the south pole of another, and the two attract. When the same ends of two magnets interact, they repel because the lines cannot cross and are compressed by each other.
So let's talk about magnetic fields, what is a magnetic field? Well a magnetic field is a vector field makes this kind of a Mathy concept which basically just says that you've got a vector at each point and this vector field is associated with forces it's just like the electric field. Remember that in electric field always points in the direction that the force on a positive charge would point in if you put that positive charge somewhere.
Magnetic fields are a little bit different they're a little more complicated as far as their relationship to the actual force, but you can still think of magnetic fields as associated with a force they don't point in the same direction but they're associated with a force. Alright magnetic fields are generated by permanent magnets which are also called hard ferromagnetic materials. The word Ferro is similar to the word ferrous which is associated with iron so Ferro magnets are associated with iron even though iron itself is not a hard ferromagnet you can't make a magnet just out of iron at least not at ordinary temperatures but there are other hard ferromagnetic materials that do generate magnetic fields.
Now, magnetic materials have two poles. These are kind of like electric charges but they're not the same, so just like electric field lines go out of positive charges and end at negative charges, magnetic field lines come out of north poles and go into south poles. However, very very very important distinction probably the most important distinction between Magnetic Fields and electric fields, electric fields are created at positive charge and they are destroyed at negative charge it is not that way with magnetic fields, magnetic fields don't ever start or stop anywhere they always make closed loops always always always always so let's see what that means about the magnetic field line diagram associated with a simple permanent magnet. Alright so we've got our north pole we've got our south pole we've got magnet field lines coming out of the north pole, so they're coming out, and then they go in to the south pole great so now how do I connect these lines? Well these north pole lines are going to come around and just like with electric fields they're going to spread out when there's room to do so and when they are close together that represents a stronger magnetic field, so we've got it coming around like this and we've got it coming around like this, so that's our magnetic field. Notice that the magnetic field is strongest at the poles and then down here it's not that strong. But now what happens inside the magnet? This is where the difference is between electric fields and magnetic fields. Inside the magnet, the magnetic fields continue all the way through, just like this so in some sense a permanent magnet is kind of like compressing together all the magnetic field lines they look far apart outside the magnet but inside the magnet it's like they've all been squished together so that's really where the magnetic field is going to be the strongest and that's going to be associated with something called the permeability of the magnet because it's how well can the magnetic field permeate this hard ferromagnetic material.
Alright, now let's see what magnetic field lines do when we take two magnets and we put them near each other. Alright, so let's consider this one first, so we've got a north pole that means that we've got field lines coming out, we've got a south pole field lines coming in well jeez that's easy there we go right? So it will be just like that going down alright? What about here? North pole field lines coming out, here south pole field lines coming in so we'll connect again just like this, just like that. Now notice that if I push this closer together, these field lines get nice and strong and it actually looks like what's going on inside the magnet so this represents attraction the north pole of a magnet attracts the south pole of another magnet and if I put them together, they just become one bigger magnet right? I'll try to pull them apart and they don't like it so these field lines would start to get bigger and bigger and bigger until they all just connect here and the two magnets will just separate.
Alright, what happens if I take two of the same pole and put them next to each other? Alright let's look down here so now we've got north pole north pole, again out out out out out, out out out out now what's the difference? You know it's just like I did before, well the issue is that now I can't connect them because these guys are all going out so these ones are going to come up and like that, these ones are going to come up and like that. Now just like all field lines they can't cross because the magnetic field that every single location has to be in a certain direction it can't you know be schizophrenic like this oh part of it is pointing that way and part no alright it's got to not cross so these field lines are not allowed to cross and that causes a lot of trouble with that because they kind are forced to go round like this and around like this and down like this and down like this and then these guys are doing the same thing so here you can see that this situation is aggravated if I tried to push the two north poles closer together because these field lines aren't allowed to cross and they're just pushing against each other this creates something that we can call magnetic field pressure and so what happens when you have two like poles and you try to push them together you feel this magnetic field pressure that wants to push them apart, they need to have room to exist on their own and if you try to push them too close together they don't have that room so they're going to complain, so that's magnetic fields.