不知道为什么运行不出来
B1 = 0.55; r1 = 0.2;
q = 1.602/10^19; m = 1.67/10^27; time = 10;
B0[r_] := If[Abs[r] > r1, 0, B1];
B = {0, 0, B0[r]} /. r -> Sqrt[x[t]^2 + y[t]^2];
v = {Derivative[1][x.][t], Derivative[1][y][t], 0};
f = q*v*B;
r2 = 0.15; v0 = (q*B0[r2]*r2)/m;
equ = {m*Derivative[2][x][t] == f[[1]],
m*Derivative[2][y][t] == f[[2]], x[0] == 0,
Derivative[1][x][0] == v0, y[0] == r2,
Derivative[1][y][0] == 0};
s = NDSolve[equ, {x, y}, {t, 0, time}]
{x, y} = {x, y} /. s[[1]];
ParametricPlot[{x[t], y[t]}, {t, 0, time}, AxesLabel -> {"x", "y"},
PlotStyle -> Thickness[0.006]]
Clear["Global`*"]
B1 = 0.55; r1 = 0.2;
q = 1.602/10^19; m = 1.67/10^27; time = 10;
B0[r_] := If[Abs[r] > r1, 0, B1];
B = {0, 0, B0[r]} /. r -> Sqrt[x[t]^2 + y[t]^2];
v = {Derivative[1][x.][t], Derivative[1][y][t], 0};
f = q*v*B;
r2 = 0.15; v0 = (q*B0[r2]*r2)/m;
equ = {m*Derivative[2][x][t] == f[[1]],
m*Derivative[2][y][t] == f[[2]], x[0] == 0,
Derivative[1][x][0] == v0, y[0] == r2,
Derivative[1][y][0] == 0};
s = NDSolve[equ, {x, y}, {t, 0, time}]
{x, y} = {x, y} /. s[[1]];
ParametricPlot[{x[t], y[t]}, {t, 0, time}, AxesLabel -> {"x", "y"},
PlotStyle -> Thickness[0.006]]
Clear["Global`*"]