Effacer les filtres
Effacer les filtres

How to do regional restriction for translational calculation

1 vue (au cours des 30 derniers jours)
Özgür Alaydin
Özgür Alaydin le 28 Mai 2024
Commenté : Özgür Alaydin le 30 Mai 2024
Dear all,
I have been doing some calculations about quantum mechanics but i stucked at one point.
I have written the given code to have four cylindirs in each region of the cartesian coordinates.
For restriction, i have used smaller and bigger signs and the code works correctly as i want.
Vb1=0.228; R=10E-9; d=14E-9;
Nx=80;
Ny=80;
Mx=68e-9;
My=68e-9;
x=linspace(-Mx/2,Mx/2,Nx);
y=linspace(-My/2,My/2,Ny);
x1=d; x2=-d; x3=-d; x4=d;
y1=d; y2=d; y3=-d; y4=-d;
w=1E+12; T=2*pi/w;
for j=1:numel(x)
for i =1: numel(y)
fx = @(t) x(j) + alfa*sin(w.*t);
idx1 =@(t) ((fx(t)-x1)/R).^2 + ((y(i)-y1)/R).^2 < 1;
idx2 =@(t) ((fx(t)-x2)/R).^2 + ((y(i)-y2)/R).^2 < 1;
idx3 =@(t) ((fx(t)-x3)/R).^2 + ((y(i)-y3)/R).^2 < 1;
idx4 =@(t) ((fx(t)-x4)/R).^2 + ((y(i)-y4)/R).^2 < 1;
Vb = @(t) (x(j)>0 & y(i)>0).*(1-idx1(t))*Vb1 +...
(x(j)<0 & y(i)>0).*(1-idx2(t))*Vb1 +...
(x(j)<0 & y(i)<0).*(1-idx3(t))*Vb1 +...
(x(j)>0 & y(i)<0).*(1-idx4(t))*Vb1;
V0(i,j) = (1/T).*integral(Vb,0,T);
end
end
However, this code is limited to 4 cylindirs. I want to make the code independent from the cylindir number. To do that i have written the given code. But i could not implement the restriction. In the above code, i did regional restriction by using variable idx1, idx2.... and so on. But for the given code i could not do it. Please help.
Vb1 = 0.228;
QWW_number = 2;
w = 1E+12; T = 2 * pi / w;
V0 = zeros(Ny, Nx);
for j = 1:Nx
for i = 1:Ny
Vb = @(t) 0;
for k = 1:QWW_number
for m = 1:QWW_number
x1 = (k - 1) * translation + x00;
y1 = (m - 1) * translation + y00;
fx = @(t) x(j) + alfa * sin(w * t);
idx = @(t) ((fx(t) - x1).^2 / R^2 + (y(i) - y1).^2 / R^2) <= 1;
Vb = @(t) Vb(t) + (1 - idx(t)) * Vb1;
end
end
V0(i, j) = (1 / T) * integral(Vb, 0, T);
end
end
What i tried is putting idx in for loop from 1:QWW_number^2. But i got error due to dependency on the t or something else.
How can i do it?
Conclusion: i want to restrict each idx.... value to the area which is in half distance of the next one. So that it can be independent of QWW_number and i do not have to use higher or lower signs.
for c=1:QWW_number^2
idx(c) = @(t) ((fx(t) - x1).^2 / R^2 + (y(i) - y1).^2 / R^2) <= 1;
Vb = @(t) Vb(t) + (1 - idx(t)) * Vb1;
end

Réponses (1)

Ganesh
Ganesh le 30 Mai 2024
The second script you have implemented seems to be right within the loop. However, I do not understand the conditions you have employed while calculating "Vb", i.e. "(x(j)>0 & y(i)>0)", "(x(j)<0 & y(i)>0)" etc.
This is the reason you are getting different results between the two.
Since I am unable to visualize how these conditions can apply to systems where QWW_number > 2, I am unable to give you a code that complies with your first code.
Hope this helps!
  1 commentaire
Özgür Alaydin
Özgür Alaydin le 30 Mai 2024
When alfa is 0 both code gives the same correct result. But when alfa IS NOT zero, results differ from each other due to summation in Vb. This is wht i add regional restriction with (x(j)>0 & y(i)>0)", "(x(j)<0 & y(i)>0).
To check the second code i have written first code and i added each region manully. But QWW_number is high, it is imposible to write the code.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by