最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python+matplotlib演示電偶極子實(shí)例代碼

 更新時(shí)間:2018年01月12日 10:38:51   投稿:mengwei  
這篇文章主要介紹了python+matplotlib演示電偶極子實(shí)例代碼,具有一定借鑒價(jià)值,需要的朋友可以參考下

使用matplotlib.tri.CubicTriInterpolator.演示變化率計(jì)算:

完整實(shí)例:

from matplotlib.tri import (
  Triangulation, UniformTriRefiner, CubicTriInterpolator)
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np


#-----------------------------------------------------------------------------
# Electrical potential of a dipole
#-----------------------------------------------------------------------------
def dipole_potential(x, y):
  """ The electric dipole potential V """
  r_sq = x**2 + y**2
  theta = np.arctan2(y, x)
  z = np.cos(theta)/r_sq
  return (np.max(z) - z) / (np.max(z) - np.min(z))


#-----------------------------------------------------------------------------
# Creating a Triangulation
#-----------------------------------------------------------------------------
# First create the x and y coordinates of the points.
n_angles = 30
n_radii = 10
min_radius = 0.2
radii = np.linspace(min_radius, 0.95, n_radii)

angles = np.linspace(0, 2 * np.pi, n_angles, endpoint=False)
angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1)
angles[:, 1::2] += np.pi / n_angles

x = (radii*np.cos(angles)).flatten()
y = (radii*np.sin(angles)).flatten()
V = dipole_potential(x, y)

# Create the Triangulation; no triangles specified so Delaunay triangulation
# created.
triang = Triangulation(x, y)

# Mask off unwanted triangles.
triang.set_mask(np.hypot(x[triang.triangles].mean(axis=1),
             y[triang.triangles].mean(axis=1))
        < min_radius)

#-----------------------------------------------------------------------------
# Refine data - interpolates the electrical potential V
#-----------------------------------------------------------------------------
refiner = UniformTriRefiner(triang)
tri_refi, z_test_refi = refiner.refine_field(V, subdiv=3)

#-----------------------------------------------------------------------------
# Computes the electrical field (Ex, Ey) as gradient of electrical potential
#-----------------------------------------------------------------------------
tci = CubicTriInterpolator(triang, -V)
# Gradient requested here at the mesh nodes but could be anywhere else:
(Ex, Ey) = tci.gradient(triang.x, triang.y)
E_norm = np.sqrt(Ex**2 + Ey**2)

#-----------------------------------------------------------------------------
# Plot the triangulation, the potential iso-contours and the vector field
#-----------------------------------------------------------------------------
fig, ax = plt.subplots()
ax.set_aspect('equal')
# Enforce the margins, and enlarge them to give room for the vectors.
ax.use_sticky_edges = False
ax.margins(0.07)

ax.triplot(triang, color='0.8')

levels = np.arange(0., 1., 0.01)
cmap = cm.get_cmap(name='hot', lut=None)
ax.tricontour(tri_refi, z_test_refi, levels=levels, cmap=cmap,
       linewidths=[2.0, 1.0, 1.0, 1.0])
# Plots direction of the electrical vector field
ax.quiver(triang.x, triang.y, Ex/E_norm, Ey/E_norm,
     units='xy', scale=10., zorder=3, color='blue',
     width=0.007, headwidth=3., headlength=4.)

ax.set_title('Gradient plot: an electrical dipole')
plt.show()

總結(jié)

以上就是本文關(guān)于python+matplotlib演示電偶極子實(shí)例代碼的全部?jī)?nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站其他相關(guān)專題,如有不足之處,歡迎留言指出。感謝朋友們對(duì)本站的支持!

相關(guān)文章

  • Python BeautifulReport可視化報(bào)告代碼實(shí)例

    Python BeautifulReport可視化報(bào)告代碼實(shí)例

    這篇文章主要介紹了Python BeautifulReport可視化報(bào)告代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • python人物視頻背景替換實(shí)現(xiàn)虛擬空間穿梭

    python人物視頻背景替換實(shí)現(xiàn)虛擬空間穿梭

    這篇文章主要為大家介紹了python實(shí)現(xiàn)人物視頻背景替換示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • 在Python程序員面試中被問的最多的10道題

    在Python程序員面試中被問的最多的10道題

    本篇文章我們?yōu)榇蠹艺砹嗽赑ython程序員面試中被問的最多的10道題,我們還給出了最簡(jiǎn)便的解決辦法,一起學(xué)習(xí)下。
    2017-12-12
  • 純用NumPy實(shí)現(xiàn)神經(jīng)網(wǎng)絡(luò)的示例代碼

    純用NumPy實(shí)現(xiàn)神經(jīng)網(wǎng)絡(luò)的示例代碼

    這篇文章主要介紹了純用NumPy實(shí)現(xiàn)神經(jīng)網(wǎng)絡(luò)的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-10-10
  • Python selenium文件上傳方法匯總

    Python selenium文件上傳方法匯總

    這篇文章主要為大家詳細(xì)介紹了Python selenium文件上傳方法,selenium文件上傳的所有方法進(jìn)行整理,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • Python使用正則表達(dá)式獲取網(wǎng)頁中所需要的信息

    Python使用正則表達(dá)式獲取網(wǎng)頁中所需要的信息

    這篇文章主要介紹了Python使用正則獲取網(wǎng)頁中所需要的信息的相關(guān)資料,需要的朋友可以參考下
    2018-01-01
  • Python實(shí)現(xiàn)合并帶有嵌入圖片的單元格

    Python實(shí)現(xiàn)合并帶有嵌入圖片的單元格

    這篇文章主要為大家詳細(xì)介紹了如何使用Python實(shí)現(xiàn)合并帶有嵌入圖片的單元格,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2024-12-12
  • Python 批量操作設(shè)備的實(shí)現(xiàn)步驟

    Python 批量操作設(shè)備的實(shí)現(xiàn)步驟

    本文將結(jié)合實(shí)例代碼,介紹Python 批量操作設(shè)備的實(shí)現(xiàn)步驟,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-07-07
  • Django框架封裝外部函數(shù)示例

    Django框架封裝外部函數(shù)示例

    這篇文章主要介紹了Django框架封裝外部函數(shù),結(jié)合Django框架表單登陸功能示例分析了封裝外部函數(shù)的相關(guān)操作步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2019-05-05
  • python 列表刪除所有指定元素的方法

    python 列表刪除所有指定元素的方法

    下面小編就為大家分享一篇python 列表刪除所有指定元素的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-04-04

最新評(píng)論

开平市| 南开区| 巴彦县| 嘉义市| 安宁市| 乌兰察布市| 南部县| 酉阳| 偏关县| 汝州市| 乳山市| 宁波市| 商洛市| 台南县| 美姑县| 项城市| 长葛市| 梅河口市| 奎屯市| 德保县| 昆明市| 湖北省| 陇川县| 巴彦县| 宜黄县| 托里县| 旌德县| 怀来县| 汉源县| 常熟市| 白银市| 曲阳县| 新兴县| 忻城县| 甘德县| 临漳县| 涟水县| 驻马店市| 镇巴县| 儋州市| 汕尾市|