Please help me to run code
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Error
Error using bvparguments (line 111)
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT,OPTIONS):
The boundary condition function BCFUN should return a column vector of length 8.
Error in bvp4c (line 129)
[n,npar,nregions,atol,rtol,Nmax,xyVectorized,printstats] = ...
Error in Untitled (line 55)
sol= bvp4c(@projfun,@projbc,solinit,options);
code
function sol = proj
clc; clf; clear;
rhof=997.1*10^-3;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;
alfaf=kf/(rhof*cpf);
bef=21*10^-5;sigf=0.05*10^-8;
ky=muf/rhof;
disp('ky');
disp((muf/rhof));
%Ag
ph1=0.01;
rho1=10500*10^-3;
cp1=235*10^4;
k1=429*10^5;be1=21*10^-5;
sig1=0.74*10^-2;
%copper
ph2=0.01;
rho2=8933*10^-3;
cp2=385*10^4;
k2=400*10^5;
sig2=5.96*10^-1;
be2=1.67*10^-5;
%Alumina
ph3=0.01;
rho3=3970*10^-3;
cp3=765*10^4;
k3=40*10^5;
be3=0.85*10^-5;
sig3=3.5*10^-1;
%Relation of ternary hyprid
kn=kf*((k3+2*kf-2*ph3*(kf-k3))/(k3+2*kf+ph3*(kf-k3)));
kh=kn*((k2+2*kn-2*ph2*(kn-k2))/(k2+2*kn+ph2*(kn-k2)));
kt=kh*((k1+2*kh-2*ph1*(kh-k1))/(k1+2*kh+ph1*(kh-k1)));
mut= muf/((1-ph1)^2.5*(1-ph2)^2.5*(1-ph3)^2.5);
rhot=(1-ph1)((1-ph2)((1-ph3)+ph3*(rho3/rhof))+ph2*(rho2/rhof))+ph1*(rho1/rhof);
sigt = sigf + (3 * ((ph1 * sig1 + ph2 * sig2) - sigf * (ph1 + ph2)) /(((ph1 * sig1 + ph2 * sig2) / (sigf * (ph1 + ph2))) + 2 - ((ph1 * sig1 + ph2 * sig2) / sigf) + (ph1 + ph2)));
%vt=rhot*cpt
vt =(1-ph1)((1-ph2)((1-ph3)+ph3*((rho3*cp3)/(rhof*cpf)))+ph2*((rho2*cp2)/(rhof*cpf)))+ph1*((rho1*cp1)/(rhof*cpf));
%disp('vt');disp(vt);
%vb=rho*betb
vb =(1-ph1)((1-ph2)((1-ph3)+ph3*((rho3*be3)/(rhof*bef)))+ph2*((rho2*be2)/(rhof*bef)))+(1-ph1)ph1((rho1*be1)/(rhof*bef));
myLegend1 = {};myLegend2 = {};
rr = [1 2 4]
for i =1:numel(rr)
M= rr(i)
pm=0.5;Pr=0.78;
H=0.5;Rd=0.5;gr=0.5;gamma=0.5;Re=0.5;
m = linspace(0,1);
y0 = [1,0,1,0,0,1,0,1];options =bvpset('stats','on','RelTol',1e-5);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
figure(1)
plot(sol.x,(sol.y(1,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=['n= ',num2str(rr(i))];
figure(2)
plot(sol.x,(sol.y(2,:)))
myLegend2{i}=['n = ',num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
figure(2)
legend(myLegend2)
function dy = projfun(~, y)
dy= zeros(8,1);
% alignComments
f = y(1);
df = y(2);
g = y(3);
dg= y(4);
h= y(5);
dh = y(6);
t = y(7);
dt=y(8);
dy(1) = df;
dy(2) = pm*f+((sigt/sigf)(1/(rhot/rhof)))*M*f-(rhot/rhof)((vb)/(rhof*bef))*gr*sin(gamma)*t-k2^2*Re*g^2+(1/(muf/rhof))*h*df+Re*f^2;
dy(3) = dg;
dy(4) = pm*g+((sigt/sigf)*(1/(rhot/rhof)))*M*g+k1*Re*f*g+(1/(muf/rhof))*h*dg;
dy(5) =dh ;
dy(6) =-(rhot/rhof)*((vb)/(rhof*bef))*gr*cos(gamma)*t-k2^2*Re*g^2+(1/(muf/rhof))*h*dh;
dy(7) =dt;
dy(8)=(1/(1+Rd))(H*t(1/(vt))-(((vt)/(rhof*cpf))/(kt/kf))*Pr*h*dt);
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1.5;
ya(5);
ya(7)-1-(ya(8)/0.5);
yb(1)-1;
yb(3)-1;
yb(7);];
end
1 comentario
Cris LaPierre
el 27 de Ag. de 2025
There are a lot of other errors this code generates, but not the ones you have shared. They seem to be locations that are missing a multiplication operator. This must be explicitely entered.
Respuestas (2)
Cris LaPierre
el 27 de Ag. de 2025
A quick glimpse at the error message suggests your BCFUN is not the expected length of 8
Error in calling BVP4C(ODEFUN,BCFUN,SOLINIT,OPTIONS):
The boundary condition function BCFUN should return a column vector of length 8.
projfun has 8 rows, but projbc returns 7. Correct this, and this error will go away.
0 comentarios
Ver también
Categorías
Más información sobre Boundary Value Problems en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!