Lösung Beispiel 6, Helmut Hörner MatNr. 08850092

Festlegen der Potentiale der sechs Leiter

randpot={0,100,0,0,100,0};

Festlegen von Geometrie und Gitterweite in Metern

dl=0.0002
yWidth=25dl
xWidth=4  yWidth

Erzeuge Gitter (x=1..xMax, y=1...yMax)

xMax=IntegerPart[Round[xWidth/dl,1]];
yMax=IntegerPart[Round[yWidth/dl,1]];
grid=Table[
If[y==1,randpot[[IntegerPart[Round[1+Floor[(x-1)/(xMax/3),1]]]]],
If[y==yWidth/dl,randpot[[IntegerPart[Round[4+Floor[(x-1)/(xMax/3),1]]]]],0]],
{y,1,yMax},{x,1,xMax}];

Potentialberechnung mit Relaxationsmethode

MaxError=0.1;
newGrid=grid;
mDiff=1;
For[zz=1,mDiff>MaxError,zz++,grid=newGrid; mDiff=0;
For[yy=2,yy<yMax,yy++,
For[xx=1,xx<=xMax,xx++,
newGrid[[yy,xx]]=N[1/4(grid[[yy-1,xx]]+grid[[yy+1,xx]]+grid[[yy,Max[1,xx-1]]]+grid[[yy,Min[xMax,xx+1]]])];
mDiff=Max[mDiff,Abs[newGrid[[yy,xx]]-grid[[yy,xx]]]]
]
]
];

ListDensityPlot[grid,AspectRatio->{xWidth/yWidth}]

ListPlot3D[grid, BoxRatios->{xWidth,yWidth,yWidth}]

Ermittlung einer Potentialfunktion ϕ[x, y] durch Interpolation

ϕ1=ListInterpolation[grid]; (*ϕ1[y,x] in Grid-Einheiten mit x=1..xMax und y=1..yMax*)
ϕ[x_,y_]=ϕ1[(y+dl)/dl,(x+dl)/dl]; (* ϕ[x,y] in Längeneinheiten (Meter) mit x=0..xWidth-dl und y=0..yWidth-dl *)
Plot3D[ϕ[x,y],{x,0,xWidth-dl},{y,0,yWidth-dl},BoxRatios->{xWidth,yWidth,yWidth}]

Feldstärke e[x,y] als -grad[ϕ[x,y]]

e[x_,y_]=-Grad[ϕ[x,y],{x,y}];
StreamPlot[e[x,y],{x,0,xWidth-dl},{y,0,yWidth-dl},AspectRatio->{xWidth/yWidth}]

Waagrecht einfallender Elektronenstrahl (Elektrostatische Linse)

physconst={q->  1.60217649 (10^(-19)), m-> 9.10938215 (10^(-31))};
anfangsbed1={vx0-> 12000000, vy0-> 0, x0-> 0, y0-> (yWidth-dl)/2};
bahnen1=
Table[
NDSolve[{m x''[t]==e[x[t],y[t]][[1]] q,x'[0]==vx0, x[0]==x0, m y''[t]==e[x[t],y[t]][[2]] q,y'[0]==vy0, y[0]==yWidth/5*i} /. physconst /. anfangsbed1,
{x,y},{t,0,1.7 (10^(-9))}],
{i,1,4}] ;
bahnplots1 = 
Table[
ParametricPlot[{bahnen1[[i,1,1,2]][t],bahnen1[[i,1,2,2]][t]},{t,0,1.7 (10^(-9))} , PlotStyle->Red, PlotRange->{{0,xWidth-dl},{0,yWidth-dl}}],
{i,1,4}];
Show[DensityPlot[ϕ[x,y],{x,0,xWidth-dl},{y,0,yWidth-dl},AspectRatio->{xWidth/yWidth}],bahnplots1]

Einfallender Elektronenstrahl mit Ablenkung nach oben

anfangsbed2={vx0-> 12000000, vy0-> 630000, x0-> 0, y0-> (yWidth-dl)/2};
bahnen2=
Table[
NDSolve[{m x''[t]==e[x[t],y[t]][[1]] q,x'[0]==vx0, x[0]==x0, m y''[t]==e[x[t],y[t]][[2]] q,y'[0]==vy0, y[0]==yWidth/5*i} /. physconst /. anfangsbed2,
{x,y},{t,0,1.7 (10^(-9))}],
{i,1,4}] ;
bahnplots2 = 
Table[
ParametricPlot[{bahnen2[[i,1,1,2]][t],bahnen2[[i,1,2,2]][t]},{t,0,1.7 (10^(-9))} , PlotStyle->Red, PlotRange->{{0,xWidth-dl},{0,yWidth-dl}}],
{i,1,4}];
Show[DensityPlot[ϕ[x,y],{x,0,xWidth-dl},{y,0,yWidth-dl},AspectRatio->{xWidth/yWidth}],bahnplots2]

Elektronenstrahl Interaktiv

Manipulate[bahnen3=
Table[
Quiet[NDSolve[{m x''[t]==e[x[t],y[t]][[1]] q,x'[0]==(Sqrt[((Abs[VX] Abs[q])/m)]), x[0]==x0, m y''[t]==e[x[t],y[t]][[2]] q,y'[0]==Sign[VY](Sqrt[((Abs[VY] Abs[q])/m)]), y[0]==yWidth/5*i} /. physconst /. anfangsbed2,
{x,y},{t,0,1.7 (10^(-9))}]],
{i,1,4}] ;
bahnplots3 = 
Table[
ParametricPlot[{bahnen2[[i,1,1,2]][t],bahnen3[[i,1,2,2]][t]},{t,0,1.7 (10^(-9))} , PlotStyle->Red, PlotRange->{{0,xWidth-dl},{0,yWidth-dl}}],
{i,2,3}];
Show[DensityPlot[ϕ[x,y],{x,0,xWidth-dl},{y,0,yWidth-dl},AspectRatio->{xWidth/yWidth}],bahnplots3],
{{VX,409,"(Subscript[X, 0]) Energy [eV]"},100,750},
{{VY,0,"(Subscript[Y, 0]) Energy [eV]"},-6,6}, ContinuousAction->False]