File:VFPt ringmagnet.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (SVG file, nominally 600 × 600 pixels, file size: 64 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: Drawing of a cylindrical ringmagnet with precisely computed magnetic field lines. The magnet consists of a flat cylinder of R/L=1.5 with a cylindrical hole of radius r/R=1/3 and is homogeneously magnetized along the cylinder axis. The north-half of the magnet is painted red, whereas the south-half is green. The precise field distribution is obtained by numerical integration. The shape of the field lines is traced with a Runge-Kutta algorithm. The density of field lines corresponds roughly to the field strength, however due to 3D variations of the field, this cannot exactly be fulfilled.
Date
Source Own work
Author Geek3
Other versions
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with VectorFieldPlot.
 
This file uses embedded text.
Source code
InfoField

Python code

# paste this code at the end of VectorFieldPlot 1.9
# https://commons.wikimedia.org/wiki/User:Geek3/VectorFieldPlot
doc = FieldplotDocument('VFPt_ringmagnet',
    commons=True, width=600, height=600)

r0 = 0.5
r1 = 1.5
h = 0.5
field = Field({'coils':[[0, 0, pi/2, r1, h, 1],
                        [0, 0, pi/2, r0, h, -1]]})

n_out = 24
for i in range(n_out):
    s = (i + 0.5) / n_out * 2. - 1.
    line = FieldLine(field, [copysign(r1 + h * (1. / s**2 - 1.), s), 0.],
        directions='both', maxr=1e3)
    doc.draw_line(line, linewidth=2.4,
        arrows_style={'dist':3, 'scale':1.1, 'offsets':[1, 0.4, 0.4, 0]})
n_in = 8
for i in range(n_in):
    a = (i + 0.5) / n_in * 2. - 1.
    line = FieldLine(field, [r0 * (1.1*a - 0.1*a**3), 0.],
        directions='both')
    doc.draw_line(line, linewidth=2.4,
        arrows_style={'dist':3, 'scale':1.1, 'offsets':[1, 0.4, 0.4, 0]})

# draw the magnet manually
colors = ['#00cc00', '#ff0000']
defs = doc.draw_object('defs', {})
grad = doc.draw_object('linearGradient', {'id':'grad',
    'x1':str(r0), 'x2':str(-r0), 'y1':'0', 'y2':'0',
    'gradientUnits':'userSpaceOnUse'}, group=defs)
for col, of, opa in [['#000000', '0', '0.125'],
    ['#ffffff', '0.07', '0.125'], ['#ffffff', '0.25', '0.5'],
    ['#ffffff', '0.6', '0.2'], ['#000000', '1', '0.33']]:
    stop = doc.draw_object('stop', {'stop-color':col, 'offset':of,
        'stop-opacity':opa}, group=grad)
mag = doc.draw_object('g', {'id':'magnet'}, bg=True)
for i in [0, 1]:
    rect = doc.draw_object('rect', group=mag)
    for attr, val in [['x', -r0], ['y', [-h, 0][i]],
        ['width', 2*r0], ['height', [2*h, h][i]],
        ['style', 'fill:{0}; stroke:none'.format(colors[i])]]:
        rect.set(attr, str(val))
rect = doc.draw_object('rect', group=mag)
for attr, val in [['x', -r0], ['y', -h],
    ['width', 2 * r0], ['height', 2 * h],
    ['style', 'fill:url(#grad); stroke-width:0.04; stroke-linejoin:miter; stroke:#000000']]:
    rect.set(attr, str(val))

for x0 in [-r1, r0]:
    mag = doc.draw_object('g')
    for i in [0, 1]:
        rect = doc.draw_object('rect', group=mag)
        for attr, val in [['x', x0], ['y', [-h, 0][i]],
            ['width', r1 - r0], ['height', [2*h, h][i]],
            ['style', 'fill:{0}; stroke:none'.format(
            ['#49da49', '#ff4949'][i])]]:
            rect.set(attr, str(val))
    rect = doc.draw_object('rect', group=mag)
    for attr, val in [['x', x0], ['y', -h],
        ['width', r1 - r0], ['height', 2 * h],
        ['style', 'fill:none; stroke-width:0.04; stroke-linejoin:miter; stroke:#000000']]:
        rect.set(attr, str(val))

doc.write()

Licensing

[edit]
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.

File history

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

Date/TimeThumbnailDimensionsUserComment
current13:33, 15 December 2018Thumbnail for version as of 13:33, 15 December 2018600 × 600 (64 KB)Geek3 (talk | contribs)User created page with UploadWizard

Metadata