File:VFPt bar-magnet-forces.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file(SVG file, nominally 572 × 660 pixels, file size: 92 KB)

Summary

Description
English: Top: Exactly computed field lines of magnetic field B of a cylindrical bar magnet with several euqipotential lines of the magnetic scalar potential. The B-field is proportional to the force exerted on external magnetic north-poles. Bottom: Exactly computed field lines of grad(abs(B)) of a cylindrical bar magnet with several euqipotential lines of abs(B). This field is proportional to the force exerted on small magnetizable particles, such as iron filings.
Date
Source Own work
Author Geek3
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with VectorFieldPlot.
Source code
InfoField

Python code

# paste this code at the end of VectorFieldPlot 3.2
# https://commons.wikimedia.org/wiki/User:Geek3/VectorFieldPlot
docB = FieldplotDocument('VFPt_bar-magnet-forces',
    commons=True, width=400, height=300)

R = 0.3
L2 = 1.
m  = 1.

def bounds_func(xy):
    out_magnet = min(L2 - fabs(xy[0]), R - fabs(xy[1]))
    out_image = max(fabs(xy[0]) - 2.0, fabs(xy[1]) - 1.5)
    return max(out_magnet, out_image)

Hfield = Field([ ['charged_disc', {'x0':-L2, 'y0':-R, 'x1':-L2, 'y1':R, 'Q':-m*.5/L2}],
    ['charged_disc', {'x0':L2, 'y0':-R, 'x1':L2, 'y1':R, 'Q':m*.5/L2}] ])
Bfield = Field([ ['coil', {'x':0, 'y':0, 'phi':0, 'R':R, 'Lhalf':L2, 'I':m/(R**2*pi)}] ])
phi0 = Hfield.V((L2, R/2))

rstart = 0.35
startpath = Startpath(Bfield, lambda t: array((L2-rstart*cos(t), (R+rstart)*sin(t))),
    t0=asin(R/(R+rstart)), t1=2*pi-asin(R/(R+rstart)))

nlines = 16
for iline in range(nlines):
    p0 = startpath.startpos((iline + 0.1) / (nlines - 0.8))
    line = FieldLine(Bfield, p0, directions='both', maxr=20, bounds_func=bounds_func)
    docB.draw_line(line, linewidth=2,arrows_style={'potential':Hfield.V,
        'at_potentials':[Hfield.V((-1.4*L2, 2*R)), Hfield.V((1.4*L2, 2*R))]})

print('computing contours...')
#docB.draw_scalar_field(func=Hfield.V, cmap=docB.cmap_AqYlFs, vmin=-phi0, vmax=phi0)
docB.draw_contours(func=Hfield.V, linewidth=0.8, linecolor='#555555',
    levels=sc.linspace(-phi0, phi0, 17))
docB.draw_object('rect', {'x':-2.005, 'y':-1.505, 'width':4.01, 'height':3.01,
    'fill':'none', 'stroke':'#aaaaaa', 'stroke-width':0.03})

docB.draw_magnets(Bfield)
docB.write()


docGrad = FieldplotDocument('VFPt_bar-magnet-forces_grad',
    commons=True, width=400, height=300)

def GradH(xy):
    d = 1e-6
    Hx0 = vabs(Hfield.F((xy[0] - d, xy[1])))
    Hx1 = vabs(Hfield.F((xy[0] + d, xy[1])))
    Hy0 = vabs(Hfield.F((xy[0], xy[1] - d)))
    Hy1 = vabs(Hfield.F((xy[0], xy[1] + d)))
    grad = array(((Hx1 - Hx0) / (2*d), (Hy1 - Hy0) / (2*d)))
    return grad

Gradfield = Field([ ['custom', {'F':GradH, 'V':lambda xy: -vabs(Hfield.F(xy))}] ])
B0 = -Gradfield.V((L2, R/2))

startpath = Startpath(Gradfield, lambda t:
    array((1.6*cos(2*pi*t), 0.9*sin(2*pi*t)+0.2*sin(6*pi*t))))

nlines = 32
for iline in range(nlines):
    p0 = startpath.startpos((iline + 0.5) / nlines)
    line = FieldLine(Gradfield, p0, directions='both', maxr=10, bounds_func=bounds_func)
    docGrad.draw_line(line, linewidth=2, arrows_style={'potential':Gradfield.V,
        'at_potentials':[Gradfield.V((1.4*L2, 2*R))]})

print('computing scalar field.')
#docGrad.draw_scalar_field(func=Gradfield.V, cmap=docGrad.cmap_AqYlFs, vmin=-B0, vmax=B0)
docGrad.draw_contours(func=Gradfield.V, linewidth=0.8, linecolor='#555555',
    levels=B0*sc.arange(-8.5, 0)/9)
docGrad.draw_object('rect', {'x':-2.005, 'y':-1.505, 'width':4.01, 'height':3.01,
    'fill':'none', 'stroke':'#aaaaaa', 'stroke-width':0.03})

docGrad.draw_magnets(Bfield)
docGrad.write()

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Field lines of B and grad(B) of a bar magnet

Items portrayed in this file

depicts

28 June 2020

image/svg+xml

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current19:39, 28 June 2020Thumbnail for version as of 19:39, 28 June 2020572 × 660 (92 KB)Geek3Uploaded own work with UploadWizard
The following pages on the English Wikipedia use this file (pages on other projects are not listed):

Metadata