# paste this code at the end of VectorFieldPlot 1.3
doc = FieldplotDocument('VFPt_Dipole_field', commons=True, width=700, height=600, unit=100)
R = 1.55
sca = 2.4; lw = 1.0
field = Field({'dipoles':[[0, 0, 0, -1]]})
F = lambda t: sc.dot(field.F([R*cos(t), R*sin(t)]), [cos(t), sin(t)])
Fi = lambda t1: ig.quad(F, 0, t1)[0] * R
Fsum = Fi(pi)
line = FieldLine(field, [0, 5], directions='forward', maxr=10)
doc.draw_line(line, linewidth=lw, arrows_style={'dist':6-2*R, 'scale':sca,
'max_arrows':2, 'min_arrows':2, 'fixed_ends':[False, True, True, False]})
n = 15
p = -0.3
for i in range(n):
a = (i + 0.5 + p) / (n + 2*p)
t = op.brentq(lambda t:Fi(t) - a*Fsum, 0, pi)
if abs(i - n/2) > 4:
line = FieldLine(field, [R*cos(t), R*sin(t)], directions='both')
doc.draw_line(line, linewidth=lw, arrows_style={'dist':2*R, 'scale':sca,
'max_arrows':2, 'min_arrows':1, 'fixed_ends':[True, False, False, True]})
elif (i != 7):
line = FieldLine(field, [R*cos(t), R*sin(t)], directions='both', maxr=3)
doc.draw_line(line, linewidth=lw, arrows_style={'dist':2*R, 'scale':sca,
'max_arrows':1, 'min_arrows':1, 'fixed_ends':[False, False, False, True]})
line = FieldLine(field, [R*cos(t), -R*sin(t)], directions='both', maxr=3)
doc.draw_line(line, linewidth=lw, arrows_style={'dist':2*R, 'scale':sca,
'max_arrows':1, 'min_arrows':1, 'fixed_ends':[True, False, False, False]})
n2 = 3
for j in [-1,1]:
for i in range(n2):
a = (i + 0.5 - p) / (n + 2*p)
t = op.brentq(lambda t1: ig.quad(lambda r:field.F([r, 0.])[1], R, t1)[0] - a*Fsum, 0.1, R)
line = FieldLine(field, [j*t, 0.], directions='both')
doc.draw_line(line, linewidth=lw, arrows_style={'dist':2*R, 'scale':sca,
'max_arrows':1, 'min_arrows':1})
Re = 0.855
earth = doc.draw_object('g', {'id':'earth'})
doc.draw_object('circle', {'r':Re, 'cx':'0', 'cy':'0',
'style':'fill:#ffffff; stroke:#000000; stroke-width:0.01'}, group=earth)
doc.draw_object('path', {'d':'M -{0},0 A {0},{1} 0 0 1 {0},0'.format(Re, 0.2*Re),
'style':'fill:none; stroke:#000000; stroke-width:0.01'}, group=earth)
text_N = doc.draw_object('text', {'text-anchor':'middle', 'x':'0', 'y':37,
'transform':'translate(0,0.7) scale(0.002,-0.002)',
'style':'fill:#000000; stroke:none; font-size:100px; font-family:Bitstream Vera Sans'})
text_N.text = 'N'
text_S = doc.draw_object('text', {'text-anchor':'middle', 'x':'0', 'y':37,
'transform':'translate(0,-0.7) scale(0.002,-0.002)',
'style':'fill:#000000; stroke:none; font-size:100px; font-family:Bitstream Vera Sans'})
text_S.text = 'S'
doc.write()