File:Magnetic field of an idealized dipole.svg
From testwiki
Jump to navigation
Jump to search
Size of this PNG preview of this SVG file: 540 × 540 pixels. Other resolutions: 240 × 240 pixels | 480 × 480 pixels | 768 × 768 pixels | 1,024 × 1,024 pixels | 2,048 × 2,048 pixels.
Original file (SVG file, nominally 540 × 540 pixels, file size: 142 KB)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionMagnetic field of an idealized dipole.svg |
English: magnetic field of an idealized dipole |
| Date | |
| Source | python/matplotlib |
| Author | Andre.holzner |
| SVG development InfoField | |
| Source code InfoField | Python codefrom pylab import *
xpoints = arange(-6,6,0.05)
ypoints = arange(-6,6,0.05)
X,Y = meshgrid(xpoints, ypoints)
circularMask = False
areaRadius = 4
# order of the magnet
n = 1
def func(x,y):
# the function to draw
return ((x + 1j * y)**(n)).real
func = vectorize(func)
V = func(X,Y)
# mask points which we don't want to draw
if circularMask:
# circular mask
distance = sqrt(X**2 + Y**2)
V = ma.masked_where(distance > areaRadius, V)
else:
# polygonal mask
# principal directions are at (i + 0.5) / (2n) * 2pi
#
for i in range(2*n):
angle = (i + 0.5) / float(2*n) * 2*pi
# define a straight angle perpendicular to angle
# mask all points on one side of this line
anchor_x = areaRadius * cos(angle)
anchor_y = areaRadius * sin(angle)
normal_x = cos(angle)
normal_y = sin(angle)
def acceptFunc(x,y):
value = (x - anchor_x) * normal_x + (y - anchor_y) * normal_y
return value > 0
acceptFunc = vectorize(acceptFunc)
V = ma.masked_where(acceptFunc(X,Y), V)
if True:
# levels equidistant in function value
V /= V.max()
levels = arange(-2,2,0.05)
else:
# levels equidistant on x and y axis
# determine the levels to draw from values on one of the axes
levels = [ float(func(x,0)) for x in arange(min(xpoints), max(xpoints),0.50) ] + \
[ float(func(0,y)) for y in arange(min(ypoints), max(ypoints),0.50) ]
levels = sorted(list(set(levels)))
figure(figsize=(6,6));
Q = contour(X,Y, V, colors= 'black', linestyles = 'solid',
levels = levels
)
axis([-5,5,-5,5])
xlabel("x coordinate")
ylabel("y coordinate")
# mask points which we don't want to draw
if not circularMask:
# polygonal mask
# principal directions are at (i + 0.5) / (2n) * 2pi
#
for i in range(2*n):
angle = (i + 0.5) / float(2*n) * 2*pi
if i % 2:
label = "N"
color = 'red'
else:
label = "S"
color = 'green'
anchor_x = 1.1 * areaRadius * cos(angle)
anchor_y = 1.1 * areaRadius * sin(angle)
text(anchor_x, anchor_y, label, size = 20, color = color,
horizontalalignment='center',
verticalalignment='center')
|
Licensing
I, the copyright holder of this work, hereby publish it under the following licenses:
| Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported 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.
You may select the license of your choice.
Captions
Add a one-line explanation of what this file represents
Items portrayed in this file
depicts
15 December 2012
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 10:05, 16 December 2012 | 540 × 540 (142 KB) | wikimediacommons>Andre.holzner | changed axis range such that no lines are drawn outside the coordinate frame on some SVG renderers |
File usage
The following page uses this file: