how to find magnetism of a compound