File:VFPt charged-rod potential+contour.svg

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

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

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: Electric field lines and equipotential lines of a uniformly charged thin rod. The field is accurately computed according to physical laws.
Date
Source Own work
Author Geek3
Other versions VFPt charged-rod.svg
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with VectorFieldPlot.
Source code
InfoField

Python code

# paste this code at the end of VectorFieldPlot 3.1
doc = FieldplotDocument('VFPt_charged-rod_potential+contour', width=600, height=600, commons=True)
L = 2.0
x0, y0, x1, y1 = 0., -L/2., 0., L/2.
field = Field([ ['charged_line', {'x0':x0, 'y0':y0, 'x1':x1, 'y1':y1, 'Q':1.0}] ])

# start the field lines on an ellipse with the rod ends in the focal points
a = L * 0.8
b = sqrt(a**2 - (L/2.0)**2)
def startpath(t):
    phi = 2 * pi * t
    return sc.array([b * sin(phi), a * cos(phi)])
nlines = 24
startpoints = Startpath(field, startpath).npoints(nlines)

Vmax = field.V([0.05, 0.])
Vmax2 = field.V([0.045, 0.])

# plot field lines
for iline in range(nlines):
    p0 = startpoints[iline]
    line = FieldLine(field, p0, directions='both', maxr=5)
    doc.draw_line(line, arrows_style={'potential':field.V,
                  'at_potentials':[0.094*Vmax2, 0.25*Vmax2]})

doc.draw_scalar_field(field.V, cmap=doc.cmap_AqYlFs, vmin=-Vmax, vmax=Vmax)
doc.draw_contours(func=field.V, linewidth=1, linecolor='#444444',
    levels=sc.linspace(0, Vmax2, 11)[1:-1])

# plot rods
D = 0.045
lw = 0.01
nsign = 8
plus = 'M 0,-0.02 v 0.04 M -0.02,0 h 0.04'
col = '#f22'
defs = doc.draw_object('g', {})
grad = doc.draw_object('linearGradient', {'id':'grad', 'x1':'0', 'x2':'0',
    'y1':str(-D), 'y2':str(D), 'gradientUnits':'userSpaceOnUse'}, defs)
for o, c, a in ((0, '#000', 0.3), (0.3, '#999', 0.2),
                (0.8, '#fff', 0.25), (1, '#fff', 0.65)):
    doc.draw_object('stop', {'id':'grad',
         'offset':str(o), 'stop-color':c, 'stop-opacity':str(a)}, grad)

M = 0.5 * (array([x0, y0]) + array([x1, y1]))
R = array([x1, y1]) - M
r = vabs(R)
phi = atan2(R[1], R[0])
transform = 'translate({:.6g},{:.6g})'.format(M[0], M[1])
transform += ' rotate({:.6g})'.format(degrees(phi))
path = 'M {},{}'.format(-r, -D)
path += ' H {}'.format(r)
path += ' A {},{} 0 0 1 {},{}'.format(D, D, r, D)
path += ' H {}'.format(-r)
path += ' A {},{} 0 0 1 {},{}'.format(D, D, -r, -D)
path += ' Z'
doc.draw_object('path', {'d':path, 'transform':transform,
    'style':'fill:{:s}; stroke:none'.format(col)})
doc.draw_object('path', {'d':path, 'transform':transform,
    'style':'fill:url(#grad); stroke:#000; stroke-width:{:.6g}'.format(lw)})
for i in range(nsign):
    pos = M + R * (2 * (i + 0.5) / nsign - 1)
    doc.draw_object('path', {'d':plus,
    'transform':'translate({:.6g},{:.6g})'.format(*pos),
    'style':'fill:none; stroke:#000; stroke-width:{:.6g}; '.format(2*lw) +
    'stroke-linecap:square'})

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
current21:25, 23 May 2020Thumbnail for version as of 21:25, 23 May 2020600 × 600 (87 KB)Geek3 (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

Metadata