# -*- coding: cp949 -*-
#작은 전류 요소에 의한 자기장
#저자:
#날짜: 2016-12-01
from visual import *
scene.height = scene.width = 800
L = 5.e3
scene.range = L
#상수
m_const = 1.e-7 #자기 상수
#작은 전류 요소
source_current = 1. #전류(암페어)
source_axis = vector(0, 0.01*L, 0) #dl 벡터
source_pos = vector(0,-10*L,0) #위치
curve(pos=[(0, -10*L, 0),(0, 10*L, 0)], color=color.green)#dl 방향 연장선
#관찰 위치
c_L=20*L
obs_radius = 0.0004*L #관찰 위치 반지름
d_theta = pi/3.
length = 2.*L #자기장을 그릴 전체 거리
obs_y = -10.*L #최초 관찰 위치 y 좌표
dy = c_L/1000.#관찰 위치 증가분
obs = [vector(0,-10*L,0)] #관찰 위치 리스트
obs1 = vector(0,-10*L,0)
while obs1.y < 10.*L:
rate(100)
obs1.y += dy
obs.append( vector(0,obs1.y,0) )
#자기장
scale_factor_m = 2.e-10 #자기장 화살표 스케일
m_field_origin = 0
i = 0
for hello in obs:
r = hello - vector(obs_radius,0,0) #전류에서 보는 관찰 점의 상대 위치
r_hat = r/mag(r) #상대위치의 단위 벡터
m_field = m_const*source_current*dy*obs_radius/(mag(r)**3)#자기장
m_field_origin += m_field
print "magnetic field by limited wire= ", m_field_origin
m_inf_field = 4.*pi*10**-7*source_current/(2.*pi*obs_radius)
print "magnetic field by infinite wire= ",m_inf_field
print "Done!!!"
I made this program that show biot-savart`s law. I think if obs_radius is much much smaller than c_L(wire total length), "magnetic field by limited wire " is same with "magnetic field by infinite wire", but If i print this two result , "magnetic field by limited wire " is much bigger than "magnetic field by infinite wire". For example, If obs_radius is 0.00004*L, "magnetic field by limited wire " is 0.000250000004808 and "magnetic field by infinite wire" is 1e-06. Why this problem happen?
(I use this formula)