1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

matplotlibメモ書き

Last updated at Posted at 2018-12-01

コンデンサ間の等電位線と電気力線の解析解をグラフ化する必要があったのでメモ:hand_splayed::sweat_smile::writing_hand:

コンデンサ間の等電位線と電気力線の解析解は、
平行平板電極がx軸に平行にy=±Lの位置に置かれ、y=+Lの極板に+V0、y=-Lの極板に-V0の電圧を印加した場合、V(x,y)の等電位線はtを媒介変数として、

\left\{
\begin{array}{ll}
x = L\,(\,t+\frac{1}{\pi}e^{\pi t}\,cos\,(\frac{\pi V}{V_0}))\\
y = L\,(\,\frac{V}{V_0}+\frac{1}{\pi}e^{\pi t}\,sin\,(\frac{\pi V}{V_0}))\\
\end{array}
\right.

で与えられる。
電気力線は任意のtで固定してVを媒介変数とすることで得られる。

E_field.py
import numpy as np
import matplotlib.pyplot as plt

L=12

t_vect = np.linspace(-2, 0.4, 201)
v_vect = np.linspace(-4, 4, 201)

V=[1,2,3,4,5,6,7,8,9]
potential = {}
for v in V:
    potential[v]=[]
    potential[v].append(L *(t_vect + 1/np.pi * np.exp(np.pi * t_vect) * np.cos((v-5)/(5)*np.pi)))
    potential[v].append(L *((v-5)/5 + 1/np.pi * np.exp(np.pi * t_vect) * np.sin((v-5) / 5 *np.pi)))


T=[-1.8,-1.5,-1.2,-0.9,-0.6,-0.3,0,0.3]
force_line ={}
for t in T:
    force_line[t]=[]
    force_line[t].append(L *(t + 1/np.pi * np.exp(np.pi * t) * np.cos((v_vect)/(5)*np.pi)))
    force_line[t].append(L *((v_vect)/5 + 1/np.pi * np.exp(np.pi * t) * np.sin((v_vect) / 5 *np.pi)))


plt.hold(True);
for f in potential.values():
    plt.plot(f[0], f[1], color='black',  linestyle='solid')
for f in force_line.values():
    plt.plot(f[0], f[1], color='black',  linestyle='dashed')

plt.xlabel('x[cm]')
plt.ylabel('y[cm]')

plt.savefig("fig.png")

fig.png

plt.hold(True)で複数の線を一個のグラフに描画
plt.plot(f[0], f[1], color='black', linestyle='solid')で線の色と種類を指定

P.S.
複数の線を描画してる時に凡例を共通させる方法(今回だったら等電位線と電気力線それぞれをまとめて凡例を出したい)がわからないので知ってる方いましたら教えてください。

1
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?