If a straight wire carrying a current is formed into a circular loop, the magnetic field is as shown. The field may be deduced by taking elements of the loop and looking at the field around each part of the loop.
PRODUCTION OF A BAR MAGNET
If a length of wire is bent into a series of loops, it forms a solenoid. The direction of the magnetic field around any small part of it can be obtained by using the corkscrew rule. If the fields for a series of such loops are combined, the result will be a field pattern similar to that of a bar magnet.
The direction of the magnetic field depends upon the direction of conventional current flow. We can find out which end of the coil is acting as the north pole and which is the south pole by observing the direction of current flow at each end. This is called the End Rule or sometimes, the clock rule, see diagram below.
RIGHT HAND GRIPPING RULE
The right hand gripping rule can also be used to determine the north pole of a coil. The coil is gripped by the right hand with the fingers pointing along the conductors in the direction of conventional current flow, when the thumb is then extended, it indicates the end of the coil that has a magnetic north polarity.