Syntax of res-function for bvp4c
Mostrar comentarios más antiguos
function res = bcfun(ya,yb,I)
ya(1)=850;
yb(1)=303;
ya(3)=850;
yb(3)=303;
ya(5)=r_cu; %constant
yb(5)=r_cu-((rho_p_T_c/A_p+rho_n_T_c/A_n)-(rho_p_T_h/A_p+rho_n_T_h/A_n))*L; %all constants
V_tho=2*I*(r_cu+(rho_p_T_c/A_p+rho_n_T_c/A_n)*L)-(alpha_p_T_h-alpha_n_T_h)*T_h-(alpha_p_T_c-alpha_n_T_c)*T_c; %all constants except for parameter I
res = [ya(1)-yb(1)
ya(3)-yb(1)
ya(2)
ya(4)
ya(5)
yb(5)
ya(6)
yb(6)-V_tho];
end
25 comentarios
Torsten
el 13 de Nov. de 2018
If you want to set yi at x=0 to a value "v", res = ya(i) - v.
If you want to set yi at x=L to a value "v", res = yb(i) - v.
Justin Riggio
el 13 de Nov. de 2018
Justin Riggio
el 13 de Nov. de 2018
Torsten
el 13 de Nov. de 2018
So y(2) at x=0 is a function of y(1) at x=1 and y(4) at x=0 is a function of y(3) at x=1 ? This is only possible if an explicit value for y(2) at x=0 or y(1) at x=1 is prescribed as a second boundary condition for the first case and if an explicit value for y(4) at x=0 or y(3) at x=1 is prescribed as a second boundary condition for the second case.
Justin Riggio
el 13 de Nov. de 2018
Editada: Justin Riggio
el 13 de Nov. de 2018
Torsten
el 13 de Nov. de 2018
If x=1 is the right boundary point, you can set
res = ya(2)-k_p_t_h*A_p*(T_h-yb(1))
But ya(2) or yb(1) must be specified somewhere else as explicit boundary condition, e.g.
res = ya(2) - 20
If x=1 is not a boundary point, the condition cannot be set in bvp4c.
Justin Riggio
el 13 de Nov. de 2018
Justin Riggio
el 14 de Nov. de 2018
Editada: madhan ravi
el 15 de Nov. de 2018
Torsten
el 14 de Nov. de 2018
Call bvp4c like
sol = bvp4c(@odefun,@(ya,yb)bcfun(ya,yb,solinit),solinit);
to make "solinit" available in "bcfun".
Justin Riggio
el 14 de Nov. de 2018
Torsten
el 14 de Nov. de 2018
Did you also change the argument list of the bcfun-routine itself:
function res = bcfun(ya,yb,solinit)
?
Justin Riggio
el 14 de Nov. de 2018
Torsten
el 15 de Nov. de 2018
Then
sol = bvp4c(@odefun,@(ya,yb,l)bcfun(ya,yb,l,solinit),solinit);
Justin Riggio
el 15 de Nov. de 2018
Torsten
el 15 de Nov. de 2018
Try if it works if you use the line
global solinit
in the program where you call bvp4c as well as in bcfun.
Justin Riggio
el 15 de Nov. de 2018
I think the error before arises because you did not initialize your parameter l within the solinit construct.
Take a look at the example
"Compute Fourth Eigenvalue of Mathieu’s Equation"
under
especially the definition of "solinit".
Justin Riggio
el 15 de Nov. de 2018
Justin Riggio
el 15 de Nov. de 2018
Justin Riggio
el 15 de Nov. de 2018
madhan ravi
el 15 de Nov. de 2018
@Justin i edited all your comment next time format it properly so that it's easy to read
Justin Riggio
el 15 de Nov. de 2018
Justin Riggio
el 15 de Nov. de 2018
Justin Riggio
el 15 de Nov. de 2018
Respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!