defining boxes that reflects particles of electron

2 visualizzazioni (ultimi 30 giorni)
I wrote a code to display particles of electron but now I want to add inner rectangular bottle-necks boundaries to the plot. This will be done by defining boxes that will reflect particles whenever it hits the boundary of the boxes.
The code I wrote below does not relect the particles instead it passes behind the boxes.
Please some to help me. Thanks
LR = 200e-9; %Length of region
BR = 100e-9; %Breadth of region
numParticles = 1000;% no of particles
numSteps = 2;
x = zeros(numParticles, numSteps);
y = zeros(numParticles, numSteps);
xx = 0:0.2e-9:200e-9;
yy = 0:0.1e-9:100e-9;
size_x = numel(xx);
size_y = numel(yy);
xindex_Particles = randi(size_x,[numParticles,2]);
yindex_Particles = randi(size_y,[numParticles,2]);
x_Particles = xx(xindex_Particles)';
y_Particles = yy(yindex_Particles)';
figure
plot(x_Particles, y_Particles)
title('Sample Particle trajectories')
% Define extent of the boxes
xv = [0.8e-7 0.8e-7 1.2e-7 1.2e-7 0.8e-7 NaN 0.8e-7 0.8e-7 1.2e-7 1.2e-7 0.8e-7];
yv = [0.0e-7 0.4e-7 0.4e-7 0.0e-7 0.1e-7 NaN 0.6e-7 1.0e-7 1.0e-7 0.6e-7 0.6e-7];
%Determine whether each particles lies inside or on the edge of the polygon area.
[in, on] = inpolygon(x_Particles, y_Particles,xv,yv);
Pinx = x_Particles(~in);
Piny = y_Particles(~in);
f1 = [Pinx(1:838,:),Pinx(839:1676,:)]';
f2 = [Piny(1:838,:),Piny(839:1676,:)]';
%Plot the polygon and the query points. Display the points inside the polygon with a red plus. Display the points outside the polygon with a blue circle.
figure
plot(xv,yv,'k') % polygon
hold on
% plot(x_Particles(in&~on),y_Particles(in&~on),'r+') % points strictly inside
% plot(x_Particles(on)',y_Particles(on)','r*') % points on edge
plot(f1,f2) % points outside
hold off
title('Sample Particles trajectories with Bottle neck')
rectangle('Position',[0.8e-7,0.0e-7,0.4e-7,0.4e-7],'FaceColor',[1 1 1],'EdgeColor','k',...
'LineWidth',2)
rectangle('Position',[0.8e-7,0.6e-7,0.4e-7,0.4e-7],'FaceColor',[1 1 1],'EdgeColor','k',...
'LineWidth',2)

Risposte (0)

Categorie

Scopri di più su Computational Geometry in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by