円電流回路を描く
In [1]:
# 半円の座標データファイル
# theta の分割数
Nth = 100
# 半径
a = 1
set print "han-en.txt"
do for [i=0:Nth]{
th = pi/Nth * i
print sprintf("%8.4f %8.4f", a*cos(th), a*sin(th))
}
print " "
# palette の際の色味対策
print sprintf("%8.4f %8.4f", a*cos(3*pi/2), a*sin(3*pi/2))
print " "
set print
# 円電流ベクトルデータファイル
set print "han-en-vec.txt"
print 0, 1.5, 0, -0.8, 0, 0
print 0, -1.5, 0, 1, 0, 0
set print
In [2]:
%gnuplot inline svg size 640,320 fixed enhanced font 'Noto Sans CJK JP,14'
In [3]:
reset
unset xtics
unset ytics
unset ztics
unset border
set zeroaxis
set zrange [0:1]
set samples 200
set view 60,15,,
set xyplane 0
# reds.pal 改
# https://github.com/Gnuplotting/gnuplot-palettes
set palette defined ( \
0 '#FCBBA1',\
1 '#FCBBA1',\
2 '#FCBBA1',\
3 '#FC9272',\
4 '#FB6A4A',\
5 '#EF3B2C',\
6 '#99000D',\
7 '#99000D' \
)
set key inside sample 2
set title "円電流"
unset colorbox
splot "han-en.txt" \
u 1: 2:(0):(-$2) w l lw 4 lc palette notitle, \
"" u 1:(-$2):(0): ($2) w l lw 4 lc palette notitle, \
"han-en-vec.txt" \
u 1: ($2):(0):(0.4*$4):5:6:(-$2) \
w vec lw 6 lc palette title "電流"
In [4]:
set output "./en-kairo.svg"
replot
set output
円電流回路の重ね合わせでソレノイドを描く
ソレノイドは1本の電線を螺旋状に密に巻いたものであるが,簡単のために円電流回路の重ね合わせで描いてみる。
In [5]:
%gnuplot inline svg size 480,480 fixed enhanced font 'Noto Sans CJK JP,14'
In [6]:
# 半円柱の座標データファイル
Nth = 100
Nz = 40
a = 1
set print "han-enchu.txt"
do for [j=0:Nz]{
z = 5./Nz*j
do for [i=0:Nth]{
th = pi/Nth * i
print sprintf("%8.4f %8.4f %8.4f", a*cos(th), a*sin(th), z)
}
print " "
print sprintf("%8.4f %8.4f %8.4f", a*cos(3*pi/2), a*sin(3*pi/2), z)
print " "
}
set print
# 円柱の電流ベクトルデータファイル
set print "han-enchu-vec.txt"
print 0, -1, 0, 1, 0, 0
print 0, -1, 2.5, 1, 0, 0
print 0, 1, 5, -1, 0, 0
print 0, -1, 5, 1, 0, 0
set print
In [7]:
reset
unset xtics
unset ytics
unset ztics
unset border
set zeroaxis
set xrange [-3:3]
set yrange [-3:3]
set zrange [0:5]
set samples 200
set view 70,15,,
set xyplane 0
# reds.pal 改
# https://github.com/Gnuplotting/gnuplot-palettes
set palette defined ( \
0 '#FCBBA1',\
1 '#FCBBA1',\
2 '#FCBBA1',\
3 '#FC9272',\
4 '#FB6A4A',\
5 '#EF3B2C',\
6 '#CB181D',\
7 '#99000D' \
)
set key inside sample 2
set title "ソレノイド"
unset colorbox
splot "han-enchu.txt" \
u 1: 2:3:(-$2) w l lw 3 lc palette notitle, \
"" u 1:(-$2):3: ($2) w l lw 3 lc palette notitle, \
"han-enchu-vec.txt" \
u 1:2:3:($4*0.1):5:6:(-$2) w vec lw 8 lc palette title "電流"
In [8]:
set output "./sole-kairo.svg"
replot
set output
ソレノイドの内部磁場
In [9]:
# 半円柱の電流ベクトルデータファイル
set print "han-enchu-vec1.txt"
print 0, 1, 5, -1, 0, 0
set print
# 半円柱の磁場ベクトル始点データファイル
set print "han-enchu-jiba.txt"
print -0.5, 0, 0
print 0, 0, 0
print 0.5, 0, 0
set print
set view 75,15,,
set xyplane 0
set zrange [0:5]
set zeroaxis
set title "ソレノイドの内部磁場"
splot "han-enchu.txt" u 1:2:3 \
w l lw 3 lc '#FB6A4A' notitle, \
"han-enchu-vec1.txt" u 1:2:3:4:5:6 \
w vec lw 3 lc '#FB6A4A' title "電流",\
"han-enchu-jiba.txt" u 1:2:3:(0):(0):(4.5) \
w vec filled head lw 6 lc "green" title "磁場"
In [10]:
set output "./sole-jiba.svg"
replot
set output