Magnets and electromagnets simulation