File:VFPt sphere-magnet-Sup.svg
Summary
{{Information
|description=
|date=2018-07-14 |source=Own work |author=Geek3 |permission=
|other versions=

|other fields={{Igen|VectorFieldPlot|0|+|s1=Python VectorFieldPlot code|c1=
- paste this code at the end of VectorFieldPlot 1.8
doc = FieldplotDocument('VFPt_sphere-magnet-Sup', commons=True,
width=600, height=600)
x0, y0 = 0.0, 0.0 R = 1.0
def spheremagnet_field(xy):
p = sc.array((0., -1.)) r = xy - sc.array((x0, y0)) d = vabs(r) if d < R: # inside the field is indeed constant Fxy = p / (2. * pi * R**3) else: # outside the field is exatly that of a point-dipole Fxy = (3. * sc.dot(p, r) * r - sc.dot(r, r) * p) / (4.*pi*d**5) return Fxy
field = Field({'custom':[spheremagnet_field]})
n = 20 for i in range(n):
p0 = (R * (2 * (i + 0.5) / n - 1), 0.) line = FieldLine(field, p0, directions='both', maxr=7) doc.draw_line(line, arrows_style={'dist':2.0, 'max_arrows':2, 'offsets':[0.9, 0.3, 0.3, 0.9], 'scale':1.25})
- draw the spherical magnet
g = doc.draw_object('g', {'id':'sphere',
'transform':'translate({},{})'.format(x0, y0)})
defs = doc.draw_object('defs', {}, group=g) grad = doc.draw_object('radialGradient', {'id':'grad', 'r':str(1.2*R),
'cx':'0', 'cy':str(0.2*R), 'fx':'0', 'fy':str(0.6*R), 'gradientUnits':'userSpaceOnUse'}, group=defs)
for col, of, opa in [['#ffffff', '0', '0.7'], ['#ffffff', '0.04', '0.6'],
['#ffffff', '0.11', '0.4'], ['#ffffff', '0.22', '0.2'], ['#555555', '0.7', '0.3'], ['#000000', '1', '0.6']]: stop = doc.draw_object('stop', {'stop-color':col, 'offset':of, 'stop-opacity':opa}, group=grad)
clip = doc.draw_object('clipPath', {'id':'circle_clip'}, group=defs) doc.draw_object('circle', {'cx':'0', 'cy':'0', 'r':str(R)}, group=clip)
gc = doc.draw_object('g', {'clip-path':'url(#circle_clip)'}, group=g) doc.draw_object('circle', {'cx':'0', 'cy':'0', 'r':str(R),
'style':'fill:#ff0000; stroke:none;'}, group=gc)
doc.draw_object('path', {'d':'M -1,0 A 1,1 0 0 0 1,0 L -1,0 Z',
'style':'fill:#00cc00; stroke:none;'}, group=gc)
text_S = doc.draw_object('text', {'text-anchor':'middle', 'x':'0', 'y':'0',
'transform':'translate({},{}) scale({},{})'.format(0, 0.56*R-0.2, 0.05, -0.05), 'style':'fill:#000000; stroke:none; ' + 'font-size:12px; font-family:Bitstream Vera Sans;'}, group=g)
text_S.text = 'S' text_N = doc.draw_object('text', {'text-anchor':'middle', 'x':'0', 'y':'0',
'transform':'translate({},{}) scale({},{})'.format(0, -0.56*R-0.2, 0.05, -0.05), 'style':'fill:#000000; stroke:none; ' + 'font-size:12px; font-family:Bitstream Vera Sans;'}, group=g)
text_N.text = 'N' doc.draw_object('circle', {'cx':'0', 'cy':'0', 'r':str(R),
'style':'fill:url(#grad); stroke:none;', 'transform':'rotate(30) scale(1.4,1)'}, group=gc)
doc.draw_object('circle', {'cx':'0', 'cy':'0', 'r':str(R),
'style':'fill:none; stroke:#000000; stroke-width:0.04;'}, group=g)
doc.write() }} }}
Licensing
- 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.