How can i include within ode45 solver a BVP solution derived by a different function-file?

Dear Sir,
I am trying to apply a RK time-marching scheme on a system of DEs. I am not including the whole scripts because i don't like to mess you up (there a several functions and subfunctions). In brief the RK function file is
function dz=tdomain(t,z)
global yf dt Nf Fifx Fify g
for i=1:Nf
% initial conditions are vectors of size Nf
% dx/dt
dz(i)=dt*Fix(i);
% dy/dt
dz(i+Nf)=dt*Fiy(i);
% dφ/dt
dz(i+2*Nf)=0.5*(Fix(i)+Fiy(i)).^2-g*yf;
end
which is called within another script file:
.... ntime=10; time=linspace(0,0.01,ntime); [t,z]=ode45(@tdomain,[0 0.01],[xf yf Fifi]);
These initial values xf, yf are coordinates, and Fifi is a zero velocity potential of a free surface. The values "Fix, Fiy" within the solver function are velocity potential gradients solved by another, Boundary element collocation method function (Laplae 2D solver). My question is how could i call this collocation function to be solved at each substep of the RK4 method or how could i call it within the DE system vector?
If helpful, the syntax of the collocation function's head is:
function [Fi,Fix,Fiy,Nw,Nf,x,y]=bemsol(xb,yb,xf,yf,xsym,ysym,xw,yw,... Vw,beta,Fifi)

Réponses (1)

I don’t fully understand what you want to do, but core MATLAB has Boundary Value Problems solvers. You don’t mention that you’ve explored them, so perhaps they will do what you want.

4 commentaires

Good morning, sir
Thank you for your notification.
My problem is not the bvp. It is how can i include this bvp or any other function within the ode45 RK4 equations? The RK4 equations must be updated on each sub-step of the ode45 solver with the "Fix,Fiy" results of my "bemsol" function (which includes the bvp and runs successfully). Thus i need to call this "bemsol" function on each substep of the Runge-Kutta method to provide me with known values for the DEs, and i don't know how to do it.
Best regards
Stefanos
If Fix(i) and Fiy(i) are defined at particular values of your independent variable (for instance, time), you can refer to them as functions of the time values passed to the ode45 function. So if the i values refer to specific times, test for that and refer to them that way.
Otherwise, you can put the ‘bemsol’ call inside your ODE function and run it each time that function is called. That is how I would do it. You can pass the arguments to it preferably as arguments to your ODE function, or if you have no other options, as globals. (I avoid global variables if at all possible.)
Thank you, Sir,
The second option did work however i had to pass some values as global. I did run the ODE function several times. I haven't checked the first option yet but i believe that will make things more automatic and be more helpful to my problem.
Best regards
Stefanos

Connectez-vous pour commenter.

Question posée :

le 20 Mai 2014

Commenté :

le 21 Mai 2014

Community Treasure Hunt

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

Start Hunting!

Translated by