{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 点電荷モデルによる静電ポテンシャル、電場、電場勾配 \n",
"\n",
"(初版:2020年3月、更新:2023年2月21日) \n",
"\n",
"## 静電ポテンシャルと電場 \n",
"\n",
"原点に配置した電荷 $Q$ による静電ポテンシャル $V$ は \n",
"\n",
"\n",
"$$\\displaystyle{V = \\frac{Q}{\\sqrt{x^2 + y^2 + z^2}}}$$ \n",
"\n",
"と書ける($4\\pi\\varepsilon_0 \\to 1$とする)。電場 $\\vec{E}$ は $\\vec{E} = -\\nabla V$ から \n",
"\n",
"$$\\begin{align*}\n",
"\\vec{E} &= \\left( \\frac{Q x}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}},\n",
"\\frac{Q y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}},\n",
"\\frac{Q z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}} \\right)\\\\\n",
" &= \\frac{Q}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}}\\left(x, y, z \\right)\n",
"\\end{align*}$$\n",
"\n",
"\n",
"となる。 \n",
"これをJuliaで書いてみる。 \n",
"数式処理にSymPyを使う。"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"using Plots\n",
"using SymPy\n",
"using LinearAlgebra"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"@vars x y z Q;"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"静電ポテンシャルと電場の式:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Esym (generic function with 1 method)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Vsym(x,y,z,Q) = Q/sqrt(x^2+y^2+z^2)\n",
"Esym(x,y,z,Q) = -1 .* [diff(Vsym(x,y,z,Q),x), diff(Vsym(x,y,z,Q),y), diff(Vsym(x,y,z,Q),z)]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"電荷の位置は原点、位置 $(x, y, z)$でのポテンシャルと電場が正しく表示されるか確認。"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\frac{Q}{\\sqrt{x^{2} + y^{2} + z^{2}}}$"
],
"text/plain": [
" Q \n",
"-----------------\n",
" ______________\n",
" / 2 2 2 \n",
"\\/ x + y + z "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Vsym(x,y,z,Q)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\left[ \\begin{array}{r}\\frac{Q x}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}}\\\\\\frac{Q y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}}\\\\\\frac{Q z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{3}{2}}}\\end{array} \\right]$\n"
],
"text/plain": [
"3-element Vector{Sym}:\n",
" Q*x/(x^2 + y^2 + z^2)^(3/2)\n",
" Q*y/(x^2 + y^2 + z^2)^(3/2)\n",
" Q*z/(x^2 + y^2 + z^2)^(3/2)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Esym(x,y,z,Q)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"電場の数値計算用の関数を作成"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#122 (generic function with 1 method)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Ecal = lambdify(Esym(x,y,z,Q), [x,y,z,Q])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"位置 $(-1, 0, 0)$ での電場を計算してみる( $Q = 1$ )。"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3-element Vector{Float64}:\n",
" -1.0\n",
" 0.0\n",
" 0.0"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Ecal(-1,0,0,1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 1つの点電荷による電場の様子を図示"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"z = 0\n"
]
},
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x1 = 0; y1 = 0; z1 = 0; # 電荷の座標\n",
"Q1 = 1; # 電荷の大きさ\n",
"zc = 0; # 計算する位置のz座標\n",
"num = 5;\n",
"div = 0.3;\n",
"\n",
"xs = -div*(num+0.5) : div : div*(num+0.5) # x座標\n",
"ys = -div*(num+0.5) : div : div*(num+0.5) # y座標\n",
"xxs = [x for x in xs for y in ys]\n",
"yys = [y for x in xs for y in ys]\n",
"\n",
"println(\"z = \", z1)\n",
"EvecNormalize(x, y) = normalize(Ecal(x-x1, y-y1, zc-z1, Q1)) ./ 5\n",
"A = [norm(Ecal(x-x1, y-y1, zc-z1, Q1)) for x in xs, y in ys]'\n",
"\n",
"contour(xs, ys, A, color=:Reds, fill=true, line=false, levs=100, aspect_ratio=:equal,\n",
" size=(400,300), xlabel=\"x\", ylabel=\"y\",xlims=[xs[begin]-div,xs[end]+div])\n",
"quiver!(xxs, yys, quiver=EvecNormalize)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 2つの点電荷による電場の様子を図示"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"z = 0\n"
]
},
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x1 = 1; y1 = 0; Q1 = 1; #電荷1の座標と大きさ\n",
"x2 = -1; y2 = 0; Q2 = 1; #電荷1の座標と大きさ\n",
"zc = 0; # 計算する位置のz座標\n",
"num = 10;\n",
"div = 0.25;\n",
"\n",
"xs = -div*(num+0.5) : div : div*(num+0.5)\n",
"ys = -div*(num+0.5) : div : div*(num+0.5)\n",
"xxs = [x for x in xs for y in ys]\n",
"yys = [y for x in xs for y in ys]\n",
"\n",
"println(\"z = \", zc)\n",
"EvecNormalize(x, y) = normalize(Ecal(x-x1, y-y1, zc-z1, Q1) + Ecal(x-x2, y-y2, zc-z1, Q2)) ./ 5\n",
"A = [norm(Ecal(x-x1, y-y1, zc-z1, 1) + Ecal(x-x2, y-y2, zc-z1, 1)) for x in xs, y in ys]'\n",
"\n",
"contour(xs, ys, A, color=:Reds, fill=true, line=false, levs=100, aspect_ratio=:equal,\n",
" size=(400,300), xlabel=\"x\", ylabel=\"y\",xlims=[xs[begin]-div,xs[end]+div])\n",
"quiver!(xxs, yys, quiver=EvecNormalize)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 電場勾配を求める \n",
"\n",
"電場勾配は静電ポテンシャルの位置による2回微分で、以下のように書ける。 \n",
"\n",
"$$\\begin{align*}\n",
"V_{\\alpha, \\beta} = \\frac{\\partial^2 V}{\\partial\\alpha\\partial\\beta} &=\n",
"\\left[ \\begin{array}{ccc}\\frac{Q \\left(2 x^{2} - y^{2} - z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q x y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q x z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\\\\\\frac{3 Q x y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{Q \\left(- x^{2} + 2 y^{2} - z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q y z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\\\\\\frac{3 Q x z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q y z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{Q \\left(- x^{2} - y^{2} + 2 z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\\end{array}\\right]\\\\\n",
"&= \n",
"\\frac{Q}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\n",
"\\left[ \\begin{array}{ccc}\n",
"2x^{2}-y^{2}-z^{2}&3xy&3xz\\\\\n",
"3xy&-x^{2}+2y^{2}-z^{2}&3yz\\\\\n",
"3xz&3yz&-x^{2}-y^{2}+2z^{2}\n",
"\\end{array}\\right]\n",
"\\end{align*}$$\n",
"\n",
"これをJuliaで書いてみる。 \n",
"数式処理にSymPyを使う。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"電場勾配(テンソル成分)の式:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"V2difsym (generic function with 1 method)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"V2difsym(a, b) = simplify(diff(Vsym(x,y,z,Q), a, b))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$\\displaystyle{V_{x,x}}$ と $\\displaystyle{V_{x,y}}$ を計算して、正しいか確認する。"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\frac{Q \\left(2 x^{2} - y^{2} - z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}$"
],
"text/plain": [
" / 2 2 2\\\n",
"Q*\\2*x - y - z /\n",
"------------------\n",
" 5/2 \n",
"/ 2 2 2\\ \n",
"\\x + y + z / "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Vxx = V2difsym(x, x)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\frac{3 Q x y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}$"
],
"text/plain": [
" 3*Q*x*y \n",
"-----------------\n",
" 5/2\n",
"/ 2 2 2\\ \n",
"\\x + y + z / "
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Vxy = V2difsym(x, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"電場勾配テンソル:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\left[ \\begin{array}{rrr}\\frac{Q \\left(2 x^{2} - y^{2} - z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q x y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q x z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\\\\\\frac{3 Q x y}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{Q \\left(- x^{2} + 2 y^{2} - z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q y z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\\\\\\frac{3 Q x z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{3 Q y z}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}&\\frac{Q \\left(- x^{2} - y^{2} + 2 z^{2}\\right)}{\\left(x^{2} + y^{2} + z^{2}\\right)^{\\frac{5}{2}}}\\end{array}\\right]$\n"
],
"text/plain": [
"3×3 Matrix{Sym}:\n",
" Q*(2*x^2 - y^2 - z^2)/(x^2 + y^2 + z^2)^(5/2) … 3*Q*x*z/(x^2 + y^2 + z^2)^(5/2)\n",
" 3*Q*x*y/(x^2 + y^2 + z^2)^(5/2) 3*Q*y*z/(x^2 + y^2 + z^2)^(5/2)\n",
" 3*Q*x*z/(x^2 + y^2 + z^2)^(5/2) Q*(-x^2 - y^2 + 2*z^2)/(x^2 + y^2 + z^2)^(5/2)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"V2difmatsym = [V2difsym(x,x) V2difsym(y, x) V2difsym(z, x)\n",
" V2difsym(x,y) V2difsym(y, y) V2difsym(z, y)\n",
" V2difsym(x,z) V2difsym(y, z) V2difsym(z, z)\n",
" ]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 正8面体の頂点に電荷が配置されているときの原点位置での電場勾配:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\left[ \\begin{array}{rrr}0&0&0\\\\0&0&0\\\\0&0&0\\end{array}\\right]$\n"
],
"text/plain": [
"3×3 Matrix{Sym}:\n",
" 0 0 0\n",
" 0 0 0\n",
" 0 0 0"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@vars a1\n",
"simplify(V2difmatsym.subs(x, 0-a1).subs(y, 0).subs(z, 0) + V2difmatsym.subs(x, 0+a1).subs(y, 0).subs(z, 0) + \n",
" V2difmatsym.subs(y, 0-a1).subs(z, 0).subs(x, 0) + V2difmatsym.subs(y, 0+a1).subs(z, 0).subs(x, 0) +\n",
" V2difmatsym.subs(z, 0-a1).subs(x, 0).subs(y, 0) + V2difmatsym.subs(z, 0+a1).subs(x, 0).subs(y, 0)\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"電場勾配はない。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### xy平面上に4回対称に電荷が配置されているときの原点位置での電場勾配:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\left[ \\begin{array}{rrr}\\frac{2 Q a_{2}^{2}}{\\left(a_{2}^{2}\\right)^{\\frac{5}{2}}}&0&0\\\\0&\\frac{2 Q a_{2}^{2}}{\\left(a_{2}^{2}\\right)^{\\frac{5}{2}}}&0\\\\0&0&- \\frac{4 Q a_{2}^{2}}{\\left(a_{2}^{2}\\right)^{\\frac{5}{2}}}\\end{array}\\right]$\n"
],
"text/plain": [
"3×3 Matrix{Sym}:\n",
" 2*Q*a2^2/(a2^2)^(5/2) 0 0\n",
" 0 2*Q*a2^2/(a2^2)^(5/2) 0\n",
" 0 0 -4*Q*a2^2/(a2^2)^(5/2)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@vars a2\n",
"simplify(V2difmatsym.subs(x, 0-a2).subs(y, 0).subs(z, 0) + V2difmatsym.subs(x, 0+a2).subs(y, 0).subs(z, 0) + \n",
" V2difmatsym.subs(y, 0-a2).subs(z, 0).subs(x, 0) + V2difmatsym.subs(y, 0+a2).subs(z, 0).subs(x, 0)\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$\\displaystyle{|V_{z,z}| > |V_{x,x}| = |V_{y,y}|}$ であることから、\n",
"$z$軸が電場勾配の最大主軸で、軸対称の異方性を有する(非対称パラメータ $\\eta = 0$ )。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### xy平面上に2回対称に電荷が配置されているときの原点位置での電場勾配:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\left[ \\begin{array}{rrr}\\frac{30 Q a_{2}^{2}}{\\left(a_{2}^{2}\\right)^{\\frac{5}{2}}}&0&0\\\\0&- \\frac{12 Q a_{2}^{2}}{\\left(a_{2}^{2}\\right)^{\\frac{5}{2}}}&0\\\\0&0&- \\frac{18 Q a_{2}^{2}}{\\left(a_{2}^{2}\\right)^{\\frac{5}{2}}}\\end{array}\\right]$\n"
],
"text/plain": [
"3×3 Matrix{Sym}:\n",
" 30*Q*a2^2/(a2^2)^(5/2) 0 0\n",
" 0 -12*Q*a2^2/(a2^2)^(5/2) 0\n",
" 0 0 -18*Q*a2^2/(a2^2)^(5/2)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@vars a2\n",
"simplify(V2difmatsym.subs(x, 0-a2/2).subs(y, 0).subs(z, 0) + V2difmatsym.subs(x, 0+a2/2).subs(y, 0).subs(z, 0) + \n",
" V2difmatsym.subs(y, 0-a2).subs(z, 0).subs(x, 0) + V2difmatsym.subs(y, 0+a2).subs(z, 0).subs(x, 0)\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$\\displaystyle{|V_{x,x}| > |V_{z,z}| > |V_{y,y}|}$ であることから、\n",
"$x$軸が電場勾配の最大主軸で、非対称パラメータは $\\displaystyle{\\eta = \\frac{1}{5}}$ となる。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### xy平面上に3回対称に電荷が配置されているときの原点位置での電場勾配:SymPy"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\left[ \\begin{array}{rrr}\\frac{9 \\sqrt{3} Q a_{3}^{2}}{2 \\left(a_{3}^{2}\\right)^{\\frac{5}{2}}}&0&0\\\\0&\\frac{9 \\sqrt{3} Q a_{3}^{2}}{2 \\left(a_{3}^{2}\\right)^{\\frac{5}{2}}}&0\\\\0&0&- \\frac{9 \\sqrt{3} Q a_{3}^{2}}{\\left(a_{3}^{2}\\right)^{\\frac{5}{2}}}\\end{array}\\right]$\n"
],
"text/plain": [
"3×3 Matrix{Sym}:\n",
" 9*sqrt(3)*Q*a3^2/(2*(a3^2)^(5/2)) … 0\n",
" 0 0\n",
" 0 -9*sqrt(3)*Q*a3^2/(a3^2)^(5/2)"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@vars a3\n",
"simplify(V2difmatsym.subs(x, 0-a3/sympy.sqrt(3)).subs(y, 0).subs(z, 0) +\n",
" V2difmatsym.subs(x, 0+a3/(2sympy.sqrt(3))).subs(y, -a3/2).subs(z, 0) + \n",
" V2difmatsym.subs(x, 0+a3/(2sympy.sqrt(3))).subs(y, +a3/2).subs(z, 0)\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"$\\displaystyle{|V_{z,z}| > |V_{x,x}| = |V_{y,y}|}$ であることから、\n",
"$z$軸が電場勾配の最大主軸で、軸対称の異方性を有する(非対称パラメータ $\\eta = 0$ )。"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 電場勾配を求める:数値計算"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"数値計算用の関数を作成"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"V2difmatcal2 (generic function with 1 method)"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"V2difmatcal = lambdify(V2difmatsym, [x,y,z,Q])\n",
"V2difmatcal2(calpoint, Qpoint, Qval) = V2difmatcal(calpoint[1]-Qpoint[1], calpoint[2]-Qpoint[2], calpoint[3]-Qpoint[3], Qval)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 正8面体の頂点に電荷が配置されているときの原点位置での電場勾配"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3×3 Matrix{Float64}:\n",
" 0.0 0.0 0.0\n",
" 0.0 0.0 0.0\n",
" 0.0 0.0 0.0"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"calpoint = [0,0,0]\n",
"Qpoint1 = [ 1 0 0\n",
" 0 1 0\n",
" -1 0 0\n",
" 0 -1 0\n",
" 0 0 1\n",
" 0 0 -1];\n",
"Qval = 1\n",
"totalV2 = zeros(3,3)\n",
"for iii in eachindex(Qpoint1[:,1])\n",
" totalV2 += V2difmatcal2(calpoint, Qpoint1[iii,:], Qval)\n",
"end\n",
"display(totalV2)\n",
"\n",
"plot([calpoint[1]], [calpoint[2]], [calpoint[3]], marker=:circle, label=\"calc. point\")\n",
"plot!(Qpoint1[:,1], Qpoint1[:,2], Qpoint1[:,3],\n",
" xlims=[-1,1], ylims=[-1,1], zlims=[-1,1],\n",
" xlabel=\"x\", ylabel=\"y\", zlabel=\"z\", label=\"charge point\",\n",
" marker=:circle, line=:false, camera=(20,30), aspect_ratio=:equal, size=(350,300))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### xy平面上に4回対称に電荷が配置されているときの原点位置での電場勾配"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3×3 Matrix{Float64}:\n",
" 2.0 0.0 0.0\n",
" 0.0 2.0 0.0\n",
" 0.0 0.0 -4.0"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"calpoint = [0,0,0]\n",
"Qpoint1 = [ 1 0 0\n",
" 0 1 0\n",
" -1 0 0\n",
" 0 -1 0];\n",
"Qval = 1\n",
"totalV2 = zeros(3,3)\n",
"for iii in eachindex(Qpoint1[:,1])\n",
" totalV2 += V2difmatcal2(calpoint, Qpoint1[iii,:], Qval)\n",
"end\n",
"display(totalV2)\n",
"\n",
"plot([calpoint[1]], [calpoint[2]], [calpoint[3]], marker=:circle, label=\"calc. point\")\n",
"plot!(Qpoint1[:,1], Qpoint1[:,2], Qpoint1[:,3],\n",
" xlims=[-1,1], ylims=[-1,1], zlims=[-1,1],\n",
" xlabel=\"x\", ylabel=\"y\", zlabel=\"z\", label=\"charge point\",\n",
" marker=:circle, line=:false, camera=(20,30), aspect_ratio=:equal, size=(350,300))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### xy平面上に2回対称に電荷が配置されているときの原点位置での電場勾配"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3×3 Matrix{Float64}:\n",
" 30.0 0.0 0.0\n",
" 0.0 -12.0 0.0\n",
" 0.0 0.0 -18.0"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"calpoint = [0,0,0]\n",
"Qpoint1 = [ 1/2 0 0\n",
" 0 1 0\n",
" -1/2 0 0\n",
" 0 -1 0];\n",
"Qval = 1\n",
"totalV2 = zeros(3,3)\n",
"for iii in eachindex(Qpoint1[:,1])\n",
" totalV2 += V2difmatcal2(calpoint, Qpoint1[iii,:], Qval)\n",
"end\n",
"display(totalV2)\n",
"\n",
"plot([calpoint[1]], [calpoint[2]], [calpoint[3]], marker=:circle, label=\"calc. point\")\n",
"plot!(Qpoint1[:,1], Qpoint1[:,2], Qpoint1[:,3],\n",
" xlims=[-1,1], ylims=[-1,1], zlims=[-1,1],\n",
" xlabel=\"x\", ylabel=\"y\", zlabel=\"z\", label=\"charge point\",\n",
" marker=:circle, line=:false, camera=(20,30), aspect_ratio=:equal, size=(350,300))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### xy平面上に3回対称に電荷が配置されているときの原点位置での電場勾配"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3×3 Matrix{Float64}:\n",
" 0.974279 0.0 0.0\n",
" 0.0 0.974279 0.0\n",
" 0.0 0.0 -1.94856"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"calpoint = [0,0,0]\n",
"Qpoint1 = [ 2/sqrt(3) 0 0\n",
" -1/sqrt(3) 1 0\n",
" -1/sqrt(3) -1 0];\n",
"Qval = 1\n",
"totalV2 = zeros(3,3)\n",
"for iii in eachindex(Qpoint1[:,1])\n",
" totalV2 += V2difmatcal2(calpoint, Qpoint1[iii,:], Qval)\n",
"end\n",
"display(totalV2)\n",
"\n",
"plot([calpoint[1]], [calpoint[2]], [calpoint[3]], marker=:circle, label=\"calc. point\")\n",
"plot!(Qpoint1[:,1], Qpoint1[:,2], Qpoint1[:,3],\n",
" xlims=[-1.5,1.5], ylims=[-1.5,1.5], zlims=[-1,1],\n",
" xlabel=\"x\", ylabel=\"y\", zlabel=\"z\", label=\"charge point\",\n",
" marker=:circle, line=:false, camera=(20,30), aspect_ratio=:equal, size=(350,300))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.9.0-beta3",
"language": "julia",
"name": "julia-1.9"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}