level 1
0放肆的坠落0
楼主
By[y_, z_] :=
NIntegrate[(R*z*
Sin[\[CurlyPhi]])/((y^2 + z^2 + R^2 -
2 y*R*Sin[\[CurlyPhi]])^(3/2)), {\[CurlyPhi], 0, 2 \[Pi]}];
Bz[y_, z_] :=
NIntegrate[(R*(R - y*Sin[\[CurlyPhi]]))/((y^2 + z^2 + R^2 -
2 y*R*Sin[\[CurlyPhi]])^(3/2)), {\[CurlyPhi], 0, 2 \[Pi]}];
R = 1.0; r1 = step = 0.005 R; r2 = 4 R; forceline = {};
Do[\[Theta] = \[Pi]/2.0; p = {y0, r1}; single = {p};
While[(Abs[p[[2]]] >= r1) \[And] (Norm[p] < r2), AppendTo[single, p];
p = p + step*{Cos[\[Theta]], Sinh[\[Theta]]};
\[Theta] = Arg[By[p[[1]], p[[2]]] + i*Bz[p[[1]], p[[2]]]]];
AppendTo[forceline, single]; m = Length[single];
single = Table[{single[[j, 1]], -single[[j, 2]]}, {j, m}];
AppendTo[forceline, single], {y0, -8 R/10, 8 R/10, R/10}]
Show[Graphics[{Thickness[0.004], Line /@ forceline}],
Axes -> True, AxesLabel -> {"y", "z"},
AxesStyle -> Thickness[0.003], AspectRatio -> 1,
Epilog -> {PointSize[0.02],
Point /@ {{-R, 0}, {R, 0}}}]
Clear[By, Bz]
用的mathematica 12版本。会有如下图这种错误:

书本是这样的:

这是结果。

2023年05月18日 10点05分
1
NIntegrate[(R*z*
Sin[\[CurlyPhi]])/((y^2 + z^2 + R^2 -
2 y*R*Sin[\[CurlyPhi]])^(3/2)), {\[CurlyPhi], 0, 2 \[Pi]}];
Bz[y_, z_] :=
NIntegrate[(R*(R - y*Sin[\[CurlyPhi]]))/((y^2 + z^2 + R^2 -
2 y*R*Sin[\[CurlyPhi]])^(3/2)), {\[CurlyPhi], 0, 2 \[Pi]}];
R = 1.0; r1 = step = 0.005 R; r2 = 4 R; forceline = {};
Do[\[Theta] = \[Pi]/2.0; p = {y0, r1}; single = {p};
While[(Abs[p[[2]]] >= r1) \[And] (Norm[p] < r2), AppendTo[single, p];
p = p + step*{Cos[\[Theta]], Sinh[\[Theta]]};
\[Theta] = Arg[By[p[[1]], p[[2]]] + i*Bz[p[[1]], p[[2]]]]];
AppendTo[forceline, single]; m = Length[single];
single = Table[{single[[j, 1]], -single[[j, 2]]}, {j, m}];
AppendTo[forceline, single], {y0, -8 R/10, 8 R/10, R/10}]
Show[Graphics[{Thickness[0.004], Line /@ forceline}],
Axes -> True, AxesLabel -> {"y", "z"},
AxesStyle -> Thickness[0.003], AspectRatio -> 1,
Epilog -> {PointSize[0.02],
Point /@ {{-R, 0}, {R, 0}}}]
Clear[By, Bz]
用的mathematica 12版本。会有如下图这种错误:

书本是这样的:
这是结果。