フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Going back and changing the variable in Newton-Raphson iteration according to iteration number

1 回表示 (過去 30 日間)
Meva
Meva 2014 年 1 月 6 日
閉鎖済み: Walter Roberson 2014 年 1 月 6 日
Dear there,
I urgently need to iterate newton-raphson. It seems easy but I cannot figure out where I am wrong. The problem is :
For mmm=1
1)If m=1 take c1=c1b c2=1-c1 and do the loop for u1,2(i) and p1,2(i)
2)If m=2 take c1=c1+dc c2=1-c1 and this time do the loop with new c1 and c2 for u1,2 (i) and p1,2 (i)
3)If m=3 take c1=(c1*st(1)-(c1-dc)*st(2))/(st(1)-st(2)) and do the loop for new c1 and c2.
Then increase the iteration number: mmm=2 ;
mmm keeps count of the number of N-R iterations. The first iteration has mmm=1, the second mmm=2, etc. [This particular run only do 2 iterations.]
sumint are inside of the integrals.
I need to plot these figures in the code but matlab gives errors of course. Please help me as soon ass possible
Relevant part of the code:
ub = cell(2, 1);
ini_cond = [0,0];
for i = 1:2;
ub{i} = zeros(1,length(x));
ub{i}(:, length(x)) = ini_cond(i) * rand(1, 1);
end
for i=1:101;
% x=i*delta_x ;
fikness=fik*sin(pi.*x);
ub{1}=(c1b-H1D*(x-0.5)+AD/2.*(x-0.5).^2)./(H1-0.5*fikness-A*(x-0.5));
ub{2}=(c2b+H1D*(x-0.5)-AD/2.*(x-0.5).^2)./(1.-H1+0.5*fikness+A*(x-0.5));
end
mmm=1;
c1=c1b;
m=1;
c2=1-c1;
u = cell(2, 1);
ini_cond = [0,0];
for i = 1:2;
u{i} = zeros(1,length(x));
u{i}(:, length(x)) = ini_cond(i) * rand(1, 1);
end
for i=1:101;
fikness=fik*sin(pi.*x);
u{1}=(c1-H1D*(x-0.5)+AD/2.*(x-0.5).^2)./(H1-0.5*fikness-A*(x-0.5));
u{2}=(c2+H1D*(x-0.5)-AD/2.*(x-0.5).^2)./(1.-H1+0.5*fikness+A*(x-0.5));
end
p = cell(2, 1);
q = cell(2, 1);
% % ini_cond = [0,0];
for i = 1:2;
p{i} = zeros(1,100);
% p{i}(:, length(t)) = ini_cond(i) * rand(1, 1);
q{i} = zeros(1,100);
% q{i}(:, length(t)) = ini_cond(i) * rand(1, 1);
end
p{1}(1)=0.5*(1.-u{1}(1).^2);
q{1}(1)=0;
p{2}(1)=0.5*(1.-u{2}(1).^2);
q{2}(1)=0;
for i=2:101
q{1}(i)=q{1}(i-1)-dx*(u{1}(i-1)-ub{1}(i-1))./dt;
p{1}(i)=0.5*(1.-u{1}(i).^2)+q{1}(i);
q{2}(i)=q{2}(i-1)-dx*(u{2}(i-1)-ub{2}(i-1))./dt;
p{2}(i)=0.5*(1.-u{2}(i).^2)+q{2}(i);
end
st = zeros(2, length(t));
st(1,:)=p{1}(100)-p{2}(100);
m=m+1;
if m==3;
c1=(c1*st(1)-(c1-dc)*st(2))/(st(1)-st(2));
c2=1-c1;
end
sumint = cell(2, 1);
for i = 1:2;
sumint{i} = zeros(1,length(x));
end
sumint{1}(1)=0.5*(p{2}(1)-p{1}(1));
sumint{2}(1)=0.5*(p{2}(1)-p{1}(1)).*(-1/2);
for i=2:100;
% x=(i-1)*dx;
sumint{1}(i)=sumint{1}(i-1)+(p{2}(i)-p{1}(i));
sumint{2}(i)=sumint{2}(i-1)+(p{2}(i)-p{1}(i)).*(x-1/2);
end
H1DDOT=-sumint{1}.*dx./rmass;
H1D=H1D+dt*H1DDOT;
H1=H1+dt*H1D;
ADDOT=sumint{2}*dx./rmomi;
AD=AD+dt*ADDOT;
A=A+dt*AD;
H1L=H1+A.*0.5;
H1R=H1-A.*0.5;
H2=1.-H1;
rat1=AD./ADinit;
rat2=ADDOT./AD;
for i=1:101
ub{1}(i)=u{1}(i);
ub{2}(i)=u{2}(i);
c1b=c1;
end
figure (1);
subplot(1,2,1);
plot(t,H1D,'.:',t,H1DDOT,'.:');
axis([0 1 0 2.5]);
xlabel('time');
ylabel('body leading and trailing edges');
hold on
subplot(1,2,2);
plot(t,A,t,AD,t,ADDOT);
xlabel('time');
ylabel('the angles');
figure (2);
subplot(1,2,1);
plot(x,u{1},x,u{2},':', 'LineWidth',1.5);
axis([0 10 0 2.5]);
xlabel('x lateral position');
ylabel('velocity profiles u1, u2 in the gaps');
hold on
subplot(1,2,2);
plot(x,p{1},':',x, p{2},':m', 'LineWidth', 2);
axis([0 10 -3 1]);
xlabel('x lateral position');
ylabel('pressure p1, p2 in the gaps');
hold on
suptitle('1 grain in a fluid (N=2)');
thank you so much

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by