gnuplot でソレノイドを螺旋状にそれらしく描く

円電流回路の重ね合わせでソレノイドを描く」では,円電流回路の重ね合わせとして(手を抜いて)描いてみたが,そうではなく,1本の電線を螺旋状に密に巻いたものとしてソレノイドをそれらしく描く。ソレノイドの内部磁場も描く。実際の磁場の計算の際は,ソレノイドを円電流回路の重ね合わせとして計算するのですよ。

ソレノイドを螺旋状にそれらしく描く

 

In [1]:
%gnuplot inline svg size 640,640 fixed enhanced font 'Noto Sans CJK JP,14'
In [2]:
# ソレノイド
reset
unset xtics
unset ytics
unset ztics
unset border
set xyplane 0
set zeroaxis
set xrange [-2:2]
set yrange [-2:2]
set samples 1000
set view 60,20,,

# reds.pal 改
set palette defined ( \
  0 '#FCBBA1',\
  1 '#FCBBA1',\
  2 '#FC9272',\
  3 '#FB6A4A',\
  4 '#EF3B2C',\
  5 '#CB181D',\
  6 '#99000D',\
  7 '#600000' \
) 
set key inside sample 2
set title "ソレノイド"
unset colorbox

a = 1
pitch=0.01
N = 20
uini = -pi/2
uend = 2*pi*N+pi/2

# y > 0 側のデータ
set print "solep.txt"
  dx = 0.1
  do for [i=0:30]{
    print -3+dx*i, -a, pitch*uini
  }
  Ndiv = 200
  Nwin = 20
  du = (uend-uini)/(Ndiv*Nwin)
  do for [i=0:Ndiv/2]{
    u = uini + du * i
    print a*cos(u), a*sin(u), pitch*u
  }
  do for [i=0:Ndiv*Nwin]{
    u = uini + du * i
    if (sin(u) >= -0.02) {print a*cos(u), a*sin(u), pitch*u}
      else {print "      ";}
  }
  do for [i=0:30]{
    print -3+dx*i, a, pitch*uend
  }
  print "          "
  print "          "
  print 0, -a, 0
set print 

# y < 0 側のデータ
set print "solem.txt"
  dx = 0.1
  do for [i=0:30]{
    print -3+dx*i, -a, pitch*uini
  }
  Ndiv = 500
  Nwin = 20
  du = (uend-uini)/(Ndiv*Nwin)
  do for [i=0:Ndiv*Nwin]{
    u = uini + du * i
    if (sin(u) <= 0.02) {print a*cos(u), a*sin(u), pitch*u}
      else {print "      ";}
  }
  do for [i=0:30]{
#    print -3+dx*i, a, pitch*uend
  }
  print "          "
  print "          "
  print 0, a, 0  
set print 

set print "sole-vec.txt"
  print -1.5, -1, pitch*uini, 1, 0, 0
  print -0.5, 1, pitch*uend, -1, 0, 0
set print

splot \
  "solep.txt" u 1:2:3:(-$2) w l lw 6 lc palette notitle, \
  "solem.txt" u 1:2:3:(-$2) w l lw 6 lc palette notitle, \
  "sole-vec.txt" using 1:2:3:4:5:6:(-$2) \
    w vec filled head lw 6 lc palette title "電流"

In [3]:
set output "./sole-rasen-kairo.svg"
replot
set output

ソレノイドの内部磁場

In [4]:
# 磁場ベクトルの始点
set print "sole-rasen-jiba.txt"
  print -0.5,0, 0
  print 0, 0, 0
  print 0.5, 0, 0
set print

set title "十分に長いソレノイドの内部磁場"
splot \
  "solep.txt" u 1:2:3:(-$2) w l lw 6 lc palette notitle, \
  "sole-rasen-jiba.txt" u 1:2:3:(0):(0):(1.3) \
    w vec lw 10 lc "green" title "磁場", \
  "solem.txt" u 1:2:3:(-$2) w l lw 6 lc palette notitle, \
  "sole-vec.txt" using 1:2:3:4:5:6:(-$2) \
    w vec filled head lw 6 lc palette title "電流"

In [5]:
set output "./sole-rasen-jiba.svg"
replot
set output
In [6]:
set title "十分に長いソレノイドの内部磁場(y=0 の断面)"
splot \
  "solep.txt" u 1:2:3:(-$2) w l lw 6 lc palette notitle, \
  "sole-rasen-jiba.txt" u 1:2:3:(0):(0):(1.3) \
    w vec lw 10 lc "green" title "磁場", \
  "sole-vec.txt" using 1:2:3:4:5:6:(-$2) \
    w vec filled head lw 6 lc palette title "電流"

In [7]:
set output "./sole-rasen-jiba2.svg"
replot
set output