2016-11-16 76 views
2

我想通過使用極大值來模擬電場偶極子。 這裏是代碼:無法繪製電場偶極子

P : 1$ 
eps0 : 8.854$ 
Ex : 3*P*y*x/(4*π*eps0*(x^2 + y^2)^2.5)$ 
Ey : P*(3*y^2/(x^2 + y^2) + 1)/(x^2 + y^2)^1.5/(4*π*eps0)$ 
ew : sqrt(Ex^2 + Ey^2)$ 

contour_plot (ew,[x, -4, 4], [y, -4,4]); 

但我只得到直線。
什麼可能是錯誤的,因爲Wolfram Mathematica中的類似代碼工作正常。

回答

2

contour_plot不像Mathematica中的相應功能那麼聰明。你可以幫助一下。

P : 1$ 
eps0 : 8.854$ 
Ex : 3*P*y*x/(4*%pi*eps0*(x^2 + y^2)^2.5)$ 
Ey : P*(3*y^2/(x^2 + y^2) + 1)/(x^2 + y^2)^1.5/(4*%pi*eps0)$ 
ew : sqrt(Ex^2 + Ey^2)$ 

BIG: subst([x=1/4, y=1/4], ew)$ 
cap_log(e, c):= if e > c then log(c) else log(e)$ 

set_plot_option ([gnuplot_preamble, "set cntrparam levels 8"])$ 
contour_plot ('cap_log(ew, BIG), [x, -4, 4], [y, -4, 4])$ 
0

您也可以使用plotdf。

(%i1) [P,eps0] : [1,8.854]$ 
(%i2) Ex : 3*P*y*x/(4*%pi*eps0*(x^2 + y^2)^2.5)$ 
(%i3) Ey : P*(3*y^2/(x^2 + y^2) + 1)/(x^2 + y^2)^1.5/(4*%pi*eps0)$ 
(%i4) plotdf([Ex,Ey],[vectors,"blank"]); 

點擊在小區的一些點,然後進入圖形設置菜單(用扳手和螺絲刀圖標),擦除fieldlines「紅色」,並選擇一種顏色,比如「藍色「,在曲線中。單擊確定返回到圖形,然後再次單擊圖形以跟蹤幾條等電位曲線。