Help us understand the problem. What is going on with this article?

matplotlibメモ書き

More than 1 year has passed since last update.

コンデンサ間の等電位線と電気力線の解析解をグラフ化する必要があったのでメモ: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.
複数の線を描画してる時に凡例を共通させる方法(今回だったら等電位線と電気力線それぞれをまとめて凡例を出したい)がわからないので知ってる方いましたら教えてください。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away