trajectory of an electron in an electron beam evaporator

I already made a code, but I want the path to be circular, please help
clc; clear all
M = 100 ;
t = linspace(0,20,M) ;
m=9.1e-31 ;
q=-1.6e-19 ;
P = zeros(M,3) ;
V = zeros(M,3) ;
p = rand(1,3) ;
v = rand(1,3) ;
P(1,:) = p ;
V(1,:) = v ;
c = rand ;
E=[0 0 c] ;
d = rand ;
B=[0 0 d] ;
for i = 2:M
f=q*E+q*cross(v,B) ;
a=f/m ;
v = v+a*t(i) ;
p = p+v*t(i) ;
P(i,:) = p ;
V(i,:) = v ;
end
plot3(P(:,1),P(:,2),P(:,3));
axis equal
xlabel('x'); ylabel('y'); zlabel('z');
grid on
set(gca,'fontsize',14);

Réponses (1)

The electron shall not go in a circle when both E field and B field are applied simultaneously,so I've modified your code such that there's just B field so that you get a trajectory as you desired.
M = 100;
t = linspace(0,20,M) ;
m=9.1e-31 ;
q=-1.6e-19 ;
P = zeros(length(t),3) ;
V = zeros(length(t),3) ;
V(1,:) = [0 rand(1) 0] ;
d = rand(1) ;
B=[0 0 10^-12] ;
for i = 2:length(t)
f=q.*(cross(V(i-1,:),B));
a=f/m;
V(i,:) = V(i-1,:)+a*(t(i)-t(i-1)) ;
P(i,:) = P(i-1,:)+V(i-1,:)*(t(i)-t(i-1)) ;
end
plot(P(:,1),P(:,2))
grid on
Hope this helps!

Catégories

En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange

Produits

Version

R2023a

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by