Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to calculate the integration that the integrand should be determined by the values of variables?

1 visualizzazione (ultimi 30 giorni)
Guu is the integration I want to calculate. However, the integrand Tuu must be determined by the values of x and y because the code
kzz=kz0(real(kz0)>=0&imag(kz0)>=0)
As a result, there appear errors. How to solve this problem and obtain the value of Guu? Many thanks!
The codes are as follows.
clear all;
syms kz x y d
m = 2;
dd=2.106*(m+1);
vh = 4;
mu = 11;
delta = 8;
HBAR = 1.05457266e-34;
ME = 9.1093897e-31;
ELEC = 1.60217733e-19;
Kh = 2.106;
vKh = [0,0,0;Kh,0,0;-Kh,0,0;0,Kh,0;0,-Kh,0];
kc = sqrt(2*ME*ELEC/HBAR^2)*1e-10;
ku = kc*sqrt(mu+delta);
kd = kc*sqrt(mu-delta);
a3 = [pi/Kh,pi/Kh,sqrt(2)*pi/Kh];
kuu =@(x,y)[-ku*sin(x)*cos(y), -ku*sin(x)*sin(y), kz];
n=0:m;
for p=1:5;
for q=1:5;
tuu(p,q)=(sum((kuu(x,y) + vKh(p,:)).^2)-ku^2)*(p==q)+ kc^2*vh*sum(exp(i*n*sum((vKh(q,:)-vKh(p,:)).*a3)))/(m+1)*(p~=q);
end
end
dtuu=det(tuu);
kz0=vpasolve(dtuu,kz);
kz0=double(kz0);
kzz=kz0(real(kz0)>=0&imag(kz0)>=0);
tuu1=subs(tuu,kz,kzz(1));
tuu2=subs(tuu,kz,kzz(2));
tuu3=subs(tuu,kz,kzz(3));
tuu4=subs(tuu,kz,kzz(4));
tuu5=subs(tuu,kz,kzz(5));
tuu11=double(tuu1);
tuu22=double(tuu2);
tuu33=double(tuu3);
tuu44=double(tuu4);
tuu55=double(tuu5);
nuu1=null(tuu11);
nuu2=null(tuu22);
nuu3=null(tuu33);
nuu4=null(tuu44);
nuu5=null(tuu55);
piuu=[nuu1,nuu2,nuu3,nuu4,nuu5];
pei=[1;0;0;0;0];
A=piuu\pei;
psiuu1=A(1)*nuu1(1)*exp(i*kzz(1)*d)+A(2)*nuu2(1)*exp(i*kzz(2)*d)+A(3)*nuu3(1)*exp(i*kzz(3)*d)+A(4)*nuu4(1)*exp(i*kzz(4)*d)+A(5)*nuu5(1)*exp(i*kzz(5)*d);
psiuu2=A(1)*nuu1(2)*exp(i*kzz(1)*d)+A(2)*nuu2(2)*exp(i*kzz(2)*d)+A(3)*nuu3(2)*exp(i*kzz(3)*d)+A(4)*nuu4(2)*exp(i*kzz(4)*d)+A(5)*nuu5(2)*exp(i*kzz(5)*d);
psiuu3=A(1)*nuu1(3)*exp(i*kzz(1)*d)+A(2)*nuu2(3)*exp(i*kzz(2)*d)+A(3)*nuu3(3)*exp(i*kzz(3)*d)+A(4)*nuu4(3)*exp(i*kzz(4)*d)+A(5)*nuu5(3)*exp(i*kzz(5)*d);
psiuu4=A(1)*nuu1(4)*exp(i*kzz(1)*d)+A(2)*nuu2(4)*exp(i*kzz(2)*d)+A(3)*nuu3(4)*exp(i*kzz(3)*d)+A(4)*nuu4(4)*exp(i*kzz(4)*d)+A(5)*nuu5(4)*exp(i*kzz(5)*d);
psiuu5=A(1)*nuu1(5)*exp(i*kzz(1)*d)+A(2)*nuu2(5)*exp(i*kzz(2)*d)+A(3)*nuu3(5)*exp(i*kzz(3)*d)+A(4)*nuu4(5)*exp(i*kzz(4)*d)+A(5)*nuu5(5)*exp(i*kzz(5)*d);
Tuux=imag(conj(psiuu1)*diff(psiuu1,d)+conj(psiuu2)*diff(psiuu2,d)+conj(psiuu3)*diff(psiuu3,d)+conj(psiuu4)*diff(psiuu4,d)+conj(psiuu5)*diff(psiuu5,d));
Tuu=subs(Tuux,d,dd);
Guu=integral2(ku*sin(x)*Tuu,0.01,pi/2,0,pi/4)

Risposte (1)

Walter Roberson
Walter Roberson il 2 Set 2018
Your tuu involves kz, x, and y. det() of that will involve kz, x, and y. You ask to vpasolve() with respect to kz, so the result is going to be in terms of x and y. But you then expect to be able to double() that result that is in terms of the unresolved variables x and y.
You could ask to vpasolve() without specifying a variable in order to get a set of numeric solutions. The equations involve sin() and cos() so there would typically be multiple solutions -- possibly 10 of them for each x and y value. Any one particular numeric solution would be of questionable worth.
  5 Commenti
Walter Roberson
Walter Roberson il 3 Set 2018
You will have difficulty solving this using MATLAB. You can use solve() and index the first five values, which would often satisfy your range requirements, but I think that you would find it tricky to prove that the roots of the fifth order equation will definitely satisfy the requirements. The equation whose roots are being taken is long and complicated. Most of the trig terms are to even powers so most of the cos terms can be replaced by sqrt(1-sin^2) but there are a few with odd powers for which you would have to adjust the sign when you did that. Perhaps if you broke it up into the four sign cases for each of the two variables, a total of 16 different cases, then just maybe you might be able to prove that the roots must be in the right range... But I would tend to doubt it.
Just maybe you could establish that taking abs() of the roots would work. Maybe.
Anyhow, once roots were selected, they are going to be symbolic because of the x and y components. And as noted in one of your previous questions, null() does not work for symbolic expressions.
I think you probably have a definition problem in your equations. Because of the trig terms it is likely that for some x and y values that the null space is higher dimension than most of the cases. That would give you a piuu that was too large to \ against that particular vector.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by