# paste this code at the end of VectorFieldPlot 2.4
RL = [ [0.1, 1.], [0.4, 0.7], [0.7, 0.4], [1.0, 0.1] ]
for i, (R, L) in enumerate(RL):
doc = FieldplotDocument('VFPt_four_magnets' + str(i+1), commons=True,
width=380, height=380)
field = Field([ ['coil', {'x':0, 'y':0, 'phi':pi/2,
'R':R, 'Lhalf':L, 'I':2.*L}] ])
field_pot = Field([
['charged_disc', {'x0':-R, 'x1':R, 'y0':L, 'y1':L, 'Q':pi*R**2}],
['charged_disc', {'x0':-R, 'x1':R, 'y0':-L, 'y1':-L, 'Q':-pi*R**2}] ])
nlines = 11
V0 = field_pot.V([0., 1.9 * 0.6 + 0.4 * L])
for iline in range(nlines):
p0 = sc.array([R * (2. * (iline + 0.5) / nlines - 1.), 0.])
line = FieldLine(field, p0, directions='both', maxr=100)
arrow_potentials = [0.]
if iline > 0 and iline < nlines -1:
arrow_potentials += [-V0, V0]
doc.draw_line(line, maxdist=1,
arrows_style={'at_potentials':arrow_potentials,
'potential':field_pot.V,
'condition_func':lambda xy: fabs(xy[0])>R or fabs(xy[1])>L})
doc.draw_magnets(field)
doc.draw_object('rect', {'x':'-1.9', 'y':'-1.9', 'width':'3.8',
'height':'3.8', 'style':'fill:none; stroke:#aaaaaa; stroke-width:0.03;'})
doc.write()