How can i include within ode45 solver a BVP solution derived by a different function-file?
Afficher commentaires plus anciens
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)
Star Strider
le 20 Mai 2014
0 votes
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
Stefanos
le 21 Mai 2014
Star Strider
le 21 Mai 2014
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.)
Stefanos
le 21 Mai 2014
Star Strider
le 21 Mai 2014
My pleasure!
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!