File:Mpl example Helmoltz coils.svg
页面内容不支持其他语言。
外观
此SVG文件的PNG预览的大小:540 × 540像素。 其他分辨率:240 × 240像素 | 480 × 480像素 | 768 × 768像素 | 1,024 × 1,024像素 | 2,048 × 2,048像素。
原始文件 (SVG文件,尺寸为540 × 540像素,文件大小:63 KB)
摘要
描述Mpl example Helmoltz coils.svg |
English: Cross section of B (magnetic field strength) magnitude in a Helmholtz coil (actually consisting of two coils: one at the top, one at the bottom in the plot). The eight contours are for field magnitudes of 0.5 {\displaystyle B_0}, 0.8 {\displaystyle B_0}, 0.9 {\displaystyle B_0}, 0.95 {\displaystyle B_0}, 0.99 {\displaystyle B_0}, 1.01 {\displaystyle B_0}, 1.05 {\displaystyle B_0}, and 1.1 {\displaystyle B_0}, where {\displaystyle B_0} is field strength at center. The large center area has almost uniform field strength. |
日期 | |
来源 | 自己的作品 |
作者 | Adrien F. Vincent |
SVG开发 InfoField | 本矢量图使用Matplotlib创作。 |
Rationale: this work aims at providing an up-to-date version of the similar work https://commons.wikimedia.org/wiki/File:Helmholtz_coil,_B_magnitude_cross_section.svg, done by Morn.
Source code has been modified into fully object-oriented matplotlib interface. It now uses the "viridis" colormap, instead of "jet" which produces perceptual glitches. Besides, some changes had to be done to work with versions of numpy more recent than the one originally used.
The matplotlib (mpl) version is 1.5.3, with Python 2.7 and numpy 1.10
##########
## Code for the figure
##########
# -*- coding: utf-8 -*-
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.cm import viridis as colormap # future default colormap
"""
Setup
"""
r = 1.0
res = 200 # grid resolution. 100 may be enough, resulting in smaller SVG file)
def dist3(a, b, c, d, e, f):
"""Compute the Euclidian distance from (d, e, f) to (a, b, c),
raised to the 3rd power (and with lower boundary `r`).
"""
return np.maximum(r, np.sqrt((a - d)**2 + (b - e)**2 + (c - f)**2))
x = np.linspace(-150, 150, res)
y = np.linspace(-150, 150, res)
X, Y = np.meshgrid(x, y)
F = np.zeros((res, res, 3))
"""
Computing part
"""
# Loop over two coils
for coils in [1.0, -1.0]:
# Sum field contributions from coil in 10-degree steps
for p in np.arange(0, 360, 10):
xc = 100 * np.sin(np.pi * p / 180.0)
yc = 50 * coils
zc = 100 * np.cos(np.pi * p / 180.0)
MAG = 1.0 / ((r + dist3(X, Y, 0.0, xc, yc, zc))**3)
# (We leave out the necessary constants that would be required
# to get proper units because only scaling behavior will be shown
# in the plot. This is also why a sum instead of an integral
# can be used.)
#
# Due to more stringent casting rules in recent Numpy (>=1.10),
# one builds an explicit list of all the vectors (X - xc, Y - yc, -zc)
# instead of relying on broadcasting. One then reshapes the array Z
# (of the cross-product results) as previously expected.
vectors = np.array([[xval - xc, yval - yc, -zc] for (xval, yval)
in zip(X.reshape(-1), Y.reshape(-1))])
Z = np.cross(vectors, (-zc, 0.0, xc))
Z = Z.reshape(res, res, 3)
F += Z * MAG[:,:,np.newaxis]
# Compute the B-field
B = np.sqrt(F[..., 0]**2 + F[..., 1]**2 + F[..., 2]**2)
# Scale field strength by value at center
B = B / B[res // 2, res // 2]
"""
Plotting part
"""
fig_label = "helmoltz_coils"
plt.close(fig_label)
fig, ax = plt.subplots(figsize=(6, 6), num=fig_label, frameon=False)
levels = (0.5, 0.8, 0.9, 0.95, 0.99, 1.01, 1.05, 1.1)
cs = ax.contour(x, y, B, cmap=colormap, levels=levels)
# Add wire symbols
ax.scatter((100, 100, -100, -100), (50, -50, 50, -50), s=400, color="Black")
ax.axis((-130, 130, -130, 130))
ax.set_xticks([])
ax.set_yticks([])
plt.tight_layout()
plt.show()
fig.savefig("Helmholtz_coil,_B_magnitude_cross_section.svg")
##########
许可协议
我,本作品著作权人,特此采用以下许可协议发表本作品:
本文件采用知识共享署名-相同方式共享 4.0 国际许可协议授权。
- 您可以自由地:
- 共享 – 复制、发行并传播本作品
- 修改 – 改编作品
- 惟须遵守下列条件:
- 署名 – 您必须对作品进行署名,提供授权条款的链接,并说明是否对原始内容进行了更改。您可以用任何合理的方式来署名,但不得以任何方式表明许可人认可您或您的使用。
- 相同方式共享 – 如果您再混合、转换或者基于本作品进行创作,您必须以与原先许可协议相同或相兼容的许可协议分发您贡献的作品。
此文件中描述的项目
描绘内容
26 9 2016
文件历史
点击某个日期/时间查看对应时刻的文件。
日期/时间 | 缩略图 | 大小 | 用户 | 备注 | |
---|---|---|---|---|---|
当前 | 2016年9月27日 (二) 09:52 | 540 × 540(63 KB) | Adrien F. Vincent | User created page with UploadWizard |
文件用途
以下页面使用本文件:
全域文件用途
以下其他wiki使用此文件:
- bn.wikipedia.org上的用途
- en.wikipedia.org上的用途
- ko.wikipedia.org上的用途
- pt.wikipedia.org上的用途
- tr.wikipedia.org上的用途
元数据
此文件含有额外信息,这些信息可能是创建或数字化该文件时使用的数码相机或扫描仪所添加的。如果文件已从其原始状态修改,某些详细信息可能无法完全反映修改后的文件。
宽度 | 432pt |
---|---|
高度 | 432pt |
隐藏分类: