File:VFPt ringmagnet2.svg
Summary
{{Information
|description=
|date=2018-12-15
|source=Own work
|author=Geek3
|permission=
|other versions=
|other fields={{Igen|VectorFieldPlot|0|+|%v|^|c1=
- paste this code at the end of VectorFieldPlot 3.1
- https://commons.wikimedia.org/wiki/User:Geek3/VectorFieldPlot
doc = FieldplotDocument('VFPt_ringmagnet2',
commons=True, width=600, height=600)
r0 = 1.0 r1 = 2.0 h = 0.5 field = Field([ ['coil', {'x':0, 'y':0, 'phi':pi/2, 'R':r1, 'Lhalf':h, 'I':1}],
['coil', {'x':0, 'y':0, 'phi':pi/2, 'R':r0, 'Lhalf':h, 'I':-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={'scale':1.1, 'potential':lambda xy: xy[1] * (1-fabs(xy[0]/2.5)**2.5-fabs(xy[1]/2)**2.5), 'at_potentials':[0], 'condition_func':lambda xy: fabs(xy[1]) > 0.7 or (fabs(xy[0]) > r1 and fabs(xy[1]) < 1e-4)})
n_in = 12 for i in range(n_in):
a = (i + 0.5) / n_in * 2. - 1. line = FieldLine(field, [r0 * (1.2*a - 0.2*a**3), 0.], directions='both') doc.draw_line(line, linewidth=2.4, arrows_style={'scale':1.1, 'potential':lambda xy: xy[1], 'at_potentials':[0], 'condition_func':lambda xy: fabs(xy[0]) < r0})
- 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
- 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.