Main Page | Report this Page
 
   
Science Forum Index  »  Mathematics Forum  »  solving time dependent coupled pde's using an ode solver
Page 1 of 1    
Author Message
Ben
Posted: Sat Apr 26, 2008 10:41 am
Guest
Hi everybody,

Is it possible to use an ode solver to solve discretized coupled time
dependent partial differential equations? I can do this for a non
coupled pde, which I explain below but I don't know the syntax
required for the ode solver to specify 2 outputs that change with
space and time (I can manage 1 output that changes in space and time
though).

For the non-coupled problem, this is what I do:

I have a standard 1D time dependent partial differential equation
(diffusion equation):

dx/dt = div (grad x) + S (my equation is 1D)

I have discretized this equation to convert it into multiple coupled
time dependent ODE's for each node which I can solve in a standard way
using one of the matlab ode solvers.

For example: [t,x] = ode45('pde',time,initial_conditions_vector)

When I do this, the output variable x is a matrix (say m by n)
containing the x variable for each node in the rows and the time
variation of x in the columns. So this is 1 output, x which varies in
space and time.



Now I want to extend this problem to solve for 2 coupled pde's like:

dx/dt = div (grad x) + S(x,y)
dy/dt = div (grad y) + S(x,y)

My problem is that I don't know the syntax for the ode solver because
now I would need to specify initial conditions for both x and y
variables (at each node) and I'd also have to specify an output for
both x and y.

The ode45 command that I'm trying is something like this:

[t,x,y] = ode45('pdediff',time,[initial_conditions_vector_for_x,
initial_conditions_vector_for_y])

This syntax doesn't work. I think ode45 expects only 1 set of coupling
(which would be coupling between the x variables at each node) instead
of 3 sets of coupling (coupling between x and y variables at each node
as well as in space).

Can anybody help at all? I've posted my code for the non-coupled pde
case below:


=== code for 1D pde ===

to solve this, run:
[t,x] = ode45('pdediff',time,initial_condition_vector);


function dphidt=pdediff(t, phi)

% solves time dependent diffusion equation:
% dx/dt = D div (grad x) + S over 10 nodes with boundary
% conditions of phi = 1 at x = 0 and phi = 0 at x = 10

S = 0;
D = 1e-3;
A = 1;
dx = 0.1;

%%% BC for phi 1
phi1BC1 = 1;
phi1BC2 = 0;

dphidt(1,Smile = D*A*((phi(2)-phi(1))/dx) - D*A*((phi(1)-phiBC1)/(dx/2))
+ S;
dphidt(10,Smile = D*A*((phiBC2-phi(10))/(dx/2)) - D*A*((phi(10) - phi(9))/
dx) + S;

for i=2:9
dphidt(i,Smile = D*A*((phi(i+1)-phi(i))/dx) - D*A*((phi(i)-phi(i-1))/
dx)+S;
end
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Sun Jul 27, 2008 2:29 am