Solving PDE with state and time dependent boundary conditions

5 views (last 30 days)
I am interested in solving the following PDE (heat equation):
In order to solve it, I discretize space uniformly into N segments and convert the PDE into N+1 ODEs:
which I can solve using any ODE routine (such as ode45 or ode15s in MATLAB). For the particular case of my problem, the Neumann boundary conditions for the PDE are dependent on the values of u_k itself, i.e
where alpha and gamma are constants and b={0,N}.
Assuming that I am solving the above problem using some numerical ODE solver (such as ode45 in MATLAB), and there are two routines: odefun (which I provide to the solver) to evaluate the derivatives and odestep which I define and the solver calls it after every successful integration step, where should I check if the boundary condition needs to be changed, in odefun or odestep? I am asking this because the odefun routine might be used internally by the solver for evaluation of jacobian etc and ideally, we should not change boundary conditions in the middle of an integration step, right?

Accepted Answer

Torsten
Torsten on 9 Apr 2015
Because the solver gets its information on how the derivatives develop over time from odefun, you will have to include the time-varying boundary condition in odefun,too.
Best wishes
Torsten.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!